stepss 3.77.1__tar.gz → 3.78__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.
Files changed (30) hide show
  1. {stepss-3.77.1/stepss.egg-info → stepss-3.78}/PKG-INFO +1 -1
  2. {stepss-3.77.1 → stepss-3.78}/stepss/__init__.py +1 -1
  3. {stepss-3.77.1 → stepss-3.78}/stepss/_bundled.py +1 -1
  4. {stepss-3.77.1 → stepss-3.78}/stepss/cases.py +60 -6
  5. {stepss-3.77.1 → stepss-3.78}/stepss/libs/lin/ramses.so +0 -0
  6. {stepss-3.77.1 → stepss-3.78}/stepss/libs/mac/ramses.so +0 -0
  7. {stepss-3.77.1 → stepss-3.78}/stepss/libs/win/ramses.dll +0 -0
  8. {stepss-3.77.1 → stepss-3.78/stepss.egg-info}/PKG-INFO +1 -1
  9. {stepss-3.77.1 → stepss-3.78}/LICENSE.rst +0 -0
  10. {stepss-3.77.1 → stepss-3.78}/MANIFEST.in +0 -0
  11. {stepss-3.77.1 → stepss-3.78}/README.rst +0 -0
  12. {stepss-3.77.1 → stepss-3.78}/setup.cfg +0 -0
  13. {stepss-3.77.1 → stepss-3.78}/setup.py +0 -0
  14. {stepss-3.77.1 → stepss-3.78}/stepss/extractor.py +0 -0
  15. {stepss-3.77.1 → stepss-3.78}/stepss/globals.py +0 -0
  16. {stepss-3.77.1 → stepss-3.78}/stepss/helios.py +0 -0
  17. {stepss-3.77.1 → stepss-3.78}/stepss/libs/helios_api.h +0 -0
  18. {stepss-3.77.1 → stepss-3.78}/stepss/libs/lin/libhelios_api.so +0 -0
  19. {stepss-3.77.1 → stepss-3.78}/stepss/libs/mac/libhelios_api.dylib +0 -0
  20. {stepss-3.77.1 → stepss-3.78}/stepss/libs/ramses.h +0 -0
  21. {stepss-3.77.1 → stepss-3.78}/stepss/libs/win/helios_api.dll +0 -0
  22. {stepss-3.77.1 → stepss-3.78}/stepss/live.py +0 -0
  23. {stepss-3.77.1 → stepss-3.78}/stepss/scripts/__init__.py +0 -0
  24. {stepss-3.77.1 → stepss-3.78}/stepss/scripts/exec.py +0 -0
  25. {stepss-3.77.1 → stepss-3.78}/stepss/simulator.py +0 -0
  26. {stepss-3.77.1 → stepss-3.78}/stepss.egg-info/SOURCES.txt +0 -0
  27. {stepss-3.77.1 → stepss-3.78}/stepss.egg-info/dependency_links.txt +0 -0
  28. {stepss-3.77.1 → stepss-3.78}/stepss.egg-info/entry_points.txt +0 -0
  29. {stepss-3.77.1 → stepss-3.78}/stepss.egg-info/requires.txt +0 -0
  30. {stepss-3.77.1 → stepss-3.78}/stepss.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stepss
3
- Version: 3.77.1
3
+ Version: 3.78
4
4
  Summary: Python interface to the STEPSS power-system simulation platform.
5
5
  Home-page: https://stepss.sps-lab.org
6
6
  Author: Petros Aristidou
@@ -24,7 +24,7 @@ Module-level flags set at import time:
24
24
  """
25
25
 
26
26
  __package_name__ = "stepss"
27
- __version__ = '3.77.1'
27
+ __version__ = '3.78'
28
28
  __author__ = "Petros Aristidou"
29
29
  __copyright__ = "Petros Aristidou"
30
30
  __license__ = "Apache-2.0"
@@ -9,5 +9,5 @@ RAMSES_VERSION is also what the stepss version number is built from, so the
9
9
  leading components of __version__ always name the library bundled here.
10
10
  """
11
11
 
12
- RAMSES_VERSION = "v3.77"
12
+ RAMSES_VERSION = "v3.78"
13
13
  HELIOS_VERSION = "v1.4.1"
