Ejemplo n.º 1
0
from pysme import sme as SME
from pysme import util
from pysme.abund import Abund
from pysme.gui import plot_plotly
from pysme.iliffe_vector import Iliffe_vector
from pysme.linelist.vald import ValdFile
from pysme.persistence import save_as_idl
from pysme.solve import solve
from pysme.synthesize import synthesize_spectrum

if __name__ == "__main__":
    # Define the location of all your files
    # this will put everything into the example dir
    target = "L_98-59"
    sdb = StellarDB()
    # sdb.auto_fill(target)
    star = sdb.load(target)
    alias = [re.sub(r"[-_ ]", "", s).lower() for s in star["id"]]

    examples_dir = dirname(realpath(__file__))
    data_dir = join(examples_dir, "data")

    # Find the correct data file for this target
    # fname = "ADP.2019-01-30T01:13:58.172.fits"
    fname = "L_98-59_mask_out.sme"
    in_file = os.path.join(examples_dir, "results", fname)
    # in_file = os.path.join(examples_dir, f"results/{target}_mask.sme")

    vald_file = os.path.join(examples_dir, f"data/hd22049.lin")
Ejemplo n.º 2
0
 def _init(self):
     self.backend = SDB()
Ejemplo n.º 3
0
        )

        m = mask[i] == sme.mask_values["continuum"]
        # plt.plot(idx_seg, spec)
        # plt.plot(idx_seg[m], spec[m], "+")
        # plt.show()
        pass

    return mask


if __name__ == "__main__":
    # Define the location of all your files
    # this will put everything into the example dir
    target = "55_Cnc"
    star = StellarDB().load(target)
    alias = [re.sub(r"[-_ ]", "", s).lower() for s in star["id"]]

    examples_dir = dirname(realpath(__file__))
    data_dir = join(examples_dir, "data")

    # Find the correct data file for this target
    fname = "ADP.2014-09-26T16:51:14.897.fits"
    in_file = os.path.join(data_dir, fname)
    # in_file = os.path.join(examples_dir, f"results/{target}_mask.sme")

    vald_file = os.path.join(examples_dir, f"data/hd22049.lin")

    out_file = os.path.join(examples_dir, f"results/{target}.sme")
    plot_file = os.path.join(examples_dir, f"results/{target}.html")
    date_string = datetime.datetime.now().isoformat().replace(":", ".")
Ejemplo n.º 4
0
class StellarDb(DataSource):
    _instance = None

    def __new__(cls, *args, **kwargs):
        if not cls._instance:
            cls._instance = DataSource.__new__(cls, *args, **kwargs)
            cls._instance._init()
        return cls._instance

    def __init__(self):
        super().__init__()

    def _init(self):
        self.backend = SDB()

    @lru_cache(128)
    def get(self, name):
        """Load the data on the star from the local database, or online
        if not available locally.
        
        Parameters
        ----------
        name : str
            Name of the star / planet
        
        Returns
        -------
        star : exoorbit.bodies.Star
            recovered Star
        """

        # self.backend.auto_fill(name)
        data = self.backend.load(name)

        if "distance" in data:
            distance = data["distance"]
        elif "parallax" in data:
            distance = Distance(parallax=data["parallax"])
        else:
            distance = None

        # Convert names
        # Stellar parameters
        star = Star(
            name=name,
            mass=data.get("mass"),
            radius=data.get("radius"),
            teff=data.get("t_eff"),
            logg=data.get("logg"),
            monh=data.get("metallicity"),
            vmac=data.get("velocity_turbulence", 1 * u.km/u.s),
            coordinates=data.get("coordinates"),
            distance=distance,
            radial_velocity=data.get("radial_velocity"),
        )

        planets = {}
        for pname, p in data["planets"].items():
            planet = Planet(
                name=pname,
                radius=p.get("radius"),
                mass=p.get("mass"),
                inc=p.get("inclination", 90 * u.deg),
                sma=p.get("semi_major_axis", 0 * u.AU),
                period=p.get("period"),
                ecc=p.get("eccentricity"),
                omega=p.get("periastron", 90 * u.deg),
                time_of_transit=p.get("transit_epoch"),
                transit_duration=p.get("transit_duration", 0 * u.day),
            )
            planets[pname] = planet

        star.planets = planets

        return star