rtc-tools 2.5.2rc4__py3-none-any.whl → 2.6.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.
Potentially problematic release.
This version of rtc-tools might be problematic. Click here for more details.
- {rtc_tools-2.5.2rc4.dist-info → rtc_tools-2.6.0.dist-info}/METADATA +7 -7
- rtc_tools-2.6.0.dist-info/RECORD +50 -0
- {rtc_tools-2.5.2rc4.dist-info → rtc_tools-2.6.0.dist-info}/WHEEL +1 -1
- rtctools/__init__.py +2 -1
- rtctools/_internal/alias_tools.py +12 -10
- rtctools/_internal/caching.py +5 -3
- rtctools/_internal/casadi_helpers.py +11 -32
- rtctools/_internal/debug_check_helpers.py +1 -1
- rtctools/_version.py +3 -3
- rtctools/data/__init__.py +2 -2
- rtctools/data/csv.py +54 -33
- rtctools/data/interpolation/bspline.py +3 -3
- rtctools/data/interpolation/bspline1d.py +42 -29
- rtctools/data/interpolation/bspline2d.py +10 -4
- rtctools/data/netcdf.py +137 -93
- rtctools/data/pi.py +304 -210
- rtctools/data/rtc.py +64 -53
- rtctools/data/storage.py +91 -51
- rtctools/optimization/collocated_integrated_optimization_problem.py +1244 -696
- rtctools/optimization/control_tree_mixin.py +68 -66
- rtctools/optimization/csv_lookup_table_mixin.py +107 -74
- rtctools/optimization/csv_mixin.py +83 -52
- rtctools/optimization/goal_programming_mixin.py +237 -146
- rtctools/optimization/goal_programming_mixin_base.py +204 -111
- rtctools/optimization/homotopy_mixin.py +36 -27
- rtctools/optimization/initial_state_estimation_mixin.py +8 -8
- rtctools/optimization/io_mixin.py +48 -43
- rtctools/optimization/linearization_mixin.py +3 -1
- rtctools/optimization/linearized_order_goal_programming_mixin.py +57 -28
- rtctools/optimization/min_abs_goal_programming_mixin.py +72 -29
- rtctools/optimization/modelica_mixin.py +135 -81
- rtctools/optimization/netcdf_mixin.py +32 -18
- rtctools/optimization/optimization_problem.py +181 -127
- rtctools/optimization/pi_mixin.py +68 -36
- rtctools/optimization/planning_mixin.py +19 -0
- rtctools/optimization/single_pass_goal_programming_mixin.py +159 -112
- rtctools/optimization/timeseries.py +4 -6
- rtctools/rtctoolsapp.py +18 -18
- rtctools/simulation/csv_mixin.py +37 -30
- rtctools/simulation/io_mixin.py +9 -5
- rtctools/simulation/pi_mixin.py +62 -32
- rtctools/simulation/simulation_problem.py +471 -180
- rtctools/util.py +84 -56
- rtc_tools-2.5.2rc4.dist-info/RECORD +0 -49
- {rtc_tools-2.5.2rc4.dist-info → rtc_tools-2.6.0.dist-info}/COPYING.LESSER +0 -0
- {rtc_tools-2.5.2rc4.dist-info → rtc_tools-2.6.0.dist-info}/entry_points.txt +0 -0
- {rtc_tools-2.5.2rc4.dist-info → rtc_tools-2.6.0.dist-info}/top_level.txt +0 -0
|
@@ -44,7 +44,7 @@ class NetCDFMixin(IOMixin):
|
|
|
44
44
|
|
|
45
45
|
:return: The variable name used in RTC-Tools
|
|
46
46
|
"""
|
|
47
|
-
return
|
|
47
|
+
return "{}__{}".format(station_id, parameter)
|
|
48
48
|
|
|
49
49
|
def netcdf_id_from_variable(self, variable_name: str) -> Tuple[str, str]:
|
|
50
50
|
"""
|
|
@@ -79,7 +79,7 @@ class NetCDFMixin(IOMixin):
|
|
|
79
79
|
# check if strictly increasing
|
|
80
80
|
for i in range(len(times) - 1):
|
|
81
81
|
if times[i] >= times[i + 1]:
|
|
82
|
-
raise Exception(
|
|
82
|
+
raise Exception("NetCDFMixin: Time stamps must be strictly increasing.")
|
|
83
83
|
|
|
84
84
|
# store the station data for later use
|
|
85
85
|
self.__stations = dataset.read_station_data()
|
|
@@ -91,21 +91,30 @@ class NetCDFMixin(IOMixin):
|
|
|
91
91
|
name = self.netcdf_id_to_variable(station_id, parameter)
|
|
92
92
|
|
|
93
93
|
if dataset.ensemble_member_variable is not None:
|
|
94
|
-
if dataset.ensemble_member_variable.dimensions[
|
|
94
|
+
if dataset.ensemble_member_variable.dimensions[
|
|
95
|
+
0
|
|
96
|
+
] in dataset.variable_dimensions(parameter):
|
|
95
97
|
for ensemble_member_index in range(self.__timeseries_import.ensemble_size):
|
|
96
|
-
values = dataset.read_timeseries_values(
|
|
97
|
-
|
|
98
|
+
values = dataset.read_timeseries_values(
|
|
99
|
+
i, parameter, ensemble_member_index
|
|
100
|
+
)
|
|
101
|
+
self.io.set_timeseries(
|
|
102
|
+
name, self.__timeseries_times, values, ensemble_member_index
|
|
103
|
+
)
|
|
98
104
|
else:
|
|
99
105
|
values = dataset.read_timeseries_values(i, parameter, 0)
|
|
100
106
|
for ensemble_member_index in range(self.__timeseries_import.ensemble_size):
|
|
101
|
-
self.io.set_timeseries(
|
|
107
|
+
self.io.set_timeseries(
|
|
108
|
+
name, self.__timeseries_times, values, ensemble_member_index
|
|
109
|
+
)
|
|
102
110
|
else:
|
|
103
111
|
values = dataset.read_timeseries_values(i, parameter, 0)
|
|
104
112
|
self.io.set_timeseries(name, self.__timeseries_times, values, 0)
|
|
105
113
|
|
|
106
|
-
logger.debug(
|
|
107
|
-
|
|
108
|
-
|
|
114
|
+
logger.debug(
|
|
115
|
+
'Read timeseries data for station id "{}" and parameter "{}", '
|
|
116
|
+
'stored under variable name "{}"'.format(station_id, parameter, name)
|
|
117
|
+
)
|
|
109
118
|
|
|
110
119
|
logger.debug("NetCDFMixin: Read timeseries")
|
|
111
120
|
|
|
@@ -120,8 +129,9 @@ class NetCDFMixin(IOMixin):
|
|
|
120
129
|
|
|
121
130
|
output_variables = [sym.name() for sym in self.output_variables]
|
|
122
131
|
|
|
123
|
-
output_station_ids, output_parameter_ids = zip(
|
|
124
|
-
self.netcdf_id_from_variable(var_name) for var_name in output_variables)
|
|
132
|
+
output_station_ids, output_parameter_ids = zip(
|
|
133
|
+
*(self.netcdf_id_from_variable(var_name) for var_name in output_variables)
|
|
134
|
+
)
|
|
125
135
|
|
|
126
136
|
# Make sure that output_station_ids and output_parameter_ids are
|
|
127
137
|
# unique, but make sure to avoid non-deterministic ordering.
|
|
@@ -137,27 +147,31 @@ class NetCDFMixin(IOMixin):
|
|
|
137
147
|
results = self.extract_results(ensemble_member)
|
|
138
148
|
|
|
139
149
|
for var_name, station_id, parameter_id in zip(
|
|
140
|
-
|
|
150
|
+
output_variables, output_station_ids, output_parameter_ids
|
|
151
|
+
):
|
|
141
152
|
# determine the output values
|
|
142
153
|
try:
|
|
143
154
|
values = results[var_name]
|
|
144
155
|
if len(values) != len(times):
|
|
145
156
|
values = self.interpolate(
|
|
146
|
-
times, self.times(var_name), values, self.interpolation_method(var_name)
|
|
157
|
+
times, self.times(var_name), values, self.interpolation_method(var_name)
|
|
158
|
+
)
|
|
147
159
|
except KeyError:
|
|
148
160
|
try:
|
|
149
161
|
ts = self.get_timeseries(var_name, ensemble_member)
|
|
150
162
|
if len(ts.times) != len(times):
|
|
151
|
-
values = self.interpolate(
|
|
152
|
-
times, ts.times, ts.values)
|
|
163
|
+
values = self.interpolate(times, ts.times, ts.values)
|
|
153
164
|
else:
|
|
154
165
|
values = ts.values
|
|
155
166
|
except KeyError:
|
|
156
167
|
logger.error(
|
|
157
|
-
|
|
158
|
-
|
|
168
|
+
"NetCDFMixin: Output requested for non-existent variable {}. "
|
|
169
|
+
"Will not be in output file.".format(var_name)
|
|
170
|
+
)
|
|
159
171
|
continue
|
|
160
172
|
|
|
161
|
-
dataset.write_output_values(
|
|
173
|
+
dataset.write_output_values(
|
|
174
|
+
station_id, parameter_id, ensemble_member, values, self.ensemble_size
|
|
175
|
+
)
|
|
162
176
|
|
|
163
177
|
dataset.close()
|