From 3df1baa3ccfdc2c74dbb12b97fd93f289b759176 Mon Sep 17 00:00:00 2001 From: Edward Emelianov Date: Thu, 6 Jul 2023 17:30:16 +0300 Subject: [PATCH] convert to ERFA instead of SOFA --- Auxiliary_utils/PCS_create/CMakeLists.txt | 10 +- Auxiliary_utils/PCS_create/PCS.c | 30 ++-- Auxiliary_utils/PCS_create/PCS_create.config | 5 +- .../PCS_create/PCS_create.creator.user | 82 ++++----- .../PCS_create/PCS_create.creator.user.22 | 139 ++++++++++++++ .../PCS_create.creator.user.7bd84e3.4.9-pre1 | 170 ++++++++++++++++++ Auxiliary_utils/PCS_create/cmdlnopts.c | 2 +- Auxiliary_utils/PCS_create/sofatools.c | 40 ++--- Auxiliary_utils/PCS_create/sofatools.h | 11 +- .../weatherdaemon.creator.user.7bd84e3 | 157 ++++++++++++++++ 10 files changed, 554 insertions(+), 92 deletions(-) create mode 100644 Auxiliary_utils/PCS_create/PCS_create.creator.user.22 create mode 100644 Auxiliary_utils/PCS_create/PCS_create.creator.user.7bd84e3.4.9-pre1 create mode 100644 Daemons/weatherdaemon_newmeteo/weatherdaemon.creator.user.7bd84e3 diff --git a/Auxiliary_utils/PCS_create/CMakeLists.txt b/Auxiliary_utils/PCS_create/CMakeLists.txt index 05c3d57..ac71c17 100644 --- a/Auxiliary_utils/PCS_create/CMakeLists.txt +++ b/Auxiliary_utils/PCS_create/CMakeLists.txt @@ -1,11 +1,11 @@ cmake_minimum_required(VERSION 3.0) set(PROJ PCS_create) -set(MINOR_VERSION "1") -set(MID_VERSION "0") +set(MINOR_VERSION "0") +set(MID_VERSION "1") set(MAJOR_VERSION "0") set(VERSION "${MAJOR_VERSION}.${MID_VERSION}.${MINOR_VERSION}") -project(${PROJ} VERSION ${PROJ_VERSION} LANGUAGES C) +project(${PROJ} VERSION ${VERSION} LANGUAGES C) #enable_language(C) message("VER: ${VERSION}") @@ -37,14 +37,14 @@ find_package(CFITSIO REQUIRED) ###### pkgconfig ###### # pkg-config modules (for pkg-check-modules) -set(MODULES usefull_macros) +set(MODULES usefull_macros erfa) # find packages: find_package(PkgConfig REQUIRED) pkg_check_modules(${PROJ} REQUIRED ${MODULES}) ###### additional flags ###### -list(APPEND ${PROJ}_LIBRARIES "-lsofa_c") +#list(APPEND ${PROJ}_LIBRARIES "-lerfa") # change wrong behaviour with install prefix if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND CMAKE_INSTALL_PREFIX MATCHES "/usr/local") diff --git a/Auxiliary_utils/PCS_create/PCS.c b/Auxiliary_utils/PCS_create/PCS.c index 23b1f12..e22d427 100644 --- a/Auxiliary_utils/PCS_create/PCS.c +++ b/Auxiliary_utils/PCS_create/PCS.c @@ -176,8 +176,14 @@ static int parse_fits_file(char *name){ if(iomode) return iomode; if(getDval(&ra_scope, fptr, "RA")) return 4; if(getDval(&dec_scope, fptr, "DEC")) return 5; - double uxt; - if(getDval(&uxt, fptr, "UNIXTIME")) return 55; + double uxt = -1.; + if(getDval(&uxt, fptr, "UNIXTIME")){ // no field "UNIXTIME" - search "JD" + if(getDval(&uxt, fptr, "JD")){ // no "JD" - search MJD + if(!getDval(&uxt, fptr, "MJD")) + uxt = (uxt - 40587.) * 86400.; // convert MJD to Unix time + }else uxt = (uxt - 2440587.5) * 86400.; // convert JD to Unix time + } + if(uxt < 0.) return 55; struct timeval tv; tv.tv_sec = (time_t) uxt; tv.tv_usec = 0; @@ -188,11 +194,11 @@ static int parse_fits_file(char *name){ fits_close_file(fptr, &status); chkstatus(); - polarCrds J2000 = {.ra = DD2R * ra_center, .dec = DD2R * dec_center}, Jnow; + polarCrds J2000 = {.ra = ERFA_DD2R * ra_center, .dec = ERFA_DD2R * dec_center}, Jnow; DBG("J2000=%g/%g", ra_center, dec_center); - DBG("J2000=%g/%g", J2000.ra/DD2R, J2000.dec/DD2R); + DBG("J2000=%g/%g", J2000.ra/ERFA_DD2R, J2000.dec/ERFA_DD2R); if(get_ObsPlace(&tv, &J2000, &Jnow, NULL)) return 1; - DBG("JNOW: RA=%g, DEC=%g, EO=%g", Jnow.ra/DD2R, Jnow.dec/DD2R, Jnow.eo/DD2R); + DBG("JNOW: RA=%g, DEC=%g, EO=%g", Jnow.ra/ERFA_DD2R, Jnow.dec/ERFA_DD2R, Jnow.eo/ERFA_DD2R); sMJD mjd; if(get_MJDt(&tv, &mjd)) return 1; double ST; @@ -202,23 +208,23 @@ static int parse_fits_file(char *name){ if(!place) return 1; if(get_LST(&mjd, adut.DUT1, place->slong, &ST)) return 1; - double ra_now = (Jnow.ra - Jnow.eo)/DD2R, dec_now = Jnow.dec/DD2R; + double ra_now = (Jnow.ra - Jnow.eo)/ERFA_DD2R, dec_now = Jnow.dec/ERFA_DD2R; DBG("RA_now=%g, DEC_now=%g", ra_now, dec_now); 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}; + polarCrds p_s = {.ra = ERFA_DD2R * ra_scope, .dec = ERFA_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; + ra_scope = h_s.az/ERFA_DD2R; dec_scope = h_s.zd/ERFA_DD2R; + ra_now = h_now.az/ERFA_DD2R; dec_now = h_now.zd/ERFA_DD2R; } - ST /= DD2R; // convert radians to degrees + ST /= ERFA_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; + if(ra_scope < 0.) ra_scope += ERFA_D2PI; ra_now = ST - ra_now; - if(ra_now < 0.) ra_now += D2PI; + if(ra_now < 0.) ra_now += ERFA_D2PI; } if(G->delta){ ra_now -= ra_scope; diff --git a/Auxiliary_utils/PCS_create/PCS_create.config b/Auxiliary_utils/PCS_create/PCS_create.config index e3e2368..0177030 100644 --- a/Auxiliary_utils/PCS_create/PCS_create.config +++ b/Auxiliary_utils/PCS_create/PCS_create.config @@ -1,3 +1,6 @@ // Add predefined macros for your project here. For example: // #define THE_ANSWER 42 -#define EBUG 1 +#define _POSIX_C_SOURCE 1234567 +#define _XOPEN_SOURCE 666 +#define EBUG +#define PACKAGE_VERSION "0.0.1" diff --git a/Auxiliary_utils/PCS_create/PCS_create.creator.user b/Auxiliary_utils/PCS_create/PCS_create.creator.user index 724641e..284e8f3 100644 --- a/Auxiliary_utils/PCS_create/PCS_create.creator.user +++ b/Auxiliary_utils/PCS_create/PCS_create.creator.user @@ -1,10 +1,10 @@ - + EnvironmentId - {7bd84e39-ca37-46d3-be9d-99ebea85bc0d} + {cf63021e-ef53-49b0-b03b-2f2570cdf3b6} ProjectExplorer.Project.ActiveTarget @@ -37,56 +37,63 @@ true true 1 - true + false + false false - 0 + 1 true true 0 8 true - 1 + false + 2 true - false + true true - false + *.md, *.MD, Makefile + true + true ProjectExplorer.Project.PluginSettings - - true + + true + true + Builtin.DefaultTidyAndClazy + 4 + + + + true + ProjectExplorer.Project.Target.0 + Desktop Desktop Desktop - {65a14f9e-e008-4c1b-89df-4eaa4774b6e3} + {91347f2c-5221-46a7-80b1-0a054ca02f79} 0 0 0 - /Big/Data/00__Small_tel/C-sources/PCS_create + /home/eddy/Docs/SAO/10micron/PCS/PCS_create all - false - - - false true - Сборка - GenericProjectManager.GenericMakeStep 1 Сборка - + Сборка ProjectExplorer.BuildSteps.Build @@ -94,24 +101,19 @@ clean - false - - - false true - Сборка - GenericProjectManager.GenericMakeStep 1 Очистка - + Очистка ProjectExplorer.BuildSteps.Clean 2 false + + false - По умолчанию По умолчанию GenericProjectManager.GenericBuildConfiguration @@ -119,38 +121,26 @@ 0 - Установка - + Развёртывание + Развёртывание ProjectExplorer.BuildSteps.Deploy 1 - Конфигурация установки - + + false ProjectExplorer.DefaultDeployConfiguration 1 - - false - false - 1000 - - true + 2 - - Особая программа - ProjectExplorer.CustomExecutableRunConfiguration - - 3768 + false true - false false true - - 1 @@ -161,10 +151,10 @@ ProjectExplorer.Project.Updater.FileVersion - 20 + 22 Version - 20 + 22 diff --git a/Auxiliary_utils/PCS_create/PCS_create.creator.user.22 b/Auxiliary_utils/PCS_create/PCS_create.creator.user.22 new file mode 100644 index 0000000..c174cdd --- /dev/null +++ b/Auxiliary_utils/PCS_create/PCS_create.creator.user.22 @@ -0,0 +1,139 @@ + + + + + + EnvironmentId + {7bd84e39-ca37-46d3-be9d-99ebea85bc0d} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + 0 + KOI8-R + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + false + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + {65a14f9e-e008-4c1b-89df-4eaa4774b6e3} + 0 + 0 + 0 + + /Big/Data/00__Small_tel/C-sources/PCS_create + + + + all + + false + + + false + true + GenericProjectManager.GenericMakeStep + + 1 + Сборка + Сборка + ProjectExplorer.BuildSteps.Build + + + + + clean + + true + + + false + true + GenericProjectManager.GenericMakeStep + + 1 + Очистка + Очистка + ProjectExplorer.BuildSteps.Clean + + 2 + false + + По умолчанию + GenericProjectManager.GenericBuildConfiguration + + 1 + + + 0 + Развёртывание + Развёртывание + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + 2 + + + ProjectExplorer.CustomExecutableRunConfiguration + + + false + + + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/Auxiliary_utils/PCS_create/PCS_create.creator.user.7bd84e3.4.9-pre1 b/Auxiliary_utils/PCS_create/PCS_create.creator.user.7bd84e3.4.9-pre1 new file mode 100644 index 0000000..048dd88 --- /dev/null +++ b/Auxiliary_utils/PCS_create/PCS_create.creator.user.7bd84e3.4.9-pre1 @@ -0,0 +1,170 @@ + + + + + + EnvironmentId + {7bd84e39-ca37-46d3-be9d-99ebea85bc0d} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + KOI8-R + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + false + true + false + + + + ProjectExplorer.Project.PluginSettings + + + true + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + {65a14f9e-e008-4c1b-89df-4eaa4774b6e3} + 0 + 0 + 0 + + /Big/Data/00__Small_tel/C-sources/PCS_create + + + + all + + false + + + false + true + Сборка + + GenericProjectManager.GenericMakeStep + + 1 + Сборка + + ProjectExplorer.BuildSteps.Build + + + + + clean + + false + + + false + true + Сборка + + GenericProjectManager.GenericMakeStep + + 1 + Очистка + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + По умолчанию + По умолчанию + GenericProjectManager.GenericBuildConfiguration + + 1 + + + 0 + Установка + + ProjectExplorer.BuildSteps.Deploy + + 1 + Конфигурация установки + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + 2 + + + Особая программа + + ProjectExplorer.CustomExecutableRunConfiguration + + 3768 + false + true + false + false + true + + + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 20 + + + Version + 20 + + diff --git a/Auxiliary_utils/PCS_create/cmdlnopts.c b/Auxiliary_utils/PCS_create/cmdlnopts.c index 4cb48c2..99bbdbe 100644 --- a/Auxiliary_utils/PCS_create/cmdlnopts.c +++ b/Auxiliary_utils/PCS_create/cmdlnopts.c @@ -67,7 +67,7 @@ static myoption cmdlnopts[] = { glob_pars *parse_args(int argc, char **argv){ void *ptr = memcpy(&G, &Gdefault, sizeof(G)); assert(ptr); // format of help: "Usage: progname [args]\n" - change_helpstring(_("Usage: %s [args] FITS_files\nMake PCS list for equatorial mount\n\tWhere args are:\n")); + change_helpstring(_("Version: " PACKAGE_VERSION "\nUsage: %s [args] FITS_files\nMake PCS list for equatorial mount\n\tWhere args are:\n")); // parse arguments parseargs(&argc, &argv, cmdlnopts); if(help) showhelp(-1, cmdlnopts); diff --git a/Auxiliary_utils/PCS_create/sofatools.c b/Auxiliary_utils/PCS_create/sofatools.c index 8d78c1c..59b38d6 100644 --- a/Auxiliary_utils/PCS_create/sofatools.c +++ b/Auxiliary_utils/PCS_create/sofatools.c @@ -1,6 +1,6 @@ /* - * This file is part of the sofa project. - * Copyright 2020 Edward V. Emelianov . + * This file is part of the PCS_create project. + * Copyright 2023 Edward V. Emelianov . * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,8 +52,8 @@ int getDUT(almDut *a){ char *radtodeg(double r){ static char buf[128]; int i[4]; char pm; - r = iauAnpm(r); - iauA2af(2, r, &pm, i); + r = eraAnpm(r); // normalize angle into range +/- pi + eraA2af(2, r, &pm, i); snprintf(buf, 128, "%c%02d %02d %02d.%02d", pm, i[0],i[1],i[2],i[3]); return buf; } @@ -61,8 +61,8 @@ char *radtodeg(double r){ char *radtohrs(double r){ static char buf[128]; int i[4]; char pm; - r = iauAnp(r); - iauA2tf(2, r, &pm, i); + r = eraAnp(r); // normalize angle into range 0 to 2pi + eraA2tf(2, r, &pm, i); snprintf(buf, 128, "%02d:%02d:%02d.%02d", i[0],i[1],i[2],i[3]); return buf; } @@ -92,15 +92,15 @@ int get_MJDt(struct timeval *tval, sMJD *MJD){ d = tms.tm_mday; double utc1, utc2; /* 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; MJD->MJD = utc1 - 2400000.5 + utc2; MJD->utc1 = utc1; MJD->utc2 = 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"); - 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"); return 0; } @@ -115,17 +115,17 @@ int get_MJDt(struct timeval *tval, sMJD *MJD){ */ int get_LST(sMJD *mjd, double dUT1, double slong, double *LST){ double ut11, ut12; - if(iauUtcut1(mjd->utc1, mjd->utc2, dUT1, &ut11, &ut12)) return 1; + if(eraUtcut1(mjd->utc1, mjd->utc2, dUT1, &ut11, &ut12)) return 1; /*double era = iauEra00(ut11, ut12) + slong; double eo = iauEe06a(mjd->tt1, mjd->tt2); printf("ERA = %s; ", radtohrs(era)); printf("ERA-eo = %s\n", radtohrs(era-eo));*/ if(!LST) return 0; - double ST = iauGst06a(ut11, ut12, mjd->tt1, mjd->tt2); + double ST = eraGst06a(ut11, ut12, mjd->tt1, mjd->tt2); ST += slong; - if(ST > D2PI) ST -= D2PI; - else if(ST < -D2PI) ST += D2PI; - *LST = ST; + //if(ST > ERFA_D2PI) ST -= ERFA_D2PI; + //else if(ST < 0.) ST += ERFA_D2PI; + *LST = eraAnp(ST); // 0..2pi return 0; } @@ -138,7 +138,7 @@ int get_LST(sMJD *mjd, double dUT1, double slong, double *LST){ void hor2eq(horizCrds *h, polarCrds *pc, double sidTime){ if(!h || !pc) return; 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->eo = 0.; } @@ -153,8 +153,8 @@ void eq2horH(polarCrds *pc, horizCrds *h){ if(!h || !pc) return; placeData *p = getPlace(); double alt; - iauHd2ae(pc->ha, pc->dec, p->slat, &h->az, &alt); - h->zd = DPI/2. - alt; + eraHd2ae(pc->ha, pc->dec, p->slat, &h->az, &alt); + h->zd = ERFA_DPI/2. - alt; } /** @@ -168,8 +168,8 @@ void eq2hor(polarCrds *pc, horizCrds *h, double sidTime){ double ha = sidTime - pc->ra + pc->eo; placeData *p = getPlace(); double alt; - iauHd2ae(ha, pc->dec, p->slat, &h->az, &alt); - h->zd = DPI/2. - alt; + eraHd2ae(ha, pc->dec, p->slat, &h->az, &alt); + h->zd = ERFA_DPI/2. - alt; } /** @@ -198,7 +198,7 @@ int get_ObsPlace(struct timeval *tval, polarCrds *p2000, polarCrds *pnow, horizC double wl = 0.55; /* ICRS to observed. */ double aob, zob, hob, dob, rob, eo; - if(iauAtco13(p2000->ra, p2000->dec, + if(eraAtco13(p2000->ra, p2000->dec, pr, pd, px, rv, MJD.utc1, MJD.utc2, d.DUT1, diff --git a/Auxiliary_utils/PCS_create/sofatools.h b/Auxiliary_utils/PCS_create/sofatools.h index 8459bb2..589c052 100644 --- a/Auxiliary_utils/PCS_create/sofatools.h +++ b/Auxiliary_utils/PCS_create/sofatools.h @@ -1,6 +1,6 @@ /* - * This file is part of the sofa project. - * Copyright 2020 Edward V. Emelianov . + * This file is part of the PCS_create project. + * Copyright 2023 Edward V. Emelianov . * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,11 +17,9 @@ */ #pragma once -#ifndef SOFA_H__ -#define SOFA_H__ -#include -#include +#include +#include #include #include #include @@ -83,4 +81,3 @@ void eq2horH(polarCrds *pc, horizCrds *h); void eq2hor(polarCrds *pc, horizCrds *h, double sidTime); int get_ObsPlace(struct timeval *tval, polarCrds *p2000, polarCrds *pnow, horizCrds *hnow); -#endif // SOFA_H__ diff --git a/Daemons/weatherdaemon_newmeteo/weatherdaemon.creator.user.7bd84e3 b/Daemons/weatherdaemon_newmeteo/weatherdaemon.creator.user.7bd84e3 new file mode 100644 index 0000000..e4de2e7 --- /dev/null +++ b/Daemons/weatherdaemon_newmeteo/weatherdaemon.creator.user.7bd84e3 @@ -0,0 +1,157 @@ + + + + + + EnvironmentId + {7bd84e39-ca37-46d3-be9d-99ebea85bc0d} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + KOI8-R + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + false + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + {65a14f9e-e008-4c1b-89df-4eaa4774b6e3} + 0 + 0 + 0 + + /Big/Data/00__Small_tel/C-sources/netdaemon + + + + all + + false + + + false + true + GenericProjectManager.GenericMakeStep + + 1 + Сборка + Сборка + ProjectExplorer.BuildSteps.Build + + + + + clean + + false + + + false + true + GenericProjectManager.GenericMakeStep + + 1 + Очистка + Очистка + ProjectExplorer.BuildSteps.Clean + + 2 + false + + По умолчанию + GenericProjectManager.GenericBuildConfiguration + + 1 + + + 0 + Развёртывание + Развёртывание + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + 2 + + + ProjectExplorer.CustomExecutableRunConfiguration + + + false + + false + true + false + false + true + + + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + +