Skip to content

Commit 401ab9e

Browse files
committed
add initial support to display variable brightness for variable stars
1 parent f2e8639 commit 401ab9e

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
@@ -429,6 +429,36 @@ struct Star
429429
pmdec = sky_orbit_vel.dot(q2) * 1000.;
430430
StelUtils::rectToSphe(&ra, &dec, v);
431431
}
432+
433+
inline void getVarStarOffset(double epoch, double &offset) const // get brightness offset for variable stars (not actual brightness)
434+
{
435+
StarId star_id; // star ID
436+
if (getGaia() == 0)
437+
{
438+
star_id = getHip();
439+
}
440+
else
441+
{
442+
star_id = getGaia();
443+
}
444+
double period = StarMgr::getGcvsPeriod(star_id);
445+
if (period == 0.) // not a variable star
446+
return;
447+
double dyrs = (epoch - STAR_CATALOG_JDEPOCH) / 365.25;
448+
double min1mag = StarMgr::getGcvsMinMagnitude(star_id) * 1000.;
449+
double maxmag = StarMgr::getGcvsMaxMagnitude(star_id) * 1000.;
450+
double epoch_offset = (StarMgr::getGcvsEpoch(star_id) - STAR_CATALOG_JDEPOCH) / 365.25;
451+
double phase = fmod(dyrs - epoch_offset, period) / period;
452+
453+
if (period && min1mag && maxmag && min1mag > maxmag)
454+
{
455+
double amplitude = (min1mag - maxmag) / 2.;
456+
if (phase < 0.0)
457+
phase += 1.0;
458+
// sine wave
459+
offset = amplitude * sin(2. * M_PI * phase);
460+
}
461+
}
432462
};
433463

434464
struct Star1 : public Star<Star1>

src/core/modules/StarWrapper.cpp

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

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

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

673677
double RA, DEC, pmra, pmdec;
674678
double Plx = s->getPlx();
@@ -895,7 +899,9 @@ QString StarWrapper3::getInfoString(const StelCore *core, const InfoStringGroup&
895899
oss << QString("%1: <b>%2</b>").arg(q_("Type"), objectTypeI18nStr) << "<br />";
896900
}
897901

898-
oss << getMagnitudeInfoString(core, flags, 2);
902+
double variable_magoffset = 0.0;
903+
s->getVarStarOffset(core->getJDE(), variable_magoffset);
904+
oss << getMagnitudeInfoString(core, flags, 2, variable_magoffset / 1000.);
899905

900906
if (flags&Extra)
901907
{

src/core/modules/ZoneArray.cpp

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

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)