summaryrefslogtreecommitdiff
path: root/widgets/astro.cpp
diff options
context:
space:
mode:
authorhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
committerhibby <d@vehibberd.com>2026-10-06 21:24:40 +0100
commitc25cbdf6fb6d946175f4335fab77bfea601b56db (patch)
tree6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /widgets/astro.cpp
parent71f5689252c9f13e70e1c24856904475b2307809 (diff)
parent0685fcada9f95fe90f70b387cd7d757da8209624 (diff)
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to 'widgets/astro.cpp')
-rw-r--r--widgets/astro.cpp82
1 files changed, 72 insertions, 10 deletions
diff --git a/widgets/astro.cpp b/widgets/astro.cpp
index c96eee6e..dcdbac44 100644
--- a/widgets/astro.cpp
+++ b/widgets/astro.cpp
@@ -1,7 +1,5 @@
#include "astro.h"
-#include <stdio.h>
-
#include <QApplication>
#include <QFile>
#include <QTextStream>
@@ -13,8 +11,6 @@
#include <QDebug>
#include <math.h>
-#include "commons.h"
-#include "MessageBox.hpp"
#include "Configuration.hpp"
#include "SettingsGroup.hpp"
#include "qt_helpers.hpp"
@@ -32,7 +28,15 @@ extern "C" {
int * ndop, int * ndop00, double * ramoon, double * decmoon, double * dgrd,
double * poloffset, double * xnr, bool extraazel, double * techo, double * width1,
double * width2, bool bTx, const char * AzElFileName,
- const char * jpleph);
+ const char * jpleph, int * ephemeris_result);
+}
+
+namespace
+{
+ constexpr int ephemeris_jpl = 0;
+ constexpr int ephemeris_analytic_fallback = 1;
+ constexpr int ephemeris_invalid_input = 2;
+ constexpr int ephemeris_unavailable = 3;
}
Astro::Astro(QSettings * settings, Configuration const * configuration, QWidget * parent)
@@ -110,7 +114,7 @@ auto Astro::astroUpdate(QDateTime const& t, QString const& mygrid, QString const
Frequency freq_moon {freq};
double azsun,elsun,azmoon,elmoon,azmoondx,elmoondx;
double ramoon,decmoon,dgrd,poloffset,xnr,techo,width1,width2;
- int ntsky;
+ int ntsky, ephemeris_result;
QString date {t.date().toString("yyyy MMM dd").trimmed ()};
QString utc {t.time().toString().trimmed ()};
int nyear {t.date().year()};
@@ -125,15 +129,56 @@ auto Astro::astroUpdate(QDateTime const& t, QString const& mygrid, QString const
auto const& jpleph = configuration_->data_dir ().absoluteFilePath ("JPLEPH");
SettingsGroup g (settings_, "Configuration");
bool extraazel=settings_->value("AzElExtraLines",false).toBool();
+
+ // changed argument from &dgrd to &m_dgrd added for Bob KA1GT
astrosub(nyear, month, nday, uth, static_cast<double> (freq_moon),
mygrid.toLatin1 ().data (),
hisgrid.toLatin1().data(),
&azsun, &elsun, &azmoon, &elmoon,
&azmoondx, &elmoondx, &ntsky, &m_dop, &m_dop00, &ramoon, &decmoon,
- &dgrd, &poloffset, &xnr, extraazel, &techo, &width1, &width2,
+ &m_dgrd, &poloffset, &xnr, extraazel, &techo, &width1, &width2,
bTx,
AzElFileName.toLocal8Bit ().constData (),
- jpleph.toLocal8Bit ().constData ());
+ jpleph.toLocal8Bit ().constData (), &ephemeris_result);
+
+ auto report_ephemeris_transition = [this] (int result)
+ {
+ if (result == m_ephemeris_result)
+ {
+ return;
+ }
+ if (result == ephemeris_analytic_fallback)
+ {
+ qWarning () << "JPL ephemeris unavailable; using analytic fallback";
+ }
+ else if (result == ephemeris_invalid_input)
+ {
+ qWarning () << "Invalid astronomical date or time";
+ }
+ else if (result == ephemeris_unavailable)
+ {
+ qWarning () << "No valid lunar ephemeris result";
+ }
+ else if (result == ephemeris_jpl && m_ephemeris_result >= 0)
+ {
+ qInfo () << "JPL ephemeris available again";
+ }
+ m_ephemeris_result = result;
+ };
+
+ report_ephemeris_transition (ephemeris_result);
+ if (ephemeris_result == ephemeris_invalid_input)
+ {
+ ui_->text_label->setText (" " + date + "\nUTC: " + utc
+ + "\nEphem: Invalid input");
+ return {};
+ }
+ if (ephemeris_result == ephemeris_unavailable)
+ {
+ ui_->text_label->setText (" " + date + "\nUTC: " + utc
+ + "\nEphem: Unavailable");
+ return {};
+ }
QString message;
{
@@ -162,12 +207,16 @@ auto Astro::astroUpdate(QDateTime const& t, QString const& mygrid, QString const
"SunAz: " << azsun << "\n"
"SunEl: " << elsun << "\n"
"Freq: " << freq / 1.e6 << "\n";
+ if (ephemeris_result == ephemeris_analytic_fallback)
+ {
+ out << "Ephem: Analytic fallback\n";
+ }
if(freq>=5000000ull) { //Suppress data not relevant below VHF
out << "Tsky: " << ntsky << "\n"
"Dpol: " << poloffset << "\n"
"MNR: " << xnr << "\n"
"Dist: " << int((techo*149896)) << "\n" //wdg
- "Dgrd: " << dgrd;
+ "Dgrd: " << m_dgrd; //changed dgrd to m_dgrd added for Bob KA1GT
}
}
ui_->text_label->setText(message);
@@ -265,7 +314,14 @@ auto Astro::astroUpdate(QDateTime const& t, QString const& mygrid, QString const
&dgrd, &poloffset, &xnr, extraazel, &techo, &width1, &width2,
bTx,
nullptr, // don't overwrite azel.dat
- jpleph.toLocal8Bit ().constData ());
+ jpleph.toLocal8Bit ().constData (), &ephemeris_result);
+
+ report_ephemeris_transition (ephemeris_result);
+ if (ephemeris_result == ephemeris_invalid_input
+ || ephemeris_result == ephemeris_unavailable)
+ {
+ return {};
+ }
FrequencyDelta offset {0};
switch (m_DopplerMethod)
@@ -303,6 +359,12 @@ auto Astro::astroUpdate(QDateTime const& t, QString const& mygrid, QString const
return correction;
}
+//added for Bob KA1GT
+double Astro::getDgrd() const
+{
+ return m_dgrd;
+}
+
void Astro::check_split ()
{
/* TEMPORARILY DISABLE