Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coupling adapters for model component temporal mismatch #119

Open
cpritcha opened this issue Aug 1, 2020 · 0 comments
Open

Coupling adapters for model component temporal mismatch #119

cpritcha opened this issue Aug 1, 2020 · 0 comments

Comments

@cpritcha
Copy link

cpritcha commented Aug 1, 2020

I've been working adapting SimpleCrop to be PyMT compatible and was wondering how you usually dealt with temporal mismatch between model components. The SimpleCrop model (as a wrapper around the command line interface at least) operates on a yearly basis. It takes in weather and irrigation data for each day of the year as well as some cross sectional soil and plant data. It returns plant and soil data for each day of the year. How would you deal with this mismatch? I was thinking that this could be made easier by having some generic memory components to build up results in. I was thinking of something like

from simplecrop.models import Weather, Irrigation, Crop
# may need to choose a different storage strategy in many model timesteps don't fit into memory
from pymt.storage import Memory
from pymt.model_adapters import TimeAggregator


# the weather and models crop operate on a daily basis but are converted to yearly components
weather = TimeAggregator(Weather(), to = 'year', storage = Memory())
# you may specify a keep option so that only model state used by other models is kept  
irrigation = TimeAggregator(Irrigation(), to = 'year', storage = Memory(), keep = ['irrigation_volume__total'])

weather.initialize(*weather.setup())
irrigation.initialize(*irrigation.setup())

# the crop model operates on a yearly basis
crop = Crop()

crop.initialize(*crop.setup())

# run the model for five years
for time in range(5):
    weather.update()
    irrigation.update()
    crop.set_value('irrigation_volume__total', irrigation.get_value('irrigation_volume__total'))
    crop.set_value('soil_temperature__max', weather.get_value('soil_temperature__max'))
    crop.set_value('soil_temperature__min', weather.get_value('soil_temperature__min'))
    crop.set_value(
        'soil_top_surface_raditation~incoming__energy_flux',
        weather.get_value('soil_top_surface_raditation~incoming__energy_flux'))
    crop.update()

What do you think? How do you currently handle differences in temporal range and resolution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant