-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeatwaveFreq_main.py
97 lines (81 loc) · 2.66 KB
/
HeatwaveFreq_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
"""Main file for heatwave frequency experiment
Adam Michael Bauer
University of Illinois at Urbana Champaign
adammb4@illinois.edu
2.26.2022
The code increments the temperature by 5 K over the current average
and measures what percentage of the daily mean temperature
and the daily mean soil moisture exceed of fail to reach, resp., a baseline.
To run: python MasterHeatwaveFreq.py
"""
from src.LocSimulation import LocSimulation
from src.tools import import_csv
from src.locations.SGP import SGP
from src.locations.DAL import DAL
from src.locations.ATL import ATL
from src.locations.SEA import SEA
from src.locations.NY import NY
from src.locations.WIT import WIT
"""
Fill in the runs you want from BVZP_research_runs.csv
"""
desired_runs = [0,1,2,3,4,5]
"""
Import data for runs.
"""
header, descriptions, data = import_csv("BVZP_research_runs", delimiter=',',
header=True, indices=2)
for run in desired_runs:
run_name = descriptions[run][1]
print("Carrying out run %i, which corresponds to %s." % (run, run_name))
"""
loc_string: name of location we're simulating
max_warming: maximum amount of temperature warming in our simulation
N_simulations: number of sub-simulations leading up to maximum warming case
N_summers: number of summers we integrate the model equations for in each
simulation
import_precip: have we already made precip for this run? (check data
directory!)
"""
loc_string, max_warming, N_simulations, N_summers, import_precip, dt = data[run]
"""
Cast variables from BVZP_research_runs.csv into proper forms.
"""
max_warming = float(max_warming)
N_simulations = int(N_simulations)
N_summers = int(N_summers)
dt = int(dt)
"""
import_precip must be boolean.
"""
if import_precip == "True":
import_precip = True
else:
import_precip = False
"""
Make an instance of the class with name loc_string.
"""
loc_constructor = globals()[loc_string]
loc = loc_constructor()
"""
Calibrate warming simulations with max_warming.
"""
loc.calibrate_warming_simulations(max_warming=max_warming)
"""
make class instance for location simulation
"""
LOC = LocSimulation(run_name, loc, N_simulations, N_summers,
import_precip=import_precip,
max_warming=max_warming, dt=dt)
"""
make time series forcing
"""
LOC.make_model_forcings()
"""
simulate model equations from SMACM
"""
LOC.make_forced_ts(save_output=False)
"""
calculate percentile exceedences for location
"""
LOC.make_simulation_output(save_output=True)