Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Avoid using h5netcdf? #23

Closed
JackKelly opened this issue May 28, 2020 · 9 comments
Closed

Avoid using h5netcdf? #23

JackKelly opened this issue May 28, 2020 · 9 comments

Comments

@JackKelly
Copy link
Member

MetOfficeMessage.load_netcdf() ends with the line:

return xr.open_dataset(netcdf_bytes_io, engine='h5netcdf')

This means we must include h5netcdf in environment.yml. But, including h5netcdf forces conda to downgrade cartopy from v0.18 to v0.17, which breaks nwp_plot.py:

>       ax = plt.axes(projection=ccrs.OSGB(approx=True))
E       TypeError: __init__() got an unexpected keyword argument 'approx'

metoffice_ec2/nwp_plot.py:35: TypeError

One solution may be to see if we can use an xarray engine which isn't h5netcdf.

@JackKelly
Copy link
Member Author

JackKelly commented May 28, 2020

It's possible that we can just remove engine='h5netcdf'. Or see here for an alternative approach: pydata/xarray#1075 (comment)

@flowirtz
Copy link
Contributor

Getting a lot of these errors atm:

2020-05-29 17:49:47,688 - metoffice_ec2 - ERROR - No module named 'h5netcdf'
Traceback (most recent call last):
  File "scripts/ec2.py", line 114, in loop
    load_subset_and_save_data(mo_message, s3)
  File "scripts/ec2.py", line 64, in load_subset_and_save_data
    dataset = mo_message.load_netcdf()
  File "/usr/src/app/metoffice_ec2/message.py", line 73, in load_netcdf
    return xr.open_dataset(netcdf_bytes_io)
  File "/opt/conda/envs/metoffice_ec2/lib/python3.8/site-packages/xarray/backends/api.py", line 533, in open_dataset
    store = backends.H5NetCDFStore.open(
  File "/opt/conda/envs/metoffice_ec2/lib/python3.8/site-packages/xarray/backends/h5netcdf_.py", line 123, in open
    import h5netcdf
ModuleNotFoundError: No module named 'h5netcdf'

Reopening this issue, didn't seem to resolve it.

@flowirtz
Copy link
Contributor

Reverted this via #30 to fix deployment.

@JackKelly
Copy link
Member Author

Eak, sorry about this, I really need to write some more tests so we can catch simple failures like this before pushing to master. Sorry, my bad! I'll look into this next week

@flowirtz
Copy link
Contributor

No worries! Yes, we should probably add some tests haha

@JackKelly
Copy link
Member Author

I've recreated this issue locally.

I've tried changing the engine to all the options (other than h5netcdf) and it always responds: ValueError: can only read bytes or file-like objects with engine='scipy' or 'h5netcdf'

JackKelly added a commit that referenced this issue Jun 1, 2020
@JackKelly
Copy link
Member Author

I've recreated this issue locally.

I've tried changing the engine to all the options (other than h5netcdf) and it always responds: ValueError: can only read bytes or file-like objects with engine='scipy' or 'h5netcdf'

But I think I've got it working without h5netcdf using the netCDF4 trick described here: pydata/xarray#1075 (comment)

@fwirtz no rush, but please could you try this new code on AWS?

@flowirtz
Copy link
Contributor

flowirtz commented Jun 9, 2020

@JackKelly Will do! Thanks.

@flowirtz
Copy link
Contributor

flowirtz commented Jun 9, 2020

That worked!

@flowirtz flowirtz closed this as completed Jun 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants