Skip to content

initialize! for InputSources #87

Open
maximilian-gelbrecht wants to merge 9 commits intomainfrom
mg/input-initialize
Open

initialize! for InputSources #87
maximilian-gelbrecht wants to merge 9 commits intomainfrom
mg/input-initialize

Conversation

@maximilian-gelbrecht
Copy link
Collaborator

@maximilian-gelbrecht maximilian-gelbrecht commented Mar 17, 2026

Resolves #86 and also adds unit tests for the Rasters extension and a convenience wrapper to also directly initialise an InputSource from RingGrids.Fields

@maximilian-gelbrecht maximilian-gelbrecht added the input-data Issue or feature related to input data handling label Mar 17, 2026
@maximilian-gelbrecht maximilian-gelbrecht marked this pull request as ready for review March 17, 2026 10:14
end

# for static rasters initialize once and then don't update anymore
function Terrarium.initialize_from_raster!(field, raster, idxmap, timedim::Nothing)
Copy link
Collaborator

Choose a reason for hiding this comment

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

No, please don't do this. This is again a leaky abstraction. Just dispatch internally within the extension module and remove the method from the main package.

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe this is a Claude thing... I don't know.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is just mirroring the existing update_from_raster! that was defined below already before, just the Terrarium. is too much. Will remove those.

# set inputs based on updated clock/state
# first initialize them, then set them to the current time
initialize_inputs!(integrator.state, integrator.inputs)
update_inputs!(integrator.state, integrator.inputs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this can be removed.

Copy link
Collaborator Author

@maximilian-gelbrecht maximilian-gelbrecht Mar 17, 2026

Choose a reason for hiding this comment

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

The update_inputs!?
Not how it's currently defined, e.g. for the FieldTimeSeriesInput initialize! does just nothing, and you need the update_inputs! that works as it did previously.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, maybe FieldTimeSeriesInput could just invoke update_inputs! by default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Then you also need the clock as an input for initialize!, but I guess that's not a big problem.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah I guess that makes sense actually, could be necessary in some cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, done.

@bgroenks96
Copy link
Collaborator

@maximilian-gelbrecht are the changes done? should I review this again?

@maximilian-gelbrecht
Copy link
Collaborator Author

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

input-data Issue or feature related to input data handling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add initialize! for InputSources

2 participants