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
# matplotlib parameters for publication plots | |
import matplotlib.pyplot as plt | |
import matplotlib.ticker as ticker | |
from matplotlib import gridspec | |
import re | |
import os | |
this_folder = os.path.dirname(__file__) | |
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
ssh -N -f -L port:server2:22 user@server1 | |
# mount the directory locally | |
sshfs -C -p port user@localhost:remote_directory local_directory(must exist) | |
# unmount | |
sudo umount local_directory |
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
/** | |
Calculates the eccentric anomaly at time t by solving Kepler's equation. | |
See "A Practical Method for Solving the Kepler Equation", Marc A. Murison, 2006 | |
@param t the time at which to calculate the eccentric anomaly. | |
@param period the orbital period of the planet | |
@param ecc the eccentricity of the orbit | |
@param t_peri time of periastron passage | |
@return eccentric anomaly. | |
*/ |
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 fun(teff=None, mass=None): | |
if teff and mass: | |
# gave two parameters | |
pass # goto 1 | |
elif teff: | |
# don't have mass, have teff | |
mass = f(teff) | |
elif mass: | |
# don't have teff, have mass | |
# teff = f(mass) |
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/env python | |
""" | |
Convert a PDF file to black&white and display it. | |
Run as: python bw.py input.pdf | |
""" | |
viewer = 'evince' | |
from contextlib import contextmanager | |
import tempfile |
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 sys | |
from astroquery.eso import Eso | |
eso = Eso() | |
# should use the default username | |
# and the keyring stored password | |
authentication = eso.login() | |
if not authentication: | |
raise RuntimeError('Something went wrong with authentication!') |
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 | |
import cStringIO | |
filename = 'example.rdb' | |
def read_rdb(filename): | |
""" Reads a .rdb file with possible comments '#' and header | |
col1 col2 col3 | |
---- ---- ---- | |
Returns a numpy record array |
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: |
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 fileinput | |
import os | |
# create a copy of the template parameter file | |
os.system('cp template_file new_file') | |
# for example, in the template you have | |
# par1 = 10 | |
# par2 = 'some path' | |
# and you want to change to |
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
real(kind=8) function pearsonr(x, y) result(r) | |
! given two arrays x and y, this function computes their Pearson correlation coefficient r | |
implicit none | |
real(kind=8), dimension(:) :: x, y | |
real(kind=8), dimension(size(x)) :: xt, yt | |
real(kind=8) :: ax, ay, df, sxx, sxy, syy | |
integer :: n | |
if (size(x) /= size(y)) STOP 'Dimension mismatch in pearsonr' | |