Skip to content

Commit

Permalink
pre-commit fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lee1043 committed Feb 27, 2025
1 parent b90e810 commit 8393e69
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 57 deletions.
6 changes: 3 additions & 3 deletions pcmdi_metrics/drcdm/param/LOCA2/drcdm_LOCA2_template_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
86400.0,
"mm/day",
)
dec_mode = "JFD" # Use JFD to match Tempest Extremes results
annual_strict = False # This only matters for 5-day values
drop_incomplete_djf = False # False to match Tempest Extremes
dec_mode = "JFD" # Use JFD to match Tempest Extremes results
annual_strict = False # This only matters for 5-day values
drop_incomplete_djf = False # False to match Tempest Extremes
regrid = False
plot = True
netcdf = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
filename_template = "tasmax.%(model).historical.*.LOCA_16thdeg_*.nc"


ModUnitsAdjust=(True, 'KtoF', 0, 'F')
ModUnitsAdjust = (True, "KtoF", 0, "F")
dec_mode = "DJF"
annual_strict = False
drop_incomplete_djf = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
filename_template = "tasmin.%(model).historical.*.LOCA_16thdeg_*.nc"


ModUnitsAdjust=(True, 'KtoF', 0, 'F')
ModUnitsAdjust = (True, "KtoF", 0, "F")
dec_mode = "DJF"
annual_strict = False
drop_incomplete_djf = False
Expand Down
54 changes: 33 additions & 21 deletions pcmdi_metrics/drcdm/param/LOCA2/launch_all_for_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,59 @@

# Before running for the first time, create the following subdirectories:
# pr/, tasmax/, and tasmin/
# Edit model name in L11 and run script to generate job submission scripts for that model.
# Edit model name in L11 and run script to generate job submission scripts for that model.
# Uncomment the os.system() calls to submit jobs.
# To change the job script contents, edit the template files in this directory
# (pr_template.txt, tasmax_template.txt, and tasmin_template.txt)
model = "TaiESM1"
dpath = "/global/cfs/projectdirs/m3522/cmip6/LOCA2/{0}/0p0625deg/".format(model)
reals = glob.glob(os.path.join(dpath,"*"))
reals = glob.glob(os.path.join(dpath, "*"))

for rpath in reals:
realization = os.path.basename(rpath)
params = {
"mymodel": '"{0}"'.format(model),
"myreal": '"{0}"'.format(realization),
"NR": "{0}".format(realization.split("i")[0].replace("r","")),
"NR": "{0}".format(realization.split("i")[0].replace("r", "")),
"modabbr": model[0:3],
"msyear": 1985
}
"msyear": 1985,
}

# PR
with open("/global/homes/a/aordonez/pmp_param/drcdm/LOCA2/pr_template.txt","r") as f:
with open(
"/global/homes/a/aordonez/pmp_param/drcdm/LOCA2/pr_template.txt", "r"
) as f:
tmpl = Template(f.read())
pf = tmpl.substitute(params)
outpath = "/global/homes/a/aordonez/pmp_param/drcdm/LOCA2/pr/run_LOCA2_pr_{0}_{1}.sh".format(model, realization)
with open(outpath,"w") as fout:
outpath = "/global/homes/a/aordonez/pmp_param/drcdm/LOCA2/pr/run_LOCA2_pr_{0}_{1}.sh".format(
model, realization
)
with open(outpath, "w") as fout:
fout.write(pf)
#os.system("sbatch {0}".format(outpath)) #uncomment to submit job
# os.system("sbatch {0}".format(outpath)) #uncomment to submit job

# TASMIN
with open("/global/homes/a/aordonez/pmp_param/drcdm/LOCA2/tasmin_template.txt","r") as f:
with open(
"/global/homes/a/aordonez/pmp_param/drcdm/LOCA2/tasmin_template.txt", "r"
) as f:
tmpl = Template(f.read())
pf = tmpl.substitute(params)
outpath = "/global/homes/a/aordonez/pmp_param/drcdm/LOCA2/tasmin/run_LOCA2_tasmin_{0}_{1}.sh".format(model, realization)
with open(outpath,"w") as fout:
outpath = "/global/homes/a/aordonez/pmp_param/drcdm/LOCA2/tasmin/run_LOCA2_tasmin_{0}_{1}.sh".format(
model, realization
)
with open(outpath, "w") as fout:
fout.write(pf)
#os.system("sbatch {0}".format(outpath))
# os.system("sbatch {0}".format(outpath))

# TASMAX
with open("/global/homes/a/aordonez/pmp_param/drcdm/LOCA2/tasmax_template.txt","r") as f:
with open(
"/global/homes/a/aordonez/pmp_param/drcdm/LOCA2/tasmax_template.txt", "r"
) as f:
tmpl = Template(f.read())
pf = tmpl.substitute(params)
outpath = "/global/homes/a/aordonez/pmp_param/drcdm/LOCA2/tasmax/run_LOCA2_tasmax_{0}_{1}.sh".format(model, realization)
with open(outpath,"w") as fout:
outpath = "/global/homes/a/aordonez/pmp_param/drcdm/LOCA2/tasmax/run_LOCA2_tasmax_{0}_{1}.sh".format(
model, realization
)
with open(outpath, "w") as fout:
fout.write(pf)
#os.system("sbatch {0}".format(outpath))
# os.system("sbatch {0}".format(outpath))
2 changes: 1 addition & 1 deletion pcmdi_metrics/drcdm/param/PRISM/drcdm_PRISM_tasmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
metrics_output_path = "/pscratch/sd/a/aordonez/pmp_data/drcdm/obs/tasmax/PRISM_2025/"


ModUnitsAdjust=(True, 'CtoF', 0, 'F')
ModUnitsAdjust = (True, "CtoF", 0, "F")
dec_mode = "DJF"
annual_strict = False
drop_incomplete_djf = False
Expand Down
2 changes: 1 addition & 1 deletion pcmdi_metrics/drcdm/param/PRISM/drcdm_PRISM_tasmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
metrics_output_path = "/pscratch/sd/a/aordonez/pmp_data/drcdm/obs/tasmin/PRISM_2025/"


ModUnitsAdjust=(True, 'CtoF', 0, 'F')
ModUnitsAdjust = (True, "CtoF", 0, "F")
dec_mode = "DJF"
annual_strict = False
drop_incomplete_djf = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# These settings are required
vars = ["pr"] # Choices are 'pr','tasmax', 'tasmin'
test_data_path = "/global/cfs/projectdirs/m3522/project_downscale/CMIP6/NAM/TTU/STAR-ESDM-V1/%(model)/CMIP/historical/%(realization)/day/%(variable)/v20241130/"
filename_template = "pr_NAM_CMIP6_%(model)_historical_%(realization)_TTU_STAR-ESDM-V1_day_*.nc"
filename_template = (
"pr_NAM_CMIP6_%(model)_historical_%(realization)_TTU_STAR-ESDM-V1_day_*.nc"
)


# Units are actually mm in data so no conversion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# These settings are required
vars = ["tasmax"] # Choices are 'pr','tasmax', 'tasmin'
test_data_path = "/global/cfs/projectdirs/m3522/project_downscale/CMIP6/NAM/TTU/STAR-ESDM-V1/%(model)/CMIP/historical/%(realization)/day/%(variable)/v20241130/"
filename_template = "tasmax_NAM_CMIP6_%(model)_historical_%(realization)_TTU_STAR-ESDM-V1_day_*.nc"
filename_template = (
"tasmax_NAM_CMIP6_%(model)_historical_%(realization)_TTU_STAR-ESDM-V1_day_*.nc"
)


ModUnitsAdjust=(True, 'KtoF', 0, 'F')
ModUnitsAdjust = (True, "KtoF", 0, "F")
dec_mode = "DJF"
annual_strict = False
drop_incomplete_djf = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# These settings are required
vars = ["tasmin"] # Choices are 'pr','tasmax', 'tasmin'
test_data_path = "/global/cfs/projectdirs/m3522/project_downscale/CMIP6/NAM/TTU/STAR-ESDM-V1/%(model)/CMIP/historical/%(realization)/day/%(variable)/v20241130/"
filename_template = "tasmin_NAM_CMIP6_%(model)_historical_%(realization)_TTU_STAR-ESDM-V1_day_*.nc"
filename_template = (
"tasmin_NAM_CMIP6_%(model)_historical_%(realization)_TTU_STAR-ESDM-V1_day_*.nc"
)


ModUnitsAdjust=(True, 'KtoF', 0, 'F')
ModUnitsAdjust = (True, "KtoF", 0, "F")
dec_mode = "DJF"
annual_strict = False
drop_incomplete_djf = False
Expand Down
52 changes: 33 additions & 19 deletions pcmdi_metrics/drcdm/param/STAR-ESDM/launch_all_for_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,60 @@

# Before running for the first time, create the following subdirectories:
# pr/, tasmax/, and tasmin/
# Edit model name in L11 and run script to generate job submission scripts for that model.
# Edit model name in L11 and run script to generate job submission scripts for that model.
# Uncomment the os.system() calls to submit jobs.
# To change the job script contents, edit the template files in this directory
# (pr_template.txt, tasmax_template.txt, and tasmin_template.txt)
model = "ACCESS-CM2"
dpath = "/global/cfs/projectdirs/m3522/project_downscale/CMIP6/NAM/TTU/STAR-ESDM-V1/{0}/CMIP/historical/".format(model)
reals = glob.glob(os.path.join(dpath,"*"))

dpath = "/global/cfs/projectdirs/m3522/project_downscale/CMIP6/NAM/TTU/STAR-ESDM-V1/{0}/CMIP/historical/".format(
model
)
reals = glob.glob(os.path.join(dpath, "*"))

