generated from carbonplan/python-project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d8ecbc
commit 72e639a
Showing
5 changed files
with
133 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,38 @@ | ||
import rioxarray # noqa | ||
import xarray as xr | ||
from ndpyramid import pyramid_reproject | ||
from ndpyramid import pyramid_reproject, pyramid_resample | ||
|
||
|
||
def make_pyramid(levels: int): | ||
def make_pyramid_resample(levels: int): | ||
# ds = xr.tutorial.open_dataset("air_temperature") | ||
|
||
files = [ | ||
'tests/data/3B-DAY.MS.MRG.3IMERG.20230729-S000000-E235959.V07B.nc4', | ||
'tests/data/3B-DAY.MS.MRG.3IMERG.20230730-S000000-E235959.V07B.nc4' | ||
] | ||
ds = xr.open_mfdataset(files, engine='netcdf4', drop_variables=["time_bnds"],decode_coords="all") | ||
|
||
ds = ds.chunk({'lat':10, 'lon':10}) | ||
ds = ds[['precipitation']] | ||
|
||
|
||
ds = ds.rio.write_crs('EPSG:4326') | ||
ds = ds.drop_vars('spatial_ref') | ||
|
||
ds = ds.transpose('time', 'lat', 'lon') | ||
|
||
# ds = ds.rename({"lon": "longitude", "lat": "latitude"}) | ||
# ds = ds.rio.write_crs("EPSG:4326") | ||
ds = ds.isel(time=slice(0, 2)) | ||
# import pdb; pdb.set_trace() | ||
return pyramid_resample(ds, levels=levels, x='lon', y='lat') | ||
|
||
|
||
def make_pyramid_reproject(levels: int): | ||
ds = xr.tutorial.open_dataset("air_temperature") | ||
|
||
ds = ds.rename({"lon": "longitude", "lat": "latitude"}) | ||
ds = ds.rio.write_crs("EPSG:4326") | ||
ds = ds.isel(time=slice(0, 2)) | ||
|
||
# other_chunks added to e2e pass of pyramid b/c target_chunks invert_meshgrid error | ||
return pyramid_reproject(ds, levels=levels, other_chunks={"time": 1}) | ||
return pyramid_reproject(ds, levels=levels) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters