CMIP NEX-GDDP Downscaled (0.25 deg)
In [3]:
Copied!
# Uncomment to install climdata in Google Colab or other environments
# !pip install climdata
# Uncomment to install climdata in Google Colab or other environments
# !pip install climdata
In [2]:
Copied!
from climdata import ClimData
import pandas as pd
import xarray as xr
import logging
logging.basicConfig(
level=logging.INFO,
format="%(levelname)s | %(message)s",
force=True,
)
from climdata import ClimData
import pandas as pd
import xarray as xr
import logging
logging.basicConfig(
level=logging.INFO,
format="%(levelname)s | %(message)s",
force=True,
)
In [3]:
Copied!
overrides = [
"dataset=nexgddp", # Choose the MSWX dataset for extraction
"lat=52",
"lon=13",
f"time_range.start_date=1989-01-01", # Start date for data extraction
f"time_range.end_date=1989-12-31", # End date for data extraction
"variables=[tasmin]", # Variables to extract: min/max temp and precipitation
"data_dir=./data", # Local directory to store raw/intermediate files
"source_id=GFDL-ESM4",
# "dsinfo.mswx.params.google_service_account=./.climdata_conf/service.json", # optional . required for MSWS data download
"index=tn10p", # Climate extreme index to calculate
"impute=BRITS"
]
# -----------------------------
# Step 3: Define the workflow sequence
# -----------------------------
seq = ["extract", "impute", "calc_index", "to_nc"]
# -----------------------------
# Step 4: Initialize the ClimData extractor
# -----------------------------
extractor = ClimData(overrides=overrides)
# -----------------------------
# Step 5: Run the Multi-Step workflow
# -----------------------------
result = extractor.run_workflow(
actions=seq,
)
overrides = [
"dataset=nexgddp", # Choose the MSWX dataset for extraction
"lat=52",
"lon=13",
f"time_range.start_date=1989-01-01", # Start date for data extraction
f"time_range.end_date=1989-12-31", # End date for data extraction
"variables=[tasmin]", # Variables to extract: min/max temp and precipitation
"data_dir=./data", # Local directory to store raw/intermediate files
"source_id=GFDL-ESM4",
# "dsinfo.mswx.params.google_service_account=./.climdata_conf/service.json", # optional . required for MSWS data download
"index=tn10p", # Climate extreme index to calculate
"impute=BRITS"
]
# -----------------------------
# Step 3: Define the workflow sequence
# -----------------------------
seq = ["extract", "impute", "calc_index", "to_nc"]
# -----------------------------
# Step 4: Initialize the ClimData extractor
# -----------------------------
extractor = ClimData(overrides=overrides)
# -----------------------------
# Step 5: Run the Multi-Step workflow
# -----------------------------
result = extractor.run_workflow(
actions=seq,
)
INFO | Starting action: extract
🔍 Auto-discovering metadata for GFDL-ESM4/historical... Checking available realizations... ✓ Found: r1i1p1f1 (grid: gr1) ✓ Discovered grid_label: gr1 🔍 Downloading NEX-GDDP-CMIP6 data from NASA THREDDS... Model: GFDL-ESM4, Experiment: historical 📥 Fetching tasmin (Daily Minimum Near-Surface Air Temperature)...
Downloading tasmin: 100%|██████████| 1/1 [00:00<00:00, 1.62it/s]
✅ Downloaded 1 files 📂 Loading 1 NEX-GDDP files... Loading tasmin from 1 file(s)...
<frozen importlib._bootstrap>:241: RuntimeWarning: numpy.ndarray size changed, may indicate binary incompatibility. Expected 16 from C header, got 96 from PyObject
✅ Loaded dataset with 1 variables
INFO | Completed action: extract
INFO | Starting action: impute
INFO | No missing data found. Imputation not required.
INFO | Completed action: impute
INFO | Starting action: calc_index
/beegfs/muduchuru/pkgs_fnl/climdata/climdata/utils/wrapper_workflow.py:672: UserWarning: Index tn10p usually requires ≥30 years, got 1
warnings.warn(f"Index {cfg.index} usually requires ≥30 years, got {n_years}", UserWarning)
INFO | Completed action: calc_index
INFO | Starting action: to_nc
INFO | Dataset saved to NetCDF file: nexgddp_tn10p_LAT52_LON13_1989-01-01_1989-12-31.nc
INFO | Completed action: to_nc
In [ ]:
Copied!
from climdata.datasets.NEXGDDP import NEXGDDP
nex = NEXGDDP(extractor.cfg)
from climdata.datasets.NEXGDDP import NEXGDDP
nex = NEXGDDP(extractor.cfg)
In [ ]:
Copied!
nex._construct_download_url('pr','2005')
nex._construct_download_url('pr','2005')
Out[ ]:
('https://ds.nccs.nasa.gov/thredds/ncss/grid/AMES/NEX/GDDP-CMIP6/MRI-ESM2-0/historical/r1i1p1f1/pr/pr_day_MRI-ESM2-0_historical_r1i1p1f1_gn_2005_v2.0.nc?var=pr&north=90&south=-90&east=180&west=-180&horizStride=1&time_start=2005-01-01T12:00:00Z&time_end=2005-12-31T12:00:00Z&accept=netcdf3&addLatLon=true',
'pr_day_MRI-ESM2-0_historical_r1i1p1f1_gn_2005_v2.0.nc')