@@ -15,6 +15,48 @@ from .globals import RAMSESError, CustomWarning
15
15
  warnings.showwarning = CustomWarning
16
16
 
17
17
 
18
+ def _dstProblem(dstfile):
19
+ """Return None if *dstfile* can drive a run, or a sentence saying what is wrong.
20
+
21
+ Mirrors what the engine itself accepts. A blank line, or one opening with
22
+ ``#`` or ``!``, is a comment. Every other line is a record whose first field
23
+ is a time and whose remainder is the description, and the run ends at the
24
+ first record whose description carries ``STOP``.
25
+
26
+ :param str dstfile: path to the disturbance file to check.
27
+ :returns: None when the file is usable, otherwise the reason it is not.
28
+ :rtype: str or None
29
+ """
30
+ records = 0
31
+ untimed = False
32
+ try:
33
+ with open(dstfile, 'r', encoding='utf-8', errors='replace') as records_file:
34
+ for line in records_file:
35
+ text = line.strip()
36
+ if not text or text[0] in '#!':
37
+ continue
38
+ _, space, description = text.partition(' ')
39
+ if not space:
40
+ # The engine refuses a record with fewer than two fields.
41
+ # Noting a bare STOP separately turns "no STOP record" into
42
+ # a sentence the reader can act on, with STOP on screen.
43
+ untimed = untimed or 'STOP' in text
44
+ continue
45
+ records += 1
46
+ if 'STOP' in description:
47
+ return None
48
+ except IOError as e:
49
+ return 'RAMSES: The disturbance file %s could not be read: %s' % (dstfile, e)
50
+
51
+ if untimed:
52
+ return ('RAMSES: The disturbance file %s has a STOP without a time. Every '
53
+ 'record starts with its time, as in "240.0 STOP".' % dstfile)
54
+ if records == 0:
55
+ return 'RAMSES: The disturbance file %s has no disturbance records.' % dstfile
56
+ return ('RAMSES: The disturbance file %s has no STOP record. A dynamic simulation '
57
+ 'ends at its STOP time, so add a line such as "240.0 STOP".' % dstfile)
58
+
59
+
18
60
  class cfg(object):
19
61
  """Simulation case configuration.
20
62
 
@@ -174,8 +216,16 @@ class cfg(object):
174
216
 
175
217
  .. warning:: If *userFile* already exists it will be overwritten.
176
218
  """
177
- if not self._dataset or not self._dstset:
178
- raise RAMSESError('Dataset and disturbance set cannot be empty.')
219
+ if not self._dataset:
220
+ raise RAMSESError('RAMSES: No data file is set. A case needs at least one.')
221
+ if not self._dstset:
222
+ raise RAMSESError('RAMSES: No disturbance file is set. A dynamic simulation '
223
+ 'needs one, ending in a STOP record.')
224
+ # Re-checked here rather than trusted from addDst: the file can be
225
+ # edited, or replaced, between being attached and being run.
226
+ problem = _dstProblem(self._dstset[0])
227
+ if problem:
228
+ raise RAMSESError(problem)
179
229
 
180
230
  cmdFile = ""
181
231
 
@@ -534,11 +584,15 @@ class cfg(object):
534
584
 
535
585
  .. warning:: A disturbance file must be provided before the simulation can start.
536
586
  """
537
- if os.path.isfile(dstfile):
538
- del self._dstset[:]
539
- self._dstset.append(dstfile)
540
- else:
587
+ if not os.path.isfile(dstfile):
541
588
  raise IOError('RAMSES: The dstfile %s does not exist or is not valid.' % (dstfile))
589
+ # Checked before the case is touched, so a rejected file never replaces
590
+ # a working one.
591
+ problem = _dstProblem(dstfile)
592
+ if problem:
593
+ raise RAMSESError(problem)
594
+ del self._dstset[:]
595
+ self._dstset.append(dstfile)
542
596
 
543
597
  def getDst(self):
544
598
  """Get disturbance
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stepss
3
- Version: 3.77.1
3
+ Version: 3.78
4
4
  Summary: Python interface to the STEPSS power-system simulation platform.
5
5
  Home-page: https://stepss.sps-lab.org
6
6
  Author: Petros Aristidou
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes