From e1a30a719fb55ba7b47f2beaefa5442faafc99fa Mon Sep 17 00:00:00 2001 From: Jonathan Slavin Date: Wed, 4 Sep 2024 14:37:19 -0400 Subject: [PATCH] Use metadata in remove lightleak (#288) * Fix paths to spectral model files in temperature response The path to the model for hybrid abundances and photospheric abundances were switched. * Fix atol in test_temperature_response_coronal.py Made atol scaled to temperature response to provide a more stringent test. * Fix atol in test_temperature_response_hybrid.py Made atol scaled to temperature response to provide a more stringent test. * Fix atol in test_temperature_response_photospheric.py Made atol scaled to temperature response to provide a more stringent test. * Fix atol in test_temperature_response.py Made atol scaled to temperature response to provide a more stringent test. * Fix atol, rtol values in test_temperature_response.py Use atol and rtol values that should lead to passing all tests. * Fix atol, rtol values in test_temperature_response_coronal.py Use atol, rtol values that should lead to passing all tests. * Fix atol, rtol values in test_temperature_response_hybrid.py Use atol, rtol values that should lead to passing all tests. * Fix atol, rtol values in test_temperature_response_photospheric.py Use atol, rtol values that should lead to passing all tests. * Another fix to test_temperature_response_hybrid.py needed to scale atol to max value of temperature response * Another fix to test_temperature_response_coronal.py need to scale atol to the max value of temperature response * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Created new directory, image_correction, and moved xrt_remove_lightleak and xrt_deconvolve to that directory. Also moved associated tests and data * small changes to image_correction/__init__.py * Changed from print statements to logger in temperature_from_filter_ratio. Also added fits keywords HGLN_OBS and HGLT_OBS to returned map metadata. * Update remove_lightleak.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- xrtpy/image_correction/remove_lightleak.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xrtpy/image_correction/remove_lightleak.py b/xrtpy/image_correction/remove_lightleak.py index f03f8ed2..eeb13a5f 100644 --- a/xrtpy/image_correction/remove_lightleak.py +++ b/xrtpy/image_correction/remove_lightleak.py @@ -98,22 +98,22 @@ def _get_stray_light_phase(date_obs): def _select_lightleak_file(filter_wheel_1, filter_wheel_2, date): phase = _get_stray_light_phase(date) file_dict = { - ("open", "al mesh"): { + ("open", "al_mesh"): { 2: "term_p2am_20150718_160913.fits", 3: "term_p3am_20170808_180126.fits", 4: "term_p4am_20180712_171919.fits", 5: "term_p5am_20220709_180901.fits", }, - ("al poly", "open"): { + ("al_poly", "open"): { 2: "term_p2ap_20150620_172818.fits", 3: "term_p3ap_20170809_183821.fits", 4: "term_p4ap_20180712_171928.fits", 5: "term_p5ap_20220709_180910.fits", }, - ("c poly", "open"): { + ("c_poly", "open"): { 2: "term_p2cp_20150620_190645.fits", }, - ("open", "ti poly"): { + ("open", "ti_poly"): { 1: "term_p1tp_20140515_182503.fits", 2: "term_p2tp_20150718_160921.fits", }, @@ -206,9 +206,9 @@ def remove_lightleak(in_map, scale=1.0, leak_map=None): warnings.warn("HISTORY indicates light leak subtraction already done on image.") # noqa: B028 if leak_map is None: - leak_filename = _select_lightleak_file( - *in_map.measurement.split("-"), in_map.date - ) + fw1 = in_map.meta["EC_FW1_"] + fw2 = in_map.meta["EC_FW2_"] + leak_filename = _select_lightleak_file(fw1, fw2, in_map.date) # NOTE: This function is being defined inline because the filename is only known once # the date and filter wheel combination are known.