Skip to content

Vectorize phenology - example#113

Draft
fnattino wants to merge 6 commits into
60-vectorize-phenologyfrom
60-weather-data-tensor
Draft

Vectorize phenology - example#113
fnattino wants to merge 6 commits into
60-vectorize-phenologyfrom
60-weather-data-tensor

Conversation

@fnattino
Copy link
Copy Markdown
Collaborator

@fnattino fnattino commented Apr 21, 2026

Mostly explorative work on how to address #60 with an Xarray-based tensor weather data provider.

It builds on top of #112, which adds the basic functionality to keep running phenology simulations even though maturity is reached (feature needed in order to make parallel runs for different locations, since not all locations will reach maturity at the same time).

This PR includes the following changes, which are also in line with what needs to be addressed for #25:

  • It adds a generic TensorWeatherDataProvider class, which allows to set up weather data providers from tensors, and takes care of the conversion from np.arrays to torch tensors.
  • It adds the matching of the shapes of the parameters and weather data at the engine level (scalar variables are broadcasted to tensor shapes). Currently, only parameters are matched to the weather data shapes, but we should also allow for the inverse.

A notebook is also added to illustrate how the changes above, together with the current diffWOFOST infrastructure, allow to make parallel phenology runs (still, for the same crop). In a nutshell, the approach consists in setting a new fictitious time axis where all locations are aligned so that the date of sowing (DOS) happens on the same date. Also, quantities derived from the weather data (the daylength in the notebook) can be calculated as pre-processing of weather data rather than during model runs.

@fnattino fnattino changed the title 60 weather data tensor Vectorize phenology - example Apr 22, 2026
DVS = self.kiosk["DVS"]

TEMP = _get_drv(drv.TEMP, self.params.shape, self.dtype, self.device)
TEMP = _get_drv(drv["TEMP"], self.params.shape, self.dtype, self.device)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed when using the TensorWeatherDataProvider

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

Successfully merging this pull request may close these issues.

1 participant