Skip to content

Add livetime correction to get_data #188

@samaloney

Description

@samaloney

Add livetime correction option to get_data via keyword default to true.

Essentially extract, and modify/generalise this part and add to get data

trigger_to_detector = STIX_INSTRUMENT.subcol_adc_mapping
# Map the triggers to all 32 detectors
triggers = pixel_data.data["triggers"][:, trigger_to_detector].astype(float)[...]
_, livefrac, _ = get_livetime_fraction(triggers / pixel_data.data["timedel"].to("s").reshape(-1, 1))
pixel_data.data["livefrac"] = livefrac
e_cor_high, e_cor_low = get_elut_correction(e_ind, pixel_data)
# Get counts and other data.
idx_pix = _PIXEL_SLICES.get(pixels.lower(), None)
if idx_pix is None:
raise ValueError(f"Unrecognised input for 'pixels': {pixels}. Supported values: {list(_PIXEL_SLICES.keys())}")
counts = pixel_data.data["counts"].astype(float)
count_errors = np.sqrt(pixel_data.data["counts_comp_err"].astype(float).value ** 2 + counts.value) * u.ct
ct = counts[t_ind][..., idx_pix, e_ind]
ct[..., 0] = ct[..., 0] * e_cor_low[..., idx_pix]
ct[..., -1] = ct[..., -1] * e_cor_high[..., idx_pix]
ct_error = count_errors[t_ind][..., idx_pix, e_ind]
ct_error[..., 0] = ct_error[..., 0] * e_cor_low[..., idx_pix]
ct_error[..., -1] = ct_error[..., -1] * e_cor_high[..., idx_pix]
lt = (livefrac * pixel_data.data["timedel"].reshape(-1, 1).to("s"))[t_ind].sum(axis=0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions