@@ -105,12 +105,14 @@ def __init__(
105
105
load_previous_data : str, optional
106
106
If True, the class will try to load the data from a previous ran Environment Analysis.
107
107
Use .json file resulted from ... as input.
108
- Default is None.
108
+ Default is None.
109
109
Returns
110
110
-------
111
111
None
112
112
"""
113
- warnings .warn ("Please notice this class is still under development, and some features may not work as expected as they were not exhaustively tested yet." )
113
+ warnings .warn (
114
+ "Please notice this class is still under development, and some features may not work as expected as they were not exhaustively tested yet."
115
+ )
114
116
115
117
# Save inputs
116
118
self .start_date = start_date
@@ -141,18 +143,34 @@ def __init__(
141
143
with open (self .load_previous_data ) as json_file :
142
144
self .loaded_data = json .load (json_file )
143
145
except :
144
- raise RuntimeError ("Unable to read json file from previous ran Environment Analysis. Please try again." )
145
-
146
+ raise RuntimeError (
147
+ "Unable to read json file from previous ran Environment Analysis. Please try again."
148
+ )
149
+
146
150
self .surfaceDataDict = self .loaded_data ["surfaceDataDict" ]
147
151
self .pressureLevelDataDict = self .loaded_data ["pressureLevelDataDict" ]
148
- print ("Information of the data loaded from previous Environment Analysis.\n " )
149
- print ("Available dates: " , self .loaded_data ["start_date" ], " to " , self .loaded_data ["end_date" ])
150
- print ("Available hours: " , self .loaded_data ["start_hour" ], " to " , self .loaded_data ["end_hour" ])
152
+ print (
153
+ "Information of the data loaded from previous Environment Analysis.\n "
154
+ )
155
+ print (
156
+ "Available dates: " ,
157
+ self .loaded_data ["start_date" ],
158
+ " to " ,
159
+ self .loaded_data ["end_date" ],
160
+ )
161
+ print (
162
+ "Available hours: " ,
163
+ self .loaded_data ["start_hour" ],
164
+ " to " ,
165
+ self .loaded_data ["end_hour" ],
166
+ )
151
167
print ("Latitude" , self .loaded_data ["latitude" ])
152
168
print ("Longitude" , self .loaded_data ["longitude" ])
153
169
print ("Elevation:" , self .loaded_data ["elevation" ])
154
170
print ("Surface data file: " , self .loaded_data ["surfaceDataFile" ])
155
- print ("Pressure level data file: " , self .loaded_data ["pressureLevelDataFile" ])
171
+ print (
172
+ "Pressure level data file: " , self .loaded_data ["pressureLevelDataFile" ]
173
+ )
156
174
print ("User timezone: " , self .loaded_data ["preferred_timezone" ])
157
175
print ("User unit system: " , self .loaded_data ["unit_system" ])
158
176
@@ -2345,7 +2363,9 @@ def process_temperature_profile_over_average_day(self):
2345
2363
max_temperature = np .max (mean_temperature_values_for_this_hour )
2346
2364
if max_temperature >= self .max_average_temperature_at_altitude :
2347
2365
self .max_average_temperature_at_altitude = max_temperature
2348
- self .average_temperature_profile_at_given_hour = average_temperature_profile_at_given_hour
2366
+ self .average_temperature_profile_at_given_hour = (
2367
+ average_temperature_profile_at_given_hour
2368
+ )
2349
2369
2350
2370
def process_pressure_profile_over_average_day (self ):
2351
2371
"""Compute the average pressure profile for each available hour of a day, over all
@@ -2376,7 +2396,9 @@ def process_pressure_profile_over_average_day(self):
2376
2396
max_pressure = np .max (mean_pressure_values_for_this_hour )
2377
2397
if max_pressure >= self .max_average_pressure_at_altitude :
2378
2398
self .max_average_pressure_at_altitude = max_pressure
2379
- self .average_pressure_profile_at_given_hour = average_pressure_profile_at_given_hour
2399
+ self .average_pressure_profile_at_given_hour = (
2400
+ average_pressure_profile_at_given_hour
2401
+ )
2380
2402
2381
2403
def process_wind_speed_profile_over_average_day (self ):
2382
2404
"""Compute the average wind profile for each available hour of a day, over all
@@ -2438,9 +2460,11 @@ def process_wind_velocity_x_profile_over_average_day(self):
2438
2460
max_windVelocityX = np .max (mean_windVelocityX_values_for_this_hour )
2439
2461
if max_windVelocityX >= self .max_average_windVelocityX_at_altitude :
2440
2462
self .max_average_windVelocityX_at_altitude = max_windVelocityX
2441
- self .average_windVelocityX_profile_at_given_hour = average_windVelocityX_profile_at_given_hour
2463
+ self .average_windVelocityX_profile_at_given_hour = (
2464
+ average_windVelocityX_profile_at_given_hour
2465
+ )
2442
2466
2443
- def process_wind_velocity_y_profile_over_average_day (self ):
2467
+ def process_wind_velocity_y_profile_over_average_day (self ):
2444
2468
"""Compute the average windVelocityY profile for each available hour of a day, over all
2445
2469
days in the dataset."""
2446
2470
altitude_list = np .linspace (* self .altitude_AGL_range , 100 )
@@ -2469,7 +2493,9 @@ def process_wind_velocity_y_profile_over_average_day(self):
2469
2493
max_windVelocityY = np .max (mean_windVelocityY_values_for_this_hour )
2470
2494
if max_windVelocityY >= self .max_average_windVelocityY_at_altitude :
2471
2495
self .max_average_windVelocityY_at_altitude = max_windVelocityY
2472
- self .average_windVelocityY_profile_at_given_hour = average_windVelocityY_profile_at_given_hour
2496
+ self .average_windVelocityY_profile_at_given_hour = (
2497
+ average_windVelocityY_profile_at_given_hour
2498
+ )
2473
2499
2474
2500
def plot_wind_profile_over_average_day (self , SAcup_altitude_constraints = False ):
2475
2501
"""Creates a grid of plots with the wind profile over the average day."""
@@ -2718,21 +2744,29 @@ def exportMeanProfiles(self, filename="export_env_analysis"):
2718
2744
2719
2745
for hour in self .average_temperature_profile_at_given_hour .keys ():
2720
2746
organized_temperature_dict [hour ] = np .column_stack (
2721
- (self .average_temperature_profile_at_given_hour [hour ][1 ],
2722
- self .average_temperature_profile_at_given_hour [hour ][0 ])
2723
- ).tolist ()
2747
+ (
2748
+ self .average_temperature_profile_at_given_hour [hour ][1 ],
2749
+ self .average_temperature_profile_at_given_hour [hour ][0 ],
2750
+ )
2751
+ ).tolist ()
2724
2752
organized_pressure_dict [hour ] = np .column_stack (
2725
- (self .average_pressure_profile_at_given_hour [hour ][1 ],
2726
- self .average_pressure_profile_at_given_hour [hour ][0 ])
2727
- ).tolist ()
2753
+ (
2754
+ self .average_pressure_profile_at_given_hour [hour ][1 ],
2755
+ self .average_pressure_profile_at_given_hour [hour ][0 ],
2756
+ )
2757
+ ).tolist ()
2728
2758
organized_windX_dict [hour ] = np .column_stack (
2729
- (self .average_windVelocityX_profile_at_given_hour [hour ][1 ],
2730
- self .average_windVelocityX_profile_at_given_hour [hour ][0 ])
2731
- ).tolist ()
2759
+ (
2760
+ self .average_windVelocityX_profile_at_given_hour [hour ][1 ],
2761
+ self .average_windVelocityX_profile_at_given_hour [hour ][0 ],
2762
+ )
2763
+ ).tolist ()
2732
2764
organized_windY_dict [hour ] = np .column_stack (
2733
- (self .average_windVelocityY_profile_at_given_hour [hour ][1 ],
2734
- self .average_windVelocityY_profile_at_given_hour [hour ][0 ])
2735
- ).tolist ()
2765
+ (
2766
+ self .average_windVelocityY_profile_at_given_hour [hour ][1 ],
2767
+ self .average_windVelocityY_profile_at_given_hour [hour ][0 ],
2768
+ )
2769
+ ).tolist ()
2736
2770
2737
2771
self .exportEnvAnalDict = {
2738
2772
"start_date" : self .start_date ,
@@ -2752,24 +2786,27 @@ def exportMeanProfiles(self, filename="export_env_analysis"):
2752
2786
"atmosphericModelPressureProfile" : organized_pressure_dict ,
2753
2787
"atmosphericModelTemperatureProfile" : organized_temperature_dict ,
2754
2788
"atmosphericModelWindVelocityXProfile" : organized_windX_dict ,
2755
- "atmosphericModelWindVelocityYProfile" : organized_windY_dict
2789
+ "atmosphericModelWindVelocityYProfile" : organized_windY_dict ,
2756
2790
}
2757
2791
2758
2792
# Convert to json
2759
- f = open (filename + ".json" ,"w" )
2793
+ f = open (filename + ".json" , "w" )
2760
2794
2761
2795
# write json object to file
2762
- f .write (json .dumps (
2763
- self .exportEnvAnalDict ,
2764
- sort_keys = False ,
2765
- indent = 4 ,
2766
- default = str )
2767
- )
2768
-
2796
+ f .write (
2797
+ json .dumps (self .exportEnvAnalDict , sort_keys = False , indent = 4 , default = str )
2798
+ )
2799
+
2769
2800
# close file
2770
2801
f .close ()
2771
- print ("Your Environment Analysis file was saved, check it out: " + filename + ".json" )
2772
- print ("You can use it in the future by using the customAtmosphere atmospheric model." )
2802
+ print (
2803
+ "Your Environment Analysis file was saved, check it out: "
2804
+ + filename
2805
+ + ".json"
2806
+ )
2807
+ print (
2808
+ "You can use it in the future by using the customAtmosphere atmospheric model."
2809
+ )
2773
2810
2774
2811
return None
2775
2812
@@ -2798,19 +2835,22 @@ def saveEnvAnalysisDict(self, filename="EnvAnalysisDict"):
2798
2835
}
2799
2836
2800
2837
# Convert to json
2801
- f = open (filename + ".json" ,"w" )
2838
+ f = open (filename + ".json" , "w" )
2802
2839
2803
2840
# write json object to file
2804
- f .write (json .dumps (
2805
- self .EnvAnalysisDict ,
2806
- sort_keys = False ,
2807
- indent = 4 ,
2808
- default = str )
2809
- )
2810
-
2841
+ f .write (
2842
+ json .dumps (self .EnvAnalysisDict , sort_keys = False , indent = 4 , default = str )
2843
+ )
2844
+
2811
2845
# close file
2812
2846
f .close ()
2813
- print ("Your Environment Analysis file was saved, check it out: " + filename + ".json" )
2814
- print ("You can use it in the future by using the customAtmosphere atmospheric model." )
2847
+ print (
2848
+ "Your Environment Analysis file was saved, check it out: "
2849
+ + filename
2850
+ + ".json"
2851
+ )
2852
+ print (
2853
+ "You can use it in the future by using the customAtmosphere atmospheric model."
2854
+ )
2815
2855
2816
2856
return None
0 commit comments