-
Notifications
You must be signed in to change notification settings - Fork 123
Update 3D field parameter with ensemble smoother with distance-based localization #12469
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
base: main
Are you sure you want to change the base?
Conversation
1554bb7 to
36554db
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12469 +/- ##
==========================================
- Coverage 90.67% 90.67% -0.01%
==========================================
Files 429 429
Lines 29803 30073 +270
==========================================
+ Hits 27025 27268 +243
- Misses 2778 2805 +27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
b52aa01 to
a9c9709
Compare
568900f to
3d044e4
Compare
e4b0c6f to
8f14437
Compare
8f14437 to
9f42875
Compare
799157d to
5471426
Compare
0bd1029 to
a464ab2
Compare
999445a to
01ed347
Compare
4ee2df8 to
69bf521
Compare
… 3D fields Added functions: - update_3D_field_with_distance_esmda - _calc_max_number_of_layers_per_batch_for_distance_localization The function 'update_3D_field_with_distance_esmda' will update one 3D field parameter (or 2D field parameter when nz = 1) using the algorithm implemented in class DistanceESMDA in repo iterative_ensemble_smoother. This function requires that an object of DistanceESMDA is input. It will split the field parameter in batches when necessary due to memory constraints. The function '_calc_max_number_of_layers_per_batch_for_distance_localization' calculates the max size of a batch of field parameter values within the limit of available memory. update pyproject.toml to include gaussianfft to be used in tests
69bf521 to
6b1d6e2
Compare
| ) | ||
|
|
||
|
|
||
| def calc_max_number_of_layers_per_batch_for_distance_localization( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe as an inspiration you can have a look at def _calculate_adaptive_batch_size ?
| X_prior_3D = X_prior.reshape(nx, ny, nz, nreal) | ||
| # No update if no observations or responses | ||
| if Y is None or Y.shape[0] == 0: | ||
| # No update of the field parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just return X_prior, yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can also remove the comments, but keep the one above. # No update if no observations or responses
| ) | ||
| ) # Use float64 | ||
| nlayer_per_batch = min(max_nlayers_per_batch, nz) | ||
| nbatch = int(nz / nlayer_per_batch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if nz==10 and nlayer_per_batch==7 then nbach = 1, is this correct?
| nlayer_per_batch = min(max_nlayers_per_batch, nz) | ||
| nbatch = int(nz / nlayer_per_batch) | ||
|
|
||
| log_msg = "Minimum number of batches required due to " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can log nbatch and nlayer_per_batch and make the message concise
| log_msg = ( | ||
| f"Batch number: {batch_number}\n" | ||
| f"start layer : {start_layer_number}\n" | ||
| f"end layer : {end_layer_number - 1}" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the logs.
|
|
||
|
|
||
| @memory_usage_decorator(enabled=False) | ||
| def update_3D_field_with_distance_esmda( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's double-check if iterative-ensemble-smoother would be a better place to host this code.
Function to update 3D field parameters with the method implemented in DistanceESMDA for ensemble smoother with
distance-based localization
Linked to: #12406
Approach
A 3D field parameter can often not be update in one go due to large memory requirements due to the Kalman gain matrix K and the localization matrix RHO. To handle this the field parameter can be split into subsets or batches. Each batch should be a set of layers of field parameter values defined in the field parameter grid (ertbox grid). Each batch must consists of a complete set of layers, not subset of layers of field parameters. The main reason for processing the update by batches of layers of field parameters is that the calculation of scaling factors (elements in the RHO matrix) can be done layer by layer due to the assumption that only lateral distance is of importance in the definition of influence of an observation, hence the calculation of RHO is done for one layer and then copied to all the other layers of the ertbox grid.