-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shoud the nc file add CRS according to cf-conventions? #36
Comments
That is interesting. Could you provide a more concrete example on how to do this? I just go through the doc you send, and the simplest way is to convert the crs in |
I'm not a specialist of that too, so I guess you're right. And I don't know the details of this conventions and if it will become popular soon. As I know, many Xarray mentioned CF data just here, and there are few informations. But this snippet returens
It seems that |
|
I test that code in an environment contains
It may be a pretty new feature? But I know it sometimes cause compatibility issues. |
I guess this is really new feature. The doc shows that api's name is I currently cannot make any test because I don't have the newest environment. From the codes you showed it is pretty simple to do this. If It seems that everything is changing to take into account the CF convention, although I knew it many years ago. |
When I tried to solve #37, I found a workaround for this. I use cartopy 0.18.0 and the returned crs from from pyproj import CRS
crs = get_data_projection(ctl, Rearth=6370000)
proj_crs = CRS(crs.proj4_init)
cf = proj_crs.to_cf() It is a little too long and not a string. But So if you want to put cf into nc file, you can put |
Yes, I've found it's an unsolved issue of Cartopy for a long time. And Xarray don't read the crs data by default. I've tried rioxarray to get the crs, but there are still some bugs. |
CF-Conventions are annoying but quite useful. I figured out the way to make panoply recgnize the crs in nc file: https://bitegrads.readthedocs.io/en/latest/Examples/02_gridded_binary_with_pdef.html The key here is to add an |
Hi @Mo-Dabao, that's very useful. Thank you for sharing this point. Recently, I've added a function to parse the global comments in ctl files output by WRF (see here). I may add a util function in def to_CFnetcdf(dset, comments, Rearth, path):
# add_comments_to_dset(dset, comments)
# add_Rearth_to_dset(dset, Rearth)
# dset.to_netcdf(path) Do you think this is OK? Can you please try if the output NC file can be recognized by panoply, as I don't have panoply? |
It's totally up to you. But the
|
Recently I've learned the cf-conventions that defines a way to store crs in
.nc
file and pyproj gives a method to get crs from and to nc.So is it possible to add crs when converting
.nc
? Otherwise we still need the original.ctl
files to store the projection information. It's weird.Thanks again for your work. It helps a lot in my work.
The text was updated successfully, but these errors were encountered: