Code Monkey home page Code Monkey logo

stardate's Issues

Fully-convective stars

Hi @RuthAngus!

I'm interested in using stardate for a project I'm working on with fully-convective stars. I see in your paper's Discussion section that these stars perhaps shouldn't trusted with stardate.ย I'm wondering if you could elaborate a bit on what circumstances need to be met to trust stardate ages for fully-convective stars?

Thanks so much ๐Ÿ˜„

Issues when testing stardate

I installed stardate on a new python=3.8 conda environment, following the instructions.

The following example MCMC fits from the readthedocs run fine (no error), but I am not getting the right results:

My code:

import stardate as sd

# Create a dictionary of observables
iso_params = {"teff": (4386, 50),     # Teff with uncertainty.
              "logg": (4.66, .05),    # logg with uncertainty.
              "feh": (0.0, .02),      # Metallicity with uncertainty.
              "parallax": (1.48, .1),  # Parallax in milliarcseconds.
              "maxAV": .1}            # Maximum extinction

prot, prot_err = 29, 3

# Set up the star object.
star = sd.Star(iso_params, prot=prot, prot_err=prot_err)  # Here's where you add a rotation period

# Run the MCMC
star.fit(max_n=1000)

# max_n is the maximum number of MCMC samples. I recommend setting this
# much higher when running for real, or using the default value of 100000.

# Print the median age with the 16th and 84th percentile uncertainties.
age, errp, errm, samples = star.age_results()
print("stellar age = {0:.2f} + {1:.2f} + {2:.2f}".format(age, errp, errm))

I get as an output 0.42 + 0.32 + 3.37 rather than 2.97 + 0.60 + 0.55, and the bias towards low stellar ages remains even for larger numbers of steps (10,000).

When directly calling the Praesepe model to get period from age or age from period however, I am getting the expected values.

Another issue is that I am getting 3 failed tests when running pytest (see below).

platform darwin -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0
rootdir: /Users/caroline/Research/GitHub/stardate
collected 13 items                                                                                    

test/isochrone_test.py F                                                                        [  7%]
test/lhf_test.py ..F..F......                                                                   [100%]

============================================== FAILURES ===============================================
___________________________________________ test_iso_lnlike ___________________________________________

    def test_iso_lnlike():
    
        iso_params = {"teff": (5770, 10),
                    "feh": (0, .01),
                    "logg": (4.44, .1),
                    "parallax": (1, 1)}
    
        mod = SingleStarModel(mist, **iso_params)  # StarModel isochrones obj
        params = [354, np.log10(4.56*1e9), 0., 1000, 0.]
        lnparams = [354, np.log10(4.56*1e9), 0., np.log(1000), 0.]
        lnpr = mod.lnprior(params)
        # lnparams = [350, 9, 0., 6, 0.]
        args1 = [mod, iso_params]
    
        # Calculate the lnprob above
        iso_lp = iso_lnprob(lnparams, *args1)
        start = time.time()
        for i in range(100):
            iso_lp = iso_lnprob(lnparams, *args1)
        end = time.time()
    
        # Calculate the stardate lnprob
        args2 = [mod, None, None, True, False, True, "praesepe"]
    
        start = time.time()
        for i in range(100):
            lp = lnprob(lnparams, *args2)[0]
        end = time.time()
        # print("time = ", end - start)
    
        ll = lnlike(lnparams, *args2)
        lnprior = lp - ll
    
        assert iso_lp == lp
        assert np.isclose(iso_lp - lnpr, ll)
>       assert lnpr == lnprior
E       assert -18.46720822861122 == -18.46720822861107

test/isochrone_test.py:62: AssertionError
____________________________________________ test_calc_bv _____________________________________________

    def test_calc_bv():
        sun = [355, np.log10(4.56*1e9), 0., np.log(1000), 0.]
        bv_sun = calc_bv(sun)
>       assert .6 < bv_sun, "Are you sure you're on the isochrones eep branch?"
E       AssertionError: Are you sure you're on the isochrones eep branch?
E       assert 0.6 < 0.42834431703148956

test/lhf_test.py:92: AssertionError
_______________________________________ test_gyro_model_rossby ________________________________________

    def test_gyro_model_rossby():
        """
        Make sure that the rossby model gives Solar values for the Sun.
        Make sure it gives a maximum rotation period of pmax.
        """
        age = np.log10(4.56*1e9)
        sun = [355, age, 0., np.log(1000), 0.]
    
        # iso_params = {"teff": (5777, 10),
        #               "logg": (4.44, .05),
        #               "feh": (0., .001),
        #               "parallax": (1., .01),  # milliarcseconds
        #               "B": (15.48, 0.02)}
    
        # # Set up the StarModel isochrones object.
        # mod = StarModel(mist, **iso_params)
        # # the lnprob arguments]
        # args = [mod, 26., 1., False, True, "praesepe"]
        # print(lnprob(sun, *args))
        # assert 0
    
        prot_sun = 10**gyro_model_rossby(sun, model="praesepe")[0]
>       assert 21 < prot_sun
E       assert 21 < 6.909888089400217

test/lhf_test.py:142: AssertionError

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.