You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rocketpy/EnvironmentAnalysis.py
+74-5Lines changed: 74 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,7 @@ def __init__(
67
67
pressureLevelDataFile=None,
68
68
timezone=None,
69
69
unit_system="metric",
70
+
load_previous_data=None,
70
71
):
71
72
"""Constructor for the EnvironmentAnalysis class.
72
73
Parameters
@@ -101,11 +102,15 @@ def __init__(
101
102
unit_system : str, optional
102
103
Unit system to be used when displaying results.
103
104
Options are: SI, metric, imperial. Default is metric.
105
+
load_previous_data : str, optional
106
+
If True, the class will try to load the data from a previous ran Environment Analysis.
107
+
Use .json file resulted from ... as input.
108
+
Default is None.
104
109
Returns
105
110
-------
106
111
None
107
112
"""
108
-
warnings.warn("Please notice this class is still under development")
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.")
109
114
110
115
# Save inputs
111
116
self.start_date=start_date
@@ -117,17 +122,39 @@ def __init__(
117
122
self.surfaceDataFile=surfaceDataFile
118
123
self.pressureLevelDataFile=pressureLevelDataFile
119
124
self.preferred_timezone=timezone
125
+
self.load_previous_data=load_previous_data
120
126
121
127
# Manage units and timezones
122
128
self.__init_data_parsing_units()
123
129
self.__find_preferred_timezone()
124
130
self.__localize_input_dates()
125
131
126
132
# Parse data files, surface goes first to calculate elevation
127
-
self.surfaceDataDict= {}
128
-
self.parseSurfaceData()
129
-
self.pressureLevelDataDict= {}
130
-
self.parsePressureLevelData()
133
+
ifload_previous_dataisNone:
134
+
self.surfaceDataDict= {}
135
+
self.parseSurfaceData()
136
+
self.pressureLevelDataDict= {}
137
+
self.parsePressureLevelData()
138
+
else:
139
+
# Opening JSON file
140
+
try:
141
+
withopen(self.load_previous_data) asjson_file:
142
+
self.loaded_data=json.load(json_file)
143
+
except:
144
+
raiseRuntimeError("Unable to read json file from previous ran Environment Analysis. Please try again.")
0 commit comments