Skip to content

BUG - GLOWS L2 Photon flux calculation needs per-bin zero handling #2370

@maxinelasp

Description

@maxinelasp

Description

The photon flux calculation currently checks if the exposure_times array has non-zero length, but should handle per-bin zero exposure times to avoid division by zero or invalid flux values for individual bins.

Location

imap_processing/glows/l2/glows_l2_data.py:80-83

Current Implementation

# TODO: Only where exposure counts != 0
if len(self.exposure_times) != 0:
    self.photon_flux = self.raw_histograms / self.exposure_times
    self.flux_uncertainties = raw_uncertainties / self.exposure_times

This checks the array length, but doesn't handle individual bins where exposure_times[i] == 0.

Required Changes

Implement element-wise division that handles zero exposure times gracefully:

# Initialize with zeros or fill values
self.photon_flux = np.zeros(len(self.raw_histograms))
self.flux_uncertainties = np.zeros(len(self.raw_histograms))

# Only calculate where exposure_times > 0
mask = self.exposure_times > 0
self.photon_flux[mask] = self.raw_histograms[mask] / self.exposure_times[mask]
self.flux_uncertainties[mask] = raw_uncertainties[mask] / self.exposure_times[mask]

Alternatively, use np.divide with appropriate handling for divide-by-zero.

Metadata

Metadata

Assignees

No one assigned

    Labels

    HelperIns: GLOWSRelated to the GLOWS instrumentLevel: L2Level 2 processingbugSomething isn't working

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions