Hi,
Also having issues opening NetCDF files post download using python package iris.
Traceback (most recent call last):
File "/gws/nopw/j04/4dhydro/data/jules/164_deg/code/drivers/rhine/../create_jules_met_era5_mp.py", line 660, in <module>
main()
File "/gws/nopw/j04/4dhydro/data/jules/164_deg/code/drivers/rhine/../create_jules_met_era5_mp.py", line 657, in main
process_driving_data(region_bounds, year, month, timestep, grid_file, era5_type, outputdir, remove_temps, dl_only, mp_run)
File "/gws/nopw/j04/4dhydro/data/jules/164_deg/code/drivers/rhine/../create_jules_met_era5_mp.py", line 621, in process_driving_data
driver_generator(i)
File "/gws/nopw/j04/4dhydro/data/jules/164_deg/code/drivers/rhine/../create_jules_met_era5_mp.py", line 501, in driver_generator
cube = iris.load_cube(jules_map[f]['filepath'], jules_map[f]['era5_names'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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/iris/__init__.py", line 358, in load_cube
cubes = _load_collection(uris, constraints, callback).cubes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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/iris/__init__.py", line 298, in _load_collection
result = _CubeFilterCollection.from_cubes(cubes, constraints)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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/iris/cube.py", line 95, in from_cubes
for cube in cubes:
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/iris/__init__.py", line 279, in _generate_cubes
for cube in iris.io.load_files(part_names, callback, constraints):
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/iris/io/__init__.py", line 219, in load_files
for cube in handling_format_spec.handler(fnames, callback, constraints):
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/iris/fileformats/netcdf/loader.py", line 633, in load_cubes
cube = _load_cube(engine, cf, cf_var, cf.filename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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/iris/fileformats/netcdf/loader.py", line 328, in _load_cube
return _load_cube_inner(engine, cf, cf_var, filename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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/iris/fileformats/netcdf/loader.py", line 357, in _load_cube_inner
engine.activate()
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/iris/fileformats/_nc_load_rules/engine.py", line 95, in activate
run_actions(self)
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/iris/fileformats/_nc_load_rules/actions.py", line 575, in run_actions
action_build_auxiliary_coordinate(engine, auxcoord_fact)
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/iris/fileformats/_nc_load_rules/actions.py", line 92, in inner
rule_name = func(engine, *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/iris/fileformats/_nc_load_rules/actions.py", line 410, in action_build_auxiliary_coordinate
hh.build_auxiliary_coordinate(engine, cf_var, coord_name=coord_name)
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/iris/fileformats/_nc_load_rules/helpers.py", line 1240, in build_auxiliary_coordinate
points_data = _get_cf_var_data(cf_coord_var, engine.filename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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/iris/fileformats/netcdf/loader.py", line 218, in _get_cf_var_data
total_bytes = cf_var.size * cf_var.dtype.itemsize
^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'str' has no attribute 'itemsize'
The workaround I currently have is to download the file in grib format and do a straight conversion with xarray. Seems to then open without issue, albeit not completely CF compliant. This also seems to be OK for cdo use (@Marco_Formenton)
Please let me know if there’s somewhere more appropriate to put this post.
Thanks, Matt