-
Notifications
You must be signed in to change notification settings - Fork 145
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
Distribution fixes #788
base: main
Are you sure you want to change the base?
Distribution fixes #788
Conversation
Functions inv_beta_cdf_params and beta_cdf_params now include an error check to make sure that the lower and upper bounds in the distribution_params_type have been set to 0 and 1 as other values are not supported. HK note it might be better to remove this and have pure functions with no side effects. Subroutine set_beta_params_from_ens has changed the distribution_params_type to an intent out argument and defines all six parameters correctly. It also set the parameter type to BETA_DISTRIBUTION. fixes #717
…mma distributions. jla commit message: A comment now makes it clear that this module only supports the standard gamma distribution that is bounded below by 0 and unbounded above. Subroutines gamma_cdf, inverse_gamma_cdf, set_gamma_params_from_ens, and inv_gamma_first_guess no longer have bounded_below, bounded_above, lower_bound, and upper_bound as arguments. inv_gamma_cdf now sets the bounded_below, bounded_above, lower_bound and upper_bound parameters to the correct values for the gamma. Functions inv_gamma_cdf_params and gamma_cdf_params now include an error check to make sure that the lower and upper bounds in the distribution_params_type have been set to 0 and missing_r8 as other values are not supported. Subroutine set_gamma_params_from_ens has changed the distribution_params_type to an intent out argument and defines all six parameters correctly. It also sets the parameter type to GAMMA_DISTRIBUTION.
jla commit message: Functions inv_std_normal_cdf and set_normal_params_from_ens now set the appropriate values for the bounded_below, bounded_above, lower_bound and upper_bound components of the distribution_params_type. The distribution_params_type was changed to intent out in set_normal_params_from_ens. The magic number definition of the maximum delta in the inv_cdf root searching routine was changed to be a parameter but the value of 1e-8 was unchanged. A comment notes that changing this parameter to 1e-9 allows all of Ian Groom’s KDE distribution tests to pass. HK note, assuming this is if you use inv_cdf from normal_distribution_mod rather than rootfinding mode with KDE. fixes #787
Only occurances on task 0 were printing #787 (comment)
assimilation_code/modules/assimilation/normal_distribution_mod.f90
Outdated
Show resolved
Hide resolved
! The comment above is not consistent with the performance of these routines | ||
! as validated by test_normal. There is no evidence that this is still | ||
! required. |
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 am not following this comment.
"'digits12' is reserved for real variables that MUST retain 64 bits of precision", when dart is built with r8=r4
Are you running test_normal with r8=r4? Should the distribution tests all be run with r8=r4
DART/assimilation_code/modules/utilities/types_mod.f90
Lines 80 to 98 in bddda57
! real precision: | |
! TO RUN WITH REDUCED PRECISION REALS (and use correspondingly less memory) | |
! comment OUT the r8 definition below and use the second one: | |
integer, parameter :: r4 = SELECTED_REAL_KIND(6,30) | |
integer, parameter :: r8 = SELECTED_REAL_KIND(12) ! 8 byte reals | |
!integer, parameter :: r8 = r4 ! alias r8 to r4 | |
! complex precision: | |
integer, parameter :: c4 = SELECTED_REAL_KIND(6,30) | |
integer, parameter :: c8 = SELECTED_REAL_KIND(12) | |
! 'digits12' is reserved for real variables that MUST retain 64 bits of | |
! precision. DO NOT CHANGE '12' to a smaller number. BAD BAD BAD things happen. | |
! This is a small subset of the variables. Changing this will ruin the ability | |
! to distinguish timesteps that are a few seconds apart, for instance. | |
integer, parameter :: digits12 = SELECTED_REAL_KIND(12) |
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.
[hkershaw:work](distribution-fixes) > ./test_normal_dist
--------------------------------------
Starting ... at YYYY MM DD HH MM SS =
2025 1 6 10 43 42
--------------------------------------
set_nml_output Echo NML values to log file only
Absolute value of differences should be less than 1e-15
Matlab Comparison Tests: PASS 0.00000000
FAIL: Max inversion diff 17.0500488 > bound 1.00000001E-10 for quantiles < 0.899999976
FAIL: Max inversion diff 17.0500488 > bound 1.00000001E-10 for quantiles < 0.990000010
FAIL: Max inversion diff 17.0500488 > bound 1.00000001E-10 for quantiles < 0.999000013
FAIL: Max inversion diff 17.0500488 > bound 1.00000001E-10 for quantiles < 0.999899983
FAIL: Max inversion diff 17.0500488 > bound 1.00000001E-10 for quantiles < 0.999989986
FAIL: Max inversion diff 17.0500488 > bound 9.99999972E-10 for quantiles < 0.999998987
FAIL: Max inversion diff 17.0500488 > bound 9.99999994E-09 for quantiles < 0.999999881
FAIL: Max inversion diff 17.0500488 > bound 1.00000001E-07 for quantiles < 1.00000000
FAIL: Max inversion diff 17.0500488 > bound 1.00000001E-07 for quantiles < 1.00000000
FAIL: Max inversion diff 17.0500488 > bound 9.99999997E-07 for quantiles < 1.00000000
FAIL: Max inversion diff 17.0500488 > bound 9.99999975E-06 for quantiles < 1.00000000
FAIL: Max inversion diff 17.0500488 > bound 9.99999975E-05 for quantiles < 1.00000000
FAIL: Max inversion diff 17.0500488 > bound 1.00000005E-03 for quantiles < 1.00000000
FAIL: Max inversion diff 17.0500488 > bound 9.99999978E-03 for quantiles < 1.00000000
FAIL: Max inversion diff 17.0500488 > bound 0.100000001 for quantiles < 1.00000000
FAIL: Max inversion diff 17.0500488 > bound 1.00000000 for quantiles < 1.00000000
--------------------------------------
Finished ... at YYYY MM DD HH MM SS =
2025 1 6 10 43 43
--------------------------------------
[hkershaw:work](distribution-fixes) > git diff
diff --git a/assimilation_code/modules/utilities/types_mod.f90 b/assimilation_code/modules/utilities/types_mod.f90
index 8e4b376ee..ecf791cf7 100644
--- a/assimilation_code/modules/utilities/types_mod.f90
+++ b/assimilation_code/modules/utilities/types_mod.f90
@@ -81,8 +81,8 @@ integer, parameter :: i8 = SELECTED_INT_KIND(13)
! TO RUN WITH REDUCED PRECISION REALS (and use correspondingly less memory)
! comment OUT the r8 definition below and use the second one:
integer, parameter :: r4 = SELECTED_REAL_KIND(6,30)
-integer, parameter :: r8 = SELECTED_REAL_KIND(12) ! 8 byte reals
-!integer, parameter :: r8 = r4 ! alias r8 to r4
+!integer, parameter :: r8 = SELECTED_REAL_KIND(12) ! 8 byte reals
+integer, parameter :: r8 = r4 ! alias r8 to r4
qceff table bounds are ignored for these
397a971
to
538d238
Compare
1a9dc77
to
e0fb360
Compare
Description:
Fixes for distributions that have been hanging out on https://github.com/NCAR/DART/tree/beta_distribution_fix
Forcing the gamma and beta qceff options (bounds) in qceff table to be:
test in developer_tests/qceff/test_force_bounds
I can split this into 3 pull requests if that is easier to review.
Fixes issue
fixes #717 only supporting standard beta
fixes #786 only supporting standard gamma - note see issue, still have upper and lower bound
fixes #787 see notes - initialize distribution_param_type to UNSET?
There was an E_MSG about failing to converge, switched this to E_ALLMSG since the failure could be on any task.
I think the documentation for the qceff available distributions probably needs updating to clarify that the GAMMA & BETA bounds are fixed (QCEFF table values are ignored) Edit: went ahead and changed the documentation.
DART/guide/qceff_probit.rst
Lines 126 to 135 in bddda57
Maybe this is sufficient, I dunno:
Types of changes
Documentation changes needed?
Tests
Please describe any tests you ran to verify your changes.
developer_tests/*_dist
developer_tests/qceff/test_force_bounds
Checklist for merging
Checklist for release
Testing Datasets