In [1]:
import numpy as np
from lcc.entities.star import Star
from lcc.utils.stars import saveStars
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
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]: