Skip to content

Commit 262a15b

Browse files
committed
add initial support to display variable brightness for variable stars
1 parent 0b30769 commit 262a15b

3 files changed

Lines changed: 44 additions & 3 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
@@ -303,7 +303,9 @@ QString StarWrapper1::getInfoString(const StelCore *core, const InfoStringGroup&
303303
{
304304
magOffset = 5.f * log10(s->getPlx()/Plx);
305305
}
306-
oss << getMagnitudeInfoString(core, flags, 2, magOffset);
306+
double variable_magoffset = 0.0;
307+
s->getVarStarOffset(core->getJDE(), variable_magoffset);
308+
oss << getMagnitudeInfoString(core, flags, 2, magOffset + variable_magoffset / 1000.);
307309

308310
// should use Plx from getPlx because Plx can change with time, but not absolute magnitude
309311
if ((flags&AbsoluteMagnitude) && s->getPlx())
@@ -658,7 +660,9 @@ QString StarWrapper2::getInfoString(const StelCore *core, const InfoStringGroup&
658660
oss << QString("%1: <b>%2</b>").arg(q_("Type"), objectTypeI18nStr) << "<br />";
659661
}
660662

661-
oss << getMagnitudeInfoString(core, flags, 2);
663+
double variable_magoffset = 0.0;
664+
s->getVarStarOffset(core->getJDE(), variable_magoffset);
665+
oss << getMagnitudeInfoString(core, flags, 2, variable_magoffset / 1000.);
662666

663667
double RA, DEC, pmra, pmdec, Plx, RadialVel;
664668
double PlxErr = s->getPlxErr();
@@ -884,7 +888,9 @@ QString StarWrapper3::getInfoString(const StelCore *core, const InfoStringGroup&
884888
oss << QString("%1: <b>%2</b>").arg(q_("Type"), objectTypeI18nStr) << "<br />";
885889
}
886890

887-
oss << getMagnitudeInfoString(core, flags, 2);
891+
double variable_magoffset = 0.0;
892+
s->getVarStarOffset(core->getJDE(), variable_magoffset);
893+
oss << getMagnitudeInfoString(core, flags, 2, variable_magoffset / 1000.);
888894

889895
if (flags&Extra)
890896
{

src/core/modules/ZoneArray.cpp

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

0 commit comments

Comments
 (0)