Skip to content

Commit

Permalink
add chunks auto to open_mfdataset to avoid memory problems
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahAlidoost committed Feb 2, 2024
1 parent 177b897 commit d3ffc6b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion PyStemmusScope/global_data/cams_co2.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def extract_cams_data(
Returns:
DataArray containing the CO2 concentration.
"""
ds = xr.open_mfdataset(files_cams)
ds = xr.open_mfdataset(files_cams, chunks='auto')

check_cams_dataset(cams_data=ds, latlon=latlon, time_range=time_range)

Expand Down
2 changes: 1 addition & 1 deletion PyStemmusScope/global_data/cci_landcover.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def extract_landcover_data(
Returns:
Dictionary containing IGBP and LCCS land cover classes.
"""
cci_dataset = xr.open_mfdataset(files_cci)
cci_dataset = xr.open_mfdataset(files_cci, chunks='auto')

check_cci_dataset(cci_dataset, latlon, time_range) # Assert spatial/temporal bounds

Expand Down
2 changes: 1 addition & 1 deletion PyStemmusScope/global_data/copernicus_lai.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def extract_lai_data(
Returns:
DataArray containing the LAI of the specified site for the given time range.
"""
ds = xr.open_mfdataset(files_lai)
ds = xr.open_mfdataset(files_lai, chunks='auto')

check_lai_dataset(ds, latlon, time_range)

Expand Down
3 changes: 2 additions & 1 deletion PyStemmusScope/global_data/era5.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def get_era5_dataset(
"""
tol = RESOLUTION_ERA5 if name == "ERA5" else RESOLUTION_ERA5LAND

ds = xr.open_mfdataset(files)
ds = xr.open_mfdataset(files, chunks='auto')

check_era5_dataset(ds, name, latlon, time_range)

try:
Expand Down

0 comments on commit d3ffc6b

Please sign in to comment.