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

Add set_value_as_xarray to models #182

Open
sverhoeven opened this issue Jul 15, 2021 · 1 comment · May be fixed by #185
Open

Add set_value_as_xarray to models #182

sverhoeven opened this issue Jul 15, 2021 · 1 comment · May be fixed by #185

Comments

@sverhoeven
Copy link
Member

As counter part of model.get_value_as_xarray() it would be nice to have model.set_value_as_xarray() method.

As now for example in docs/examples/Irrigation.ipynb we have to flatten an xarray with

soil_moisture = experiment.get_value_as_xarray('upper_soil_saturation_degree', )
soil_moisture[31:41, 18:28] = 1
experiment.set_value('upper_soil_saturation_degree', soil_moisture.values.flatten())   

It would be nicer if you could do

soil_moisture = experiment.get_value_as_xarray('upper_soil_saturation_degree', )
soil_moisture[31:41, 18:28] = 1
experiment.set_value_as_xarray('upper_soil_saturation_degree', soil_moisture)   
@Peter9192
Copy link
Collaborator

I'm willing to implement this, but we need to agree on some details.

Should set_value_as_xarray only work if the xarray exactly matches the model grid? Or also a for subregion? Should the coordinates match exactly, or do we want to pass them through _coords_to_indices (that might give weird effects if two coords map to the same grid cell)?

Suggestion: start with the simplest case where the xarray must match the model grid exactly.

@Peter9192 Peter9192 linked a pull request Jul 16, 2021 that will close this issue
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 a pull request may close this issue.

2 participants