rtc-tools 2.7.0a2__tar.gz → 2.7.0a3__tar.gz

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.

Files changed (58) hide show
  1. {rtc-tools-2.7.0a2/src/rtc_tools.egg-info → rtc-tools-2.7.0a3}/PKG-INFO +1 -1
  2. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/setup.py +1 -1
  3. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3/src/rtc_tools.egg-info}/PKG-INFO +1 -1
  4. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtc_tools.egg-info/requires.txt +1 -1
  5. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/_version.py +3 -3
  6. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/data/pi.py +44 -10
  7. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/simulation/simulation_problem.py +19 -0
  8. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/COPYING.LESSER +0 -0
  9. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/MANIFEST.in +0 -0
  10. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/README.md +0 -0
  11. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/pyproject.toml +0 -0
  12. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/setup.cfg +0 -0
  13. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtc_tools.egg-info/SOURCES.txt +0 -0
  14. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtc_tools.egg-info/dependency_links.txt +0 -0
  15. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtc_tools.egg-info/entry_points.txt +0 -0
  16. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtc_tools.egg-info/top_level.txt +0 -0
  17. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/__init__.py +0 -0
  18. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/_internal/__init__.py +0 -0
  19. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/_internal/alias_tools.py +0 -0
  20. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/_internal/caching.py +0 -0
  21. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/_internal/casadi_helpers.py +0 -0
  22. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/_internal/debug_check_helpers.py +0 -0
  23. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/data/__init__.py +0 -0
  24. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/data/csv.py +0 -0
  25. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/data/interpolation/__init__.py +0 -0
  26. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/data/interpolation/bspline.py +0 -0
  27. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/data/interpolation/bspline1d.py +0 -0
  28. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/data/interpolation/bspline2d.py +0 -0
  29. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/data/netcdf.py +0 -0
  30. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/data/rtc.py +0 -0
  31. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/data/storage.py +0 -0
  32. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/__init__.py +0 -0
  33. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/collocated_integrated_optimization_problem.py +0 -0
  34. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/control_tree_mixin.py +0 -0
  35. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/csv_lookup_table_mixin.py +0 -0
  36. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/csv_mixin.py +0 -0
  37. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/goal_programming_mixin.py +0 -0
  38. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/goal_programming_mixin_base.py +0 -0
  39. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/homotopy_mixin.py +0 -0
  40. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/initial_state_estimation_mixin.py +0 -0
  41. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/io_mixin.py +0 -0
  42. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/linearization_mixin.py +0 -0
  43. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/linearized_order_goal_programming_mixin.py +0 -0
  44. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/min_abs_goal_programming_mixin.py +0 -0
  45. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/modelica_mixin.py +0 -0
  46. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/netcdf_mixin.py +0 -0
  47. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/optimization_problem.py +0 -0
  48. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/pi_mixin.py +0 -0
  49. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/planning_mixin.py +0 -0
  50. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/single_pass_goal_programming_mixin.py +0 -0
  51. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/optimization/timeseries.py +0 -0
  52. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/rtctoolsapp.py +0 -0
  53. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/simulation/__init__.py +0 -0
  54. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/simulation/csv_mixin.py +0 -0
  55. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/simulation/io_mixin.py +0 -0
  56. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/simulation/pi_mixin.py +0 -0
  57. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/src/rtctools/util.py +0 -0
  58. {rtc-tools-2.7.0a2 → rtc-tools-2.7.0a3}/versioneer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rtc-tools
3
- Version: 2.7.0a2
3
+ Version: 2.7.0a3
4
4
  Summary: Toolbox for control and optimization of water systems.
5
5
  Home-page: https://oss.deltares.nl/web/rtc-tools/home
6
6
  Author: Deltares
@@ -48,7 +48,7 @@ setup(
48
48
  "numpy >= 1.16.0, <1.26",
49
49
  "scipy >= 1.0.0, <1.11",
50
50
  "pymoca >= 0.9.1, == 0.9.*",
51
- "rtc-tools-channel-flow >= 1.1.0",
51
+ "rtc-tools-channel-flow >= 1.2.0",
52
52
  "defusedxml >= 0.7.0",
53
53
  ],
54
54
  tests_require=["pytest", "pytest-runner", "netCDF4"],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rtc-tools
3
- Version: 2.7.0a2
3
+ Version: 2.7.0a3
4
4
  Summary: Toolbox for control and optimization of water systems.
5
5
  Home-page: https://oss.deltares.nl/web/rtc-tools/home
6
6
  Author: Deltares
@@ -2,7 +2,7 @@ casadi==3.6.*,>=3.6.3
2
2
  numpy<1.26,>=1.16.0
3
3
  scipy<1.11,>=1.0.0
4
4
  pymoca==0.9.*,>=0.9.1
5
- rtc-tools-channel-flow>=1.1.0
5
+ rtc-tools-channel-flow>=1.2.0
6
6
  defusedxml>=0.7.0
7
7
 
8
8
  [all]
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2024-05-14T15:15:45+0200",
11
+ "date": "2024-07-23T15:26:53+0200",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "6d06af067e4be71ea3b47593feb9be8ee7c37adc",
15
- "version": "2.7.0a2"
14
+ "full-revisionid": "4657ff3b5634df60af117b022fca4e968b88feb7",
15
+ "version": "2.7.0a3"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -369,8 +369,6 @@ class Timeseries:
369
369
  self.__folder = folder
370
370
  self.__basename = basename
371
371
 
372
- self.__path_xml = os.path.join(self.__folder, basename + ".xml")
373
-
374
372
  self.__internal_dtype = np.float64
375
373
  self.__pi_dtype = np.float32
376
374
 
@@ -378,7 +376,7 @@ class Timeseries:
378
376
  if self.make_new_file:
379
377
  self.__reset_xml_tree()
380
378
  else:
381
- self.__tree = DefusedElementTree.parse(self.__path_xml)
379
+ self.__tree = DefusedElementTree.parse(self.path)
382
380
  self.__xml_root = self.__tree.getroot()
383
381
 
384
382
  self.__values = [{}]
@@ -801,13 +799,20 @@ class Timeseries:
801
799
  # Add series to xml
802
800
  self.__xml_root.append(series)
803
801
 
804
- def write(self):
802
+ def write(self, output_folder=None, output_filename=None) -> None:
805
803
  """
806
804
  Writes the time series data to disk.
805
+
806
+ :param output_folder: The folder in which the output file is located.
807
+ If None, the original folder is used.
808
+ :param output_filename: The name of the output file without extension.
809
+ If None, the original filename is used.
807
810
  """
811
+ xml_path = self.output_path(output_folder, output_filename)
812
+ binary_path = self.output_binary_path(output_folder, output_filename)
808
813
 
809
814
  if self.__binary:
810
- f = io.open(self.binary_path, "wb")
815
+ f = io.open(binary_path, "wb")
811
816
 
812
817
  if self.make_new_file:
813
818
  # Force reinitialization in case write() is called more than once
@@ -911,7 +916,7 @@ class Timeseries:
911
916
  f.close()
912
917
 
913
918
  self.format_xml_data()
914
- self.__tree.write(self.__path_xml)
919
+ self.__tree.write(xml_path)
915
920
 
916
921
  def format_xml_data(self):
917
922
  """
@@ -1170,16 +1175,45 @@ class Timeseries:
1170
1175
  self.__end_datetime = end_datetime
1171
1176
 
1172
1177
  @property
1173
- def path(self):
1174
- return self.__path_xml
1178
+ def path(self) -> str:
1179
+ """
1180
+ The path to the original xml file.
1181
+ """
1182
+ return os.path.join(self.__folder, self.__basename + ".xml")
1175
1183
 
1176
1184
  @property
1177
- def binary_path(self):
1185
+ def binary_path(self) -> str:
1178
1186
  """
1179
- The path for the binary data .bin file.
1187
+ The path to the original binary data .bin file.
1180
1188
  """
1181
1189
  return os.path.join(self.__folder, self.__basename + ".bin")
1182
1190
 
1191
+ def _output_path_without_extension(self, output_folder=None, output_filename=None) -> str:
1192
+ """
1193
+ Get the output path without file extension.
1194
+ """
1195
+ if output_folder is None:
1196
+ output_folder = self.__folder
1197
+ if output_filename is None:
1198
+ output_filename = self.__basename
1199
+ return os.path.join(output_folder, output_filename)
1200
+
1201
+ def output_path(self, output_folder=None, output_filename=None) -> str:
1202
+ """
1203
+ Get the path to the output xml file.
1204
+
1205
+ The optional arguments are the same as in :py:method:`write`.
1206
+ """
1207
+ return self._output_path_without_extension(output_folder, output_filename) + ".xml"
1208
+
1209
+ def output_binary_path(self, output_folder=None, output_filename=None) -> str:
1210
+ """
1211
+ Get the path to the output binary file.
1212
+
1213
+ The optional arguments are the same as in :py:method:`write`.
1214
+ """
1215
+ return self._output_path_without_extension(output_folder, output_filename) + ".bin"
1216
+
1183
1217
  def items(self, ensemble_member=0):
1184
1218
  """
1185
1219
  Returns an iterator over all timeseries IDs and value arrays for the given
@@ -838,6 +838,8 @@ class SimulationProblem(DataStoreAccessor):
838
838
  self.set_var("time", self.get_current_time() + dt)
839
839
 
840
840
  # take a step
841
+ if np.isnan(self.__state_vector).any():
842
+ logger.error("Found a nan in the state vector (before making the step)")
841
843
  guess = self.__state_vector[: self.__n_states]
842
844
  if len(self.__mx["parameters"]) > 0:
843
845
  next_state = self.__do_step(
@@ -845,6 +847,23 @@ class SimulationProblem(DataStoreAccessor):
845
847
  )
846
848
  else:
847
849
  next_state = self.__do_step(guess, dt, self.__state_vector)
850
+
851
+ try:
852
+ if np.isnan(next_state).any():
853
+ index_to_name = {index[0]: name for name, index in self.__indices.items()}
854
+ named_next_state = {
855
+ index_to_name[i]: float(next_state[i]) for i in range(0, next_state.shape[0])
856
+ }
857
+ variables_with_nan = [
858
+ name for name, value in named_next_state.items() if np.isnan(value)
859
+ ]
860
+ if variables_with_nan:
861
+ logger.error(
862
+ f"Found nan(s) in the next_state vector for:\n\t {variables_with_nan}"
863
+ )
864
+ except (KeyError, IndexError, TypeError):
865
+ logger.warning("Something went wrong while checking for nans in the next_state vector")
866
+
848
867
  # Check convergence of rootfinder
849
868
  rootfinder_stats = self.__do_step.stats()
850
869
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes