<p>A helpful developer downloaded a light curve of Algol from STScI's MAST service of the TESS archive for me.</p>
<p>Its content looks like this:</p>
<pre><code># Time (BTJD),Normalized SAP_FLUX,Normalized SAP_BKG
1791.7659704711036,0.9953357713196904,0.20449268441018317
1791.7868043033843,0.9966320680638372,0.20297345806471756
1791.8076381341903,0.9975026399246625,0.20580296858683853
1791.828471963651,0.9983619224857635,0.20546566683189757
1791.8493057916578,0.9992328214823062,0.20573661958168665
</code></pre>
<p>He told me I could calculate the magnitude in the following way</p>
<pre><code>import juliandate
import datetime
import numpy as np

def get_algol_magnitude(date): # python datetime
    # read data from the text file
    data = np.genfromtxt('hlsp_qlp_tess_ffi_s0018-0000000346783960_tess_v01_llc.txt', delimiter=',')

    tess_start_date = 2457000.0
    tess_algol_mag = 3.3684
    
    # calculate Julian Date and BTJD offset
    jd = juliandate.from_gregorian(date.year,date.month,date.day,date.hour,date.minute,date.second)
    btjd_offset = jd - tess_start_date

    # find index of closest time to datetime_obj
    index = np.absolute(data[0] - btjd_offset).argmin()

    # calculate Algol magnitude
    magnitude = tess_algol_mag - 2.5 * math.log10(data[1][index])

    return magnitude
</code></pre>
<p>But he also told me this method works only work if the intended query date is in the range of the observation dates of TESS for this object. If not, I need an eclipsing binary model to predict magnitudes on arbitary dates.</p>
<p>There's been another helpful person who advised me how to calculate the phase of Algol for a given date.</p>
<pre><code>def get_algol_phase(time):
     time_jd = juliandate.from_gregorian(date.year,date.month,date.day,date.hour,date.minute,date.second)
     
     epoch_minimum_jd=2460072.826389
     algol_period=2.867328

     days_from_epoch = abs(epoch minimum_jd - time_jd)
     algol_phase = (days_from_epoch / algol_period) % 1.0   
 
     return algol_phase


time = datetime.datetime.now()
algol_phase = get_algol_phase(time)
</code></pre>
<p>Well since I don't really understand this, is there a way how to combine those 2 functions/datas together so I can have a function to obtain the magnitude of Algol for any date?</p>

CC BY-SA 4.0
2023-05-10T21:03:45.273Z
These two methods do very different things.  The first looks up an observation of algol from history.  The second is (part of) a theoretical model for algol.  You need to decide: do you want to use a theoretical model?  Or do you want to use observations?  It is your choice.
James K
CC BY-SA 4.0
2023-05-10T21:46:52.393Z
I mean can I make my own theoretical model from the observation data? I would take the observation data and combine them with Algol phase. So for example - first line  BTJD 1791.7659704711036 this is JD 2458791.7659704713 and using the function I get Algol phase 0.7784705930066593 and this gives magnitude of 3.373475968909212. Than for any date whose Algol phase is close to 0.7784705930066593 I had a magnitude of 3.373475968909212...
velkyvont
CC BY-SA 4.0
2023-05-10T22:31:36.143Z
You could but there are easier ways. Like using an existing light curve.
James K
<python><variable-star><tess>
Computing Algol's apparent magnitude from TESS observation data
velkyvont
# Computing Algol's apparent magnitude from TESS observation data

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

A helpful developer downloaded a light curve of Algol from STScI's MAST service of the TESS archive for me.
Its content looks like this:
# Time (BTJD),Normalized SAP_FLUX,Normalized SAP_BKG
1791.7659704711036,0.9953357713196904,0.20449268441018317
1791.7868043033843,0.9966320680638372,0.20297345806471756
1791.8076381341903,0.9975026399246625,0.20580296858683853
1791.828471963651,0.9983619224857635,0.20546566683189757
1791.8493057916578,0.9992328214823062,0.20573661958168665

He told me I could calculate the magnitude in the following way
import juliandate
import datetime
import numpy as np

def get_algol_magnitude(date): # python datetime
    # read data from the text file
    data = np.genfromtxt('hlsp_qlp_tess_ffi_s0018-0000000346783960_tess_v01_llc.txt', delimiter=',')

    tess_start_date = 2457000.0
    tess_algol_mag = 3.3684
    
    # calculate Julian Date and BTJD offset
    jd = juliandate.from_gregorian(date.year,date.month,date.day,date.hour,date.minute,date.second)
    btjd_offset = jd - tess_start_date

    # find index of closest time to datetime_obj
    index = np.absolute(data[0] - btjd_offset).argmin()

    # calculate Algol magnitude
    magnitude = tess_algol_mag - 2.5 * math.log10(data[1][index])

    return magnitude

But he also told me this method works only work if the intended query date is in the range of the observation dates of TESS for this object. If not, I need an eclipsing binary model to predict magnitudes on arbitary dates.
There's been another helpful person who advised me how to calculate the phase of Algol for a given date.
def get_algol_phase(time):
     time_jd = juliandate.from_gregorian(date.year,date.month,date.day,date.hour,date.minute,date.second)
     
     epoch_minimum_jd=2460072.826389
     algol_period=2.867328

     days_from_epoch = abs(epoch minimum_jd - time_jd)
     algol_phase = (days_from_epoch / algol_period) % 1.0   
 
     return algol_phase


time = datetime.datetime.now()
algol_phase = get_algol_phase(time)

Well since I don't really understand this, is there a way how to combine those 2 functions/datas together so I can have a function to obtain the magnitude of Algol for any date?

**Tags:** python, variable-star, tess

> **Comments:**
> **username_1**: These two methods do very different things.  The first looks up an observation of algol from history.  The second is (part of) a theoretical model for algol.  You need to decide: do you want to use a theoretical model?  Or do you want to use observations?  It is your choice.  
> **username_0**: I mean can I make my own theoretical model from the observation data? I would take the observation data and combine them with Algol phase. So for example - first line  BTJD 1791.7659704711036 this is JD 2458791.7659704713 and using the function I get Algol phase 0.7784705930066593 and this gives magnitude of 3.373475968909212. Than for any date whose Algol phase is close to 0.7784705930066593 I had a magnitude of 3.373475968909212...  
> **username_1**: You could but there are easier ways. Like using an existing light curve.  

---

## 0 answers

