firewxpy 2.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.
firewxpy/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ import firewxpy.observations.upper_air.soundings as observed_soundings
2
+ import firewxpy.observations.upper_air.profiles as observed_vertical_profiles
@@ -0,0 +1,3 @@
1
+ # (C) Eric J. Drewitz 2024-2026
2
+
3
+ import firewxpy.calc.calc as calc
firewxpy/calc/calc.py ADDED
@@ -0,0 +1,267 @@
1
+ """
2
+ This file hosts functions used to perform various calculations of our weather data.
3
+
4
+ (C) Eric J. Drewitz 2024-2026
5
+ """
6
+
7
+ import pandas as pd
8
+ import numpy as np
9
+
10
+ def knots_to_mph(knots):
11
+
12
+ """
13
+ Converts knots to mph
14
+
15
+ Returns
16
+ -------
17
+
18
+ Speed in mpg.
19
+ """
20
+
21
+ return knots * 1.1507767864272770986
22
+
23
+ def knots_to_mps(knots):
24
+
25
+ """
26
+ Converts knots to m/s
27
+
28
+ Returns
29
+ -------
30
+
31
+ Speed in m/s.
32
+ """
33
+
34
+ return knots * 0.51444325460445
35
+
36
+ def mps_to_mph(mps):
37
+
38
+ """
39
+ Converts m/s to mph
40
+
41
+ Returns
42
+ -------
43
+
44
+ Speed in mph
45
+ """
46
+
47
+ return mps * 2.23694
48
+
49
+ def mph_to_kts(mps):
50
+
51
+ """
52
+ Converts mps to knots
53
+
54
+ Returns
55
+ -------
56
+
57
+ Speed in knots
58
+ """
59
+
60
+ def round_values(df,
61
+ parameter,
62
+ to_nearest=0,
63
+ data_type='integer'):
64
+
65
+ """
66
+ Rounds Value to the nearest {to_nearest} and returns either an integer or float datatype
67
+
68
+ Required Arguments:
69
+
70
+ 1) values (Float or Integer) - The values to round.
71
+
72
+ 2) parameter (String) - The parameter being rounded.
73
+
74
+ Optional Arguments:
75
+
76
+ 1) to_nearest (Integer) - Default=0. 0 for whole number, 1 for tenths, 2 for hundredths and so on.
77
+
78
+ 2) data_type (String) - Default='integer'. Set to 'float' when rounding to a decimal.
79
+
80
+ Returns
81
+ -------
82
+
83
+ Rounded values
84
+ """
85
+
86
+ data_type = data_type.lower()
87
+
88
+ if data_type == 'integer':
89
+ df[parameter] = df[parameter].round(to_nearest)
90
+ df[parameter] = df[parameter].convert_dtypes(convert_string=False,
91
+ convert_integer=True,
92
+ convert_boolean=False,
93
+ convert_floating=False)
94
+ else:
95
+ df[parameter] = df[parameter].round(to_nearest)
96
+
97
+ return df[parameter]
98
+
99
+ def kelvin_to_fahrenheit(kelvin):
100
+
101
+ """
102
+ Converts temperature from celsius to fahrenheit.
103
+
104
+ Required Arguments:
105
+
106
+ 1) celsius (Integer or Float) - Temperature in celsius.
107
+
108
+ Returns
109
+ -------
110
+
111
+ Temperature in fahrenheit.
112
+ """
113
+ celsius= kelvin - 273.15
114
+
115
+ fahrenheit = (celsius * (9/5)) + 32
116
+
117
+ return fahrenheit
118
+
119
+ def fahrenheit_to_kelvin(fahrenheit):
120
+
121
+ """
122
+ Converts temperature from fahrenheit to kelvin.
123
+
124
+ Required Arguments:
125
+
126
+ 1) fahrenheit (Integer or Float) - Temperature in fahrenheit.
127
+
128
+ Returns
129
+ -------
130
+
131
+ Temperature in kelvin.
132
+ """
133
+ celsius = (fahrenheit - 32) * (5/9)
134
+
135
+ kelvin = celsius + 273.15
136
+
137
+ return kelvin
138
+
139
+ def celsius_to_fahrenheit(celsius):
140
+
141
+ """
142
+ Converts temperature from celsius to fahrenheit.
143
+
144
+ Required Arguments:
145
+
146
+ 1) celsius (Integer or Float) - Temperature in celsius.
147
+
148
+ Returns
149
+ -------
150
+
151
+ Temperature in fahrenheit.
152
+ """
153
+
154
+ fahrenheit = (celsius * (9/5)) + 32
155
+
156
+ return fahrenheit
157
+
158
+ def fahrenheit_to_celsius(fahrenheit):
159
+
160
+ """
161
+ Converts temperature from fahrenheit to celsius.
162
+
163
+ Required Arguments:
164
+
165
+ 1) celsius (Integer or Float) - Temperature in fahrenheit.
166
+
167
+ Returns
168
+ -------
169
+
170
+ Temperature in celsius.
171
+ """
172
+
173
+ celsius = (fahrenheit - 32) * (5/9)
174
+
175
+ return celsius
176
+
177
+ def kelvin_to_celsius(celsius):
178
+
179
+ """
180
+ Converts temperature from kelvin to celsius.
181
+
182
+ Required Arguments:
183
+
184
+ 1) celsius (Integer or Float) - Temperature in kelvin.
185
+
186
+ Returns
187
+ -------
188
+
189
+ Temperature in celsius.
190
+ """
191
+
192
+ return celsius - 273.15
193
+
194
+ def celsius_to_kelvin(celsius):
195
+
196
+ """
197
+ Converts temperature fromcelsius to kelvin.
198
+
199
+ Required Arguments:
200
+
201
+ 1) celsius (Integer or Float) - Temperature in celsius.
202
+
203
+ Returns
204
+ -------
205
+
206
+ Temperature in kelvin.
207
+ """
208
+
209
+ return celsius + 273.15
210
+
211
+ def kilometers_to_meters(kilometers):
212
+
213
+ """
214
+ Converts kilometers to meters
215
+
216
+ Required Arguments:
217
+
218
+ 1) kilometers (Integer or Float) - Height in Kilometers
219
+
220
+ Returns
221
+ -------
222
+
223
+ Height in meters
224
+ """
225
+
226
+ return kilometers * 1000
227
+
228
+
229
+ def meters_to_feet(meters):
230
+
231
+ """
232
+ Converts meters to feet.
233
+
234
+ Required Arguments:
235
+
236
+ 1) meters (Integer or Float) - Height in meters.
237
+
238
+ Returns
239
+ -------
240
+
241
+ Height in feet.
242
+ """
243
+
244
+ return meters * 3.28084
245
+
246
+ def u_v_components(ds,
247
+ u_var_key,
248
+ v_var_key,
249
+ deg_var_key,
250
+ speed_var_key):
251
+
252
+ """
253
+ Calculates u and v components in a data array.
254
+
255
+ Returns
256
+ -------
257
+
258
+ Data Array with u and v components.
259
+ """
260
+
261
+ ds['wind_direction_radians'] = np.deg2rad(ds[deg_var_key])
262
+ ds[u_var_key] = -ds[speed_var_key] * np.sin(ds['wind_direction_radians'])
263
+ ds[v_var_key] = -ds[speed_var_key] * np.cos(ds['wind_direction_radians'])
264
+
265
+ return ds
266
+
267
+
@@ -0,0 +1,2 @@
1
+ import firewxpy.observations.upper_air.soundings as observed_soundings
2
+ import firewxpy.observations.upper_air.profiles as observed_vertical_profiles