Skip to content

Instantly share code, notes, and snippets.

@andycasey
Created December 13, 2015 23:25
Show Gist options
  • Select an option

  • Save andycasey/f6a4c15ff0d2390cb279 to your computer and use it in GitHub Desktop.

Select an option

Save andycasey/f6a4c15ff0d2390cb279 to your computer and use it in GitHub Desktop.
import numpy as np
from astropy.table import Table
import thecannon as tc
# The Ness et al. (2015) data is accessible from [URL]
labelled_set = Table.read("Ness_2015_labelled.csv")
normalized_flux = np.memmap("Ness_2015_normalized_flux.memmap",
mode="r", dtype=float)
normalized_ivar = np.memmap("Ness_2015_normalized_ivar.memmap",
mode="r", dtype=float)
# Reshape the flux and inverse variance arrays.
normalized_flux = normalized_flux.reshape((len(labelled_set), -1))
normalized_ivar = normalized_ivar.reshape((len(labelled_set), -1))
# Create a second-order polynomial model that contains a set of
# labelled fluxes and inverse variances.
model = tc.CannonModel(labelled_set, normalized_flux, normalized_ivar)
model.vectorizer = tc.vectorizer.NormalizedPolynomialVectorizer(labelled_set,
tc.vectorizer.polynomial.terminator(["TEFF", "LOGG", "PARAM_M_H"], 2))
# Train the model!
model.train()
# Plot some results.
fig = tc.diagnostics.label_residuals(model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment