Add horizontal coordinates calculation to PCS_create

This commit is contained in:
eddyem 2020-06-01 17:11:27 +03:00
parent e0fbd955a6
commit b0bba12a9d
4 changed files with 28 additions and 6 deletions

View File

@ -201,11 +201,20 @@ static int parse_fits_file(char *name){
placeData *place = getPlace(); placeData *place = getPlace();
if(!place) return 1; if(!place) return 1;
if(get_LST(&mjd, adut.DUT1, place->slong, &ST)) 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; double ra_now = (Jnow.ra - Jnow.eo)/DD2R, dec_now = Jnow.dec/DD2R;
DBG("RA_now=%g, DEC_now=%g", ra_now, dec_now); 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; ra_scope = ST - ra_scope;
if(ra_scope < 0.) ra_scope += D2PI; if(ra_scope < 0.) ra_scope += D2PI;
ra_now = ST - ra_now; ra_now = ST - ra_now;
@ -254,8 +263,15 @@ static int parse_fits_file(char *name){
} }
static void printheader(){ 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 *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; const char *raunits, *decunits;
if(G->crdstrings){ if(G->crdstrings){
raunits = G->raindeg ? "dms" : "hms"; raunits = G->raindeg ? "dms" : "hms";
@ -267,9 +283,9 @@ static void printheader(){
const char *apparent = G->delta ? "(app-enc)" : "Apparent"; const char *apparent = G->delta ? "(app-enc)" : "Apparent";
char a[4][32]; char a[4][32];
snprintf(a[0], 32, "Encoder %s,%s", raha, raunits); 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[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]); printf("%-16s%-16s Pier %-18s%-19s", a[0], a[1], a[2], a[3]);
if(!G->ha){ if(!G->ha){
printf("Sid. time,"); printf("Sid. time,");
@ -293,10 +309,14 @@ int main(int argc, char **argv) {
if(G->pmm) G->pressure /= hpa2mm; if(G->pmm) G->pressure /= hpa2mm;
setWeath(G->pressure, G->temperature, 0.5); setWeath(G->pressure, G->temperature, 0.5);
if(G->for10m){ if(G->for10m){
G->horcoords = 0;
G->crdstrings = 1; G->crdstrings = 1;
G->raindeg = 0; G->raindeg = 0;
G->ha = 0; G->ha = 0;
G->stindegr = 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){ if(G->printhdr){
printheader(); printheader();

View File

@ -53,6 +53,7 @@ static myoption cmdlnopts[] = {
{"pressure",NEED_ARG, NULL, 'P', arg_double, APTR(&G.pressure), _("atmospheric pressure (hPa)")}, {"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")}, {"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")}, {"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 end_option
}; };

View File

@ -29,6 +29,7 @@ typedef struct{
int raindeg; // RA in degrees int raindeg; // RA in degrees
int crdstrings; // coordinates in string form int crdstrings; // coordinates in string form
int ha; // print HA instead of RA 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 stindegr; // sidereal time in degrees instead of hours
int delta; // show delta: apparent-encoder instead of apparent coordinates int delta; // show delta: apparent-encoder instead of apparent coordinates
double pressure; // atmospheric pressure (HPa or mmHg if pmm==1) double pressure; // atmospheric pressure (HPa or mmHg if pmm==1)

View File

@ -80,7 +80,7 @@ int get_MJDt(struct timeval *tval, sMJD *MJD);
int get_LST(sMJD *mjd, double dUT1, double slong, double *LST); int get_LST(sMJD *mjd, double dUT1, double slong, double *LST);
void hor2eq(horizCrds *h, polarCrds *pc, double sidTime); void hor2eq(horizCrds *h, polarCrds *pc, double sidTime);
void eq2horH(polarCrds *pc, horizCrds *h); 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); int get_ObsPlace(struct timeval *tval, polarCrds *p2000, polarCrds *pnow, horizCrds *hnow);
#endif // SOFA_H__ #endif // SOFA_H__