File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -707,10 +707,11 @@ def interpolate_map_flux_to_helio_frame(
707707 )
708708
709709 # Statistical uncertainty propagation (Equation 75):
710- # δJ = J * sqrt((δJ_left/J_left)^2 * (1 + unc_factor^2) + (δJ_right/J_right)^2)
710+ # δJ = J * sqrt((δJ_left/J_left)^2 * (1 + unc_factor^2)
711+ # + unc_factor^2 * (δJ_right/J_right)^2)
711712 stat_unc_sc = flux_sc * np .sqrt (
712713 (stat_unc_left / flux_left ) ** 2 * (1.0 + unc_factor ** 2 )
713- + (stat_unc_right / flux_right ) ** 2
714+ + unc_factor ** 2 * (stat_unc_right / flux_right ) ** 2
714715 )
715716
716717 # Systematic uncertainty propagation (Equation 76):
Original file line number Diff line number Diff line change @@ -379,8 +379,9 @@ def combine_calibration_products(
379379 combined_flux = weighted_flux_sum / flux_weights .sum (dim = "calibration_prod" )
380380
381381 map_ds ["ena_intensity" ] = combined_flux
382+ # Statistical uncertainty
382383 map_ds ["ena_intensity_stat_uncert" ] = np .sqrt (
383- ( map_ds ["ena_intensity_stat_uncert" ] ** 2 ).sum (dim = "calibration_prod" )
384+ 1 / ( 1 / ( map_ds ["ena_intensity_stat_uncert" ] ** 2 ) ).sum (dim = "calibration_prod" )
384385 )
385386 # For systematic error, just do quadrature sum over the systematic error for
386387 # each calibration product.
Original file line number Diff line number Diff line change @@ -712,6 +712,10 @@ def test_power_law_interpolation_accuracy(self):
712712 expected_flux_middle = (
713713 (e_sc ** power_law_slope ) * (e_helio / e_sc ) * spatial_factor
714714 )
715+ unc_factor = np .log (e_sc / 500 ) / np .log (1000 / 500 )
716+ expected_stat_uncert = expected_flux_middle * np .sqrt (
717+ 0.1 ** 2 * (1 + unc_factor ** 2 ) + unc_factor ** 2 * 0.1 ** 2
718+ )
715719
716720 # Compare interpolated result to expected value
717721 # (should be very close for a perfect power-law)
@@ -721,6 +725,13 @@ def test_power_law_interpolation_accuracy(self):
721725 rtol = 1e-10 ,
722726 )
723727
728+ # Check expected stat. unc.
729+ np .testing .assert_allclose (
730+ result_ds ["ena_intensity_stat_uncert" ].values [1 , 0 ],
731+ expected_stat_uncert ,
732+ rtol = 1e-10 ,
733+ )
734+
724735 # The flux should be finite and positive
725736 assert np .all (np .isfinite (result_ds ["ena_intensity" ].values ))
726737 assert np .all (result_ds ["ena_intensity" ].values > 0 )
Original file line number Diff line number Diff line change @@ -632,9 +632,8 @@ def test_statistical_uncertainty_combination_correctness():
632632 result_ds = combine_calibration_products (test_ds , geom_factors , esa_energies )
633633
634634 # Manual calculation of expected statistical uncertainty combination
635- # stat_weights = 1/σ² = [1/151, 1/151]
636- # combined_stat_unc = sqrt(1/sum(stat_weights)) = sqrt(2/151) = sqrt(20) ≈ 4.47
637- expected_combined_stat_unc = np .sqrt (np .sum (stat_unc_values ** 2 ))
635+ # combined_stat_unc = sqrt(1/sum(1 / stat_unc**2))
636+ expected_combined_stat_unc = np .sqrt (1 / np .sum (1 / stat_unc_values ** 2 ))
638637 flux_weights = 1.0 / (np .array ([101 , 101 ]) + np .array ([4 , 16 ]))
639638 expected_flux = np .sum (flux_values .squeeze () * flux_weights ) / np .sum (flux_weights )
640639
You can’t perform that action at this time.
0 commit comments