Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/core/modules/Star.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,31 @@ struct Star
pmdec = sky_orbit_vel.dot(q2) * 1000.;
StelUtils::rectToSphe(&ra, &dec, v);
}

inline void getVarStarOffset(double epoch, double &offset) const // get brightness offset for variable stars (not actual brightness)
{
StarId star_id = (getGaia() == 0) ? getHip() : getGaia();
double period = StarMgr::getGcvsPeriod(star_id) / 365.25;
if (period <=0.) // not a variable star
return;
double dyrs = (epoch - STAR_CATALOG_JDEPOCH) / 365.25;
double min1mag = StarMgr::getGcvsMinMagnitude(star_id) * 1000.;
double maxmag = StarMgr::getGcvsMaxMagnitude(star_id) * 1000.;
QString name = StarMgr::getGcvsVariabilityType(star_id);
if (!name.isEmpty())
qDebug() << "Star " << name << " has period " << period << " days, min1mag " << min1mag << ", maxmag " << maxmag;
double epoch_offset = (StarMgr::getGcvsEpoch(star_id) - STAR_CATALOG_JDEPOCH) / 365.25;
double phase = fmod(dyrs - epoch_offset, period) / period;

if (period && min1mag && maxmag && min1mag > maxmag)
{
double amplitude = (min1mag - maxmag) / 2.;
if (phase < 0.0)
phase += 1.0;
// sine wave
offset = amplitude * sin(2. * M_PI * phase);
}
}
};

struct Star1 : public Star<Star1>
Expand Down
12 changes: 9 additions & 3 deletions src/core/modules/StarWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ QString StarWrapper1::getInfoString(const StelCore *core, const InfoStringGroup&
{
magOffset = 5.f * log10(s->getPlx()/Plx);
}
oss << getMagnitudeInfoString(core, flags, 2, magOffset);
double variable_magoffset = 0.0;
s->getVarStarOffset(core->getJDE(), variable_magoffset);
oss << getMagnitudeInfoString(core, flags, 2, magOffset + variable_magoffset / 1000.);

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

oss << getMagnitudeInfoString(core, flags, 2);
double variable_magoffset = 0.0;
s->getVarStarOffset(core->getJDE(), variable_magoffset);
oss << getMagnitudeInfoString(core, flags, 2, variable_magoffset / 1000.);

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

oss << getMagnitudeInfoString(core, flags, 2);
double variable_magoffset = 0.0;
s->getVarStarOffset(core->getJDE(), variable_magoffset);
oss << getMagnitudeInfoString(core, flags, 2, variable_magoffset / 1000.);

if (flags&Extra)
{
Expand Down
5 changes: 5 additions & 0 deletions src/core/modules/ZoneArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ void SpecialZoneArray<Star>::draw(StelPainter* sPainter, int index, bool isInsid
Vec3d u = (r * (1. + pmr0 * dyrs) + pmvec0 * dyrs) * f;
v.set(u[0], u[1], u[2]);
}
// take variable star brightness delta into account
double variable_magoffset = 0.0;
s->getVarStarOffset(core->getJDE(), variable_magoffset);
starMag += variable_magoffset;

// recompute magIndex with the new magnitude
magIndex = static_cast<int>((starMag - (mag_min - 7000.)) * 0.02); // 1 / (50 milli-mag)

Expand Down
Loading