You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I have an issue working with the xesmf regridding tool. I am trying to regrid curvilinear POP (parrellel-ocean-program) onto a rectilinear (0.5x0.5) grid. The package xesmf is loaded into python without any issues. The POP-data is defined gx1v3 grid (384 x 320) (384 latitude indeces and 320 longitude Indices). See the figure below to get an idea on how this grid looks like.
To give an idea of my code, first I load the data (in this case, I am interested in the salinity field with dimensions (time, lat, lon)).
The last line dr_out = regridder(data_xr) gives the error, attached in the word document below. ValueError Traceback.docx
The final line of the error reads; 'cannot reshape array of size 31850496000 into shape (360, 720, 384, 320)', which is odd because 360,720384*320 = 31850496000 . I therefore believe that this error is somehow related to the sparse matrix format the matrices are in. Furthermore, this problem does not occur when trying to regrid to e.g. a (4°, 5°)-grid, as in the example (https://xesmf.readthedocs.io/en/latest/notebooks/Curvilinear_grid.html).
For reference purposes, I add the two necessary files to run this code (2GB file!);
Hello, I have an issue working with the xesmf regridding tool. I am trying to regrid curvilinear POP (parrellel-ocean-program) onto a rectilinear (0.5x0.5) grid. The package xesmf is loaded into python without any issues. The POP-data is defined gx1v3 grid (384 x 320) (384 latitude indeces and 320 longitude Indices). See the figure below to get an idea on how this grid looks like.
![Grid_POP](https://private-user-images.githubusercontent.com/92996521/281402610-a8833c93-8635-44cf-bb03-4472bea35091.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg3ODkxODQsIm5iZiI6MTcxODc4ODg4NCwicGF0aCI6Ii85Mjk5NjUyMS8yODE0MDI2MTAtYTg4MzNjOTMtODYzNS00NGNmLWJiMDMtNDQ3MmJlYTM1MDkxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE5VDA5MjEyNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQzNzFmZDY3ZGQzYWI1MmU4ZDAyMGY0YjZhY2I5M2NlYjY4ZWYxYmU2NTBiODcwMmJhMjU5NzljOTM2NjMzMmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.EL-J9j4PMI4NbPY1761kBIpGGf7v_foTMxe-YkiBEJA)
To give an idea of my code, first I load the data (in this case, I am interested in the salinity field with dimensions (time, lat, lon)).
file = "DATA_CESM_SALT_BUDGET/SALT_BUDGET_0_50.nc"
File_open = xr.open_dataset(file, decode_times=False)
#Load Salt-content
SALT_CESM = np.array(File_open.variables['SALT_INT'])
#Load lon-lat-mesh coordinates
file = 'B.E.13.B1850C5.ne30g16.sehires38.003.sunway.pop.h.0001-01.nc'
File_open = xr.open_dataset(file, decode_times = False)
lon_CESM_Mesh = np.array(File_open.variables['TLONG'])
lon_CESM_Mesh[lon_CESM_Mesh>180] = lon_CESM_Mesh[lon_CESM_Mesh>180] - 360
lat_CESM_Mesh = np.array(File_open.variables['TLAT'])
After the data is loaded, I transform the SALT_CESM file, to a proper xarray file that can be used by the xesmf utilities.
data_xr = xr.DataArray(data = SALT_CESM,
coords=dict(latitude=(['latitude', 'longitude'], lat_CESM_Mesh), longitude=(['latitude', 'longitude'], lon_CESM_Mesh), time=('time', time)),
dims=["time", "latitude", "longitude"],
attrs=dict(key = "SALT",
description="Upper layer salinity.",
units="g/kg",
))
Then I define a regridder with the xesmf module. The rectilinear grid I want to redefine the salinity data on has resolution 0.5°x0.5°.
ds_out = xe.util.grid_global(0.5, 0.5)
regridder = xe.Regridder(data_xr, ds_out, 'bilinear', periodic = True)
dr_out = regridder(data_xr)
The last line dr_out = regridder(data_xr) gives the error, attached in the word document below.
ValueError Traceback.docx
The final line of the error reads; 'cannot reshape array of size 31850496000 into shape (360, 720, 384, 320)', which is odd because 360,720384*320 = 31850496000 . I therefore believe that this error is somehow related to the sparse matrix format the matrices are in. Furthermore, this problem does not occur when trying to regrid to e.g. a (4°, 5°)-grid, as in the example (https://xesmf.readthedocs.io/en/latest/notebooks/Curvilinear_grid.html).
For reference purposes, I add the two necessary files to run this code (2GB file!);
https://we.tl/t-uq6umtExXd
Any help would be greatly appreciated!!!
The text was updated successfully, but these errors were encountered: