<p>I'm building a pipeline to look at several thousand eclipsing binary systems for my master's thesis, and I've run into an issue I am having a hard time fixing. I'm using the Python module Lightkurve.</p>
<p>I am only able to pull TPFs for some of my targets instead of directly pulling light curves through Lightkurve &amp; MAST. Ideally, I would like to combine all of the TPFS from different TESS sectors into a single TPF so I can graph them all at once.</p>
<p>I have looked at the &quot;Combining Multiple Quarters of Kepler Data&quot; tutorial, but my issue is arising in creating a function that turns the TPFs to light curves and then into the light curve compendium object.</p>
<p>I can graph a single sector, but as soon as I try to make a for loop to repeat the process automatically, I get a &quot;scalar divide by zero&quot; error. Here is my code for a sample EB system:</p>
<pre><code>tpf_list = lk.search_targetpixelfile('TIC 1003831',  mission='TESS').download_all()


def tpf_to_lc_collection(tpf_list):

    tpf = tpf_list[0]
    
    lightcurve = tpf_list[0].to_lightcurve(aperture_mask = tpf.pipeline_mask)
    
    lcc = lk.LightCurveCollection(lightcurve)
    
    for i in tpf_list:

        if i == 0: #prevents tpf_list[0] from being used twice

            continue
        
        lc = tpf_list[i].to_lightcurve(aperture_mask = tpf_list[i].pipeline_mask)

        lcc.append(lc)

    return lcc

</code></pre>
<p>Line 4 is my solution to not knowing how to create an empty light curve compendium (I tried LightCurveCollection() and got an error along the lines of it not being valid). My original plan was to create an empty collection like I would do a numpy array and then append objects into it. This would create a single lightcurve that I could then graph with Plotly.</p>
<p>Thank you so much for your help. I am still fairly new to coding, so I will answer any questions to the best of my ability!</p>

CC BY-SA 4.0
2023-12-29T06:39:37.597Z
To expand on the error in the second to last paragraph, downloading the light curves with lk.search_lightcurve() yields an error of: "Not recognized as a supported data produce: (pathname). This file may be corrupt due to an interrupted download. Please remove it from your disk and try again."

Deleting the file in the cache and attempting to run the command again yields the same result.
Erika Dunning
CC BY-SA 4.0
2023-12-29T10:34:51.793Z
shouldn't it be for i in range(len(tpf_list) if later you're using it as tpf_list[i] ?
Marco Leonardi
<python>
Python Lightkurve Module -- How to combine different TESS sectors into one graph
Erika Dunning
# Python Lightkurve Module -- How to combine different TESS sectors into one graph

(Asked by: username_0 on 2023-12-29)

I'm building a pipeline to look at several thousand eclipsing binary systems for my master's thesis, and I've run into an issue I am having a hard time fixing. I'm using the Python module Lightkurve.
I am only able to pull TPFs for some of my targets instead of directly pulling light curves through Lightkurve & MAST. Ideally, I would like to combine all of the TPFS from different TESS sectors into a single TPF so I can graph them all at once.
I have looked at the "Combining Multiple Quarters of Kepler Data" tutorial, but my issue is arising in creating a function that turns the TPFs to light curves and then into the light curve compendium object.
I can graph a single sector, but as soon as I try to make a for loop to repeat the process automatically, I get a "scalar divide by zero" error. Here is my code for a sample EB system:
tpf_list = lk.search_targetpixelfile('TIC 1003831',  mission='TESS').download_all()


def tpf_to_lc_collection(tpf_list):

    tpf = tpf_list[0]
    
    lightcurve = tpf_list[0].to_lightcurve(aperture_mask = tpf.pipeline_mask)
    
    lcc = lk.LightCurveCollection(lightcurve)
    
    for i in tpf_list:

        if i == 0: #prevents tpf_list[0] from being used twice

            continue
        
        lc = tpf_list[i].to_lightcurve(aperture_mask = tpf_list[i].pipeline_mask)

        lcc.append(lc)

    return lcc


Line 4 is my solution to not knowing how to create an empty light curve compendium (I tried LightCurveCollection() and got an error along the lines of it not being valid). My original plan was to create an empty collection like I would do a numpy array and then append objects into it. This would create a single lightcurve that I could then graph with Plotly.
Thank you so much for your help. I am still fairly new to coding, so I will answer any questions to the best of my ability!

**Tags:** python
> **Comments:**
> **username_0**: To expand on the error in the second to last paragraph, downloading the light curves with lk.search_lightcurve() yields an error of: "Not recognized as a supported data produce: (pathname). This file may be corrupt due to an interrupted download. Please remove it from your disk and try again."  Deleting the file in the cache and attempting to run the command again yields the same result.  
> **username_1**: shouldn't it be for i in range(len(tpf_list) if later you're using it as tpf_list[i] ?  

---

## 0 answers