for rpath in reals:
realization = os.path.basename(rpath)
params = {
"mymodel": '"{0}"'.format(model),
"myreal": '"{0}"'.format(realization),
"NR": "{0}".format(realization.split("i")[0].replace("r","")),
"NR": "{0}".format(realization.split("i")[0].replace("r", "")),
"modabbr": model[0:3],
}
}

# PR
with open("/global/homes/a/aordonez/pmp_param/drcdm/STAR-ESDM/pr_template.txt","r") as f:
with open(
"/global/homes/a/aordonez/pmp_param/drcdm/STAR-ESDM/pr_template.txt", "r"
) as f:
tmpl = Template(f.read())
pf = tmpl.substitute(params)
outpath = "/global/homes/a/aordonez/pmp_param/drcdm/STAR-ESDM/pr/run_STAR-ESDM_pr_{0}_{1}.sh".format(model, realization)
with open(outpath,"w") as fout:
outpath = "/global/homes/a/aordonez/pmp_param/drcdm/STAR-ESDM/pr/run_STAR-ESDM_pr_{0}_{1}.sh".format(
model, realization
)
with open(outpath, "w") as fout:
fout.write(pf)
os.system("sbatch {0}".format(outpath))

# TASMIN
with open("/global/homes/a/aordonez/pmp_param/drcdm/STAR-ESDM/tasmin_template.txt","r") as f:
with open(
"/global/homes/a/aordonez/pmp_param/drcdm/STAR-ESDM/tasmin_template.txt", "r"
) as f:
tmpl = Template(f.read())
pf = tmpl.substitute(params)
outpath = "/global/homes/a/aordonez/pmp_param/drcdm/STAR-ESDM/tasmin/run_STAR-ESDM_tasmin_{0}_{1}.sh".format(model, realization)
with open(outpath,"w") as fout:
outpath = "/global/homes/a/aordonez/pmp_param/drcdm/STAR-ESDM/tasmin/run_STAR-ESDM_tasmin_{0}_{1}.sh".format(
model, realization
)
with open(outpath, "w") as fout:
fout.write(pf)
os.system("sbatch {0}".format(outpath))

# TASMAX
with open("/global/homes/a/aordonez/pmp_param/drcdm/STAR-ESDM/tasmax_template.txt","r") as f:
with open(
"/global/homes/a/aordonez/pmp_param/drcdm/STAR-ESDM/tasmax_template.txt", "r"
) as f:
tmpl = Template(f.read())
pf = tmpl.substitute(params)
outpath = "/global/homes/a/aordonez/pmp_param/drcdm/STAR-ESDM/tasmax/run_STAR-ESDM_tasmax_{0}_{1}.sh".format(model, realization)
with open(outpath,"w") as fout:
outpath = "/global/homes/a/aordonez/pmp_param/drcdm/STAR-ESDM/tasmax/run_STAR-ESDM_tasmax_{0}_{1}.sh".format(
model, realization
)
with open(outpath, "w") as fout:
fout.write(pf)
os.system("sbatch {0}".format(outpath))
os.system("sbatch {0}".format(outpath))
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
test_data_path = "/pscratch/sd/a/aordonez/nclim/pr/"
filename_template = "pr_day_nClimGrid-Daily-1-0_PCMDI_5km_*.nc"

metrics_output_path = "/pscratch/sd/a/aordonez/pmp_data/drcdm/obs/pr/nClimGrid-Daily-1-0/"
metrics_output_path = (
"/pscratch/sd/a/aordonez/pmp_data/drcdm/obs/pr/nClimGrid-Daily-1-0/"
)

ModUnitsAdjust = (
True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
test_data_path = "/pscratch/sd/a/aordonez/nclim/tasmax/"
filename_template = "tasmax_day_nClimGrid-Daily-1-0_PCMDI_5km_*.nc"

metrics_output_path = "/pscratch/sd/a/aordonez/pmp_data/drcdm/obs/tasmax/nClimGrid-Daily-1-0/"
metrics_output_path = (
"/pscratch/sd/a/aordonez/pmp_data/drcdm/obs/tasmax/nClimGrid-Daily-1-0/"
)


ModUnitsAdjust=(True, 'KtoF', 0, 'F')
ModUnitsAdjust = (True, "KtoF", 0, "F")
dec_mode = "DJF"
annual_strict = False
drop_incomplete_djf = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
test_data_path = "/pscratch/sd/a/aordonez/nclim/tasmin/"
filename_template = "tasmin_day_nClimGrid-Daily-1-0_PCMDI_5km_*.nc"

metrics_output_path = "/pscratch/sd/a/aordonez/pmp_data/drcdm/obs/tasmin/nClimGrid-Daily-1-0/"
metrics_output_path = (
"/pscratch/sd/a/aordonez/pmp_data/drcdm/obs/tasmin/nClimGrid-Daily-1-0/"
)


ModUnitsAdjust=(True, 'KtoF', 0, 'F')
ModUnitsAdjust = (True, "KtoF", 0, "F")
dec_mode = "DJF"
annual_strict = False
drop_incomplete_djf = False
Expand Down

0 comments on commit 8393e69

Please sign in to comment.