-
Notifications
You must be signed in to change notification settings - Fork 44
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
dataset Grid not understood #100
Comments
The name of your lon/lat coordinates wasn't in the list of accepted coords. Can you try latest master and let me know if that works?
|
Hi, I installed To give some context: I have a set of raster files in Lambert Conformal Conic (LCC) coordinate reference system. Since each file is large and has many bands, I am interested in cropping the extent to only my study area to reduce the size of the entire collection. I am really interested in using Here I am pasting the netcdf summary after opening it with
Please, is there anything I can do to fix this grid problem? |
Hi @Irene-GM , thanks for the report. In order for salem to understand the grid of your file, it must be able to parse the projection information out of the file's metadata. Your file seems quite well defined, so it should be possible. Would you mind sharing a small temporal subset out of it with me? Alternatively, you could define the projection yourself and and give it at runtime as explained in the docs: https://salem.readthedocs.io/en/latest/xarray_acc.html#custom-projection |
Hi @fmaussion , thanks for your quick response! Unfortunately, i cannot share the file with you, since it is experimental data. I tried the trick you suggested in the link and it seems it is not working:
Note that :
So I keep getting the Hope this helps, |
What happens if you do: ds = xr.open_dataset(path_in_nc)
# Since I have many bands, I am extracting only one
ugs = ds.ugs.isel(time=225)
ugs.attrs['pyproj_srs'] = '+proj=lcc +lat_1=51.967 +lat_0=51.967 +lon_0=4.9 +k_0=1 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs'
# Shows in matplotlib, FYI
ugs.salem.quick_map(varname="ugs") ? |
Yes! It worked! Now I only need to figure out why the raster is shifted with respect to the outline of Europe. I guess it has to do with the lat/lon parameters specified in the SRS, so I should find the correct coordinates of the bounding box in LCC-1SP (any suggestion is welcome, btw). Then I can try the subsetting. Thanks a lot for finding this workaround for me, much appreciated :-) |
For the attribute setting problem, see: https://salem.readthedocs.io/en/latest/xarray_acc.html#keeping-track-of-attributes Basically you are going to have to keep track of the attributes, a behavior I would like to change in a future version of salem (#62) Now regarding the shift, there are two things you could look at:
In order to check that salem understands your data well, there is a very simple check: import numpy as np
salem_lon, salem_lat = ugs.salem.grid.ll_coordinates
# Check that they are the same
np.testing.assert_almost_equal(salem_lon, ugs.lon, atol=1e-4)
np.testing.assert_almost_equal(salem_lat, ugs.lat, atol=1e-4) The lon/lat coordinates should be similar at the 3rd or 4th decimal |
If you want me to have a look, please share your data (modified if you want). For example: ds = xr.open_dataset(path_in_nc)
ds = ds[['lon', 'lat']]
ds.to_netcdf('simplified_data.nc') would be enough for me and won't hold any sensitive data other than the coordinates... |
Hello I am also facing the Grid not understood error. I am using a netcdf file of weather forecasts. I subset my file to only precipitation observations and attempt to set the projection as suggested above. However my script is still failing with the error. I would include the file but even after compression it is 160mb. I would subset and re-save the file but I am uncertain whether my subsetting may be causing the problem. Additional note, each file I have is only for one hour of forecasts so the time dimension is purposefully absent. Here is the xarray output: ` ds Here is the code that produced the error. ` ds_sub = ds['TMP_P0_L1_GLC0'] I would appreciate any insight you may have. Thank you! |
Hi, one of the reasons salem can't read your data is that the dimension and coordinate names are not standard (
Salem works only with rectilinear grids in the projection space, i.e. it needs the northings and eastings of your grid. Currently you only have the 2D lons and lats of your grid -> with these you can plot things on a map with cartopy or resample them with xesmf, but you can't use salem. I have written more info about these things scattered on github (pangeo-data/pangeo#356 (comment) or geoxarray/geoxarray#3) but I will write them down in the salem documentation for future reference |
Thank you for the quick response! I am also interested in why the grid lat and longs are coded in a non-standard fashion. I have made no changes to the dataset. In fact there appears to be a couple non-standard aspects to this file that are causing me problems. However, with the current government shutdown my source for this information is unavailable. I am sorry for my lack of experience in working with GIS data, such that I neglected to provide adequate context and information. If my understanding of your response is correct then I do believe this dataset has the northings and eastings, i just failed to include them earlier as they were not understood by xarray and so not reported. The below information comes from a simple ncdump command output. ' Corner Coordinates: #from the xgrid and ygrid dimensions. Latitude Longitude of Grid Corners: Geolocation: Additionally, I know that each gridpoint is exactly 3km by 3km. I also included the geolocation information as I am unsure whether it may be relevant to this discussion. Given this information does it now make sense to try to utilize Salem? |
I have the same issue. Could I ask you @fmaussion to check my data? |
I am also having the "dataset grid not understood" error. I have many time dimensions, and I am trying to create a composite map of the PBLH height, using this code. As far as I can see, the coordinates have remained the same from the original dataset, so I am not sure why I am getting this error. twentyfour = ds.PBLH.groupby('time.hour').mean().isel(hour = 23) <xarray.DataArray 'PBLH' (south_north: 5, west_east: 5)>
|
@sbr-5260 how did you create |
Hi fmaussion, Here is my ds dataset: <xarray.Dataset>
Which of the attributes are needed for constructing the grid? Maybe I could add them back in after the operation. Or open to alternate methods if you have and suggestions! Thanks :) |
|
@sbr-5260 OK, this might be useful: https://salem.readthedocs.io/en/v0.2.3/xarray_acc.html#keeping-track-of-attributes |
I am using the salem.open_mf_wrf_dataset to get the dataset, and the dataset "ds" plots fine until my function-- looks like its the lost attributes that are causing it. Thanks so much! I just need to figure out how to save them or add them back in then. |
|
Got it working! Thanks :) |
Do you have a plan to understand CF projection data?It seems weird to set the projection in code other than files for me. Or did it already supported but I missed it? |
When salem was developed there was no system to interpret CF conventions, and even less files using them ;-). For example WRF is still not using them AFAIK. salem is on "maintainance mode" since a few years now and I don't really think there is much reason to develop it further given all the great tools around (metpy, cartopy, etc). But if someone wants to spend some time on it I am all for it! I am still using salem regularly and I think others do. |
@weirdoyang721 your dataset is probably in rotated pole projection. You need to tell salem how to interpret this. One example of implementation for the MetUM model can be found here: https://github.com/fmaussion/salem/blob/master/salem/sio.py#L1042 |
Hi @fmaussion , yes, the dataset is in rotated pole projection. Here's the information of the rotated map:
I tried to add a function
and the params:
comes out
error In addition, if run Hope for your help! Thanks :) |
Yes, this is a known issue in salem. You need to use Regarding your other issue I'm afraid I can't help much. Maybe plotting with cartopy would be an option? |
It seems that the |
I am trying to apply the
.subset
function on axarray.core.dataset.Dataset
object. However, I getRuntimeError: dataset Grid not understood
. I am able to reproduce the example from the documentation (here), however, when providing another data set I get the error.Here is a snippet of my data: test_data.zip
Here my code:
Any advice?
The text was updated successfully, but these errors were encountered: