aboutsummaryrefslogtreecommitdiff
path: root/src/fes/cf_limbang.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-03-04 21:21:30 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-03-04 21:21:30 -0500
commitd54fe7c1f704a63824c5bfa0ece65245572e9b27 (patch)
treeafc52015ffc2c74e0266653eecef1c8ef8ba5d91 /src/fes/cf_limbang.c
downloadcalfuse-d54fe7c1f704a63824c5bfa0ece65245572e9b27.tar.gz
Initial commit
Diffstat (limited to 'src/fes/cf_limbang.c')
-rw-r--r--src/fes/cf_limbang.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/fes/cf_limbang.c b/src/fes/cf_limbang.c
new file mode 100644
index 0000000..8bd230f
--- /dev/null
+++ b/src/fes/cf_limbang.c
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ * Johns Hopkins University
+ * Center For Astrophysical Sciences
+ * FUSE
+ *****************************************************************************
+ *
+ * Synopsis: cf_limbang_calc(fitsfile *outfits, double mjd)
+ * cf_min_limbang(fitsfile *outfits,
+ * double mjd_start, double mjd_end)
+ * Description: cf_limbang_calc - Calculates the limb angle at a given mjd
+ * cf_min_limbang - determines the minimum limb angle between
+ * the start and end times. The limb angle is
+ * calculated every 8.6 seconds( .0001 MJD)
+ *
+ * Arguments: fitsfile *outfits Pointer to FITS file containing the
+ * input data and orbital elements
+ * double mjd The limb angle calculation is done for
+ * this time. The time is given as
+ * a Modified Julian Date.
+ * double mjd_start The range of times for which the minimum
+ * double mjd_end limb angle should be determined.
+ * Both are given as Modified Julian Dates.
+ *
+ * History: 08/09/99 mlr copied cf_velang.c to start
+ * 08/09/99 mlr removed excess calls then made the
+ * limb_ang calls - same as cf_check_point
+ *
+ ****************************************************************************/
+
+#include <stdio.h>
+#include "calfuse.h"
+#include "sgp4.h"
+static char CF_PRGM_ID[] = "cf_limbang";
+
+SGP4 set_orbit_parms(fitsfile *);
+
+double cf_limbang_calc(fitsfile *outfits, double mjd)
+{
+ int status=0, isday_dummy;
+ char comment[FLEN_CARD];
+ double ra, dec, pos[3], vel[3];
+ double lim_ang, zdist_dummy;
+ SGP4 sgp4;
+
+ sgp4 = set_orbit_parms(outfits);
+
+ /* get the state vector at time mjd */
+ SGP4_getStateVector(sgp4, mjd, pos, vel);
+ SGP4_precess(pos, mjd, MJD2000); SGP4_precess(vel, mjd, MJD2000);
+
+ FITS_read_key(outfits, TDOUBLE, "RA_TARG", &ra, comment, &status);
+ FITS_read_key(outfits, TDOUBLE, "DEC_TARG", &dec, comment, &status);
+
+ lim_ang = state_limb(pos, mjd, ra, dec, &zdist_dummy, &isday_dummy);
+
+ return(lim_ang);
+}
+
+void cf_min_limbang(fitsfile *outfits, double mjd_start, double mjd_end)
+{
+
+ int status = 0;
+ double lim_ang, min_lim;
+ double mjd;
+
+ mjd = mjd_start;
+ min_lim = cf_limbang_calc(outfits, mjd);
+
+#ifdef DEBUG
+ printf("mjd: %lf mjd_end = %lf minlim = %lf\n", mjd, mjd_end, min_lim);
+#endif
+ /* .0001 = 8.6 seconds */
+ while ( (mjd_end - mjd) > .0001 )
+ {
+ mjd = mjd + .0001;
+ lim_ang = cf_limbang_calc(outfits, mjd);
+#ifdef DEBUG
+ printf("mjd: %lf mjd_end = %lf minlim = %lf, limang = %lf\n",
+ mjd, mjd_end, min_lim, lim_ang);
+#endif
+ if (lim_ang < min_lim) min_lim = lim_ang;
+ }
+
+ mjd = mjd_end;
+ lim_ang = cf_limbang_calc(outfits, mjd);
+
+#ifdef DEBUG
+ printf("mjd: %lf mjd_end = %lf minlim = %lf, limang = %lf\n",
+ mjd, mjd_end, min_lim, lim_ang);
+#endif
+
+ if (lim_ang < min_lim) min_lim = lim_ang;
+
+#ifdef DEBUG
+ printf("mjd: %lf mjd_end = %lf minlim = %lf\n", mjd, mjd_end, min_lim);
+#endif
+
+ FITS_update_key(outfits, TDOUBLE, "MIN_LIMB", &min_lim, NULL, &status);
+
+}