Author Topic: Calculate Airmass  (Read 276 times)

Offline CraigNZ

  • PixInsight Enthusiast
  • **
  • Posts: 94
    • View Profile
Calculate Airmass
« on: 2019 August 25 16:13:46 »
Is there a function or script that calculates the Airmass given an image.  I want to modify the aperture photometry script to calculate the airmass instead of using the value in the FITS header.  The reason is because the FITS header value is incorrect and I don't want to abandon the images.

Craig

Offline CraigNZ

  • PixInsight Enthusiast
  • **
  • Posts: 94
    • View Profile
Re: Calculate Airmass
« Reply #1 on: 2019 August 25 20:26:26 »
One way to do this would be to read the keyword 'OBJCTALT' and use that to calculate the airmass.  It is a string in the format of ## ## ##  so I would need to convert the string to decimal degrees, subtract from 90 degrees to get the zenith distance in degrees, convert this to radians and calculate 1/cos(za).

Offline CraigNZ

  • PixInsight Enthusiast
  • **
  • Posts: 94
    • View Profile
Re: Calculate Airmass
« Reply #2 on: 2019 August 25 21:21:40 »
This appears to work:

   this.GetWindowAirMass = function (window)
   {
       var keywords = window.keywords;
       for (var i = 0; i < keywords.length; i++)
       {
           var key = keywords;
           if (key && key.name == "OBJCTALT")
           {
               var value = key.value;
          var s2 = value.split("");
               var D = s2[1] + s2[2];
               var M = s2[4] + s2[5];
               var S = s2[7] + s2[8];
               var alt = +D/1.0 + M/60.0 + S/3600.0;
               var zd = 90.0 - alt;
               var am=1.0 / Math.cos(zd * Math.PI / 180.0);
              return am.toFixed(11);
           }
       }
      
       return "UNK";
   }