Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid AIRMASS in fit header #1345

Open
ivenzor opened this issue Nov 8, 2024 · 4 comments
Open

Invalid AIRMASS in fit header #1345

ivenzor opened this issue Nov 8, 2024 · 4 comments

Comments

@ivenzor
Copy link
Contributor

ivenzor commented Nov 8, 2024

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.

@rzellem
Copy link
Owner

rzellem commented Nov 8, 2024

I could see two different options:

  1. If EXOTIC encounters any invalid airmass value, it recalculates airmass for all FITS files.
  2. If EXOTIC encounters any invalid airmass value, it recalculates airmass for just the one FITS files.

@ivenzor
Copy link
Contributor Author

ivenzor commented Nov 8, 2024

The least intrusive approach would be option 2, as it’s currently implemented this way:

airMassList.append(air_mass(image_header, pDict['ra'], pDict['dec'], exotic_infoDict['lat'], exotic_infoDict['long'],
                            exotic_infoDict['elev'], jd_times[i]))

Currently, we calculate airmass for every frame. If we update the air_mass function, no further modifications are needed.

That said, if there’s a bad header, the new airmass calculation in EXOTIC may not match the airmass values in the other headers, potentially creating an 'out-of-distribution' value. In this case, we could argue that recalculating the airmass for all FITS files might be a better approach to ensure consistency across all airmass measurements. This assumes we consider our calculation more accurate than the values in the headers (except for the ones with clearly incorrect values).

@ivenzor
Copy link
Contributor Author

ivenzor commented Nov 13, 2024

@rzellem which way would you prefer?

@rzellem
Copy link
Owner

rzellem commented Nov 25, 2024

@ivenzor - what do you prefer? :)

another way to think about it - how often do we get a bad airmass error? I've only seen it once to date - for that one user, were all of their airmass values bad or just a few? if all, then we'd need to be safe and recalculate for all images, if only a few, then we only need to recalculate for the few that have "bad" ones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants