@@ -142,7 +142,7 @@ def __init__(
142
142
143
143
# Convert units
144
144
self .set_unit_system (unit_system )
145
- else : # In case of loading previous data, still need to test if all the other functions will work!
145
+ else : # In case of loading previous data, still need to test if all the other functions will work!
146
146
# Opening JSON file
147
147
try :
148
148
with open (self .load_previous_data ) as json_file :
@@ -155,7 +155,7 @@ def __init__(
155
155
# Load dictionary
156
156
self .surfaceDataDict = self .loaded_data ["surfaceDataDict" ]
157
157
self .pressureLevelDataDict = self .loaded_data ["pressureLevelDataDict" ]
158
-
158
+
159
159
# Initialize variables again, to accomplish to the data available at the loaded file
160
160
self .elevation = self .loaded_data ["elevation" ]
161
161
self .latitude = self .loaded_data ["latitude" ]
@@ -164,13 +164,46 @@ def __init__(
164
164
# Convert back to Function objects, then we will be able to process set_unit_system
165
165
## Use the units on the files, and then convert to the final/selected units
166
166
decodeDict = {
167
- "pressure" : ["Height Above Sea Level (m)" , "Pressure ({})" .format (self .loaded_data ["unit_system" ]['pressure' ])],
168
- "temperature" : ["Height Above Sea Level (m)" , "Temperature ({})" .format (self .loaded_data ["unit_system" ]['temperature' ])],
169
- "windDirection" : ["Height Above Sea Level (m)" , "Wind Direction ({})" .format (self .loaded_data ["unit_system" ]['angle' ])],
170
- "windHeading" : ["Height Above Sea Level (m)" , "Wind Heading ({})" .format (self .loaded_data ["unit_system" ]['angle' ])],
171
- "windSpeed" : ["Height Above Sea Level (m)" , "Wind Speed ({})" .format (self .loaded_data ["unit_system" ]['wind_speed' ])],
172
- "windVelocityX" : ["Height Above Sea Level (m)" , "Wind Velocity X ({})" .format (self .loaded_data ["unit_system" ]['velocity' ])],
173
- "windVelocityY" : ["Height Above Sea Level (m)" , "Wind Velocity Y ({})" .format (self .loaded_data ["unit_system" ]['velocity' ])],
167
+ "pressure" : [
168
+ "Height Above Sea Level (m)" ,
169
+ "Pressure ({})" .format (self .loaded_data ["unit_system" ]["pressure" ]),
170
+ ],
171
+ "temperature" : [
172
+ "Height Above Sea Level (m)" ,
173
+ "Temperature ({})" .format (
174
+ self .loaded_data ["unit_system" ]["temperature" ]
175
+ ),
176
+ ],
177
+ "windDirection" : [
178
+ "Height Above Sea Level (m)" ,
179
+ "Wind Direction ({})" .format (
180
+ self .loaded_data ["unit_system" ]["angle" ]
181
+ ),
182
+ ],
183
+ "windHeading" : [
184
+ "Height Above Sea Level (m)" ,
185
+ "Wind Heading ({})" .format (
186
+ self .loaded_data ["unit_system" ]["angle" ]
187
+ ),
188
+ ],
189
+ "windSpeed" : [
190
+ "Height Above Sea Level (m)" ,
191
+ "Wind Speed ({})" .format (
192
+ self .loaded_data ["unit_system" ]["wind_speed" ]
193
+ ),
194
+ ],
195
+ "windVelocityX" : [
196
+ "Height Above Sea Level (m)" ,
197
+ "Wind Velocity X ({})" .format (
198
+ self .loaded_data ["unit_system" ]["velocity" ]
199
+ ),
200
+ ],
201
+ "windVelocityY" : [
202
+ "Height Above Sea Level (m)" ,
203
+ "Wind Velocity Y ({})" .format (
204
+ self .loaded_data ["unit_system" ]["velocity" ]
205
+ ),
206
+ ],
174
207
}
175
208
176
209
# TODO: document this
@@ -179,11 +212,14 @@ def __init__(
179
212
for variable in decodeDict .keys ():
180
213
lst = self .pressureLevelDataDict [days ][hours ][variable ]
181
214
self .pressureLevelDataDict [days ][hours ][variable ] = Function (
182
- source = np .column_stack (([item [0 ] for item in lst ], [item [1 ] for item in lst ])),
215
+ source = np .column_stack (
216
+ ([item [0 ] for item in lst ], [item [1 ] for item in lst ])
217
+ ),
183
218
inputs = [decodeDict [variable ][0 ]],
184
- outputs = [decodeDict [variable ][1 ]],
185
- interpolation = 'linear' ,
186
- extrapolation = 'constant' )
219
+ outputs = [decodeDict [variable ][1 ]],
220
+ interpolation = "linear" ,
221
+ extrapolation = "constant" ,
222
+ )
187
223
188
224
print (
189
225
"Information of the data loaded from previous Environment Analysis.\n "
@@ -218,8 +254,9 @@ def __init__(
218
254
self .set_unit_system (unit_system )
219
255
print (self .unit_system )
220
256
print ()
221
- print ("Alright, the previous data file were completely loaded, all set to go!" )
222
-
257
+ print (
258
+ "Alright, the previous data file were completely loaded, all set to go!"
259
+ )
223
260
224
261
# Initialize result variables
225
262
self .average_max_temperature = 0
@@ -675,7 +712,7 @@ def parsePressureLevelData(self):
675
712
variablePointsArray = np .array ([heightAboveSeaLevelArray , valueArray ]).T
676
713
variableFunction = Function (
677
714
variablePointsArray ,
678
- inputs = "Height Above Ground Level (m)" , # TODO: Check if it is really AGL or ASL here
715
+ inputs = "Height Above Ground Level (m)" , # TODO: Check if it is really AGL or ASL here
679
716
outputs = key ,
680
717
extrapolation = "constant" ,
681
718
)
@@ -925,7 +962,7 @@ def convertSurfaceData(self):
925
962
# Calculations
926
963
def process_data (self ):
927
964
"""Process data that is shown in the allInfo method."""
928
- # TODO: self.calculate_pressure_stats()
965
+ self .calculate_pressure_stats ()
929
966
self .calculate_average_max_temperature ()
930
967
self .calculate_average_min_temperature ()
931
968
self .calculate_record_max_temperature ()
@@ -941,9 +978,9 @@ def process_data(self):
941
978
self .calculate_average_min_surface_100m_wind_speed ()
942
979
self .calculate_record_max_surface_100m_wind_speed ()
943
980
self .calculate_record_min_surface_100m_wind_speed ()
944
- # TODO: self.calculate_percentage_of_days_with_precipitation()
945
- # TODO: self.calculate_average_cloud_base_height()
946
- # TODO: self.calculate_min_cloud_base_height()
981
+ self .calculate_percentage_of_days_with_precipitation ()
982
+ self .calculate_average_cloud_base_height ()
983
+ self .calculate_min_cloud_base_height ()
947
984
self .calculate_percentage_of_days_with_no_cloud_coverage ()
948
985
949
986
@property
@@ -2868,8 +2905,16 @@ def saveEnvAnalysisDict(self, filename="EnvAnalysisDict"):
2868
2905
for days in pressureLevelDataDictCopy .keys ():
2869
2906
for hours in pressureLevelDataDictCopy [days ].keys ():
2870
2907
for variable in pressureLevelDataDictCopy [days ][hours ].keys ():
2871
- pressureLevelDataDictCopy [days ][hours ][variable ] = np .column_stack ( (pressureLevelDataDictCopy [days ][hours ][variable ].getSource ()[:,0 ], pressureLevelDataDictCopy [days ][hours ][variable ].getSource ()[:,1 ])).tolist ()
2872
-
2908
+ pressureLevelDataDictCopy [days ][hours ][variable ] = np .column_stack (
2909
+ (
2910
+ pressureLevelDataDictCopy [days ][hours ][
2911
+ variable
2912
+ ].getSource ()[:, 0 ],
2913
+ pressureLevelDataDictCopy [days ][hours ][
2914
+ variable
2915
+ ].getSource ()[:, 1 ],
2916
+ )
2917
+ ).tolist ()
2873
2918
2874
2919
self .EnvAnalysisDict = {
2875
2920
"start_date" : self .start_date .strftime ("%Y-%m-%d" ),
0 commit comments