Skip to content

Invalid AIRMASS in fit header #1345

@ivenzor

Description

@ivenzor

There was a recent discussion regarding AIRMASS values in FITS headers. A header had an AIRMASS value of -1, which was read by EXOTIC without checks.

We could add basic checks in the air_mass function for both AIRMASS and TELALT. Something like this:

    if 'AIRMASS' in hdr:
        am = float(hdr['AIRMASS'])
        if am < 1.0:
            log_info(f"Invalid AIRMASS value {hdr['AIRMASS']} in header. EXOTIC will calculate a new AIRMASS value.")
        else:
            return am
    elif 'TELALT' in hdr:
        alt = float(hdr['TELALT'])
        if 0 <= alt <= 90:
            cos_am = np.cos((np.pi / 180) * (90.0 - alt))
            return 1 / cos_am
        log_info(f"Invalid TELALT value {hdr['TELALT']} in header. EXOTIC will not use this value to calculate AIRMASS.")

    # If we get here, we either:
    # - Have no AIRMASS/TELALT in header
    # - Have invalid AIRMASS (< 1.0)
    # - Have invalid TELALT (< 0 or > 90)
    pointing = SkyCoord(f"{ra} {dec}", unit=(u.deg, u.deg), frame='icrs')
    location = EarthLocation.from_geodetic(lat=lat * u.deg, lon=long * u.deg, height=elevation)
    time = Time(time, format='jd', scale='utc', location=location)
    point_altaz = pointing.transform_to(AltAz(obstime=time, location=location))
    return float(point_altaz.secz)

@tamimfatahi, let me know if this makes sense to you; if it does, I can work on a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions