<pre><code>import lightkurve as lk

# Specify the TIC ID for Algol
tic_id = 346783960

# Search for and download the TESS data using the TIC ID
lc = lk.search_lightcurve(f&quot;TIC {tic_id}&quot;).download().PDCSAP_FLUX.normalize()

# Plot the light curve
ax = lc.plot()
ax.figure.savefig('algol_lc.png')
</code></pre>
<p>Is this Algol?</p>
<p><img src="https://i.imgur.com/Wi6cDFh.png" alt="Algol" /></p>

CC BY-SA 4.0
2023-05-12T01:34:19.520Z
This looks like a comment or more information for the question rather than an answer.
GrapefruitIsAwesome
CC BY-SA 4.0
2023-05-08T03:11:02.123Z
2023-05-08T03:11:02.123Z
velkyvont
<p>First off, do learn about <a href="https://en.wikipedia.org/wiki/Julian_day" rel="nofollow noreferrer">Julian dates</a>. They are a convenient way of representing time as a single number They are merely the number of days since a point in ancient history. Converting a time (with timezone and date in the Gregorian calendar) to a Julian date can be done with various packages.</p>
<p>Now, there was a <a href="https://skyandtelescope.org/observing/the-minima-of-algol/" rel="nofollow noreferrer">minimum of Algol</a> at 05/08/2023 @ 07:50 UT
As a Julian date that is <code>epoch_minimum_jd=2460072.826389</code></p>
<p>Now if you have an event that occurs at <code>time_jd</code>, you can find the number of days between that time and the above minimum just as <code>days_from_epoch = abs(epoch minimum_jd - time_jd)</code></p>
<p>The period of Algol is <code>period=2.867328</code> (according to Wikipeida) So we can find the number of periods of Algol by division: <code>days_from_epoch / period</code>  But we only want the fractional part of this <code>algol_phase = (days_from_epoch / period) % 1.0</code>.</p>
<p>This variable will hold a number between 0.0 and 1.0 where 0.0 means Algol is at a minium, 0.5 means Algol is half way between miniuma and 1.0 means Algol is at a minimum again.</p>
<p>To convert this to a magnitude, you need a model of Algol's light curve. To do that, get a copy of Algol's light curve and work out a formula that will fit the curve.  Here is a graph from <a href="https://www.researchgate.net/figure/Phase-light-curve-of-Algol-b-Per-The-points-are-observations-by-24-the-lines-are_fig1_311430673" rel="nofollow noreferrer">researchgate</a> that you could use as a basis:</p>
<p><a href="https://i.sstatic.net/hIPyD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/hIPyD.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2023-05-07T19:58:28.857Z
Thank you very much for your post, it made me understand from a theoretical point of view what I have to do. If I understand correctly, for my needs I basically need a function that is able to generate points on that curve. I've tried to search the internet for how to do this, but so far I've been unsuccessful.
velkyvont
CC BY-SA 4.0
2023-05-07T20:02:44.820Z
This should get you close enough to what you need. For utmost accuracy, you need to correct for the Earth's position around the Sun to account for the time required for the light to Traverse extra distance or lesser distance.
JohnHoltz
CC BY-SA 4.0
2023-05-07T20:21:46.280Z
You can probably do a simple piecewise  function  That is your phase to magnitude function is one big `if` statement:  if x is between 0 and 0.05:  return a*x+b  elif x is between 0.05 and 0.45 return....
James K
CC BY-SA 4.0
2023-05-07T20:27:41.713Z
Or you might not need the actual magnitude, you can just feed the phase to your AI,
James K
CC BY-SA 4.0
2023-05-07T06:13:44.307Z
2023-05-07T15:21:47.793Z
2023-05-07T15:21:47.793Z
James K
<pre><code>import lightkurve as lk
import astropy.units as u
from astropy.time import Time
from scipy.interpolate import interp1d


# Specify the TIC ID for Algol
tic_id = 346783960

# Define the specific date and time (in UTC) as a Julian date
jd = Time('2023-05-08 12:00:00').jd

# Search for and download the TESS data using the TIC ID
lc = lk.search_lightcurve(f&quot;TIC {tic_id}&quot;).download().PDCSAP_FLUX.normalize()


folded_lc = lc.fold(period=2.867328, t0=2460072.826389)
flux_interp = interp1d(folded_lc.time, folded_lc.flux)
flux_at_time = flux_interp(jd)

# Compute the flux of Algol at the specified time
flux = lc.flux.interp_time(jd)

# Convert the flux to apparent magnitude
mag = -2.5 * u.log10(flux.value) + lc.flux_unit.log10() * u.dex(u.mag)

# Print the apparent magnitude of Algol at the specified time
print(f&quot;The apparent magnitude of Algol at JD {jd:.2f} is {mag:.2f}&quot;)

