Skip to content

Forcings .bc file

The forcings .bc files contain forcing data for point locations, for example time series input for a boundary condition. Various quantities and function types are supported.

The forcings file is represented by the classes below.

Model

ForcingBase (DataBlockINIBasedModel) pydantic-model

validate(v) classmethod

Try to iniatialize subclass based on the function field. This field is compared to each function field of the derived models of ForcingBase. The derived model with an equal function type will be initialized.

Exceptions:

Type Description
ValueError

When the given type is not a known structure type.

Source code in hydrolib/core/io/bc/models.py
@classmethod
def validate(cls, v):
    """Try to iniatialize subclass based on the `function` field.
    This field is compared to each `function` field of the derived models of `ForcingBase`.
    The derived model with an equal function type will be initialized.

    Raises:
        ValueError: When the given type is not a known structure type.
    """

    # should be replaced by discriminated unions once merged
    # https://github.com/samuelcolvin/pydantic/pull/2336
    if isinstance(v, dict):
        for c in cls.__subclasses__():
            if (
                c.__fields__.get("function").default.lower()
                == v.get("function", "").lower()
            ):
                v = c(**v)
                break
        else:
            raise ValueError(
                f"Function of {cls.__name__} with name={v.get('name', '')} and function={v.get('function', '')} is not recognized."
            )
    return v

QuantityUnitPair (tuple)

QuantityUnitPair(quantity, unit)

__getnewargs__(self) special

Return self as a plain tuple. Used by copy and pickle.

Source code in hydrolib/core/io/bc/models.py
def __getnewargs__(self):
    'Return self as a plain tuple.  Used by copy and pickle.'
    return _tuple(self)

__new__(_cls, quantity: str, unit: str) special staticmethod

Create new instance of QuantityUnitPair(quantity, unit)

__repr__(self) special

Return a nicely formatted representation string

Source code in hydrolib/core/io/bc/models.py
def __repr__(self):
    'Return a nicely formatted representation string'
    return self.__class__.__name__ + repr_fmt % self

TimeInterpolation (str, Enum)

An enumeration.

VerticalInterpolation (str, Enum)

An enumeration.

VerticalPositionType (str, Enum)

An enumeration.

Back to top