Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #57: Check if ERA5 nc file for this year exists, else, use latest date from prev year #58

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion run_era5_forecast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@ for HEMI in south north; do

# ERA5 tracks behind the SIC, there was an issue causing the need to use SIC
# FORECAST_INIT=`python -c 'import xarray as xr; print(str(xr.open_dataset("data/osisaf/'$HEMI'/siconca/'${DATE_RANGE:0:4}'.nc").time.values.max())[0:10])'`
FORECAST_INIT=`python -c 'import xarray as xr; print(str(xr.open_dataset("data/era5/'$HEMI'/tas/'${DATE_RANGE:0:4}'.nc").time.values.max())[0:10])'`

# If ERA5 `tas` variable netCDF file does not exist for this year, likely because we've just hit first week of new year where there is no ERA5 data
# available yet due to ~5 day lag in data availability.
if [ ! -f "data/era5/'$HEMI'/tas/'${DATE_RANGE:0:4}'.nc" ]; then
# Use latest day data has been downloaded for in the previous year
YEAR=`date +%Y --date='last year'`
FORECAST_INIT=`python -c 'import xarray as xr; print(str(xr.open_dataset("data/era5/'$HEMI'/tas/'${YEAR}'.nc").time.values.max())[0:10])'`
else
YEAR=${DATE_RANGE:0:4}
FORECAST_INIT=`python -c 'import xarray as xr; print(str(xr.open_dataset("data/era5/'$HEMI'/tas/'${YEAR}'.nc").time.values.max())[0:10])'`
fi

export FORECAST_START="$FORECAST_INIT"
export FORECAST_END="$FORECAST_INIT"
Expand Down