forked from RocketPy-Team/RocketPy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweather_model_mapping.py
More file actions
155 lines (151 loc) · 4.35 KB
/
Copy pathweather_model_mapping.py
File metadata and controls
155 lines (151 loc) · 4.35 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
class WeatherModelMapping:
"""Class to map the weather model variables to the variables used in the
Environment class.
"""
GFS = {
"time": "time",
"latitude": "lat",
"longitude": "lon",
"level": "lev",
"temperature": "tmpprs",
"surface_geopotential_height": "hgtsfc",
"geopotential_height": "hgtprs",
"geopotential": None,
"u_wind": "ugrdprs",
"v_wind": "vgrdprs",
}
NAM = {
"time": "time",
"latitude": "lat",
"longitude": "lon",
"level": "lev",
"temperature": "tmpprs",
"surface_geopotential_height": "hgtsfc",
"geopotential_height": "hgtprs",
"geopotential": None,
"u_wind": "ugrdprs",
"v_wind": "vgrdprs",
}
ECMWF_v0 = {
"time": "time",
"latitude": "latitude",
"longitude": "longitude",
"level": "level",
"ensemble": "number",
"temperature": "t",
"surface_geopotential_height": None,
"geopotential_height": None,
"geopotential": "z",
"u_wind": "u",
"v_wind": "v",
}
ECMWF = {
"time": "valid_time",
"latitude": "latitude",
"longitude": "longitude",
"level": "pressure_level",
"ensemble": "number",
"temperature": "t",
"surface_geopotential_height": None,
"geopotential_height": None,
"geopotential": "z",
"u_wind": "u",
"v_wind": "v",
}
NOAA = {
"time": "time",
"latitude": "lat",
"longitude": "lon",
"level": "lev",
"temperature": "tmpprs",
"surface_geopotential_height": "hgtsfc",
"geopotential_height": "hgtprs",
"geopotential": None,
"u_wind": "ugrdprs",
"v_wind": "vgrdprs",
}
RAP = {
"time": "time",
"latitude": "lat",
"longitude": "lon",
"level": "lev",
"temperature": "tmpprs",
"surface_geopotential_height": "hgtsfc",
"geopotential_height": "hgtprs",
"geopotential": None,
"u_wind": "ugrdprs",
"v_wind": "vgrdprs",
}
CMC = {
"time": "time",
"latitude": "lat",
"longitude": "lon",
"level": "lev",
"ensemble": "ens",
"temperature": "tmpprs",
"surface_geopotential_height": None,
"geopotential_height": "hgtprs",
"geopotential": None,
"u_wind": "ugrdprs",
"v_wind": "vgrdprs",
}
GEFS = {
"time": "time",
"latitude": "lat",
"longitude": "lon",
"level": "lev",
"ensemble": "ens",
"temperature": "tmpprs",
"surface_geopotential_height": None,
"geopotential_height": "hgtprs",
"geopotential": None,
"u_wind": "ugrdprs",
"v_wind": "vgrdprs",
}
HIRESW = {
"time": "time",
"latitude": "lat",
"longitude": "lon",
"level": "lev",
"temperature": "tmpprs",
"surface_geopotential_height": "hgtsfc",
"geopotential_height": "hgtprs",
"u_wind": "ugrdprs",
"v_wind": "vgrdprs",
}
MERRA2 = {
"time": "time",
"latitude": "lat",
"longitude": "lon",
"level": "lev",
"temperature": "T",
"surface_geopotential_height": None,
"surface_geopotential": "PHIS", # special key for Geopotential (m^2/s^2)
"geopotential_height": "H",
"geopotential": None,
"u_wind": "U",
"v_wind": "V",
}
def __init__(self):
"""Initialize the class, creates a dictionary with all the weather models
available and their respective dictionaries with the variables."""
self.all_dictionaries = {
"GFS": self.GFS,
"NAM": self.NAM,
"ECMWF_v0": self.ECMWF_v0,
"ECMWF": self.ECMWF,
"NOAA": self.NOAA,
"RAP": self.RAP,
"CMC": self.CMC,
"GEFS": self.GEFS,
"HIRESW": self.HIRESW,
"MERRA2": self.MERRA2,
}
def get(self, model):
try:
return self.all_dictionaries[model]
except KeyError as e:
raise KeyError(
f"Model {model} not found in the WeatherModelMapping. "
f"The available models are: {self.all_dictionaries.keys()}"
) from e