Skip to content

Commit c96db9d

Browse files
MAINT: formatting with black
1 parent 506503d commit c96db9d

File tree

1 file changed

+67
-22
lines changed

1 file changed

+67
-22
lines changed

rocketpy/EnvironmentAnalysis.py

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def __init__(
142142

143143
# Convert units
144144
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!
146146
# Opening JSON file
147147
try:
148148
with open(self.load_previous_data) as json_file:
@@ -155,7 +155,7 @@ def __init__(
155155
# Load dictionary
156156
self.surfaceDataDict = self.loaded_data["surfaceDataDict"]
157157
self.pressureLevelDataDict = self.loaded_data["pressureLevelDataDict"]
158-
158+
159159
# Initialize variables again, to accomplish to the data available at the loaded file
160160
self.elevation = self.loaded_data["elevation"]
161161
self.latitude = self.loaded_data["latitude"]
@@ -164,13 +164,46 @@ def __init__(
164164
# Convert back to Function objects, then we will be able to process set_unit_system
165165
## Use the units on the files, and then convert to the final/selected units
166166
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+
],
174207
}
175208

176209
# TODO: document this
@@ -179,11 +212,14 @@ def __init__(
179212
for variable in decodeDict.keys():
180213
lst = self.pressureLevelDataDict[days][hours][variable]
181214
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+
),
183218
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+
)
187223

188224
print(
189225
"Information of the data loaded from previous Environment Analysis.\n"
@@ -218,8 +254,9 @@ def __init__(
218254
self.set_unit_system(unit_system)
219255
print(self.unit_system)
220256
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+
)
223260

224261
# Initialize result variables
225262
self.average_max_temperature = 0
@@ -675,7 +712,7 @@ def parsePressureLevelData(self):
675712
variablePointsArray = np.array([heightAboveSeaLevelArray, valueArray]).T
676713
variableFunction = Function(
677714
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
679716
outputs=key,
680717
extrapolation="constant",
681718
)
@@ -925,7 +962,7 @@ def convertSurfaceData(self):
925962
# Calculations
926963
def process_data(self):
927964
"""Process data that is shown in the allInfo method."""
928-
# TODO: self.calculate_pressure_stats()
965+
self.calculate_pressure_stats()
929966
self.calculate_average_max_temperature()
930967
self.calculate_average_min_temperature()
931968
self.calculate_record_max_temperature()
@@ -941,9 +978,9 @@ def process_data(self):
941978
self.calculate_average_min_surface_100m_wind_speed()
942979
self.calculate_record_max_surface_100m_wind_speed()
943980
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()
947984
self.calculate_percentage_of_days_with_no_cloud_coverage()
948985

949986
@property
@@ -2868,8 +2905,16 @@ def saveEnvAnalysisDict(self, filename="EnvAnalysisDict"):
28682905
for days in pressureLevelDataDictCopy.keys():
28692906
for hours in pressureLevelDataDictCopy[days].keys():
28702907
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()
28732918

28742919
self.EnvAnalysisDict = {
28752920
"start_date": self.start_date.strftime("%Y-%m-%d"),

0 commit comments

Comments
 (0)