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

Use the same enum for inversion type for both std_enkf and ies_enkf #2469

Merged
merged 1 commit into from
Dec 14, 2021

Conversation

joakim-hove
Copy link
Contributor

Part of: #2412

With this PR some of the configuration for the std_enkf and ies_enkf modules are harmonized.

@joakim-hove
Copy link
Contributor Author

test this please

@joakim-hove
Copy link
Contributor Author

test this please

@joakim-hove
Copy link
Contributor Author

test ert please

@codecov-commenter
Copy link

codecov-commenter commented Dec 7, 2021

Codecov Report

Merging #2469 (929f896) into main (a409daf) will decrease coverage by 3.90%.
The diff coverage is 76.78%.

❗ Current head 929f896 differs from pull request most recent head 9550a25. Consider uploading reports for the commit 9550a25 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2469      +/-   ##
==========================================
- Coverage   64.42%   60.51%   -3.91%     
==========================================
  Files         645      335     -310     
  Lines       54302    37258   -17044     
  Branches     4537     4545       +8     
==========================================
- Hits        34983    22548   -12435     
+ Misses      17938    13325    -4613     
- Partials     1381     1385       +4     
Impacted Files Coverage Δ
libres/lib/enkf/local_config.cpp 56.52% <ø> (ø)
res/enkf/local_config.py 86.31% <ø> (ø)
libres/lib/analysis/std_enkf.cpp 59.23% <76.78%> (+18.21%) ⬆️
res/job_queue/queue_differ.py 71.05% <0.00%> (-21.06%) ⬇️
res/job_queue/queue.py 69.40% <0.00%> (-12.83%) ⬇️
res/enkf/observations/gen_observation.py 80.00% <0.00%> (-8.75%) ⬇️
res/enkf/export/gen_kw_collector.py 94.11% <0.00%> (-5.89%) ⬇️
res/enkf/key_manager.py 91.42% <0.00%> (-5.72%) ⬇️
res/job_queue/forward_model_status.py 88.75% <0.00%> (-5.00%) ⬇️
res/enkf/enkf_obs.py 66.96% <0.00%> (-3.58%) ⬇️
... and 323 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a409daf...9550a25. Read the comment docs.

@joakim-hove
Copy link
Contributor Author

test ert please

@dafeda
Copy link
Contributor

dafeda commented Dec 9, 2021

Screenshot 2021-12-09 at 08 36 47

Note that the job ERT - pytest is not Required, which means that we can merge without it passing.
It can fail due to reasons not related to changes in this PR.

@@ -96,10 +98,56 @@ static UTIL_SAFE_CAST_FUNCTION_CONST(std_enkf_data, STD_ENKF_TYPE_ID)
return data->truncation;
}

/*
The std_enkf module originally used two boolean flags use_EE and use_GE to
Copy link
Contributor

Choose a reason for hiding this comment

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

For us newbies - what are EE and GE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hehe - I am glad you that ask that question .... frankly don't know fully myself either.

It is about choosing the algorithm for (lowrank)inversion of the covariance matrix - which in general do not have. The use_EE flag is whether we should use the approximation C = EE^T. If the use_EE flag is false the (pseudo)inversion is done using the S matrix - without ever constructing or using E.

The difference between use_GE is a formulation where E is used - but not the covariance estimator EE^T.

Would have been healthy to go properly through this again.

The purpose of this PR is alignment and code reuse between the old std_enkf implementation and the newer ies_enkf.

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes a little bit of sense, but I am not yet that comfortable with the math. Thanks!

I think what we want is to document the different types in ies_inversion_type and link them to literature.

I have created an issue that I've called Questions for Geir Evensen and have now added this question as well.

@@ -75,8 +76,9 @@ struct std_enkf_data_struct {
double truncation; // Controlled by config key: ENKF_TRUNCATION_KEY
int subspace_dimension; // Controlled by config key: ENKF_NCOMP_KEY (-1: use Truncation instead)
long option_flags;
bool use_EE;
bool use_GE;
bool __use_EE;
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps add a comment to here that states that both __use_EE and __use_GE are deprecated and shall be removed.
I don't have a clear overview as to what has to be done in order for us to be able to remove them.
Is this something that can be done as part of the ies-refactoring you are doing now, or do we have to make bigger changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps add a comment to here that states that both __use_EE and __use_GE are deprecated and shall be removed.

I will.

I don't have a clear overview as to what has to be done in order for us to be able to remove them.

The only thing which still keeps them around is the users current ability to set them in the config file - i.e. this works:

ANALYSIS_SET STD_ENKF USE_EE True
ANALYSIS_SET STD_ENKF USE_GE False

I assume the actual use of such settings is very limited; so after some brief investigation (log peeking?) I guess they can be removed.

Is this something that can be done as part of the ies-refactoring you are doing now

Absolutely - as explained it is more of a political than a technical question.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good stuff - I've created and issue here: #2534

return name_recognized;
}
}

bool std_enkf_set_string(void *arg, const char *var_name, const char *value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use std::string for var_name and value instead of char *?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I think we can't because it is used as:

.set_string = std_enkf_set_string,

Is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have not looked into it - but I think that would be a quite large change. The point is that the std_enkf_set_string function is called through a function pointer embedded in: analysis_module - so those changes would ripple a bit here and there. But certainly I agree with the idea, and I am happy to investigate it in a separate PR

@@ -0,0 +1,39 @@
#include <catch2/catch.hpp>

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider changing the name of the test-file to test_std_enkf.cpp.
We are basically following similar naming conventions as used in pytest (not always perfectly though).
Whether or not this is a good idea can be discussed, but it's nice if we can be somewhat consistent I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do


#include <ert/analysis/std_enkf.hpp>

TEST_CASE("std_enkf", "[analysis]") {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a nice candidate to use the GIVEN - WHEN - THEN pattern in catch2 as shown here:

https://github.com/catchorg/Catch2/blob/v2.x/docs/tutorial.md#bdd-style

It's a bit of a pain to get used to at first, but I think it's quite nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is a nice candidate to use the GIVEN - WHEN - THEN pattern in catch2 as shown here:

OK - I'll take the pill. Thank you for the pointer.

@joakim-hove joakim-hove force-pushed the use-ies-enum branch 2 times, most recently from 1af43b5 to d2477a0 Compare December 9, 2021 09:33
@joakim-hove
Copy link
Contributor Author

OK @dafeda - thank you for the review; I have tried to address all your comments.

Copy link
Contributor

@dafeda dafeda left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@oyvindeide
Copy link
Collaborator

Note that the job ERT - pytest is not Required, which means that we can merge without it passing.
It can fail due to reasons not related to changes in this PR.

That is true, just note that we need to check why it fails before we merge to know that it is not related. You should hopefully have access to check yourself soon.

@joakim-hove joakim-hove force-pushed the use-ies-enum branch 2 times, most recently from 4a2f0ef to 929f896 Compare December 14, 2021 08:30
@joakim-hove joakim-hove merged commit 600567b into equinor:main Dec 14, 2021
@joakim-hove joakim-hove deleted the use-ies-enum branch December 14, 2021 09:00
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 this pull request may close these issues.

None yet

4 participants