Skip to content

Setting 1-dimensional SeasonalParameter by setattr  #78

@sivogel

Description

@sivogel

If you try to set a Seasonal Parameter directly by its toy-attribute, you receive an error because the shape has been not initialized yet.
hydpy.pub.timegrids = "2018-01-01", "2019-01-01", "1d" model = hydpy.prepare_model("dam_v008") model.parameters.control.neardischargeminimumthreshold.toy_1_1(5)
AttributeError: Seasonal parameter neardischargeminimumthreshold of element ? has neither a normal attribute nor does it handle a "time of year" named toy_1_1.

Workarounds:
Setting the parameter directly or with a dictionary:
model.parameters.control.neardischargeminimumthreshold(**{"toy_1_1": 5})
Define shape:

model.parameters.control.neardischargeminimumthreshold.shape = None
model.parameters.control.neardischargeminimumthreshold.shape
(366,)
model.parameters.control.neardischargeminimumthreshold.toy_1_1(5)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions