30 #include <giastroutils.h>
42 static const cxdouble TINY = 1.e-12;
44 static const cxdouble RV_DPI =
45 3.1415926535897932384626433832795028841971693993751;
47 static const cxdouble DEG_TO_RAD =
48 0.017453292519943295769236907684886127134428718885417;
50 static const cxdouble SEC_TO_DEG = 15. / 3600.;
75 inline static cxdouble
76 _giraffe_compute_zdistance(cxdouble hourangle, cxdouble delta,
80 cxdouble p0 = sin(latitude) * sin(delta);
81 cxdouble p1 = cos(latitude) * cos(delta);
82 cxdouble z = p0 + cos(hourangle) * p1;
85 z = z < 0. ? -TINY : TINY;
109 inline static cxdouble
110 _giraffe_compute_airmass_young_irvine(cxdouble secz)
113 return secz * (1. - 0.0012 * (pow(secz, 2.) - 1.));
133 inline static cxdouble
134 _giraffe_compute_airmass_young(cxdouble secz)
137 cxdouble z = 1. / secz;
141 x = 1.002432 * z * z + 0.148386 * z + 0.0096467;
142 y = z * z * z + 0.149864 * z * z + 0.0102963 * z + 0.000303978;
178 cxdouble exptime, cxdouble latitude)
181 const cxchar*
const fctid =
"giraffe_compute_airmass";
186 const cxdouble weights[] = {1. / 6., 2. / 3., 1. / 6.};
194 const cxdouble airmass_upper_limit = 10.;
198 cxdouble hourangle = 0.;
199 cxdouble airmass = 0.;
206 hourangle = lst * SEC_TO_DEG - alpha;
214 if (hourangle < -180.) {
218 if (hourangle > 180.) {
228 latitude *= DEG_TO_RAD;
229 hourangle *= DEG_TO_RAD;
240 z = _giraffe_compute_zdistance(hourangle, delta, latitude);
242 if (fabs(z) < TINY) {
243 cpl_msg_debug(fctid,
"Airmass computation failed. Object is "
244 "below the horizon.");
248 airmass = _giraffe_compute_airmass_young(z);
252 const cxint nweights = CX_N_ELEMENTS(weights);
256 cxdouble timestep = exptime / (nweights - 1) * SEC_TO_DEG *
260 airmass *= weights[0];
262 for (i = 1; i < nweights; i++) {
264 z = _giraffe_compute_zdistance(hourangle + i * timestep,
267 if (fabs(z) < TINY) {
269 cpl_msg_debug(fctid,
"Airmass computation failed. Object "
270 "is below the horizon.");
275 airmass += weights[i] * _giraffe_compute_airmass_young(z);
282 if (airmass > airmass_upper_limit) {
283 cpl_msg_debug(fctid,
"Airmass larger than %f", airmass_upper_limit);
cxdouble giraffe_compute_airmass(cxdouble alpha, cxdouble delta, cxdouble lst, cxdouble exptime, cxdouble latitude)
Compute the airmass for a given pointing direction and observing site.