How to use the phoebe.parse_lc function in phoebe

To help you get started, we’ve selected a few phoebe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phoebe-project / phoebe2 / phoebe-testlib / test_parsing / test_parse.py View on Github external
def check_parse_with_numpy(myfile, type='lc', **kwargs):
    """
    Compare the contents and shape of data read in by Phoebe and by Numpy.
    
    Bottom line: we need to have as many columns and lines, and, assuming that
    the first column is time, all numbers need to be the same after read in by
    Numpy and by Phoebe.
    """
    # Read via Phoebe
    print("filename: {}, type: {}".format(myfile,type))
    if type == 'lc':
        obs, pbdep = phoebe.parse_lc(myfile, **kwargs)
    elif type == 'rv':
        obs, pbdep = phoebe.parse_rv(myfile, **kwargs)
    # Read via Numpy
    data = np.loadtxt(myfile)
    
    # We need to have as many lines:
    assert(data.shape[0] == obs.shape[0])
    
    # We can't really test the number of columns, as the sigma column is
    # added if it's not there
    
    # Test if the columns contain the same data:
    columns = obs['columns']
    for col in range(min(len(columns),data.shape[1])):
        # Sigma column could have been added, so we don't test for it
        if columns[col] == 'sigma':
github phoebe-project / phoebe2 / phoebe-testlib / test_parsing / test_parse.py View on Github external
def test_parse_lc_01():
    """
    File parsing: parse_lc (5)
    """
    
    obs, pbdep = phoebe.parse_lc(os.path.join(basedir, 'datafiles/example1.lc'), estimate_sigma=False)
    assert(obs['columns'] == ['time', 'flux'])
    assert(len(obs['time']) == 4)
    
    obs, pbdep = phoebe.parse_lc(os.path.join(basedir, 'datafiles/example2.lc'))
    assert(obs['columns'] == ['time', 'flux', 'sigma', 'flag'])
    assert(len(obs['time']) == 4)
    assert(pbdep['passband']=='JOHNSON.B')
    
    obs, pbdep = phoebe.parse_lc(os.path.join(basedir, 'datafiles/example3.lc'))
    assert(obs['columns'] == ['time', 'flux', 'flag', 'sigma'])
    assert(len(obs['time']) == 4)
    assert(np.all(obs['flag'] == 0))
    assert(pbdep['passband']=='JOHNSON.B')
    
    obs, pbdep = phoebe.parse_lc(os.path.join(basedir, 'datafiles/example4.lc'))
    assert(obs['columns'] == ['phase', 'flux', 'sigma', 'flag'])
github phoebe-project / phoebe2 / phoebe-unittests / test_parse.py View on Github external
def test_parse_lc_01():
    
    obs, pbdep = phoebe.parse_lc('../phoebe-testlib/datafiles/example1.lc')
    assert(obs['columns'] == ['time', 'flux', 'sigma'])
    assert(len(obs['time']) == 4)
    
    obs, pbdep = phoebe.parse_lc('../phoebe-testlib/datafiles/example2.lc')
    assert(obs['columns'] == ['time', 'flux', 'sigma', 'flag'])
    assert(len(obs['time']) == 4)
    assert(pbdep['passband']=='JOHNSON.B')
    
    obs, pbdep = phoebe.parse_lc('../phoebe-testlib/datafiles/example3.lc')
    assert(obs['columns'] == ['time', 'flux', 'flag', 'sigma'])
    assert(len(obs['time']) == 4)
    assert(np.all(obs['flag'] == 0))
    assert(pbdep['passband']=='JOHNSON.B')
    
    obs, pbdep = phoebe.parse_lc('../phoebe-testlib/datafiles/example4.lc')
    assert(obs['columns'] == ['phase', 'flux', 'sigma', 'flag'])
    assert(len(obs['time']) == 0)
    assert(len(obs['phase']) == 4)
    assert(np.all(obs['flag'] == 0))
    assert(isinstance(obs['flag'][0], float))
github phoebe-project / phoebe2 / phoebe-unittests / test_parse.py View on Github external
def check_parse_with_numpy(myfile, type='lc', **kwargs):
    """
    Compare the contents and shape of data read in by Phoebe and by Numpy.
    
    Bottom line: we need to have as many columns and lines, and, assuming that
    the first column is time, all numbers need to be the same after read in by
    Numpy and by Phoebe.
    """
    # Read via Phoebe
    print("filename: {}, type: {}".format(myfile,type))
    if type == 'lc':
        obs, pbdep = phoebe.parse_lc(myfile, **kwargs)
    elif type == 'rv':
        obs, pbdep = phoebe.parse_rv(myfile, **kwargs)
        
    # Read via Numpy
    data = np.loadtxt(myfile)
    
    # We need to have as many lines:
    assert(data.shape[0] == obs.shape[0])
    
    # We can't really test the number of columns, as the sigma column is
    # added if it's not there
    
    # Test if the columns contain the same data:
    columns = obs['columns']
    for col in range(min(len(columns),data.shape[1])):
        # Sigma column could have been added, so we don't test for it
