Skip to content

Commit 53a6cd0

Browse files
authored
2374 lo l2 integrate cg correction for hf maps - prepare for lo integration (#2381)
* Add method to HiLoBasePointingSet for calculating the ram pixel mask * Update CG correction code to call update_ram_mask method * Move ram_mask calculation to corrections.py module * self review updates * Convert CG correction functions to take xarray.Dataset as input and output * Update Hi L2 to only use HiPointintSet class for map projection purposes * PR feedback * Try to fix test failing in github by correctly handling NaNs in float -> int64 conversion * Try again to fix github tests * Fix bug that was causing test failures Improve test so that bug would be caught locally
1 parent d73d824 commit 53a6cd0

5 files changed

Lines changed: 212 additions & 223 deletions

File tree

imap_processing/ena_maps/ena_maps.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from abc import ABC, abstractmethod
88
from enum import Enum
99
from pathlib import Path
10-
from typing import TypeVar
10+
from typing import ClassVar, TypeVar
1111

1212
import astropy_healpix.healpy as hp
1313
import numpy as np
@@ -653,24 +653,26 @@ class HiPointingSet(LoHiBasePointingSet):
653653
Hi L1C pointing set data loaded in a xarray.DataArray.
654654
"""
655655

656+
# class variable that stores the mapping of variables that need to be
657+
# renamed to match L2 variables
658+
l1c_to_l2_var_mapping: ClassVar[dict[str, str]] = {
659+
"exposure_times": "exposure_factor",
660+
"background_rates": "bg_rates",
661+
"background_rates_uncertainty": "bg_rates_unc",
662+
}
663+
656664
def __init__(self, dataset: xr.Dataset | str | Path):
657665
super().__init__(dataset, spice_reference_frame=geometry.SpiceFrame.IMAP_HAE)
658666

659667
self.spatial_coords = ("spin_angle_bin",)
660668

661-
# Rename some PSET vars to match L2 variables
662-
self.data = self.data.rename(
663-
{
664-
"exposure_times": "exposure_factor",
665-
"background_rates": "bg_rates",
666-
"background_rates_uncertainty": "bg_rates_unc",
667-
}
668-
)
669-
670-
# Add obs_date variable to be used in determining a map mean obs_date
671-
self.data["obs_date"] = xr.full_like(
672-
self.data["exposure_factor"], self.data["epoch"].values[0]
673-
)
669+
# Rename some PSET vars to match L2 variables (if necessary)
670+
rename_dict = {
671+
key: value
672+
for key, value in self.l1c_to_l2_var_mapping.items()
673+
if key in self.data
674+
}
675+
self.data = self.data.rename(rename_dict)
674676

675677
# Update az_el_points using the base class method
676678
self.update_az_el_points()

0 commit comments

Comments
 (0)