CDRUtilities 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CDRUtilities/__init__.py +9 -0
- CDRUtilities/iso_mapping.py +361 -0
- CDRUtilities/lmrlib.py +671 -0
- CDRUtilities/py.typed +0 -0
- cdrutilities-1.0.0.dist-info/METADATA +79 -0
- cdrutilities-1.0.0.dist-info/RECORD +9 -0
- cdrutilities-1.0.0.dist-info/WHEEL +5 -0
- cdrutilities-1.0.0.dist-info/licenses/LICENSE +674 -0
- cdrutilities-1.0.0.dist-info/top_level.txt +1 -0
CDRUtilities/__init__.py
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
class iso_mapping:
|
|
4
|
+
def convertUpperCloud(cloud: str):
|
|
5
|
+
value = cloud.lower()
|
|
6
|
+
if "cumulo" in value and "nimbus" in value:
|
|
7
|
+
return "Cl9"
|
|
8
|
+
elif "cumulo" in value and "stratus" in value:
|
|
9
|
+
return "Cm7"
|
|
10
|
+
elif "cirr" in value and "cumul" in value:
|
|
11
|
+
return "Cm8"
|
|
12
|
+
elif "cirr" in value and "strat" in value:
|
|
13
|
+
return "Ch8"
|
|
14
|
+
elif "cirr" in value:
|
|
15
|
+
return "Ch9"
|
|
16
|
+
elif "strat" in value:
|
|
17
|
+
return "Ch8"
|
|
18
|
+
elif "nimb" in value:
|
|
19
|
+
return "Cm2"
|
|
20
|
+
elif "cumul" in value:
|
|
21
|
+
return "Ch9"
|
|
22
|
+
elif "scud" in value or "passing" in value:
|
|
23
|
+
return "Cm4"
|
|
24
|
+
elif ("obscured" in value or "hidden" in value or "fog" in value or "haz" in value or "smoke" in value
|
|
25
|
+
or "mist" in value or "overcast" in value):
|
|
26
|
+
return "Ch/"
|
|
27
|
+
elif ("-" in value or "clear" in value or "none apparent" in value or "0" in value or "imp" in value):
|
|
28
|
+
return "Ch0"
|
|
29
|
+
return "-999"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def convertLowerCloud(cloud: str):
|
|
33
|
+
value = cloud.lower()
|
|
34
|
+
if "cumul" in value and "nimb" in value:
|
|
35
|
+
return "Cl9"
|
|
36
|
+
elif "cumul" in value and "strat" in value:
|
|
37
|
+
return "Cl4"
|
|
38
|
+
elif "nimb" in value and "strat" in value:
|
|
39
|
+
return "Cm2"
|
|
40
|
+
elif "nimb" in value:
|
|
41
|
+
return "Cl7"
|
|
42
|
+
elif "cirr" in value:
|
|
43
|
+
return "Ch6"
|
|
44
|
+
elif "strat" in value:
|
|
45
|
+
return "Cl6"
|
|
46
|
+
elif "cumul" in value:
|
|
47
|
+
return "Cl2"
|
|
48
|
+
elif "scud" in value or "passing" in value:
|
|
49
|
+
return "Cl5"
|
|
50
|
+
elif ("obscured" in value or "hidden" in value or "fog" in value or "haz" in value or "smoke" in value
|
|
51
|
+
or "mist" in value or "vapour" in value or "overcast" in value):
|
|
52
|
+
return "Cl/"
|
|
53
|
+
elif ("-" in value or "clear" in value or "none apparent" in value or "0" in value or "imp" in value):
|
|
54
|
+
return "Cl0"
|
|
55
|
+
return "-999"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def convertBeauforttext(wf: str):
|
|
59
|
+
value = wf.lower()
|
|
60
|
+
if "gale" in value:
|
|
61
|
+
if "near" in value:
|
|
62
|
+
return 15.4
|
|
63
|
+
elif "strong" in value:
|
|
64
|
+
return 22.6
|
|
65
|
+
else:
|
|
66
|
+
return 19
|
|
67
|
+
elif "storm" in value:
|
|
68
|
+
if "violent" in value:
|
|
69
|
+
return 30.9
|
|
70
|
+
else:
|
|
71
|
+
return 26.8
|
|
72
|
+
elif "hurricane" in value:
|
|
73
|
+
return 35.
|
|
74
|
+
elif "calm" in value:
|
|
75
|
+
return 0
|
|
76
|
+
elif "air" in value:
|
|
77
|
+
return 1
|
|
78
|
+
elif "light" in value:
|
|
79
|
+
return 2.6
|
|
80
|
+
elif ("gentle" in value or "modest" in value):
|
|
81
|
+
return 4.6
|
|
82
|
+
elif "moderate" in value:
|
|
83
|
+
return 6.7
|
|
84
|
+
elif "fresh" in value:
|
|
85
|
+
return 9.3
|
|
86
|
+
elif "strong" in value:
|
|
87
|
+
return 12.3
|
|
88
|
+
else:
|
|
89
|
+
return -999
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def convertBeaufort(wf: str):
|
|
93
|
+
value = int(wf)
|
|
94
|
+
if value == 0:
|
|
95
|
+
return 0
|
|
96
|
+
elif value == 1:
|
|
97
|
+
return 1
|
|
98
|
+
elif value == 2:
|
|
99
|
+
return 2.6
|
|
100
|
+
elif value == 3:
|
|
101
|
+
return 4.6
|
|
102
|
+
elif value == 4:
|
|
103
|
+
return 6.7
|
|
104
|
+
elif value == 5:
|
|
105
|
+
return 9.3
|
|
106
|
+
elif value == 6:
|
|
107
|
+
return 12.3
|
|
108
|
+
elif value == 7:
|
|
109
|
+
return 15.4
|
|
110
|
+
elif value == 8:
|
|
111
|
+
return 19
|
|
112
|
+
elif value == 9:
|
|
113
|
+
return 22.6
|
|
114
|
+
elif value == 10:
|
|
115
|
+
return 26.8
|
|
116
|
+
elif value == 11:
|
|
117
|
+
return 30.9
|
|
118
|
+
elif value == 12:
|
|
119
|
+
return 35
|
|
120
|
+
else:
|
|
121
|
+
return (-999)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def convertSmithsonian(wf: str):
|
|
125
|
+
value = int(wf)
|
|
126
|
+
if value == 0:
|
|
127
|
+
return 0
|
|
128
|
+
elif value == 1:
|
|
129
|
+
return 1 # 2mph /2.237
|
|
130
|
+
elif value == 2:
|
|
131
|
+
return (float(4/2.237))
|
|
132
|
+
elif value == 3:
|
|
133
|
+
return (float(12/2.237))
|
|
134
|
+
elif value == 4:
|
|
135
|
+
return (float(25/2.237))
|
|
136
|
+
elif value == 5:
|
|
137
|
+
return (float(35/2.237))
|
|
138
|
+
elif value == 6:
|
|
139
|
+
return (float(45/2.237))
|
|
140
|
+
elif value == 7:
|
|
141
|
+
return (float(60/2.237))
|
|
142
|
+
elif value == 8:
|
|
143
|
+
return (float(75/2.237))
|
|
144
|
+
elif value == 9:
|
|
145
|
+
return (float(90/2.237))
|
|
146
|
+
elif value == 10:
|
|
147
|
+
return (float(100/2.237))
|
|
148
|
+
else:
|
|
149
|
+
return (-999)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
# map to convert directions to iso - key should be lower case
|
|
153
|
+
convert_directions = {
|
|
154
|
+
"north": 0,
|
|
155
|
+
"north by east": 11.25,
|
|
156
|
+
"north-north-east": 22.5,
|
|
157
|
+
"northeast by north": 33.75,
|
|
158
|
+
"north-east": 45,
|
|
159
|
+
"northeast by east": 56.25,
|
|
160
|
+
"east-north-east": 67.5,
|
|
161
|
+
"east by north": 78.75,
|
|
162
|
+
"east": 90,
|
|
163
|
+
"east by south": 101.25,
|
|
164
|
+
"east-south-east": 112.5,
|
|
165
|
+
"southeast by east": 123.75,
|
|
166
|
+
"south-east": 135,
|
|
167
|
+
"southeast by south": 146.25,
|
|
168
|
+
"south-south-east": 157.5,
|
|
169
|
+
"south by east": 168.75,
|
|
170
|
+
"south": 180,
|
|
171
|
+
"south by west": 191.25,
|
|
172
|
+
"south-south-west": 202.5,
|
|
173
|
+
"southwest by south": 213.75,
|
|
174
|
+
"south-west": 225,
|
|
175
|
+
"southwest by west": 236.25,
|
|
176
|
+
"west-south-west": 247.5,
|
|
177
|
+
"west by south": 258.75,
|
|
178
|
+
"west": 270,
|
|
179
|
+
"west by north": 281.25,
|
|
180
|
+
"west-north-west": 292.5,
|
|
181
|
+
"northwest by west": 303.75,
|
|
182
|
+
"north-west": 315,
|
|
183
|
+
"northwest by north": 326.25,
|
|
184
|
+
"north-north-west": 337.5,
|
|
185
|
+
"north by west": 348.75,
|
|
186
|
+
"hidden": -999}
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
# map to convert directions to abbreviation - key should be lower case
|
|
190
|
+
abbr_directions = {
|
|
191
|
+
"north": "N",
|
|
192
|
+
"north by east": "NbyE",
|
|
193
|
+
"north-north-east": "NNE",
|
|
194
|
+
"northeast by north": "NEbyN",
|
|
195
|
+
"northeast by east": "NEbyE",
|
|
196
|
+
"north-east": "NE",
|
|
197
|
+
"east-north-east": "ENE",
|
|
198
|
+
"east by north": "EbyN",
|
|
199
|
+
"east": "E",
|
|
200
|
+
"east by south": "EbyS",
|
|
201
|
+
"east-south-east": "ESE",
|
|
202
|
+
"southeast by east": "SEbyE",
|
|
203
|
+
"south-east": "SE",
|
|
204
|
+
"southeast by south": "SEbyS",
|
|
205
|
+
"south-south-east": "SSE",
|
|
206
|
+
"south by east": "SbyE",
|
|
207
|
+
"south": "S",
|
|
208
|
+
"south by west": "SbyW",
|
|
209
|
+
"south-south-west": "SSW",
|
|
210
|
+
"southwest by south": "SWbyS",
|
|
211
|
+
"south-west": "SW",
|
|
212
|
+
"southwest by west": "SWbyW",
|
|
213
|
+
"west-south-west": "WSW",
|
|
214
|
+
"west by south": "WbyS",
|
|
215
|
+
"west": "W",
|
|
216
|
+
"west by north": "WbyN",
|
|
217
|
+
"west-north-west": "WNW",
|
|
218
|
+
"northwest by west": "NWbyW",
|
|
219
|
+
"north-west": "NW",
|
|
220
|
+
"northwest by north": "NwbyN",
|
|
221
|
+
"north-north-west": "NNW",
|
|
222
|
+
"north by west": "NbyW",
|
|
223
|
+
"calm": "C",
|
|
224
|
+
"0": "C",
|
|
225
|
+
"hidden": "N/A"
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
convert_clouds_upper = {"cirrus": "Ch6",
|
|
230
|
+
"cirrostratus": "Ch8",
|
|
231
|
+
"cirro-stratus": "Ch8",
|
|
232
|
+
"cirro-cumulus": "Cm8",
|
|
233
|
+
"nimbostratus": "Cm2",
|
|
234
|
+
"cumulonimbus": "Cl9",
|
|
235
|
+
"stratus": "Ch8",
|
|
236
|
+
"nimbus": "Cm2",
|
|
237
|
+
"cumulostratus": "Cm7",
|
|
238
|
+
"cumulonimbus": "Cl9",
|
|
239
|
+
"cumulus": "Ch9",
|
|
240
|
+
"passing": "Cm4",
|
|
241
|
+
"scud": "Cm4",
|
|
242
|
+
"obscured": "Ch/",
|
|
243
|
+
"hidden": "Ch/",
|
|
244
|
+
"mist": "Ch/",
|
|
245
|
+
"fog": "Ch/",
|
|
246
|
+
"haze": "Ch/",
|
|
247
|
+
"hazy": "Ch/",
|
|
248
|
+
"smoke": "Ch/",
|
|
249
|
+
"?": "Ch/",
|
|
250
|
+
"clear": "Ch0",
|
|
251
|
+
"none apparent": "C10",
|
|
252
|
+
"0": "Ch0"
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
convert_cloud_lower = {"cirrus": "Ch6",
|
|
257
|
+
"stratus cirro-stratus": "Ch8 Cl6",
|
|
258
|
+
"stratus cirrus": "Ch8 Cl6",
|
|
259
|
+
"stratus cumulonimbus": "Ch6 Ch8 Cl4",
|
|
260
|
+
"cirro-stratus": "Ch8",
|
|
261
|
+
"cirrostratus": "Ch8",
|
|
262
|
+
"cirro-cumulus": "Cm8",
|
|
263
|
+
"cirro-cumulus illegible": "Ch9",
|
|
264
|
+
"cirrocumulus": "Ch9",
|
|
265
|
+
"nimbostratus": "Cm2",
|
|
266
|
+
"stratus": "Cl6",
|
|
267
|
+
"nimbus": "Cl7",
|
|
268
|
+
"cumulo-stratus": "Cl4",
|
|
269
|
+
"cumulostratus": "Cl4",
|
|
270
|
+
"cumulonimbus": "Cl9",
|
|
271
|
+
"cumulus cirro-stratus": "C12, Ch8",
|
|
272
|
+
"cumulus": "Cl2",
|
|
273
|
+
"passing": "Cl2",
|
|
274
|
+
"scud": "Cl5",
|
|
275
|
+
"hidden": "Cl/",
|
|
276
|
+
"obscured": "Cl/",
|
|
277
|
+
"mist": "Cl/",
|
|
278
|
+
"fog": "Cl/",
|
|
279
|
+
"haze": "Cl/",
|
|
280
|
+
"hazy": "Cl/",
|
|
281
|
+
"smoke": "Cl/",
|
|
282
|
+
"overcast": "Cl7",
|
|
283
|
+
"?": "Cl/",
|
|
284
|
+
"0": "Cl0",
|
|
285
|
+
"clear": "Cl0",
|
|
286
|
+
"none apparent": "C10",
|
|
287
|
+
"imp": "Cl0"
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
abbr_cloud = {"cirrus": "Ci",
|
|
292
|
+
"cirro-stratus": "CiSt",
|
|
293
|
+
"cirro-cumulus": "CiCu",
|
|
294
|
+
"stratus": "St",
|
|
295
|
+
"nimbus": "Ni",
|
|
296
|
+
"nimbostratus": "NiSt",
|
|
297
|
+
"cumulo-stratus": "CuSt",
|
|
298
|
+
"cirrostratus": "CiSt",
|
|
299
|
+
"cirrocumulus": "CiCu",
|
|
300
|
+
"cirro-cumulus": "CiCu",
|
|
301
|
+
"cumulonimbus": "CuNi",
|
|
302
|
+
"cumulus": "Cu",
|
|
303
|
+
"overcast": "NiSt",
|
|
304
|
+
"passing": "P",
|
|
305
|
+
"scud": "Sc",
|
|
306
|
+
"hidden": "Hi",
|
|
307
|
+
"obscured": "Hi",
|
|
308
|
+
"mist": "Ms",
|
|
309
|
+
"fog": "Fg",
|
|
310
|
+
"haze": "Hz",
|
|
311
|
+
"hazy": "Hz",
|
|
312
|
+
"smoke": "Sm",
|
|
313
|
+
"clear": "Cl",
|
|
314
|
+
"0": "Cl"
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
# weather: R =rain, D =drizzle, F = foggy, Gloomy = cloudy
|
|
318
|
+
weather = {"dull": "cloudy",
|
|
319
|
+
"gloomy": "cloudy",
|
|
320
|
+
"fair": "clear",
|
|
321
|
+
"r": "rain",
|
|
322
|
+
"d": "drizzle",
|
|
323
|
+
"f": "fog",
|
|
324
|
+
"s": "snow",
|
|
325
|
+
"sh": "shower",
|
|
326
|
+
"sn sh": "snow shower"
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
# define unit translation
|
|
331
|
+
map_unit = {"F": "C",
|
|
332
|
+
"inHg": "hPa",
|
|
333
|
+
"in": "mm",
|
|
334
|
+
"okta": "okta",
|
|
335
|
+
"dir": "deg",
|
|
336
|
+
"direction": "deg",
|
|
337
|
+
"lct": "cloudatlas",
|
|
338
|
+
"uct": "cloudatlas",
|
|
339
|
+
"Sm": "mps",
|
|
340
|
+
"Bf": "mps",
|
|
341
|
+
"p": "%",
|
|
342
|
+
"%": "%",
|
|
343
|
+
"cloudtext": "none",
|
|
344
|
+
"cloudtype": "cloudatlas",
|
|
345
|
+
"mno": "manual observation",
|
|
346
|
+
"cloudvel": "0-10",
|
|
347
|
+
"hcv": "0-10",
|
|
348
|
+
"cv": "0-10",
|
|
349
|
+
"hr": "hour",
|
|
350
|
+
"tenths": "tenths",
|
|
351
|
+
"tenth": "tenths",
|
|
352
|
+
"abb": "1-10",
|
|
353
|
+
"hh:mm": "none",
|
|
354
|
+
"text": "none",
|
|
355
|
+
"du": "du",
|
|
356
|
+
"RE_scale": "Beaufort",
|
|
357
|
+
"mph": "mps",
|
|
358
|
+
"lbsft": "mps",
|
|
359
|
+
"oz": "scale",
|
|
360
|
+
"scale": "scale"
|
|
361
|
+
}
|