mirror of
https://github.com/eddyem/small_tel.git
synced 2025-12-06 10:45:16 +03:00
port from libsofa to liberfa
This commit is contained in:
parent
f38e6a1e06
commit
f07d63c970
@ -1,5 +1,5 @@
|
|||||||
PROGRAM = stellariumdaemon
|
PROGRAM = stellariumdaemon
|
||||||
LDFLAGS = -lsofa_c -pthread
|
LDFLAGS = -lerfa -pthread
|
||||||
SRCS = $(wildcard *.c)
|
SRCS = $(wildcard *.c)
|
||||||
CC = gcc
|
CC = gcc
|
||||||
DEFINES = -D_GNU_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=1111
|
DEFINES = -D_GNU_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=1111
|
||||||
|
|||||||
@ -1 +1,6 @@
|
|||||||
Stellarium control of 10-micron mount
|
Stellarium control of 10-micron mount
|
||||||
|
|
||||||
|
|
||||||
|
Special commands in terminal mode:
|
||||||
|
PAUSE - pause output to port from everywhere except terminal thread
|
||||||
|
CONTINUE - allow to write to port for everyone
|
||||||
|
|||||||
@ -27,18 +27,18 @@ void reprd(char* s, double ra, double dc){
|
|||||||
char pm;
|
char pm;
|
||||||
int i[4];
|
int i[4];
|
||||||
printf ( "%s:", s );
|
printf ( "%s:", s );
|
||||||
iauA2tf ( 7, ra, &pm, i );
|
eraA2tf ( 7, ra, &pm, i );
|
||||||
printf ( " %2.2d %2.2d %2.2d.%7.7d", i[0],i[1],i[2],i[3] );
|
printf ( " %2.2d %2.2d %2.2d.%7.7d", i[0],i[1],i[2],i[3] );
|
||||||
iauA2af ( 6, dc, &pm, i );
|
eraA2af ( 6, dc, &pm, i );
|
||||||
printf ( " %c%2.2d %2.2d %2.2d.%6.6d\n", pm, i[0],i[1],i[2],i[3] );
|
printf ( " %c%2.2d %2.2d %2.2d.%6.6d\n", pm, i[0],i[1],i[2],i[3] );
|
||||||
}
|
}
|
||||||
void radtodeg(double r){
|
void radtodeg(double r){
|
||||||
int i[4]; char pm;
|
int i[4]; char pm;
|
||||||
int rem = (int)(r / D2PI);
|
int rem = (int)(r / ERFA_D2PI);
|
||||||
if(rem) r -= D2PI * rem;
|
if(rem) r -= ERFA_D2PI * rem;
|
||||||
if(r > DPI) r -= D2PI;
|
if(r > ERFA_DPI) r -= ERFA_D2PI;
|
||||||
else if(r < -DPI) r += D2PI;
|
else if(r < -ERFA_DPI) r += ERFA_D2PI;
|
||||||
iauA2af (2, r, &pm, i);
|
eraA2af (2, r, &pm, i);
|
||||||
printf("%c%02d %02d %02d.%2.d", pm, i[0],i[1],i[2],i[3]);
|
printf("%c%02d %02d %02d.%2.d", pm, i[0],i[1],i[2],i[3]);
|
||||||
}
|
}
|
||||||
#define REP(a,b,c) reprd(a,b,c)
|
#define REP(a,b,c) reprd(a,b,c)
|
||||||
@ -98,7 +98,7 @@ almDut *getDUT(){
|
|||||||
void r2sHMS(double radians, char *hms, int len){
|
void r2sHMS(double radians, char *hms, int len){
|
||||||
char pm;
|
char pm;
|
||||||
int i[4];
|
int i[4];
|
||||||
iauA2tf(2, radians, &pm, i);
|
eraA2tf(2, radians, &pm, i);
|
||||||
snprintf(hms, len, "'%c%02d:%02d:%02d.%02d'", pm, i[0],i[1],i[2],i[3]);
|
snprintf(hms, len, "'%c%02d:%02d:%02d.%02d'", pm, i[0],i[1],i[2],i[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ void r2sHMS(double radians, char *hms, int len){
|
|||||||
void r2sDMS(double radians, char *dms, int len){
|
void r2sDMS(double radians, char *dms, int len){
|
||||||
char pm;
|
char pm;
|
||||||
int i[4];
|
int i[4];
|
||||||
iauA2af(1, radians, &pm, i);
|
eraA2af(1, radians, &pm, i);
|
||||||
snprintf(dms, len, "'%c%02d:%02d:%02d.%d'", pm, i[0],i[1],i[2],i[3]);
|
snprintf(dms, len, "'%c%02d:%02d:%02d.%d'", pm, i[0],i[1],i[2],i[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,15 +140,15 @@ int get_MJDt(struct timeval *tval, sMJD *MJD){
|
|||||||
d = tms.tm_mday;
|
d = tms.tm_mday;
|
||||||
double utc1, utc2;
|
double utc1, utc2;
|
||||||
/* UTC date. */
|
/* UTC date. */
|
||||||
if(iauDtf2d("UTC", y, m, d, tms.tm_hour, tms.tm_min, tSeconds, &utc1, &utc2) < 0) return -1;
|
if(eraDtf2d("UTC", y, m, d, tms.tm_hour, tms.tm_min, tSeconds, &utc1, &utc2) < 0) return -1;
|
||||||
if(!MJD) return 0;
|
if(!MJD) return 0;
|
||||||
MJD->MJD = utc1 - 2400000.5 + utc2;
|
MJD->MJD = utc1 - 2400000.5 + utc2;
|
||||||
MJD->utc1 = utc1;
|
MJD->utc1 = utc1;
|
||||||
MJD->utc2 = utc2;
|
MJD->utc2 = utc2;
|
||||||
//DBG("UTC(m): %g, %.8f\n", utc1 - 2400000.5, utc2);
|
//DBG("UTC(m): %g, %.8f\n", utc1 - 2400000.5, utc2);
|
||||||
if(iauUtctai(utc1, utc2, &MJD->tai1, &MJD->tai2)) return -1;
|
if(eraUtctai(utc1, utc2, &MJD->tai1, &MJD->tai2)) return -1;
|
||||||
//DBG("TAI");
|
//DBG("TAI");
|
||||||
if(iauTaitt(MJD->tai1, MJD->tai2, &MJD->tt1, &MJD->tt2)) return -1;
|
if(eraTaitt(MJD->tai1, MJD->tai2, &MJD->tt1, &MJD->tt2)) return -1;
|
||||||
//DBG("TT");
|
//DBG("TT");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -167,16 +167,16 @@ int get_LST(sMJD *mjd, double dUT1, double slong, double *LST){
|
|||||||
if(!mjd){
|
if(!mjd){
|
||||||
if(get_MJDt(NULL, &Mjd)) return 1;
|
if(get_MJDt(NULL, &Mjd)) return 1;
|
||||||
}else memcpy(&Mjd, mjd, sizeof(sMJD));
|
}else memcpy(&Mjd, mjd, sizeof(sMJD));
|
||||||
if(iauUtcut1(Mjd.utc1, Mjd.utc2, dUT1, &ut11, &ut12)) return 2;
|
if(eraUtcut1(Mjd.utc1, Mjd.utc2, dUT1, &ut11, &ut12)) return 2;
|
||||||
/*double era = iauEra00(ut11, ut12) + slong;
|
/*double era = iauEra00(ut11, ut12) + slong;
|
||||||
double eo = iauEe06a(mjd->tt1, mjd->tt2);
|
double eo = iauEe06a(mjd->tt1, mjd->tt2);
|
||||||
printf("ERA = %s; ", radtohrs(era));
|
printf("ERA = %s; ", radtohrs(era));
|
||||||
printf("ERA-eo = %s\n", radtohrs(era-eo));*/
|
printf("ERA-eo = %s\n", radtohrs(era-eo));*/
|
||||||
if(!LST) return 0;
|
if(!LST) return 0;
|
||||||
double ST = iauGst06a(ut11, ut12, Mjd.tt1, Mjd.tt2);
|
double ST = eraGst06a(ut11, ut12, Mjd.tt1, Mjd.tt2);
|
||||||
ST += slong;
|
ST += slong;
|
||||||
if(ST > D2PI) ST -= D2PI;
|
if(ST > ERFA_D2PI) ST -= ERFA_D2PI;
|
||||||
else if(ST < 0.) ST += D2PI;
|
else if(ST < 0.) ST += ERFA_D2PI;
|
||||||
*LST = ST;
|
*LST = ST;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ 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){
|
||||||
if(!h || !pc) return;
|
if(!h || !pc) return;
|
||||||
placeData *p = getPlace();
|
placeData *p = getPlace();
|
||||||
iauAe2hd(h->az, DPI/2. - h->zd, p->slat, &pc->ha, &pc->dec); // A,H -> HA,DEC; phi - site latitude
|
eraAe2hd(h->az, ERFA_DPI/2. - h->zd, p->slat, &pc->ha, &pc->dec); // A,H -> HA,DEC; phi - site latitude
|
||||||
pc->ra = sidTime - pc->ha;
|
pc->ra = sidTime - pc->ha;
|
||||||
pc->eo = 0.;
|
pc->eo = 0.;
|
||||||
}
|
}
|
||||||
@ -206,8 +206,8 @@ void eq2horH(polarCrds *pc, horizCrds *h){
|
|||||||
if(!h || !pc) return;
|
if(!h || !pc) return;
|
||||||
placeData *p = getPlace();
|
placeData *p = getPlace();
|
||||||
double alt;
|
double alt;
|
||||||
iauHd2ae(pc->ha, pc->dec, p->slat, &h->az, &alt);
|
eraHd2ae(pc->ha, pc->dec, p->slat, &h->az, &alt);
|
||||||
h->zd = DPI/2. - alt;
|
h->zd = ERFA_DPI/2. - alt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,8 +221,8 @@ void eq2hor(polarCrds *pc, horizCrds *h, double sidTime){
|
|||||||
double ha = sidTime - pc->ra + pc->eo;
|
double ha = sidTime - pc->ra + pc->eo;
|
||||||
placeData *p = getPlace();
|
placeData *p = getPlace();
|
||||||
double alt;
|
double alt;
|
||||||
iauHd2ae(ha, pc->dec, p->slat, &h->az, &alt);
|
eraHd2ae(ha, pc->dec, p->slat, &h->az, &alt);
|
||||||
h->zd = DPI/2. - alt;
|
h->zd = ERFA_DPI/2. - alt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ int get_ObsPlace(struct timeval *tval, polarCrds *p2000, localWeather *weath, po
|
|||||||
p2000->ra, p2000->dec, pr, pd, px, rv, MJD.utc1, MJD.utc2, d.DUT1, p.slong, p.slat, p.salt,
|
p2000->ra, p2000->dec, pr, pd, px, rv, MJD.utc1, MJD.utc2, d.DUT1, p.slong, p.slat, p.salt,
|
||||||
d.px, d.py, p, t, h, wl);
|
d.px, d.py, p, t, h, wl);
|
||||||
*/
|
*/
|
||||||
if(iauAtco13(p2000->ra, p2000->dec,
|
if(eraAtco13(p2000->ra, p2000->dec,
|
||||||
pr, pd, px, rv,
|
pr, pd, px, rv,
|
||||||
MJD.utc1, MJD.utc2,
|
MJD.utc1, MJD.utc2,
|
||||||
dut1.DUT1,
|
dut1.DUT1,
|
||||||
@ -280,7 +280,7 @@ int get_ObsPlace(struct timeval *tval, polarCrds *p2000, localWeather *weath, po
|
|||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
printf("A(bta)/Z: ");
|
printf("A(bta)/Z: ");
|
||||||
radtodeg(aob);
|
radtodeg(aob);
|
||||||
printf("("); radtodeg(DPI-aob);
|
printf("("); radtodeg(ERFA_DPI-aob);
|
||||||
printf(")/"); radtodeg(zob);
|
printf(")/"); radtodeg(zob);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -19,8 +19,8 @@
|
|||||||
#ifndef LIBSOFA_H__
|
#ifndef LIBSOFA_H__
|
||||||
#define LIBSOFA_H__
|
#define LIBSOFA_H__
|
||||||
|
|
||||||
#include <sofa.h>
|
#include <erfa.h>
|
||||||
#include <sofam.h>
|
#include <erfam.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
// JD2451544.5 == 2000.0
|
// JD2451544.5 == 2000.0
|
||||||
|
|||||||
@ -230,7 +230,7 @@ int proc_data(uint8_t *data, ssize_t len){
|
|||||||
horizCrds hnow; // without refraction
|
horizCrds hnow; // without refraction
|
||||||
polarCrds p2000, pnow;
|
polarCrds p2000, pnow;
|
||||||
p2000.ra = tagRA/12. * M_PI;
|
p2000.ra = tagRA/12. * M_PI;
|
||||||
p2000.dec = tagDec * DD2R;
|
p2000.dec = tagDec * ERFA_DD2R;
|
||||||
// now J2000 obs Jnow
|
// now J2000 obs Jnow
|
||||||
if(get_ObsPlace(NULL, &p2000, NULL, &pnow, &hnow)){
|
if(get_ObsPlace(NULL, &p2000, NULL, &pnow, &hnow)){
|
||||||
WARNX("Can't convert coordinates to Jnow");
|
WARNX("Can't convert coordinates to Jnow");
|
||||||
@ -238,22 +238,22 @@ int proc_data(uint8_t *data, ssize_t len){
|
|||||||
}
|
}
|
||||||
#ifdef EBUG
|
#ifdef EBUG
|
||||||
int i[4], j[4]; char pm, pm1;
|
int i[4], j[4]; char pm, pm1;
|
||||||
iauA2af(2, hnow.az, &pm, i);
|
eraA2af(2, hnow.az, &pm, i);
|
||||||
iauA2af(2, hnow.zd, &pm1, j);
|
eraA2af(2, hnow.zd, &pm1, j);
|
||||||
DBG("az: %c%02d %02d %02d.%2.d, zd: %c%02d %02d %02d.%2.d",
|
DBG("az: %c%02d %02d %02d.%2.d, zd: %c%02d %02d %02d.%2.d",
|
||||||
pm, i[0],i[1],i[2],i[3],
|
pm, i[0],i[1],i[2],i[3],
|
||||||
pm1,j[0],j[1],j[2],j[3]);
|
pm1,j[0],j[1],j[2],j[3]);
|
||||||
iauA2af(2, M_PI_2 - hnow.zd, &pm, i);
|
eraA2af(2, M_PI_2 - hnow.zd, &pm, i);
|
||||||
DBG("h: %c%02d %02d %02d.%2.d", pm, i[0],i[1],i[2],i[3]);
|
DBG("h: %c%02d %02d %02d.%2.d", pm, i[0],i[1],i[2],i[3]);
|
||||||
#endif
|
#endif
|
||||||
if(hnow.zd > 80.*DD2R){
|
if(hnow.zd > 80.*ERFA_DD2R){
|
||||||
WARNX("Z > 80degr, stop telescope");
|
WARNX("Z > 80degr, stop telescope");
|
||||||
putlog("Z>80 - stop!");
|
putlog("Z>80 - stop!");
|
||||||
stop_telescope();
|
stop_telescope();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
tagRA = (pnow.ra - pnow.eo) / M_PI * 12.;
|
tagRA = (pnow.ra - pnow.eo) / M_PI * 12.;
|
||||||
tagDec = pnow.dec / DD2R;
|
tagDec = pnow.dec / ERFA_DD2R;
|
||||||
if(!setCoords(tagRA, tagDec)) return 0;
|
if(!setCoords(tagRA, tagDec)) return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -499,7 +499,7 @@ void wrhdr(){
|
|||||||
DBG("Failed");
|
DBG("Failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LST *= 15.*DD2R; // convert hours to radians
|
LST *= 15.*ERFA_DD2R; // convert hours to radians
|
||||||
}else{
|
}else{
|
||||||
lst = MALLOC(char, 32);
|
lst = MALLOC(char, 32);
|
||||||
r2sHMS(LST, lst, 32);
|
r2sHMS(LST, lst, 32);
|
||||||
@ -512,7 +512,7 @@ void wrhdr(){
|
|||||||
jd = MALLOC(char, 32);
|
jd = MALLOC(char, 32);
|
||||||
snprintf(jd, 32, "%.10f", mjd.MJD);
|
snprintf(jd, 32, "%.10f", mjd.MJD);
|
||||||
}
|
}
|
||||||
polarCrds pNow = {.ra = r*15.*DD2R, .dec = d*DD2R}; // coordinates now
|
polarCrds pNow = {.ra = r*15.*ERFA_DD2R, .dec = d*ERFA_DD2R}; // coordinates now
|
||||||
horizCrds hNow;
|
horizCrds hNow;
|
||||||
eq2hor(&pNow, &hNow, LST);
|
eq2hor(&pNow, &hNow, LST);
|
||||||
failcounter = 0;
|
failcounter = 0;
|
||||||
@ -569,9 +569,9 @@ void wrhdr(){
|
|||||||
WRHDR("RA", val, "Telescope right ascension, current epoch, deg");
|
WRHDR("RA", val, "Telescope right ascension, current epoch, deg");
|
||||||
snprintf(val, 22, "%.10f", d);
|
snprintf(val, 22, "%.10f", d);
|
||||||
WRHDR("DEC", val, "Telescope declination, current epoch, deg");
|
WRHDR("DEC", val, "Telescope declination, current epoch, deg");
|
||||||
snprintf(val, 22, "%.10f", hNow.az * DR2D);
|
snprintf(val, 22, "%.10f", hNow.az * ERFA_DR2D);
|
||||||
WRHDR("AZ", val, "Telescope azimuth, current epoch, deg");
|
WRHDR("AZ", val, "Telescope azimuth, current epoch, deg");
|
||||||
snprintf(val, 22, "%.10f", hNow.zd * DR2D);
|
snprintf(val, 22, "%.10f", hNow.zd * ERFA_DR2D);
|
||||||
WRHDR("ZD", val, "Telescope zenith distance, current epoch, deg");
|
WRHDR("ZD", val, "Telescope zenith distance, current epoch, deg");
|
||||||
WRHDR("TELSTAT", strstatus(mountstatus), "Telescope mount status");
|
WRHDR("TELSTAT", strstatus(mountstatus), "Telescope mount status");
|
||||||
if(!get_MJDt(NULL, &mjd)){
|
if(!get_MJDt(NULL, &mjd)){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user