This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
from scipy.interpolate import LSQUnivariateSpline | |
def continuum(wave, flux, type='ratio', order=1, low_reject=2, high_reject=0, | |
niter=10): | |
m1 = np.ones_like(wave, dtype=np.bool) # use all points at first | |
m1 &= flux!=0 # but remove those where flux = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import sin | |
from scipy import optimize | |
sine = lambda t, p: p[0] * sin(1. / p[1] * t + p[2]) + p[3] | |
sinefit = lambda t, y, ye, p0, **kwargs: optimize.leastsq(lambda p, t, y, ye: (sine(t, p) - y)/ye, p0, args=(t, y, ye), **kwargs)[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
months = { | |
'Jan': 1, | |
'Feb': 2, | |
'Mar': 3, | |
'Apr': 4, | |
'May': 5, | |
'Jun': 6, | |
'Jul': 7, | |
'Aug': 8, | |
'Sep': 9, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
############################################################################### | |
# the following is mostly a copy of the scipy implementation of | |
# binned_statistic and binned_statistic_dd | |
# but allowing for a weights parameter | |
from scipy._lib.six import callable, xrange | |
from scipy._lib._numpy_compat import suppress_warnings | |
## careful here! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sympy import symbols, sin, nsolve | |
E = symbols('E') | |
def eccentric_anomaly(M, ecc, prec=15): | |
return nsolve(E - e*sin(E) - M, M, prec=prec) | |
import mpmath as mp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sympy import * | |
from astropy.constants import G | |
import astropy.units as u | |
G = G.to(u.m**3 / (u.solMass * u.s**2)) | |
f_rhs = lambda P, K, e: (P * K**3 * (1 - e**2)**(3/2)) / (2 * pi * G.value) | |
f_lhs = lambda m1, m2, i: (m2**3 * sin(i)) / (m1 + m2)**2 | |
# the earth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sh downloadRequestNNNNNNscript.sh -X "-P 8 -L 1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
try: # numba will provide a ~2x speedup | |
from numba import jit | |
except ImportError: # but we can do without it | |
jit = lambda fn: fn | |
@jit | |
def massTorres(teff, erteff, logg, erlogg, feh, erfeh, | |
ntrials=10000, corrected=True, add_intrinsic=True): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.aanda.org/67-author-information/frequent-abbreviations | |
name_abbrv = { | |
'Astronomy and Astrophysics': 'A&A', | |
'Astronomy & Astrophysics': 'A&A', | |
'Monthly Notices of the Royal Astronomical Society': 'MNRAS', | |
'The Astrophysical Journal': 'ApJ', | |
'The Astronomical Journal': 'AJ', | |
'Publications of the Astronomical Society of the Pacific': 'PASP', | |
'Annual Review of Astronomy and Astrophysics': 'ARA&A' , |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/env/python | |
# -*- coding: utf-8 -*- | |
# Written by Pedro Figueira. | |
# Original version can be found at https://pedrofigueira@bitbucket.org/pedrofigueira/bayesiancorrelation | |
# Modified by João Faria | |
"""Bayesian Correlation. | |
Usage: |