</code></pre>
<p>This is not working, I get:</p>
<pre><code>Traceback (most recent call last):
  File &quot;/mod/al60.py&quot;, line 19, in &lt;module&gt;
    flux_at_time = flux_interp(jd)
                   ^^^^^^^^^^^^^^^
  File &quot;/home/au/.local/lib/python3.11/site-packages/scipy/interpolate/_polyint.py&quot;, line 80, in __call__
    y = self._evaluate(x)
        ^^^^^^^^^^^^^^^^^
  File &quot;/home/au/.local/lib/python3.11/site-packages/scipy/interpolate/_interpolate.py&quot;, line 752, in _evaluate
    below_bounds, above_bounds = self._check_bounds(x_new)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File &quot;/home/au/.local/lib/python3.11/site-packages/scipy/interpolate/_interpolate.py&quot;, line 786, in _check_bounds
    raise ValueError(&quot;A value ({}) in x_new is above &quot;
ValueError: A value (2460073.0) in x_new is above the interpolation range's maximum value (1.433572665945614).
</code></pre>
<p>but I think I'm getting closer to what I' trying to accomplish</p>

CC BY-SA 4.0
2023-05-08T08:22:07.880Z
You can't get real-time or future light-curve data this way.  2460073.0 is  in the future (as I write, three hours in the future) That's because this is observed values, not modelled.
James K
CC BY-SA 4.0
2023-05-12T01:35:08.040Z
Not sure this is really an answer, this looks like it should be more content to be added to the original question.
GrapefruitIsAwesome
CC BY-SA 4.0
2023-05-08T03:33:05.020Z
2023-05-08T03:58:02.830Z
2023-05-08T03:58:02.830Z
velkyvont
<p>I've heard that in ancient Egypt they had a calendar to determine the lucky and less lucky days, which alternated approximately every 2.8 days. According to researchers, this may have been related to the periodicity of Algol's brightness. I'd like to experiment with this a bit (I'm trying to develop a certain AI model). But I have no idea how to get the data.</p>
<p>Can you please advise me how to get the apparent magnitude data of Algol for a specific point in time? I have a large database of events that happened in 2021-2023 (more specifically sport matches, their scores, coordinates of the stadiums and very exact timing of all game events such as goal kicks). I'd like to connect these data with the apparent magnitude of Algol for the given moment and let AI decide if there is some connection.</p>

CC BY-SA 4.0
2023-05-07T05:47:39.697Z
relevant https://iopscience.iop.org/article/10.1088/0004-637X/773/1/1/pdf
James K
CC BY-SA 4.0
2023-05-07T06:11:23.327Z
How are you representing "time"?  Our calendars don't go back that far, and the conversion of ancient Egyptian calendars to modern ones is uncertain. Are you familiar with Julian dates?  https://en.wikipedia.org/wiki/Julian_day That would be the most convenient way to measure time
James K
CC BY-SA 4.0
2023-05-07T12:00:21.837Z
Well I don't want to deal with Egyptian records at all.... I'd like to do something very different. I have a large database of events that happened in 2021-2023 (more specifically sport matches, their scores, coordinates of the stadiums and very exact timing of all game events such as goal kicks). I'd like to connect these data with the apparent magnitude of Algol for the given moment and let AI decide if there is some connection.
velkyvont
<python><variable-star>
Getting (variable) apparent magnitude of Algol
velkyvont
# Getting (variable) apparent magnitude of Algol

(Asked by: username_0 on 2023-05-07)

I've heard that in ancient Egypt they had a calendar to determine the lucky and less lucky days, which alternated approximately every 2.8 days. According to researchers, this may have been related to the periodicity of Algol's brightness. I'd like to experiment with this a bit (I'm trying to develop a certain AI model). But I have no idea how to get the data.

Can you please advise me how to get the apparent magnitude data of Algol for a specific point in time? I have a large database of events that happened in 2021-2023 (more specifically sport matches, their scores, coordinates of the stadiums and very exact timing of all game events such as goal kicks). I'd like to connect these data with the apparent magnitude of Algol for the given moment and let AI decide if there is some connection.

**Tags:** python, variable-star
> **Comments:**
> **username_1**: relevant https://iopscience.iop.org/article/10.1088/0004-637X/773/1/1/pdf  
> **username_1**: How are you representing "time"?  Our calendars don't go back that far, and the conversion of ancient Egyptian calendars to modern ones is uncertain. Are you familiar with Julian dates?  https://en.wikipedia.org/wiki/Julian_day That would be the most convenient way to measure time  
> **username_0**: Well I don't want to deal with Egyptian records at all.... I'd like to do something very different. I have a large database of events that happened in 2021-2023 (more specifically sport matches, their scores, coordinates of the stadiums and very exact timing of all game events such as goal kicks). I'd like to connect these data with the apparent magnitude of Algol for the given moment and let AI decide if there is some connection.  

---

## 3 answers

### Answer by username_0 on 2023-05-08. Score: 1

import lightkurve as lk

# Specify the TIC ID for Algol
tic_id = 346783960

# Search for and download the TESS data using the TIC ID
lc = lk.search_lightcurve(f"TIC {tic_id}").download().PDCSAP_FLUX.normalize()

# Plot the light curve
ax = lc.plot()
ax.figure.savefig('algol_lc.png')

Is this Algol?

> **Comments:**
> **username_2**: This looks like a comment or more information for the question rather than an answer.  

---

### Answer by username_1 on 2023-05-07. Score: 0

First off, do learn about [Julian dates](https://en.wikipedia.org/wiki/Julian_day). They are a convenient way of representing time as a single number They are merely the number of days since a point in ancient history. Converting a time (with timezone and date in the Gregorian calendar) to a Julian date can be done with various packages.

Now, there was a [minimum of Algol](https://skyandtelescope.org/observing/the-minima-of-algol/) at 05/08/2023 @ 07:50 UT
As a Julian date that is `epoch_minimum_jd=2460072.826389`

Now if you have an event that occurs at `time_jd`, you can find the number of days between that time and the above minimum just as `days_from_epoch = abs(epoch minimum_jd - time_jd)`

The period of Algol is `period=2.867328` (according to Wikipeida) So we can find the number of periods of Algol by division: `days_from_epoch / period` But we only want the fractional part of this `algol_phase = (days_from_epoch / period) % 1.0`.

This variable will hold a number between 0.0 and 1.0 where 0.0 means Algol is at a minium, 0.5 means Algol is half way between miniuma and 1.0 means Algol is at a minimum again.

To convert this to a magnitude, you need a model of Algol's light curve. To do that, get a copy of Algol's light curve and work out a formula that will fit the curve. Here is a graph from [researchgate](https://www.researchgate.net/figure/Phase-light-curve-of-Algol-b-Per-The-points-are-observations-by-24-the-lines-are_fig1_311430673) that you could use as a basis:

[![enter image description here](https://i.sstatic.net/hIPyD.png)](https://i.sstatic.net/hIPyD.png)

> **Comments:**
> **username_0**: Thank you very much for your post, it made me understand from a theoretical point of view what I have to do. If I understand correctly, for my needs I basically need a function that is able to generate points on that curve. I've tried to search the internet for how to do this, but so far I've been unsuccessful.  
> **username_3**: This should get you close enough to what you need. For utmost accuracy, you need to correct for the Earth's position around the Sun to account for the time required for the light to Traverse extra distance or lesser distance.  
> **username_1**: You can probably do a simple piecewise  function  That is your phase to magnitude function is one big `if` statement:  if x is between 0 and 0.05:  return a*x+b  elif x is between 0.05 and 0.45 return....  
> **username_1**: Or you might not need the actual magnitude, you can just feed the phase to your AI,  

---

### Answer by username_0 on 2023-05-08. Score: -1

import lightkurve as lk
import astropy.units as u
from astropy.time import Time
from scipy.interpolate import interp1d


# Specify the TIC ID for Algol
tic_id = 346783960

# Define the specific date and time (in UTC) as a Julian date
jd = Time('2023-05-08 12:00:00').jd

# Search for and download the TESS data using the TIC ID
lc = lk.search_lightcurve(f"TIC {tic_id}").download().PDCSAP_FLUX.normalize()


folded_lc = lc.fold(period=2.867328, t0=2460072.826389)
flux_interp = interp1d(folded_lc.time, folded_lc.flux)
flux_at_time = flux_interp(jd)

# Compute the flux of Algol at the specified time
flux = lc.flux.interp_time(jd)

# Convert the flux to apparent magnitude
mag = -2.5 * u.log10(flux.value) + lc.flux_unit.log10() * u.dex(u.mag)

# Print the apparent magnitude of Algol at the specified time
print(f"The apparent magnitude of Algol at JD {jd:.2f} is {mag:.2f}")


This is not working, I get:
Traceback (most recent call last):
  File "/mod/al60.py", line 19, in 
    flux_at_time = flux_interp(jd)
                   ^^^^^^^^^^^^^^^
  File "/home/au/.local/lib/python3.11/site-packages/scipy/interpolate/_polyint.py", line 80, in __call__
    y = self._evaluate(x)
        ^^^^^^^^^^^^^^^^^
  File "/home/au/.local/lib/python3.11/site-packages/scipy/interpolate/_interpolate.py", line 752, in _evaluate
    below_bounds, above_bounds = self._check_bounds(x_new)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/au/.local/lib/python3.11/site-packages/scipy/interpolate/_interpolate.py", line 786, in _check_bounds
    raise ValueError("A value ({}) in x_new is above "
ValueError: A value (2460073.0) in x_new is above the interpolation range's maximum value (1.433572665945614).

but I think I'm getting closer to what I' trying to accomplish

> **Comments:**
> **username_1**: You can't get real-time or future light-curve data this way.  2460073.0 is  in the future (as I write, three hours in the future) That's because this is observed values, not modelled.  
> **username_2**: Not sure this is really an answer, this looks like it should be more content to be added to the original question.  

---

