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/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
Print the acknowledgements sentence with all the project references! | |
See acknowledgements.py -h or run acknowledgements.py ? for help or simply use as | |
acknowledgements.py Author1 Author2 | |
""" | |
name = 'acknowledgements' |
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
def develop(): | |
import reimport, os | |
mod = reimport.modified() | |
try: | |
mod.remove('__main__') | |
except ValueError: | |
pass | |
reimport.reimport(*mod) | |
print 'Done re-importing' |
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
#include <iostream> | |
#include <mkl.h> | |
#include <math.h> | |
#include <pybind11/pybind11.h> | |
#include <pybind11/numpy.h> | |
namespace py = pybind11; | |
using namespace pybind11::literals; | |
using namespace std; |
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 IPython import get_ipython | |
timer = lambda code: get_ipython().run_line_magic('timeit', '-o ' + code) | |
out = timer('pass') | |
out = timer('a = 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
import numpy as np | |
from scipy.stats import binned_statistic | |
from astropy.convolution import convolve, Box1DKernel | |
def f8(time, flux): | |
""" | |
Calculate the F8 statistic, as in Bastien et al. | |
Both `time` and `flux` should be numpy arrays. | |
The 8-hour flicker (F8) is determined by performing a 16-point (8 hour) | |
boxcar smoothing of the light curve, subtracting it from the original light curve |
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
# MIT Licensed | |
# Copyright (c) 2009-2010 Peter Shinners <pete@shinners.org> | |
# | |
# Permission is hereby granted, free of charge, to any person | |
# obtaining a copy of this software and associated documentation | |
# files (the "Software"), to deal in the Software without | |
# restriction, including without limitation the rights to use, | |
# copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the | |
# Software is furnished to do so, subject to the following |
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
gs -o - -sDEVICE=inkcov input.pdf | grep -v "^ 0.00000 0.00000 0.00000" | grep "^ " | wc -l |
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
def massTorres(teff, erteff, logg, erlogg, feh, erfeh, | |
ntrials=10000, corrected=True): | |
randomteff = teff + erteff * np.random.randn(ntrials) | |
randomlogg = logg + erlogg * np.random.randn(ntrials) | |
randomfeh = feh + erfeh * np.random.randn(ntrials) | |
# Parameters for the Torres calibration | |
a1 = 1.5689 | |
a2 = 1.3787 | |
a3 = 0.4243 |
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
import astropy.constants as c | |
import astropy.units as u | |
from math import pi | |
C = (2*pi*c.G)**(1/3) | |
# K [m/s] = C1 .... | |
C1 = C.to( (u.meter/u.second) * u.year**(1/3.) * (1/u.M_jup) * u.M_sun**(2/3.) ).value | |
# mp sini [Mjup] = C2 .... |