Skip to content

Instantly share code, notes, and snippets.

View rodluger's full-sized avatar
👽

Rodrigo Luger rodluger

👽
View GitHub Profile
@rodluger
rodluger / hack_syw_cache.py
Created September 8, 2022 19:18
Get showyourwork cache info
def get_cache_info(*args, **kwargs):
import inspect
from pathlib import Path
# Wait until the DAG has been built
snakemake.workflow.checkpoints.syw__dag.get()
# Get all jobs from the DAG
dag = None
levels = inspect.stack()
@rodluger
rodluger / oblate_sketch.py
Created September 1, 2021 18:27
Constructing an oblate stellar model in PyMC3 w/ starry
import pymc3 as pm
import pymc3_ext as pmx
import numpy as np
import starry
import theano.tensor as tt
from astropy import constants, units
import matplotlib.pyplot as plt
def get_stellar_inclination_prior(incstar):
@rodluger
rodluger / distributed_hack.py
Created June 2, 2021 23:10
Hack to allow importing `pymc3` without an internet connection
# Hack to allow importing `pymc3` without an internet connection
# This was fixed in https://github.com/dask/distributed/pull/3991
try:
import distributed
except Exception as e:
try:
import socket
getaddrinfo = socket.getaddrinfo
socket.getaddrinfo = lambda *args: [
@rodluger
rodluger / eigensolver.ipynb
Created February 21, 2021 21:52
Eigendecomposition trick for applying covariance matrix inverses w/ different white noise
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rodluger
rodluger / SyntheticLikelihood.ipynb
Created October 27, 2020 19:22
A toy synthetic likelihood problem
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rodluger
rodluger / brute-force-gp.py
Last active September 24, 2020 19:43
A brute-force implementation of a Gaussian process for stellar light curves
"""
A very simple / slow / inefficient / unstable implementation of a Gaussian
process for stellar light curves. We sample lots of surface maps from a
given distribution of spot sizes / locations / contrasts and compute the
empirical mean and covariance of the resulting distribution. In the limit
that our number of samples is infinite, this yields the meand and covariance
of the desired GP!
"""
import starry
import numpy as np
@rodluger
rodluger / degeneracies.py
Created September 19, 2020 16:39
Degeneracies in the light curve inversion problem for mapping stars and planets
import starry
import matplotlib.pyplot as plt
import numpy as np
from tqdm import tqdm
# Settings
starry.config.lazy = False
np.random.seed(12)
# Load a map of the earth
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rodluger
rodluger / vplanet_bfg.md
Last active June 20, 2018 17:40
Removing large files from git history

Cleaning the vplanet repo

Most of what we need to know is here. First we download BFG and create the alias

alias bfg='java -jar bfg-1.13.0.jar'

Note that we need the latest version of the Java Runtime Environment installed.