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

Support transformation types LN, SET and MULTIPLY in state updating for EnKF via BB stoch model config #404

Open
erikpelgrim opened this issue Jan 31, 2025 · 11 comments

Comments

@erikpelgrim
Copy link
Contributor

Currently only the axpy (=add) transformation is available for state updating in BB stoch model config for EnKF.

Simplest solution would be to extend vector config with option transformation="LN / SET / MULTIPLY"

In BBStochModelInstance.axpyOnState the option can be read in and instead of calling axpy the method addParameterDeltaToExchangeItem can be called which modifies the exchange item values according to the transformation option.

Only thing that is not so nice is that the method is already called axpyOnState all the way up to the EnKF class where it is called in the updateModelWithGain method.

Nicer would be to either rename this method or add another method which has a name similar to addParameterDelta, but this requires a high level OpenDA interface change.

@nilsvanvelzen
Copy link
Member

nilsvanvelzen commented Jan 31, 2025

It is a very deliberate choice in OpenDA to not support a SET method. The reason is that for "real" models the full state of an (ensemble) member contains much more stuff than the "filter" state that is updated.
Multiply does not have any meaning for non-linear models. Hence I'm interested in what situation we (think we) need this.

@erikpelgrim
Copy link
Contributor Author

erikpelgrim commented Jan 31, 2025

@nilsvanvelzen: good to know. The LN is the one that is requested by Julius Sumihar, as I understood to prevent values to become negative for instance. In order to be consistent we thought supporting the other options as well.

Do you also have an option about this implementation within the axpyOnState method?
If the method would have a different name, I think that would be the best place for it.

@nilsvanvelzen
Copy link
Member

nilsvanvelzen commented Jan 31, 2025

No, LN en multiply on state are not ok (based on the available information I have). It is unclear why you need it, what it means. I only see options to bad things with it.

Please elaborate on why you need it

@erikpelgrim
Copy link
Contributor Author

Oh, sorry I missed part of your reply, I edited my reply but what I added was this:

The LN is the one that is requested by Julius Sumihar, as I understood to prevent values to become negative for instance. In order to be consistent we thought supporting the other options as well. But maybe involving Julius in the discussion would be a good idea.

@nilsvanvelzen
Copy link
Member

The original idea on the AXPY is that the model (in that time WAQUA) was able to absorb a change to the model that would lead to a non-physical state (like negative depth). The strength of the AXPY is that the model has is own "correct/allowed" state and the delta. That gives more options to fix things nicely than a "incorrect" state that is externally computed.

In the black box model that might be a bit less obvious although some additional support at that level might be useful to allow a model builder to insert same clever state-fixing optional step.

@sumihar
Copy link
Contributor

sumihar commented Jan 31, 2025

Hi @nilsvanvelzen,

We would like to do a state-parameter estimation with EnKF and are trying to find the best way to do it in OpenDA. A first approach being investigated is to treat parameter just as state variable, i.e. to include its exchangeItem in state vector definition in stochModel.xml. In the analysis step of EnKF, this effectively just adds the parameter with delta_parameter (AXPY). We haven't tested it, but this may lead to incorrect results, like for example negative value for parameter that can only be positive. So, I have been thinking to treat the parameter as parameter-vector defintion (<\parameter>) in stochModel so that we can use the available "transformation" on parameter exchange item in the analysis step. Using transformation="ln", for example, it will make sure that the parameter estimates will stay positive.

Do you have any suggestions?

Many thanks,
Julius

@nilsvanvelzen
Copy link
Member

If you want to add parameters to the state. Do you mean like al Kalman smoother?
In that case there is a (more elegant) solution outside the black box model.

The idea is not to keep extending the models (in this case the black box model) but combine models into new models.
We do have an implementation of a Kalman smoother model that takes an existing model an combines some selected parameters and state together. The LN transformation on (some of the) parameters would perfectly fit into that model. The transformations (e.g. using a log) can be done in that model.

Look if
models/java/src/org/openda/models/smootherModel
and
models/java/src/org/openda/models/biasAwareObservations

can be used as an inspiration.

@sumihar
Copy link
Contributor

sumihar commented Jan 31, 2025

Hi @nilsvanvelzen,

thanks for your input.

Our approach is to use state-parameter augmentation and estimate them simultaneously using EnKF. So, it's not a smoother.

We will have a look at the codes you mentioned.

@nilsvanvelzen
Copy link
Member

In that approach the same solution via an "parent" model should be able to do the trick and it avoids all kinds of obscure/seldom used functionality in the BB model (is already much more complex that I'd rather see)

@sumihar
Copy link
Contributor

sumihar commented Jan 31, 2025

Hi @nilsvanvelzen,

the smootherModel seems to do what we want, that it allows the model state to contain both state and parameter vectors. The axpy on state is then done correspondingly on state and parameter.

However, there is no configuration example available in git that makes use of smootherModel. Do you perhaps have a setup example for smootherModel?

Many thanks,
Julius

@nilsvanvelzen
Copy link
Member

I have used it for groundwater modelling with MikeShe. It might be here:
model_mikeshe/tests/Karup/XML

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

No branches or pull requests

3 participants