text stringlengths 81 112k |
|---|
The maximum number of AR coefficients that shall or can be
determined.
It is the minimum of |ARMA.max_ar_order| and the number of
coefficients of the pure |MA| after their turning point.
def effective_max_ar_order(self):
"""The maximum number of AR coefficients that shall or can be
... |
Determine the AR coefficients.
The number of AR coefficients is subsequently increased until the
required precision |ARMA.max_rel_rmse| is reached. Otherwise,
a |RuntimeError| is raised.
def update_ar_coefs(self):
"""Determine the AR coefficients.
The number of AR coefficient... |
Sum of the absolute deviations between the central moments of the
instantaneous unit hydrograph and the ARMA approximation.
def dev_moments(self):
"""Sum of the absolute deviations between the central moments of the
instantaneous unit hydrograph and the ARMA approximation."""
return num... |
Multiply all coefficients by the same factor, so that their sum
becomes one.
def norm_coefs(self):
"""Multiply all coefficients by the same factor, so that their sum
becomes one."""
sum_coefs = self.sum_coefs
self.ar_coefs /= sum_coefs
self.ma_coefs /= sum_coefs |
The sum of all AR and MA coefficients
def sum_coefs(self):
"""The sum of all AR and MA coefficients"""
return numpy.sum(self.ar_coefs) + numpy.sum(self.ma_coefs) |
Determine the AR coeffcients based on a least squares approach.
The argument `ar_order` defines the number of AR coefficients to be
determined. The argument `ma_order` defines a pure |MA| model.
The least squares approach is applied on all those coefficents of the
pure MA model, which ... |
Extract the independent variables of the given values and return
them as a matrix with n columns in a form suitable for the least
squares approach applied in method |ARMA.update_ar_coefs|.
def get_a(values, n):
"""Extract the independent variables of the given values and return
them as ... |
Determine the MA coefficients.
The number of MA coefficients is subsequently increased until the
required precision |ARMA.max_dev_coefs| is reached. Otherwise,
a |RuntimeError| is raised.
def update_ma_coefs(self):
"""Determine the MA coefficients.
The number of MA coefficien... |
Determine the MA coefficients of the ARMA model based on its
predetermined AR coefficients and the MA ordinates of the given
|MA| model.
The MA coefficients are determined one at a time, beginning with the
first one. Each ARMA MA coefficient in set in a manner that allows
for t... |
Return the response to a standard dt impulse.
def response(self):
"""Return the response to a standard dt impulse."""
values = []
sum_values = 0.
ma_coefs = self.ma_coefs
ar_coefs = self.ar_coefs
ma_order = self.ma_order
for idx in range(len(self.ma.delays)):
... |
The first two time delay weighted statistical moments of the
ARMA response.
def moments(self):
"""The first two time delay weighted statistical moments of the
ARMA response."""
timepoints = self.ma.delays
response = self.response
moment1 = statstools.calc_mean_time(timep... |
Barplot of the ARMA response.
def plot(self, threshold=None, **kwargs):
"""Barplot of the ARMA response."""
try:
# Works under matplotlib 3.
pyplot.bar(x=self.ma.delays+.5, height=self.response,
width=1., fill=False, **kwargs)
except TypeError: #... |
Returns the Cython method header for methods without arguments except
`self`.
def method_header(method_name, nogil=False, idx_as_arg=False):
"""Returns the Cython method header for methods without arguments except
`self`."""
if not config.FASTCYTHON:
nogil = False
header = 'cpdef inline voi... |
The decorated method will return a |Lines| object including
a method header. However, the |Lines| object will be empty if
the respective model does not implement a method with the same
name as the wrapped method.
def decorate_method(wrapped):
"""The decorated method will return a |Lines| object includ... |
Appends the given text line with prefixed spaces in accordance with
the given number of indentation levels.
def add(self, indent, line):
"""Appends the given text line with prefixed spaces in accordance with
the given number of indentation levels.
"""
if isinstance(line, str):
... |
Name of the compiled module.
def pyname(self):
"""Name of the compiled module."""
if self.pymodule.endswith('__init__'):
return self.pymodule.split('.')[-2]
else:
return self.pymodule.split('.')[-1] |
Update the pyx file.
def pyxwriter(self):
"""Update the pyx file."""
model = self.Model()
if hasattr(self, 'Parameters'):
model.parameters = self.Parameters(vars(self))
else:
model.parameters = parametertools.Parameters(vars(self))
if hasattr(self, 'Seque... |
All source files of the actual models Python classes and their
respective base classes.
def pysourcefiles(self):
"""All source files of the actual models Python classes and their
respective base classes."""
sourcefiles = set()
for (name, child) in vars(self).items():
... |
True if at least one of the |Cythonizer.pysourcefiles| is
newer than the compiled file under |Cythonizer.pyxfilepath|,
otherwise False.
def outdated(self):
"""True if at least one of the |Cythonizer.pysourcefiles| is
newer than the compiled file under |Cythonizer.pyxfilepath|,
o... |
Translate cython code to C code and compile it.
def compile_(self):
"""Translate cython code to C code and compile it."""
from Cython import Build
argv = copy.deepcopy(sys.argv)
sys.argv = [sys.argv[0], 'build_ext', '--build-lib='+self.buildpath]
exc_modules = [
... |
Try to find the resulting dll file and to move it into the
`cythons` package.
Things to be aware of:
* The file extension either `pyd` (Window) or `so` (Linux).
* The folder containing the dll file is system dependent, but is
always a subfolder of the `cythons` package.
... |
Constants declaration lines.
def constants(self):
"""Constants declaration lines."""
lines = Lines()
for (name, member) in vars(self.cythonizer).items():
if (name.isupper() and
(not inspect.isclass(member)) and
(type(member) in TYPE2STR)):
... |
Parameter declaration lines.
def parameters(self):
"""Parameter declaration lines."""
lines = Lines()
lines.add(0, '@cython.final')
lines.add(0, 'cdef class Parameters(object):')
for subpars in self.model.parameters:
if subpars:
lines.add(1, 'cdef pub... |
Sequence declaration lines.
def sequences(self):
"""Sequence declaration lines."""
lines = Lines()
lines.add(0, '@cython.final')
lines.add(0, 'cdef class Sequences(object):')
for subseqs in self.model.sequences:
lines.add(1, 'cdef public %s %s'
... |
Special declaration lines for the given |IOSequence| object.
def iosequence(seq):
"""Special declaration lines for the given |IOSequence| object.
"""
lines = Lines()
lines.add(1, 'cdef public bint _%s_diskflag' % seq.name)
lines.add(1, 'cdef public str _%s_path' % seq.name)
... |
Open file statements.
def open_files(subseqs):
"""Open file statements."""
print(' . open_files')
lines = Lines()
lines.add(1, 'cpdef open_files(self, int idx):')
for seq in subseqs:
lines.add(2, 'if self._%s_diskflag:' % seq.name)
lines.add(3,... |
Close file statements.
def close_files(subseqs):
"""Close file statements."""
print(' . close_files')
lines = Lines()
lines.add(1, 'cpdef inline close_files(self):')
for seq in subseqs:
lines.add(2, 'if self._%s_diskflag:' % seq.name)
lines.add... |
Load data statements.
def load_data(subseqs):
"""Load data statements."""
print(' . load_data')
lines = Lines()
lines.add(1, 'cpdef inline void load_data(self, int idx) %s:' % _nogil)
lines.add(2, 'cdef int jdx0, jdx1, jdx2, jdx3, jdx4, jdx5')
for seq in subse... |
Set_pointer functions for link sequences.
def set_pointer(self, subseqs):
"""Set_pointer functions for link sequences."""
lines = Lines()
for seq in subseqs:
if seq.NDIM == 0:
lines.extend(self.set_pointer0d(subseqs))
break
for seq in subseqs:
... |
Set_pointer function for 0-dimensional link sequences.
def set_pointer0d(subseqs):
"""Set_pointer function for 0-dimensional link sequences."""
print(' . set_pointer0d')
lines = Lines()
lines.add(1, 'cpdef inline set_pointer0d'
'(self, str name, pointerut... |
Allocate memory for 1-dimensional link sequences.
def alloc(subseqs):
"""Allocate memory for 1-dimensional link sequences."""
print(' . setlength')
lines = Lines()
lines.add(1, 'cpdef inline alloc(self, name, int length):')
for seq in subseqs:
lines.add(2,... |
Deallocate memory for 1-dimensional link sequences.
def dealloc(subseqs):
"""Deallocate memory for 1-dimensional link sequences."""
print(' . dealloc')
lines = Lines()
lines.add(1, 'cpdef inline dealloc(self):')
for seq in subseqs:
lines.add(2, 'PyMem_Free... |
Set_pointer function for 1-dimensional link sequences.
def set_pointer1d(subseqs):
"""Set_pointer function for 1-dimensional link sequences."""
print(' . set_pointer1d')
lines = Lines()
lines.add(1, 'cpdef inline set_pointer1d'
'(self, str name, pointerut... |
Numeric parameter declaration lines.
def numericalparameters(self):
"""Numeric parameter declaration lines."""
lines = Lines()
if self.model.NUMERICAL:
lines.add(0, '@cython.final')
lines.add(0, 'cdef class NumConsts(object):')
for name in ('nmb_methods', 'nm... |
Attribute declarations of the model class.
def modeldeclarations(self):
"""Attribute declarations of the model class."""
lines = Lines()
lines.add(0, '@cython.final')
lines.add(0, 'cdef class Model(object):')
lines.add(1, 'cdef public int idx_sim')
lines.add(1, 'cdef pub... |
Standard functions of the model class.
def modelstandardfunctions(self):
"""Standard functions of the model class."""
lines = Lines()
lines.extend(self.doit)
lines.extend(self.iofunctions)
lines.extend(self.new2old)
lines.extend(self.run)
lines.extend(self.update... |
Numerical functions of the model class.
def modelnumericfunctions(self):
"""Numerical functions of the model class."""
lines = Lines()
lines.extend(self.solve)
lines.extend(self.calculate_single_terms)
lines.extend(self.calculate_full_terms)
lines.extend(self.get_point_s... |
Do (most of) it function of the model class.
def doit(self):
"""Do (most of) it function of the model class."""
print(' . doit')
lines = Lines()
lines.add(1, 'cpdef inline void doit(self, int idx) %s:' % _nogil)
lines.add(2, 'self.idx_sim = idx')
if getatt... |
Input/output functions of the model class.
def iofunctions(self):
"""Input/output functions of the model class."""
lines = Lines()
for func in ('open_files', 'close_files', 'load_data', 'save_data'):
if ((func == 'load_data') and
(getattr(self.model.sequences, 'i... |
Lines of model method with the same name.
def calculate_single_terms(self):
"""Lines of model method with the same name."""
lines = self._call_methods('calculate_single_terms',
self.model.PART_ODE_METHODS)
if lines:
lines.insert(1, (' self.n... |
User functions of the model class.
def listofmodeluserfunctions(self):
"""User functions of the model class."""
lines = []
for (name, member) in vars(self.model.__class__).items():
if (inspect.isfunction(member) and
(name not in ('run', 'new2old')) and
... |
Cleaned code lines.
Implemented cleanups:
* eventually remove method version
* remove docstrings
* remove comments
* remove empty lines
* remove line brackes within brackets
* replace `modelutils` with nothing
* remove complete lines contain... |
r"""Remove line breaks within equations.
This is not a exhaustive test, but shows how the method works:
>>> code = 'asdf = \\\n(a\n+b)'
>>> from hydpy.cythons.modelutils import FuncConverter
>>> FuncConverter.remove_linebreaks_within_equations(code)
'asdf = (a+b)'
def remove_l... |
Remove mathematical expressions that require Pythons global
interpreter locking mechanism.
This is not a exhaustive test, but shows how the method works:
>>> lines = [' x += 1*1']
>>> from hydpy.cythons.modelutils import FuncConverter
>>> FuncConverter.remove_imath_operators... |
Cython code lines.
Assumptions:
* Function shall be a method
* Method shall be inlined
* Method returns nothing
* Method arguments are of type `int` (except self)
* Local variables are generally of type `int` but of type `double`
when their name sta... |
Return the smoothing parameter corresponding to the given meta
parameter when using |smooth_logistic2|.
Calculate the smoothing parameter value corresponding the meta parameter
value 2.5:
>>> from hydpy.auxs.smoothtools import calc_smoothpar_logistic2
>>> smoothpar = calc_smoothpar_logistic2(2.5)
... |
Return a |Date| instance based on date information (year,
month, day, hour, minute, second) stored as the first entries of
the successive rows of a |numpy.ndarray|.
>>> from hydpy import Date
>>> import numpy
>>> array1d = numpy.array([1992, 10, 8, 15, 15, 42, 999])
>>> ... |
Return a 1-dimensional |numpy| |numpy.ndarray| with six entries
defining the actual date (year, month, day, hour, minute, second).
>>> from hydpy import Date
>>> Date('1992-10-8 15:15:42').to_array()
array([ 1992., 10., 8., 15., 15., 42.])
.. note::
... |
Return a |Date| object representing the reference date of the
given `units` string agreeing with the NetCDF-CF conventions.
The following example string is taken from the `Time Coordinate`_
chapter of the NetCDF-CF conventions documentation (modified).
Note that the first entry (the uni... |
Return a `units` string agreeing with the NetCDF-CF conventions.
By default, |Date.to_cfunits| takes `hours` as time unit, and the
the actual value of |Options.utcoffset| as time zone information:
>>> from hydpy import Date
>>> date = Date('1992-10-08 15:15:42')
>>> date.to_cfu... |
Convenience method for `_set_year`, `_set_month`...
def _set_thing(self, thing, value):
"""Convenience method for `_set_year`, `_set_month`..."""
try:
value = int(value)
except (TypeError, ValueError):
raise TypeError(
f'Changing the {thing} of a `Date` i... |
The actual hydrological year according to the selected
reference month.
The reference mont reference |Date.refmonth| defaults to November:
>>> october = Date('1996.10.01')
>>> november = Date('1996.11.01')
>>> october.wateryear
1996
>>> november.wateryear
... |
Return a |str| object representing the actual date in
accordance with the given style and the eventually given
UTC offset (in minutes).
Without any input arguments, the actual |Date.style| is used
to return a date string in your local time zone:
>>> from hydpy import Date
... |
Return a |Period| instance based on a given number of seconds.
def fromseconds(cls, seconds):
"""Return a |Period| instance based on a given number of seconds."""
try:
seconds = int(seconds)
except TypeError:
seconds = int(seconds.flatten()[0])
return cls(datetim... |
Guess the unit of the period as the largest one, which results in
an integer duration.
def _guessunit(self):
"""Guess the unit of the period as the largest one, which results in
an integer duration.
"""
if not self.days % 1:
return 'd'
elif not self.hours % 1... |
Returns a |Timegrid| instance based on two date and one period
information stored in the first 13 rows of a |numpy.ndarray| object.
def from_array(cls, array):
"""Returns a |Timegrid| instance based on two date and one period
information stored in the first 13 rows of a |numpy.ndarray| object.
... |
Returns a 1-dimensional |numpy| |numpy.ndarray| with thirteen
entries first defining the start date, secondly defining the end
date and thirdly the step size in seconds.
def to_array(self):
"""Returns a 1-dimensional |numpy| |numpy.ndarray| with thirteen
entries first defining the start... |
Return a |Timegrid| object representing the given starting
`timepoints` in relation to the given `refdate`.
The following examples identical with the ones of
|Timegrid.to_timepoints| but reversed.
At least two given time points must be increasing and
equidistant. By default, t... |
Return an |numpy.ndarray| representing the starting time points
of the |Timegrid| object.
The following examples identical with the ones of
|Timegrid.from_timepoints| but reversed.
By default, the time points are given in hours:
>>> from hydpy import Timegrid
>>> timeg... |
Prefix the information of the actual Timegrid object to the given
array and return it.
The Timegrid information is stored in the first thirteen values of
the first axis of the returned series. Initialize a Timegrid object
and apply its `array2series` method on a simple list containing
... |
Raise an |ValueError| if the dates or the step size of the time
frame are inconsistent.
def verify(self):
"""Raise an |ValueError| if the dates or the step size of the time
frame are inconsistent.
"""
if self.firstdate >= self.lastdate:
raise ValueError(
... |
Return a |repr| string with an prefixed assignement.
Without option arguments given, printing the returned string
looks like:
>>> from hydpy import Timegrid
>>> timegrid = Timegrid('1996-11-01 00:00:00',
... '1997-11-01 00:00:00',
... ... |
Raise an |ValueError| it the different time grids are
inconsistent.
def verify(self):
"""Raise an |ValueError| it the different time grids are
inconsistent."""
self.init.verify()
self.sim.verify()
if self.init.firstdate > self.sim.firstdate:
raise ValueError(... |
Return a |repr| string with a prefixed assignment.
def assignrepr(self, prefix):
"""Return a |repr| string with a prefixed assignment."""
caller = 'Timegrids('
blanks = ' ' * (len(prefix) + len(caller))
prefix = f'{prefix}{caller}'
lines = [f'{self.init.assignrepr(prefix)},']
... |
Amount of time passed in seconds since the beginning of the year.
In the first example, the year is only one minute and thirty seconds
old:
>>> from hydpy.core.timetools import TOY
>>> TOY('1_1_0_1_30').seconds_passed
90
The second example shows that the 29th February ... |
Remaining part of the year in seconds.
In the first example, only one minute and thirty seconds of the year
remain:
>>> from hydpy.core.timetools import TOY
>>> TOY('12_31_23_58_30').seconds_left
90
The second example shows that the 29th February is generally included:... |
Return a |Timegrid| object defining the central time points
of the year 2000 for the given simulation step.
>>> from hydpy.core.timetools import TOY
>>> TOY.centred_timegrid('1d')
Timegrid('2000-01-01 12:00:00',
'2001-01-01 12:00:00',
'1d')
def centred... |
The prefered way for HydPy objects to respond to |dir|.
Note the depencence on the `pub.options.dirverbose`. If this option is
set `True`, all attributes and methods of the given instance and its
class (including those inherited from the parent classes) are returned:
>>> from hydpy import pub
>>>... |
Return the class name of the given instance object or class.
>>> from hydpy.core.objecttools import classname
>>> from hydpy import pub
>>> print(classname(float))
float
>>> print(classname(pub.options))
Options
def classname(self):
"""Return the class name of the given instance object or ... |
Name of the class of the given instance in lower case letters.
This function is thought to be implemented as a property. Otherwise
it would violate the principle not to access or manipulate private
attributes ("_name"):
>>> from hydpy.core.objecttools import name
>>> class Test(object):
... ... |
Raises an |ValueError| if the given name is not a valid Python
identifier.
For example, the string `test_1` (with underscore) is valid...
>>> from hydpy.core.objecttools import valid_variable_identifier
>>> valid_variable_identifier('test_1')
...but the string `test 1` (with white space) is not:
... |
Augment an exception message with additional information while keeping
the original traceback.
You can prefix and/or suffix text. If you prefix something (which happens
much more often in the HydPy framework), the sub-clause ', the following
error occurred:' is automatically included:
>>> from hy... |
Wrap a function with |augment_excmessage|.
Function |excmessage_decorator| is a means to apply function
|augment_excmessage| more efficiently. Suppose you would apply
function |augment_excmessage| in a function that adds and returns
to numbers:
>>> from hydpy.core import objecttools
>>> def ... |
Print the given values in multiple lines with a certain maximum width.
By default, each line contains at most 70 characters:
>>> from hydpy import print_values
>>> print_values(range(21))
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20
You can change this default beha... |
Return a prefixed, wrapped and properly aligned string representation
of the given values using function |repr|.
>>> from hydpy.core.objecttools import assignrepr_values
>>> print(assignrepr_values(range(1, 13), 'test(', 20) + ')')
test(1, 2, 3, 4, 5,
6, 7, 8, 9, 10,
11, 12)
If n... |
Return a prefixed and properly aligned string representation
of the given 2-dimensional value matrix using function |repr|.
>>> from hydpy.core.objecttools import assignrepr_values2
>>> import numpy
>>> print(assignrepr_values2(numpy.eye(3), 'test(') + ')')
test(1.0, 0.0, 0.0,
0.0, 1.0, 0.... |
Return a prefixed, wrapped and properly aligned bracketed string
representation of the given 2-dimensional value matrix using function
|repr|.
def _assignrepr_bracketed2(assignrepr_bracketed1, values, prefix, width=None):
"""Return a prefixed, wrapped and properly aligned bracketed string
representatio... |
Prints values with a maximum number of digits in doctests.
See the documentation on function |repr| for more details. And
note thate the option keyword arguments are passed to the print function.
Usually one would apply function |round_| on a single or a vector
of numbers:
>>> from hydpy import ... |
Return a generator that extracts certain objects from `values`.
This function is thought for supporting the definition of functions
with arguments, that can be objects of of contain types or that can
be iterables containing these objects.
The following examples show that function |extract|
basical... |
Return an enumeration string based on the given values.
The following four examples show the standard output of function
|enumeration|:
>>> from hydpy.core.objecttools import enumeration
>>> enumeration(('text', 3, []))
'text, 3, and []'
>>> enumeration(('text', 3))
'text and 3'
>>> en... |
Trim upper values in accordance with :math:`IC \\leq ICMAX`.
>>> from hydpy.models.hland import *
>>> parameterstep('1d')
>>> nmbzones(5)
>>> icmax(2.0)
>>> states.ic(-1.0, 0.0, 1.0, 2.0, 3.0)
>>> states.ic
ic(0.0, 0.0, 1.0, 2.0, 2.0)
def trim(self, lower=None, ... |
Trim values in accordance with :math:`WC \\leq WHC \\cdot SP`.
>>> from hydpy.models.hland import *
>>> parameterstep('1d')
>>> nmbzones(7)
>>> whc(0.1)
>>> states.wc.values = -1.0, 0.0, 1.0, -1.0, 0.0, 0.5, 1.0
>>> states.sp(-1., 0., 0., 5., 5., 5., 5.)
>>> stat... |
Trim values in accordance with :math:`WC \\leq WHC \\cdot SP`.
>>> from hydpy.models.hland import *
>>> parameterstep('1d')
>>> nmbzones(7)
>>> whc(0.1)
>>> states.sp = 0.0, 0.0, 0.0, 5.0, 5.0, 5.0, 5.0
>>> states.wc(-1.0, 0.0, 1.0, -1.0, 0.0, 0.5, 1.0)
>>> state... |
Trim negative value whenever there is no internal lake within
the respective subbasin.
>>> from hydpy.models.hland import *
>>> parameterstep('1d')
>>> nmbzones(2)
>>> zonetype(FIELD, ILAKE)
>>> states.lz(-1.0)
>>> states.lz
lz(-1.0)
>>> zonetype(... |
Call method |InputSequences.load_data| of all handled
|InputSequences| objects.
def load_data(self, idx):
"""Call method |InputSequences.load_data| of all handled
|InputSequences| objects."""
for subseqs in self:
if isinstance(subseqs, abctools.InputSequencesABC):
... |
Call method `save_data|` of all handled |IOSequences|
objects registered under |OutputSequencesABC|.
def save_data(self, idx):
"""Call method `save_data|` of all handled |IOSequences|
objects registered under |OutputSequencesABC|."""
for subseqs in self:
if isinstance(subseq... |
Nested dictionary containing the values of all condition
sequences.
See the documentation on property |HydPy.conditions| for further
information.
def conditions(self) -> Dict[str, Dict[str, Union[float, numpy.ndarray]]]:
"""Nested dictionary containing the values of all condition
... |
Read the initial conditions from a file and assign them to the
respective |StateSequence| and/or |LogSequence| objects handled by
the actual |Sequences| object.
If no filename or dirname is passed, the ones defined by the
|ConditionManager| stored in module |pub| are used.
def load_con... |
Query the actual conditions of the |StateSequence| and/or
|LogSequence| objects handled by the actual |Sequences| object and
write them into a initial condition file.
If no filename or dirname is passed, the ones defined by the
|ConditionManager| stored in module |pub| are used.
def sa... |
Absolute path of the directory of the internal data file.
Normally, each sequence queries its current "internal" directory
path from the |SequenceManager| object stored in module |pub|:
>>> from hydpy import pub, repr_, TestIO
>>> from hydpy.core.filetools import SequenceManager
... |
Move internal data from disk to RAM.
def disk2ram(self):
"""Move internal data from disk to RAM."""
values = self.series
self.deactivate_disk()
self.ramflag = True
self.__set_array(values)
self.update_fastaccess() |
Move internal data from RAM to disk.
def ram2disk(self):
"""Move internal data from RAM to disk."""
values = self.series
self.deactivate_ram()
self.diskflag = True
self._save_int(values)
self.update_fastaccess() |
Shape of the whole time series (time being the first dimension).
def seriesshape(self):
"""Shape of the whole time series (time being the first dimension)."""
seriesshape = [len(hydpy.pub.timegrids.init)]
seriesshape.extend(self.shape)
return tuple(seriesshape) |
Shape of the array of temporary values required for the numerical
solver actually being selected.
def numericshape(self):
"""Shape of the array of temporary values required for the numerical
solver actually being selected."""
try:
numericshape = [self.subseqs.seqs.model.numc... |
Internal time series data within an |numpy.ndarray|.
def series(self) -> InfoArray:
"""Internal time series data within an |numpy.ndarray|."""
if self.diskflag:
array = self._load_int()
elif self.ramflag:
array = self.__get_array()
else:
raise Attribu... |
Read the internal data from an external data file.
def load_ext(self):
"""Read the internal data from an external data file."""
try:
sequencemanager = hydpy.pub.sequencemanager
except AttributeError:
raise RuntimeError(
'The time series of sequence %s can... |
Adjust a short time series to a longer timegrid.
Normally, time series data to be read from a external data files
should span (at least) the whole initialization time period of a
HydPy project. However, for some variables which are only used
for comparison (e.g. observed runoff used fo... |
Raise a |RuntimeError| if the |IOSequence.series| contains at
least one |numpy.nan| value, if option |Options.checkseries| is
enabled.
>>> from hydpy import pub
>>> pub.timegrids = '2000-01-01', '2000-01-11', '1d'
>>> from hydpy.core.sequencetools import IOSequence
>>> c... |
Write the internal data into an external data file.
def save_ext(self):
"""Write the internal data into an external data file."""
try:
sequencemanager = hydpy.pub.sequencemanager
except AttributeError:
raise RuntimeError(
'The time series of sequence %s c... |
Load internal data from file and return it.
def _load_int(self):
"""Load internal data from file and return it."""
values = numpy.fromfile(self.filepath_int)
if self.NDIM > 0:
values = values.reshape(self.seriesshape)
return values |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.