Error in cf.write when writing UM data fields
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
Piste de recherche
Reproduisez le problème avec le fichier UM et un exemple minimal de cf.read/cf.write. Commencez par cf/read_write/write.py et par le chemin cfdm netcdfwrite.py _write_global_attributes indiqué dans le traceback, puis déterminez pourquoi les valeurs des attributs globaux contiennent un dict non hachable. C’est terminé lorsque le champ UM s’écrit correctement sans cette TypeError.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 151
- Forks
- 23
- Merge moyen
- 1 j 2 h
- PR mergées (30 j)
- 1
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de NCAS-CMS/cf-python
-
installation
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
-
Attempt at unsupported conservative 3D mesh regriddingPeut-être à nouveau libre @sadielbartholomew l’a pris il y a 41 jours, et aucune pull request n’est ouverte. Ouvertebug?
-
error from netCDF in cf.writeOuvertebug
Difficulté 3/5 1-2 jours Accessibilité débutants 45/100
-
API review (4.0.0) documentation
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
-
Testing of to/from xarrayOuverteenhancement xarray
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
Toutes les issues de NCAS-CMS/cf-python
Issues similaires
-
bug good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
yunaremaia/proto-drift#22 ·
-
bug good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
yunaremaia/memwatch#96 ·
-
bug good first issue
Difficulté 1/5 Moins d'une heure Accessibilité débutants 91/100
yunaremaia/ci-gate-watch#34 ·
-
bug good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
yunaremaia/agent-capability-attestation#64 ·
Les mainteneurs répondent en général sous 1 jour
-
bug good first issue
Difficulté 1/5 Moins d'une heure Accessibilité débutants 86/100
yunaremaia/agent-call-graph#43 ·
Les mainteneurs répondent en général sous 1 jour