question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] Is it possible to store/save a starry model?

See original GitHub issue

I have generated a load of starry models by fitting to data, and I would like to save them so I can plot the model in future notebooks. I don’t think there is a feature to do this, and it’s not possible to use pickle on a starry.Map object.

I think the best way for me to do this currently is to save all the map amplitudes and dictionaries of the orbital parameters, and then re-initialize the model when I want to use it in a new notebook. I can totally do this for now, but if there is an easy way to store the models and then re-open them I’d love to use it!

Thanks C

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
taylorbell57commented, May 19, 2020

Upvoting this to allow for the combination of emcee and multiprocessing which requires a pickleable object or a new star and planet object to be created at each iteration which is a huge overhead time cost (2 ms for v0.3 or 8 ms for v1.0; that’s 100-400% of my current likelihood computation time without using starry). On a related note, v1.0 takes an order of magnitude longer just to update the map (2 us for v0.3 versus 3 ms for v1.0 for a planet that has a ydeg=1). The “Pre-computing some matrices… Done.” being repeated a million times when initialising a planet in each MCMC step is also pretty rough and is something I’ve commented out locally.

0reactions
jvinescommented, Aug 17, 2021

Well, after a clean install I got your snippet there working, and I coded up this:

def LC_model(theta, lds, time):
    """Evaluate light curve model.

    Parameters
    ----------
    theta: array_like
        Array with the orbital parameters.
    theta_ld: array_like
        Array with the kipping limb darkening coefficients.
    time: array_like
        The time array.
    model: starry.kepler.System
        The starry System object.
    law: str
        The limb darkening law.

    Returns
    -------
    flux: array
        The transit flux.
    """
    p = theta[0]
    e = theta[1]
    w = theta[2]
    tp = theta[3]
    rr = theta[4]
    b = theta[5]
    a = theta[6]
    
    inc = np.arccos(b / a) * 180 / np.pi
    star = starry.Primary(starry.Map(udeg=2))
    star.map[1] = lds[0]
    star.map[2] = lds[1]
    planet = starry.kepler.Secondary(starry.Map(amp=0),
                                     m=0, porb=p, inc=inc, ecc=e,
                                     r=rr, w=w, t0=tp)
    model = starry.System(star, planet)

    flux = model.flux(time)
    return flux

# Compile `slow_flux` into a theano function
starry.config.lazy = True
theta = tt.dvector()
lds = tt.dvector()
time = tt.dvector()
fast_flux = theano.function(
    [theta, lds, time],
    LC_model(theta, lds, time))

I’m unsure, however, if that’s the correct approach here, so any guidance would be appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature Requests: What are they and how to manage them
Feature requests are a form of product feedback you may frequently encounter as a SaaS product manager. They typically come in the form...
Read more >
Feature Requests: How to Collect Them and Engage Users in ...
Inside the idea board, customers should be able to see what other users have suggested. This way, they can check if the idea...
Read more >
Feature Request Template: How to Manage Suggestions at ...
Streamline and organize user feedback with this free feature request template. Available in Google Docs and Sheets (no email required).
Read more >
How To Manage Feature Requests [Template included]
This guide will teach you everything about feature requests – how to process them, manage them, respond to them, prioritize them – so...
Read more >
Increase your chances of a successful feature request
Feature requests by and large are submitted via ticket systems and a gatekeeper replies before consulting with product management as he or she...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found