In [1]:
import numpy as np

from lcc.entities.star import Star
from lcc.utils.stars import saveStars


---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa

In [2]:
## Preparation of data of the star
# Name of the star
star_name = "LMC_SC_1_1"

# Identifier of the star (names of the same object in different databases)
# In our example no counterpart in other catalogs is know so just one entry is saved
# "db_ident" key is query dict which can be used to query the object in particular databases
ident = {"OgleII" : {"name" : "LMC_SC_1_1",
                     "db_ident" : {"field_num" : 1,
                                   "starid" : 1,
                                   "target" : "lmc"}}}

# Coordinates of the star in degrees. Also it can be astropy SkyCoord object
coordinates = (83.2372045, -70.55790)
         
# All other information about the object
# This values are just demonstrative (not real)
other_info = {"b_mag" : 14.28,
             "i_mag" : 13.54,
             "mass_sun" : 1.12,
             "distance_pc" : 346.12,
             "period_days" : 16.57}

# Light curve created from from 3 arrays (list or other iterable)
time = np.linspace(1, 200, 20)
mag = np.sin(time)
error = np.random.random_sample(20)

In [3]:
# Create Star object
star = Star(name=star_name, ident=ident, coo=coordinates, more=other_info)

# Put light curve into the star object
star.putLightCurve([time, mag, error])

In [4]:
# Show star
print(star)

# Show light curve
print(star.lightCurve)

# Light curve attributes can be acessed by "time", "mag", "err" attributes
# such as st.lightCurve.mag


OgleII identifier:	name: LMC_SC_1_1	db_ident: {'field_num': 1, 'starid': 1, 'target': 'lmc'}	
	Coordinate: 05h32m56.9291s -70d33m28.44s
Time	Mag	Err
-------------------
1.00	0.84	0.15
11.47	-0.89	0.61
21.95	0.04	0.09
32.42	0.84	0.55
42.89	-0.89	0.01
53.37	0.04	0.11
63.84	0.85	0.41
74.32	-0.88	0.97
84.79	0.03	0.21
95.26	0.85	0.36
105.74	-0.88	0.11
116.21	0.03	0.14
126.68	0.85	0.28
137.16	-0.88	0.74
147.63	0.02	0.29
158.11	0.85	0.70
168.58	-0.88	0.26
179.05	0.02	0.51
189.53	0.86	0.62
200.00	-0.87	0.23


In [5]:
# List of Star object can be saved as fits files
# File is saved in /tmp folder with name according to "name" attribute. In our example it is "LMC_SC_1_1.fits".
saveStars([star], "/tmp")


Out[5]:
['LMC_SC_1_1']