Skip to content

Commit

Permalink
Updating comparision script for RFMIP example to fix broken link
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertPincus committed Apr 20, 2020
1 parent 0f72e9e commit 69d36c9
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions examples/rfmip-clear-sky/compare-to-reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@
import urllib.request

tst_dir = "."
rrtmg_suffix = "_Efx_RTE-RRTMGP-181204_rad-irf_r1i1p1f1_gn.nc"
rrtmgp_suffix = "_Efx_RTE-RRTMGP-181204_rad-irf_r1i1p1f1_gn.nc"

#
# Construct URL for RTE+RRTMGP results for RFMIP from ESGF
#
def construct_esgf_file(var):
esgf_url_base = "http://esgf3.dkrz.de/thredds/fileServer/cmip6/RFMIP/RTE-RRTMGP-Consortium/RTE-RRTMGP-181204/rad-irf/r1i1p1f1/Efx/"
esgf_url_ver = "gn/v20191007/"
return (os.path.join(esgf_url_base, var, esgf_url_ver, var+rrtmgp_suffix))
#
# Comparing reference and test results
#
Expand All @@ -30,21 +37,14 @@
vars = ['rlu', 'rld', 'rsu', 'rsd']
# Download reference data
# If versions of all files exist in the reference directory, no need to download (can be over-ridden)
if not all([os.path.exists(os.path.join(args.ref_dir, v + rrtmg_suffix)) for v in vars]) or args.download_reference:
if not all([os.path.exists(os.path.join(args.ref_dir, v + rrtmgp_suffix)) for v in vars]) or args.download_reference:
print("Dowloading reference data")
os.makedirs(args.ref_dir, exist_ok=True)
urllib.request.urlretrieve("https://owncloud.gwdg.de/index.php/s/kbhl3JOSccGtR0m/download", \
os.path.join(args.ref_dir, "rld_Efx_RTE-RRTMGP-181204_rad-irf_r1i1p1f1_gn.nc"))
urllib.request.urlretrieve("https://owncloud.gwdg.de/index.php/s/5DbhryVSfztioPG/download", \
os.path.join(args.ref_dir, "rlu_Efx_RTE-RRTMGP-181204_rad-irf_r1i1p1f1_gn.nc"))
urllib.request.urlretrieve("https://owncloud.gwdg.de/index.php/s/uCemCHlGxbGK0gJ/download", \
os.path.join(args.ref_dir, "rsd_Efx_RTE-RRTMGP-181204_rad-irf_r1i1p1f1_gn.nc"))
urllib.request.urlretrieve("https://owncloud.gwdg.de/index.php/s/l8ZG28j9ttZWD9r/download", \
os.path.join(args.ref_dir, "rsu_Efx_RTE-RRTMGP-181204_rad-irf_r1i1p1f1_gn.nc"))

for v in vars:
urllib.request.urlretrieve(construct_esgf_file(v), os.path.join(args.ref_dir, v+rrtmgp_suffix))

tst = xr.open_mfdataset(os.path.join( tst_dir, "r??" + rrtmg_suffix), combine='by_coords')
ref = xr.open_mfdataset(os.path.join(args.ref_dir, "r??" + rrtmg_suffix), combine='by_coords')
tst = xr.open_mfdataset(os.path.join( tst_dir, "r??" + rrtmgp_suffix), combine='by_coords')
ref = xr.open_mfdataset(os.path.join(args.ref_dir, "r??" + rrtmgp_suffix), combine='by_coords')

failed = False
for v in vars:
Expand Down

0 comments on commit 69d36c9

Please sign in to comment.