Skip to content

Commit d3ffc6b

Browse files
committed
add chunks auto to open_mfdataset to avoid memory problems
1 parent 177b897 commit d3ffc6b

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

PyStemmusScope/global_data/cams_co2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def extract_cams_data(
6060
Returns:
6161
DataArray containing the CO2 concentration.
6262
"""
63-
ds = xr.open_mfdataset(files_cams)
63+
ds = xr.open_mfdataset(files_cams, chunks='auto')
6464

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

PyStemmusScope/global_data/cci_landcover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def extract_landcover_data(
6262
Returns:
6363
Dictionary containing IGBP and LCCS land cover classes.
6464
"""
65-
cci_dataset = xr.open_mfdataset(files_cci)
65+
cci_dataset = xr.open_mfdataset(files_cci, chunks='auto')
6666

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

PyStemmusScope/global_data/copernicus_lai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def extract_lai_data(
6060
Returns:
6161
DataArray containing the LAI of the specified site for the given time range.
6262
"""
63-
ds = xr.open_mfdataset(files_lai)
63+
ds = xr.open_mfdataset(files_lai, chunks='auto')
6464

6565
check_lai_dataset(ds, latlon, time_range)
6666

PyStemmusScope/global_data/era5.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ def get_era5_dataset(
124124
"""
125125
tol = RESOLUTION_ERA5 if name == "ERA5" else RESOLUTION_ERA5LAND
126126

127-
ds = xr.open_mfdataset(files)
127+
ds = xr.open_mfdataset(files, chunks='auto')
128+
128129
check_era5_dataset(ds, name, latlon, time_range)
129130

130131
try:

0 commit comments

Comments
 (0)