NOAA-ORR-ERD / gridded

A single API for accessing / working with gridded model results on multiple grid types
https://noaa-orr-erd.github.io/gridded/index.html
The Unlicense
64 stars 14 forks source link

Issue to load a nc file with curvilinear grid. #38

Open wk1984 opened 5 years ago

wk1984 commented 5 years ago

I have a sample NC file with the following data structure:

File format: NetCDF4
    -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter ID
     1 : unknown  unknown  v instant       1   1    129600   1  F32  : -1            
   Grid coordinates:
     1 : curvilinear              : points=129600 (360x360)
                            XLONG : -179.9979 to 179.9961 degree_east
                             XLAT : 24.70594 to 89.79536 degree_north
   Vertical coordinates :
     1 : surface                  : levels=1
   Time coordinate :  1 step
     RefTime =  1901-01-01 00:00:00  Units = hours  Calendar = standard
  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss
  2000-01-16 11:00:00

When I use gridded.Dataset to load this file, it shows an error message:

ValueError: Can not figure out what type of grid this is. Try specifying the grid_topology attributes or specifying the grid type

This is a curvilinear grid structure and irregular lat-lon names.

How can I load this kind of data file? and how to extract pixels by using lat-lon?

Thanks for your help!

test.nc.zip

jay-hennen commented 5 years ago

When using a file that doesn't comply with the UGrid or SGrid standards, being more explicit and more specific is always more helpful.

Do you really want the entire Dataset? or do you just want one Variable, or even just the Grid? The more specific, the easier it is to produce what you want.

grd = Grid_S.from_netCDF('filename', grid_topology={'node_lon': 'XLONG', 'node_lat': 'XLAT'})
var = Variable.from_netCDF('filename', grid=grd, varname='INSERT_NAME')

Alternatively, you could try this and see if it's enough:

ds = Dataset(grid_topology={'node_lon': 'XLONG', 'node_lat': 'XLAT'})