コード例 #1
0
    def sanity_ramirez2005(self):
        """
        Check sanity Ramirez/Melendez 2005 conversions
        """
        from PyAstronomy import pyasl
        import numpy as np
        from itertools import product

        feh = 0.0
        r = pyasl.Ramirez2005()
        # Compare with numbers given in Allen (astrophysical quantities, 4th edition)
        for teff, bv in zip([7000., 5950., 5310., 4410.],
                            [0.35, 0.58, 0.74, 1.15]):
            self.assertAlmostEqual(bv,
                                   r.teffToColor("B-V", teff, feh),
                                   delta=0.03,
                                   msg="B-V conversion (Teff " + str(teff) +
                                   ") out of sync with Allen")

        for teff, bv in zip([6500., 6000., 5000.], [0.286, 0.36, 0.535]):
            self.assertAlmostEqual(bv,
                                   r.teffToColor("b-y", teff, feh),
                                   delta=0.01,
                                   msg="B-V conversion (Teff " + str(teff) +
                                   ") out of sync with Allen")

        for teff, bv in zip([5000., 4500., 4000.], [0.433, 0.51, 0.735]):
            self.assertAlmostEqual(bv,
                                   r.teffToColor("R_C-I_C", teff, feh, 'g'),
                                   delta=0.04,
                                   msg="R_C-I_C conversion (Teff " +
                                   str(teff) +
                                   ") out of sync with Allen (giants)")

        for teff, bv in zip([5050., 4660., 4050.], [0.86, 1., 1.5]):
            self.assertAlmostEqual(bv,
                                   r.teffToColor("B-V", teff, feh, 'g'),
                                   delta=0.1,
                                   msg="B-V conversion (Teff " + str(teff) +
                                   ") out of sync with Allen (giants)")

        # Check consistency
        bv = np.arange(0.4, 1.01, 0.05)
        feh = np.arange(-2., 0.3, 0.2)
        for x in product(bv, feh):
            teff = r.colorToTeff("B-V", x[0], x[1], 'ms')
            col = r.teffToColor("B-V", teff, x[1], 'ms')
            self.assertAlmostEqual(
                x[0],
                col,
                delta=1e-2,
                msg=
                "Two-way color-temperature conversion is inconsistent. bv = %.4e, feh = %.4e"
                % x)
コード例 #2
0
    def sanity_ramirez2005Example2(self):
        """
      Checking Ramirez, Ballesteros example
    """
        from PyAstronomy import pyasl

        b = pyasl.BallesterosBV_T()
        r = pyasl.Ramirez2005()

        # Convert B-V to effective temperature and back
        for bv in [
                0.35, 0.45, 0.55, 0.65, 0.75, 0.85, 0.95, 1.05, 1.15, 1.25,
                1.35, 1.45
        ]:
            tr = r.colorToTeff("B-V", bv, 0.0)
            tb = b.bv2T(bv)

            print(("B-V [mag] = {3:4.2f} : Teff (R05) = {0:4.0f} K, " + \
                    "Teff (B12) = {1:4.0f} K, dTeff = {2: 4.0f} K").format(tr, tb, tr - tb, bv))
コード例 #3
0
    def sanity_ramirez2005Example(self):
        """
        Check sanity of Ramirez/Melendez 2005 example
        """
        from PyAstronomy import pyasl

        # Create class instance
        r = pyasl.Ramirez2005()

        # Which color bands are available
        print("Available color bands: ", r.availableBands())

        # Convert B-V to effective temperature and back
        bv = 0.75
        feh = 0.0
        teff = r.colorToTeff("B-V", bv, feh)
        bv1 = r.teffToColor("B-V", teff, feh)
        # Watch out for differences between input bv and the output bv1
        print("B-V = ", bv, ", Teff = ", teff, ", bv1 = ", bv1, ", bv-bv1 = ",
              bv - bv1)
コード例 #4
0
ファイル: tfp_hmc.py プロジェクト: ni-phy/year4-project
pip install arviz

import numpy as np
import arviz as az
import pandas as pd
import matplotlib.pyplot as plt
import tensorflow.compat.v2 as tf
import tensorflow_probability as tfp
from mpl_toolkits.mplot3d import Axes3D
from google.colab import files
import io
from PyAstronomy import pyasl
import time
r = pyasl.BallesterosBV_T()
b = pyasl.Ramirez2005()

uploaded = files.upload()

data0 = data = np.array(pd.read_csv(io.BytesIO(uploaded['SItable1.csv'])))

import tensorflow.math as tf_m
def mean_fn(x, y, a, b, c, d):
  return (np.exp(x)*1000)**a * b*(y - c)**d #the m relation was through trial and error
#fn from Barnes 2007

pd.read_csv(io.BytesIO(uploaded['SItable1.csv']))
#tolist makes array to list to remove 'dtype=float64' from the end of the array
te = data0[:,2].tolist()
tee= data0[:,3].tolist()
age = data0[:,4].tolist()
コード例 #5
0
tsi = pd.read_csv('tsi_data_6h.txt')  # TSI SORCE data (6-hourly)

montet = pd.read_csv(
    'montet_stars.txt')  #Original data from Montet et al. (2018)

#Downloaded from: https://iopscience.iop.org/0004-637X/851/2/116/suppdata/apjaa9e00t1_mrt.txt

#-------------------------------- FILTER DATA ----------------------------------------
montet = montet[(montet['Notes1'] == 0)]  #Filter out short-period binaries

#Temperature limit stars for analysis (sun-like stars only):
T_upper = 6000
T_lower = 5000
#Convert chosen temperature limits to B-V using method in Ramirez & Melendez (2005)
bv_upper = pyasl.Ramirez2005().teffToColor_nop("B-V", T_upper, 0.0)
bv_lower = pyasl.Ramirez2005().teffToColor_nop("B-V", T_lower, 0.0)

montet_bv = montet[(montet['B-V'] < bv_lower)]  #Filter stars by temperature
montet_bv = montet[(montet['B-V'] > bv_upper)]

montet = montet_bv[(montet_bv['Scatter'] <
                    10)]  #Remove high scatter stars (> 10)
montet = montet[(montet['Prot'] >
                 1)]  #Remove stars with rotations periods < 1 day

#----------------------------------------------------------------------------------------

fac = montet[(montet['Var'] == 'Faculae'
              )].reset_index()  #Montet stars identified as facula-dominated
spots = montet[(montet['Var'] == 'Spots'