fmaussion / salem

Add geolocalised subsetting, masking, and plotting operations to xarray
http://salem.readthedocs.io
Other
179 stars 43 forks source link

Add a specific grid to salem for RACMO greenland data #163

Open bearecinos opened 4 years ago

bearecinos commented 4 years ago

Hello @fmaussion,

My problem is that I am trying to open two NetCDF files with this salem function:

data = salem.GeoNetcdf(fpath)

salem.GeoNetcdf()

  1. Greenland mask (topography)
  2. Greenland MB data

Both files have a not well define grid: mask = salem.GeoNetcdf(mask_path)

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-5-a371a0171808> in <module>
----> 1 mask = salem.GeoNetcdf(mask_path)

~/.virtualenvs/oggm_env_latest/lib/python3.6/site-packages/salem/datasets.py in __init__(self, file, grid, time, monthbegin)
    382             grid = sio.grid_from_dataset(self._nc)
    383             if grid is None:
--> 384                 raise RuntimeError('File grid not understood')
    385         if time is None:
    386             time = sio.netcdf_time(self._nc, monthbegin=monthbegin)

RuntimeError: File grid not understood`

I then use xarray to open it but I still encounter the grid interpretation problem. With a grid defined like this:

mask = xr.open_dataset(mask_path) mask.grid

Map Projection:Polar Stereographic Ellipsoid - Map Reference Latitude: 90.0 - Map Reference Longitude: -39.0 - Map Second Reference Latitude: 71.0 - Map Eccentricity: 0.081819190843 ;wgs84 - Map Equatorial Radius: 6378137.0 ;wgs84 meters - Grid Map Origin Column: 160 - Grid Map Origin Row: -120 - Grid Map Units per Cell: 5000 - Grid Width: 301 - Grid Height: 561

Without salem or xarray being able to read such a grid I wont be able to build a function to interpolate each pixel of the data to the glacier grid in OGGM. Would it be possible to integrate this type of grid in Salem?

Could we also add a different calendar? smb_data = xr.open_dataset(smb_path, decode_times=False) If I read the MB data I must also add that decode_times = False statement. Since the time units are also not recognise:

smb_data.time.units
'Months since 2018-01-15 00:00:0'

For more information on the data write me on slack. :) I appreciate the help.

fmaussion commented 4 years ago

Hi Bea, can you please share a data file? (ideally not too big)