github phoebe-project / phoebe2 / phoebe-unittests / test_parse.py View on Github external
obs, pbdep = phoebe.parse_lc('../phoebe-testlib/datafiles/example1.lc')
    assert(obs['columns'] == ['time', 'flux', 'sigma'])
    assert(len(obs['time']) == 4)
    
    obs, pbdep = phoebe.parse_lc('../phoebe-testlib/datafiles/example2.lc')
    assert(obs['columns'] == ['time', 'flux', 'sigma', 'flag'])
    assert(len(obs['time']) == 4)
    assert(pbdep['passband']=='JOHNSON.B')
    
    obs, pbdep = phoebe.parse_lc('../phoebe-testlib/datafiles/example3.lc')
    assert(obs['columns'] == ['time', 'flux', 'flag', 'sigma'])
    assert(len(obs['time']) == 4)
    assert(np.all(obs['flag'] == 0))
    assert(pbdep['passband']=='JOHNSON.B')
    
    obs, pbdep = phoebe.parse_lc('../phoebe-testlib/datafiles/example4.lc')
    assert(obs['columns'] == ['phase', 'flux', 'sigma', 'flag'])
    assert(len(obs['time']) == 0)
    assert(len(obs['phase']) == 4)
    assert(np.all(obs['flag'] == 0))
    assert(isinstance(obs['flag'][0], float))
    bla = obs.get_value('flux','mag')
    assert(np.all(bla-np.array([10., 11.1, 10.7, 10.8])<1e-14))
    assert(pbdep['passband']=='JOHNSON.B')
    
    obs, pbdep = phoebe.parse_lc('../phoebe-testlib/datafiles/example5.lc')
    assert(obs['columns'] == ['phase', 'flux', 'sigma', 'flag'])
    assert(len(obs['time']) == 0)
    assert(len(obs['phase']) == 4)
    assert(np.all(obs['flag'] == 0))
    assert(isinstance(obs['flag'][0], int))
    bla = obs.get_value('flux','mag')
github phoebe-project / phoebe2 / phoebe-testlib / test_parsing / test_parse.py View on Github external
def test_parse_phased_data_mag():
    """
    File parsing: phased data and magnitudes
    """
    
    phasedfile = os.path.join(basedir, 'HD174884/hd174884.phased.data')
    obs, pbdep = phoebe.parse_lc(phasedfile, columns=['phase', 'mag'], estimate_sigma=False)
    assert(len(obs['time']) == 0)
    assert(obs['columns'] == ['phase', 'flux'])
    
    data = np.loadtxt(phasedfile).T
    
    #flux1 = phoebe.convert('mag','erg/s/cm2/AA',data[1], passband=pbdep['passband'])
    flux1 = phoebe.convert('mag','W/m3',data[1], passband=pbdep['passband'])
    #flux2 = phoebe.convert('W/m3','erg/s/cm2/AA',10**(-data[1]/2.5))
    assert(np.all(flux1 == obs['flux']))
    #assert(np.all(flux2 == obs['flux']))
github phoebe-project / phoebe2 / phoebe-unittests / test_parse.py View on Github external
def test_parse_lc_01():
    
    obs, pbdep = phoebe.parse_lc('../phoebe-testlib/datafiles/example1.lc')
    assert(obs['columns'] == ['time', 'flux', 'sigma'])
    assert(len(obs['time']) == 4)
    
    obs, pbdep = phoebe.parse_lc('../phoebe-testlib/datafiles/example2.lc')
    assert(obs['columns'] == ['time', 'flux', 'sigma', 'flag'])
    assert(len(obs['time']) == 4)
    assert(pbdep['passband']=='JOHNSON.B')
    
    obs, pbdep = phoebe.parse_lc('../phoebe-testlib/datafiles/example3.lc')
    assert(obs['columns'] == ['time', 'flux', 'flag', 'sigma'])
    assert(len(obs['time']) == 4)
    assert(np.all(obs['flag'] == 0))
    assert(pbdep['passband']=='JOHNSON.B')
    
    obs, pbdep = phoebe.parse_lc('../phoebe-testlib/datafiles/example4.lc')
    assert(obs['columns'] == ['phase', 'flux', 'sigma', 'flag'])