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

Change Component first/last after it is added #805

Closed
lrennels opened this issue Apr 1, 2021 · 1 comment
Closed

Change Component first/last after it is added #805

lrennels opened this issue Apr 1, 2021 · 1 comment
Assignees

Comments

@lrennels
Copy link
Collaborator

lrennels commented Apr 1, 2021

Right now when we add a component to a model, we can optionally set its first and last. If they are set there are set the component's first and last will not change if the model time dimension is changed (they have a first_free and last_free flag that is set to false. If they are not set, they will take the first and last of the model itself, and vary freely with the model, so if someone calls set_dimension(:time, values on the model, that time will propagate through the components and change the first and last of the components.

This creates a problem in the FUND_FAIR case:

We start with

m = MimiFUND.get_model(;nsteps = 551 )

Currently, m runs from 1950 to 2500, and the components and model all have first and last of 1950 and 2500 respectively. Now we want to widen the time dimension so that we can couple FAIR, so we call:

set_dimension!(m, :time, collect(1765:2500))
add_comp!(m, MimiFAIR_composite, after = MimiFUND_emissionscomposite)

The problem now is that this time dimension automatically flows through all the FUND components, so all FUND components have a first and last of 1765 and 2500 respectively ... which is wrong!

Thus we need a user-facing function to retroactively set first for the FUND components. This should call my existing functions Mimi.propagate_time! (or Mimi._propagate_firstlast!) under the hood and will look something like this ...

set_firstlast!(m::ModelDef, comp_name::Symbol; first = NothingInt, last = NothingInt)

so that we can call

m = MimiFUND.get_model(;nsteps = 551 )
set_dimension!(m, :time, collect(1765:2500))
add_comp!(m, MimiFAIR_composite, after = MimiFUND_emissionscomposite)

set_firstlast!(m, MimiFUND_emissionscomposite, first = 1950);
set_firstlast!(m, MimiFUND_climatecomposite, first = 1950);
set_firstlast!(m, MimiFUND_impactscomposite, first = 1950);

Ideas for the name? I guess it could be update_firstlast!? Also can we put this in the exported API or should I keep it out?

@lrennels lrennels self-assigned this Apr 1, 2021
@lrennels lrennels modified the milestones: v1.2.1, v1.3.0 Apr 1, 2021
@lrennels lrennels mentioned this issue Apr 5, 2021
@lrennels
Copy link
Collaborator Author

#811

@lrennels lrennels modified the milestones: v1.3.0, v1.2.2 Apr 23, 2021
@lrennels lrennels closed this as completed May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant