Error in cf.write when writing UM data fields
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
Reproduza o problema com o arquivo UM e um exemplo mínimo de cf.read/cf.write. Comece em cf/read_write/write.py e no caminho cfdm netcdfwrite.py _write_global_attributes indicado no traceback; depois determine por que os valores dos atributos globais contêm um dict não hashable. A tarefa estará concluída quando o campo UM for gravado com sucesso sem este TypeError.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Hi folks. I'm encountering issues again with processing UM data. It's a related task to ticket #817 but a different error so I figured I'd start a new topic.
I can load in a single file (either on a surface level, UM tiles, or pressure levels) with no problem and perform usual cf-python tasks like amending and adding attributes, but when it comes to writing the file I get an unhashable type error as follows:
>>> cf.write(f[0], 'test.nc')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.11/mf3-23.11.0-0/envs/jaspy3.11-mf3-23.11.0-0-v20240815/lib/python3.11/site-packages/cfdm/decorators.py", line 171, in verbose_override_wrapper
return method_with_verbose_kwarg(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.11/mf3-23.11.0-0/envs/jaspy3.11-mf3-23.11.0-0-v20240815/lib/python3.11/site-packages/cf/read_write/write.py", line 808, in write
netcdf.write(
File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.11/mf3-23.11.0-0/envs/jaspy3.11-mf3-23.11.0-0-v20240815/lib/python3.11/site-packages/cfdm/decorators.py", line 171, in verbose_override_wrapper
return method_with_verbose_kwarg(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.11/mf3-23.11.0-0/envs/jaspy3.11-mf3-23.11.0-0-v20240815/lib/python3.11/site-packages/cfdm/read_write/netcdf/netcdfwrite.py", line 4911, in write
self._file_io_iteration(
File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.11/mf3-23.11.0-0/envs/jaspy3.11-mf3-23.11.0-0-v20240815/lib/python3.11/site-packages/cfdm/read_write/netcdf/netcdfwrite.py", line 5153, in _file_io_iteration
self._write_global_attributes(fields)
File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.11/mf3-23.11.0-0/envs/jaspy3.11-mf3-23.11.0-0-v20240815/lib/python3.11/site-packages/cfdm/read_write/netcdf/netcdfwrite.py", line 4289, in _write_global_attributes
force_global = {
^
File "/apps/jasmin/jaspy/miniforge_envs/jaspy3.11/mf3-23.11.0-0/envs/jaspy3.11-mf3-23.11.0-0-v20240815/lib/python3.11/site-packages/cfdm/read_write/netcdf/netcdfwrite.py", line 4292, in <dictcomp>
if len(v) == len(fields) and len(set(v)) == 1
^^^^^^
TypeError: unhashable type: 'dict'
I've managed to process hourly and daily files with this workflow and v similar code with no problem so far. I've also double-checked that all the files I'm currently trying to process here are fully formed and compliant, so that's not the issue (I think this was the main problem in my previous ticket).
I have also tested this behaviour with a MWE, where I load a UM file and then try to write it to netcdf, and the same occurs, i.e.
f = cf.read('/path/to/file/UM_file')
cf.write(f[0], 'test.nc')
Can you help me understand what's going on here? I am able to save the fields in iris without a problem, so it doesn't seem to be packing or underlying file problem, but I'd like to use cf-python to maintain consistency with the other files I've post-processed with this method.
- Linguagem predominante
- Python
- Estrelas
- 151
- Forks
- 23
- Merge médio
- 1d 2h
- PRs com merge (30d)
- 1
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de NCAS-CMS/cf-python
-
installation
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
-
Attempt at unsupported conservative 3D mesh regriddingTalvez livre de novo @sadielbartholomew assumiu há 41 dias e não há nenhum pull request aberto. Abertabug?
-
bug
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 45/100
-
API review (4.0.0) documentation
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
-
Testing of to/from xarrayAbertaenhancement xarray
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
Todas as issues de NCAS-CMS/cf-python
Issues semelhantes
-
bug good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
yunaremaia/proto-drift#22 ·
-
bug good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
yunaremaia/memwatch#96 ·
-
bug good first issue
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 91/100
yunaremaia/ci-gate-watch#34 ·
-
bug good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
yunaremaia/agent-capability-attestation#64 ·
Mantenedores costumam responder em até 1 dia
-
bug good first issue
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 86/100
yunaremaia/agent-call-graph#43 ·
Mantenedores costumam responder em até 1 dia