From b0bba12a9d210b426d331164ecd515a5870a2c0d Mon Sep 17 00:00:00 2001 From: eddyem Date: Mon, 1 Jun 2020 17:11:27 +0300 Subject: [PATCH] Add horizontal coordinates calculation to PCS_create --- Auxiliary_utils/PCS_create/PCS.c | 30 +++++++++++++++++++++----- Auxiliary_utils/PCS_create/cmdlnopts.c | 1 + Auxiliary_utils/PCS_create/cmdlnopts.h | 1 + Auxiliary_utils/PCS_create/sofatools.h | 2 +- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Auxiliary_utils/PCS_create/PCS.c b/Auxiliary_utils/PCS_create/PCS.c index 6f06c7c..23b1f12 100644 --- a/Auxiliary_utils/PCS_create/PCS.c +++ b/Auxiliary_utils/PCS_create/PCS.c @@ -201,11 +201,20 @@ static int parse_fits_file(char *name){ placeData *place = getPlace(); if(!place) return 1; if(get_LST(&mjd, adut.DUT1, place->slong, &ST)) return 1; - ST /= DD2R; // convert radians to degrees double ra_now = (Jnow.ra - Jnow.eo)/DD2R, dec_now = Jnow.dec/DD2R; DBG("RA_now=%g, DEC_now=%g", ra_now, dec_now); - if(G->ha){ // print HA instead of RA + + if(G->horcoords){ // horizontal coordinates: change ra->AZ, dec->ZD + horizCrds h_s, h_now; + polarCrds p_s = {.ra = DD2R * ra_scope, .dec = DD2R * dec_scope}; + eq2hor(&p_s, &h_s, ST); + eq2hor(&Jnow, &h_now, ST); + ra_scope = h_s.az/DD2R; dec_scope = h_s.zd/DD2R; + ra_now = h_now.az/DD2R; dec_now = h_now.zd/DD2R; + } + ST /= DD2R; // convert radians to degrees + if(G->ha && !G->horcoords){ // print HA instead of RA ra_scope = ST - ra_scope; if(ra_scope < 0.) ra_scope += D2PI; ra_now = ST - ra_now; @@ -254,8 +263,15 @@ static int parse_fits_file(char *name){ } static void printheader(){ - printf("# Pointing data @ p=%.f %s, T=%.1f degrC\n", G->pressure*(G->pmm ? hpa2mm : 1.), G->pmm ? "mmHg" : "hPa", G->temperature); + printf("# Pointing data @ p=%.f %s, T=%.1f degrC", G->pressure*(G->pmm ? hpa2mm : 1.), G->pmm ? "mmHg" : "hPa", G->temperature); const char *raha = G->ha ? "HA" : "RA"; + const char *deczd = "DEC"; + if(G->horcoords){ + raha = "AZ"; + deczd = " ZD"; + printf(", AZ from north clockwise"); + } + printf("\n"); const char *raunits, *decunits; if(G->crdstrings){ raunits = G->raindeg ? "dms" : "hms"; @@ -267,9 +283,9 @@ static void printheader(){ const char *apparent = G->delta ? "(app-enc)" : "Apparent"; char a[4][32]; snprintf(a[0], 32, "Encoder %s,%s", raha, raunits); - snprintf(a[1], 32, "Encoder DEC,%s", decunits); + snprintf(a[1], 32, "Encoder %s,%s", deczd, decunits); snprintf(a[2], 32, "%s %s,%s", apparent, raha, raunits); - snprintf(a[3], 32, "%s DEC,%s", apparent, decunits); + snprintf(a[3], 32, "%s %s,%s", apparent, deczd, decunits); printf("%-16s%-16s Pier %-18s%-19s", a[0], a[1], a[2], a[3]); if(!G->ha){ printf("Sid. time,"); @@ -293,10 +309,14 @@ int main(int argc, char **argv) { if(G->pmm) G->pressure /= hpa2mm; setWeath(G->pressure, G->temperature, 0.5); if(G->for10m){ + G->horcoords = 0; G->crdstrings = 1; G->raindeg = 0; G->ha = 0; G->stindegr = 0; + }else if(G->horcoords){ + G->ha = 1; // omit Hour Angle output + G->raindeg = 1; // both coordinates are in degrees } if(G->printhdr){ printheader(); diff --git a/Auxiliary_utils/PCS_create/cmdlnopts.c b/Auxiliary_utils/PCS_create/cmdlnopts.c index d26b6fd..4cb48c2 100644 --- a/Auxiliary_utils/PCS_create/cmdlnopts.c +++ b/Auxiliary_utils/PCS_create/cmdlnopts.c @@ -53,6 +53,7 @@ static myoption cmdlnopts[] = { {"pressure",NEED_ARG, NULL, 'P', arg_double, APTR(&G.pressure), _("atmospheric pressure (hPa)")}, {"pinmm", NO_ARGS, NULL, 'm', arg_int, APTR(&G.pmm), _("pressure in mmHg instead of hPa")}, {"temperature",NEED_ARG,NULL, 'T', arg_double, APTR(&G.temperature),_("temperature, degrC")}, + {"horcoords",NO_ARGS, NULL, 'A', arg_int, APTR(&G.horcoords), _("show horizontal coordinates instead of equatorial")}, end_option }; diff --git a/Auxiliary_utils/PCS_create/cmdlnopts.h b/Auxiliary_utils/PCS_create/cmdlnopts.h index 97f52ed..76532e1 100644 --- a/Auxiliary_utils/PCS_create/cmdlnopts.h +++ b/Auxiliary_utils/PCS_create/cmdlnopts.h @@ -29,6 +29,7 @@ typedef struct{ int raindeg; // RA in degrees int crdstrings; // coordinates in string form int ha; // print HA instead of RA + int horcoords; // show horizontal coordinates instead of equatorial int stindegr; // sidereal time in degrees instead of hours int delta; // show delta: apparent-encoder instead of apparent coordinates double pressure; // atmospheric pressure (HPa or mmHg if pmm==1) diff --git a/Auxiliary_utils/PCS_create/sofatools.h b/Auxiliary_utils/PCS_create/sofatools.h index 210f2d1..8459bb2 100644 --- a/Auxiliary_utils/PCS_create/sofatools.h +++ b/Auxiliary_utils/PCS_create/sofatools.h @@ -80,7 +80,7 @@ int get_MJDt(struct timeval *tval, sMJD *MJD); int get_LST(sMJD *mjd, double dUT1, double slong, double *LST); void hor2eq(horizCrds *h, polarCrds *pc, double sidTime); void eq2horH(polarCrds *pc, horizCrds *h); -void eq2hor(polarCrds *pc, horizCrds *h, double sidTime);; +void eq2hor(polarCrds *pc, horizCrds *h, double sidTime); int get_ObsPlace(struct timeval *tval, polarCrds *p2000, polarCrds *pnow, horizCrds *hnow); #endif // SOFA_H__