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

Calliope.model() from existing model issue, Windows OS #740

Open
ddahawkins-TUDelft opened this issue Feb 12, 2025 · 0 comments
Open

Calliope.model() from existing model issue, Windows OS #740

ddahawkins-TUDelft opened this issue Feb 12, 2025 · 0 comments

Comments

@ddahawkins-TUDelft
Copy link

Description

Hello. Whether an issue with the code itself, or just the documentation, I encountered issue with creating a Calliope model with calliope.model(...) from a previous model.

I was attempting to run a model in 'plan' mode and then use the capacity outputs from that model in a new model in 'operate' mode. Although it states that this is possible, it is not immediately clear from the documentation how to do this. Apologies, I do not have this code any longer to upload but to explain...

I created a plan model object: model_plan = calliope.model('model.yaml', ...)
Then built and solve: model_plan.build() >> model_plan.solve()

I then tried to create an operate model object, taking the model_plan as an input argument for the 'model_definition' parameter i.e.: model_operate = calliope.model(model_plan,...)

This failed.

I expected this to work as the dev5 documentation (https://calliope.readthedocs.io/en/v0.7.0.dev5/reference/api/model/?h=calliope.model#calliope.Model) for calliope.model() suggests that 'model_definition' can be a string, path, dictionary, or xarray dataset. With model_plan, a calliope model object, being an xarray dataset, I expected it to be a valid argument. Instead I received 'encoding' errors which may or may not be unique to the Windows OS. I did notice in the calliope backend a few times where UTF-8 was hardcoded for os.reads but not os.writes. Perhaps it may be better to use OS default or at least make this encoding consisting for writing and reading.

What i have later been informed is that instead of importing the model_plan object, I could have saved this file as a .netcdf and run the calliope.read_netcdf('model_plan_path') as the input parameter for 'model_definition.' If this is the case, it is not clear from your documentation and in any case, i feel it is good practice that one should be able to import the object and not have to write>read in order to access an object for re-runs.

Apologies if any of the above if unclear, happy to discuss!

Kind regards,
Dano

Related links

-https://calliope.readthedocs.io/en/v0.7.0.dev5/reference/api/model/?h=calliope.model#calliope.Model

...

Version

v.0.7.0.dev5

Proposed change

The simplest short-term solution might be an example in the documentation of chaining models i.e. running 'operate' from the output of a 'build.'

Further, a clear explanation within the calliope.model() documentation to explain the precise format of xarray permissible for the model_definition parameter.

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