Example #1
0
class State1DSequence(sequencetools.StateSequence):
    """Base class for 1-dimensional state subclasses that support
    aggregation with respect to |ZoneArea|.

    All |State1DSequence| subclasses must implement fitting mask objects
    individually.

    The following example shows how subclass |SM| works, which
    implements mask |Soil|:

    >>> from hydpy.models.hland import *
    >>> parameterstep("1d")
    >>> nmbzones(4)
    >>> zonetype(FIELD, FOREST, GLACIER, ILAKE)
    >>> zonearea(10.0, 20.0, 30.0, 40.0)
    >>> fc(100.0)
    >>> states.sm(50.0, 20.0, 40.0, 10.0)
    >>> from hydpy import round_
    >>> round_(states.sm.average_values())
    30.0
    """

    mask = hland_masks.Complete()

    @property
    def refweights(self):
        """Alias for the associated instance of |ZoneArea| for calculating
        areal values."""
        return self.subseqs.seqs.model.parameters.control.zonearea
Example #2
0
class Flux1DSequence(sequencetools.FluxSequence):
    """Base class for 1-dimensional flux subclasses that support
    aggregation with respect to |ZoneArea|.

    All |Flux1DSequence| subclasses should stick to the mask |Complete|.


    The following example shows how subclass |PC| works:

    >>> from hydpy.models.hland import *
    >>> parameterstep("1d")
    >>> nmbzones(4)
    >>> zonetype(FIELD, FOREST, GLACIER, ILAKE)
    >>> zonearea(10.0, 20.0, 30.0, 40.0)
    >>> fluxes.pc(5.0, 2.0, 4.0, 1.0)
    >>> from hydpy import round_
    >>> round_(fluxes.pc.average_values())
    2.5
    """

    mask = hland_masks.Complete()

    @property
    def refweights(self):
        """Alias for the associated instance of |ZoneArea| for calculating
        areal values."""
        return self.subseqs.seqs.model.parameters.control.zonearea
Example #3
0
class ParameterComplete(parametertools.ZipParameter):
    """Base class for 1-dimensional parameters relevant for all types
    of zones.

    |ParameterComplete| applies the features of class |ZipParameter|
    on the land use types `field`, `forest`, `glacier`, and `ilake`
    and consideres them all as relevant (e.g. for calculating
    weighted averages).

    The following examples are based on parameter |PCorr|, which is
    directly derived from |ParameterComplete|.  After preparing
    the parameter |NmbZones|, parameter |PCorr| allows to set its
    values using the relevant land use types as keywords:

    >>> from hydpy.models.hland import *
    >>> parameterstep("1d")
    >>> nmbzones(5)
    >>> zonetype(FIELD, FOREST, GLACIER, ILAKE, FIELD)
    >>> pcorr(field=2.0, forest=1.0, glacier=4.0, ilake=3.0)
    >>> pcorr
    pcorr(field=2.0, forest=1.0, glacier=4.0, ilake=3.0)
    >>> pcorr.values
    array([ 2.,  1.,  4.,  3.,  2.])

    Parameter |ZoneArea| is used for calculating the areal means (see
    |property| |ParameterComplete.refweights|):

    >>> zonearea(0.0, 1.0, 2.0, 3.0, 4.0)
    >>> from hydpy import round_
    >>> round_(pcorr.average_values())
    2.6

    Alternatively, pass other masks defined in module |hland_masks|,
    to take only certain types of zones into account:

    >>> round_(pcorr.average_values(model.masks.field))
    2.0
    >>> round_(pcorr.average_values("soil"))
    1.8
    >>> round_(pcorr.average_values(model.masks.field, "forest"))
    1.8

    All other masks (e.g. |hland_masks.Soil| used by |ParameterSoil|
    subclasses as |hland_control.IcMax|) are subsets of mask
    |hland_masks.Complete|:

    >>> icmax.mask in pcorr.mask
    True
    >>> pcorr.mask in icmax.mask
    False
    """

    MODEL_CONSTANTS = hland_constants.CONSTANTS
    mask = hland_masks.Complete()

    @property
    def refweights(self):
        """Reference to the associated instance of |RelZoneArea| for
        calculating areal mean values."""
        return self.subpars.pars.control.zonearea
Example #4
0
class ParameterComplete(parametertools.ZipParameter):
    """Base class for 1-dimensional parameters relevant for all types of zones.

    |ParameterComplete| applies the features of class |ZipParameter| on the land use
    types |FIELD|, |FOREST|, |GLACIER|, |ILAKE|, and |SEALED| and considers them all as
    relevant (e.g., for calculating weighted averages).

    We use parameter |PCorr| as an example, which is a subclass of |ParameterComplete|.
    After preparing the parameter |ZoneType|, |PCorr| allows setting its values using
    the relevant land-use types as keywords:

    >>> from hydpy.models.hland import *
    >>> parameterstep("1d")
    >>> nmbzones(6)
    >>> zonetype(FIELD, FOREST, GLACIER, ILAKE, FIELD, SEALED)
    >>> pcorr(field=2.0, forest=1.0, glacier=4.0, ilake=3.0, sealed=5.0)
    >>> pcorr
    pcorr(field=2.0, forest=1.0, glacier=4.0, ilake=3.0, sealed=5.0)
    >>> pcorr.values
    array([2., 1., 4., 3., 2., 5.])

    Parameter |ZoneArea| serves for calculating areal means (see the documentation on
    |property| |ParameterComplete.refweights|):

    >>> zonearea.values = 0.0, 1.0, 2.0, 3.0, 4.0, 5.0
    >>> from hydpy import round_
    >>> round_(pcorr.average_values())
    3.4

    Alternatively, pass other masks defined in module |hland_masks| to take only
    certain types of zones into account:

    >>> round_(pcorr.average_values(model.masks.field))
    2.0
    >>> round_(pcorr.average_values("soil"))
    1.8
    >>> round_(pcorr.average_values(model.masks.field, "forest"))
    1.8

    All other masks (for example, |hland_masks.Soil|, being used by |ParameterSoil|
    subclasses as |hland_control.IcMax|) are subsets of mask |hland_masks.Complete|:

    >>> icmax.mask in pcorr.mask
    True
    >>> pcorr.mask in icmax.mask
    False
    """

    MODEL_CONSTANTS = hland_constants.CONSTANTS
    mask = hland_masks.Complete()

    @property
    def refweights(self):
        """Reference to the associated instance of |RelZoneAreas| for calculating areal
        mean values."""
        return self.subpars.pars.control.zonearea
Example #5
0
class SfC(hland_sequences.Factor1DSequence):
    """Actual precipitation correction related to frozen precipitation [-]."""

    mask = hland_masks.Complete()
Example #6
0
class FracRain(hland_sequences.Factor1DSequence):
    """Fraction rainfall / total precipitation [-]."""

    mask = hland_masks.Complete()
Example #7
0
class TC(hland_sequences.Factor1DSequence):
    """Corrected temperature [°C]."""

    mask = hland_masks.Complete()
Example #8
0
class PC(hland_sequences.Flux1DSequence):
    """Corrected precipitation [mm/T]."""

    mask = hland_masks.Complete()