Skip to content

Commit 7dd3e4a

Browse files
henryskyalex-w
authored andcommitted
add initial support to display variable brightness for variable stars
1 parent 46bab87 commit 7dd3e4a

4 files changed

Lines changed: 48 additions & 5 deletions

File tree

src/core/modules/Star.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,36 @@ struct Star
446446
pmdec = sky_orbit_vel.dot(q2) * 1000.;
447447
StelUtils::rectToSphe(&ra, &dec, v);
448448
}
449+
450+
inline void getVarStarOffset(double epoch, double &offset) const // get brightness offset for variable stars (not actual brightness)
451+
{
452+
StarId star_id; // star ID
453+
if (getGaia() == 0)
454+
{
455+
star_id = getHip();
456+
}
457+
else
458+
{
459+
star_id = getGaia();
460+
}
461+
double period = StarMgr::getGcvsPeriod(star_id) / 365.25;
462+
if (period <=0.) // not a variable star
463+
return;
464+
double dyrs = (epoch - STAR_CATALOG_JDEPOCH) / 365.25;
465+
double min1mag = StarMgr::getGcvsMinMagnitude(star_id) * 1000.;
466+
double maxmag = StarMgr::getGcvsMaxMagnitude(star_id) * 1000.;
467+
double epoch_offset = (StarMgr::getGcvsEpoch(star_id) - STAR_CATALOG_JDEPOCH) / 365.25;
468+
double phase = fmod(dyrs - epoch_offset, period) / period;
469+
470+
if (period && min1mag && maxmag && min1mag > maxmag)
471+
{
472+
double amplitude = (min1mag - maxmag) / 2.;
473+
if (phase < 0.0)
474+
phase += 1.0;
475+
// sine wave
476+
offset = amplitude * sin(2. * M_PI * phase);
477+
}
478+
}
449479
};
450480

451481
struct Star1 : public Star<Star1>

src/core/modules/StarWrapper.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,9 @@ QString StarWrapper1::getInfoString(const StelCore *core, const InfoStringGroup&
308308
{
309309
magOffset = 5.f * log10(s->getPlx()/Plx);
310310
}
311-
oss << getMagnitudeInfoString(core, flags, 2, magOffset);
311+
double variable_magoffset = 0.0;
312+
s->getVarStarOffset(core->getJDE(), variable_magoffset);
313+
oss << getMagnitudeInfoString(core, flags, 2, magOffset + variable_magoffset / 1000.);
312314

313315
// should use Plx from getPlx because Plx can change with time, but not absolute magnitude
314316
if ((flags&AbsoluteMagnitude) && s->getPlx())
@@ -666,7 +668,9 @@ QString StarWrapper2::getInfoString(const StelCore *core, const InfoStringGroup&
666668
oss << QString("%1: <b>%2</b>").arg(q_("Type"), objectTypeI18nStr) << "<br />";
667669
}
668670

669-
oss << getMagnitudeInfoString(core, flags, 2);
671+
double variable_magoffset = 0.0;
672+
s->getVarStarOffset(core->getJDE(), variable_magoffset);
673+
oss << getMagnitudeInfoString(core, flags, 2, variable_magoffset / 1000.);
670674

671675
double RA, DEC, pmra, pmdec, Plx, RadialVel;
672676
double PlxErr = s->getPlxErr();
@@ -891,7 +895,9 @@ QString StarWrapper3::getInfoString(const StelCore *core, const InfoStringGroup&
891895
oss << QString("%1: <b>%2</b>").arg(q_("Type"), objectTypeI18nStr) << "<br />";
892896
}
893897

894-
oss << getMagnitudeInfoString(core, flags, 2);
898+
double variable_magoffset = 0.0;
899+
s->getVarStarOffset(core->getJDE(), variable_magoffset);
900+
oss << getMagnitudeInfoString(core, flags, 2, variable_magoffset / 1000.);
895901

896902
if (flags&Extra)
897903
{

src/core/modules/ZoneArray.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,11 @@ void SpecialZoneArray<Star>::draw(StelPainter* sPainter, int index, bool isInsid
484484
Vec3d u = (r * (1. + pmr0 * dyrs) + pmvec0 * dyrs) * f;
485485
v.set(u[0], u[1], u[2]);
486486
}
487+
// take variable star brightness delta into account
488+
double variable_magoffset = 0.0;
489+
s->getVarStarOffset(core->getJDE(), variable_magoffset);
490+
starMag += variable_magoffset;
491+
487492
// recompute magIndex with the new magnitude
488493
magIndex = static_cast<int>((starMag - (mag_min - 7000.)) * 0.02); // 1 / (50 milli-mag)
489494

src/core/modules/ZoneArray.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ class ZoneArray
111111
const RCMag* rcmag_table, int limitMagIndex, StelCore* core,
112112
int maxMagStarName, float names_brightness,
113113
const QVector<SphericalCap>& boundingCaps,
114-
const bool withAberration, const Vec3d vel, const double withParallax, const Vec3d diffPos) const = 0;
114+
const bool withAberration, const Vec3d vel, const double withParallax,
115+
const Vec3d diffPos) const = 0;
115116

116117
//! Get whether or not the catalog was successfully loaded.
117118
//! @return @c true if at least one zone was loaded, otherwise @c false
@@ -183,7 +184,8 @@ class SpecialZoneArray : public ZoneArray
183184
const RCMag *rcmag_table, int limitMagIndex, StelCore* core,
184185
int maxMagStarName, float names_brightness,
185186
const QVector<SphericalCap>& boundingCaps,
186-
const bool withAberration, const Vec3d vel, const double withParallax, const Vec3d diffPos) const override;
187+
const bool withAberration, const Vec3d vel, const double withParallax,
188+
const Vec3d diffPos) const override;
187189

188190
void searchAround(const StelCore* core, int index, const Vec3d &v, const double withParallax,
189191
const Vec3d diffPos, double cosLimFov, QList<StelObjectP > &result) override;

0 commit comments

Comments
 (0)