Skip to content

Instantly share code, notes, and snippets.

View jobovy's full-sized avatar
:octocat:

Jo Bovy jobovy

:octocat:
View GitHub Profile
@jobovy
jobovy / test_py3_nose.py
Last active August 29, 2015 14:12
Show python3 warnings for specific module when running a test suite with nose
# Run this as
# python -3 MODULE TESTFILE NOSETESTS_OPTIONS
# where:
# MODULE: module that you want to check for python3 compatibility
# TESTFILE: file with tests
# NOSETESTS OPTIONS: other options that you would give to nosetests (e.g., -v, -x, --nocapture)
import sys
import warnings
import nose
@jobovy
jobovy / README.rst
Last active August 29, 2015 14:27
Python script to create non-axisymmetric velocity fields with galpy

Usage

The Python script nonaxi_velocity_field.py can be used to compute the velocity distribution function using the backwards-integration method of Dehnen (2000), as implemented in galpy (Bovy 2015). You can use the nonaxi_velocity_field.py code in a few different ways:

python nonaxi_velocity_field.py -h

gives information on the various options. Possible ways to run the code are:

python nonaxi_velocity_field.py bar_altrect_vr.ps \
@jobovy
jobovy / README.rst
Last active August 29, 2015 14:27
Some IDL code for Meszaros et al. (2015)

This gist contains some code used in Meszaros et al. (2015) pertaining to the analysis of multiple populations in globular clusters using the extreme deconvolution algorithm. The necessary data files are available upon request.

The basic use of the code is to run:

IDL> analyze_gc, gc=2, ngauss=2, outfilename='m2pho_2comp.fits'

This runs the analysis on a given globular cluster (see read_gc.pro for the mapping between gc and globular cluster). The produced output file is a fits file that has the ID, the component that the XD code assigns (xdpop), the probability of that assignment (logp, actually the natural log of the probability), and the population that was in the original data file from a preliminary analysis of membership probability. Information on the best-fit amplitudes, means, and covariances of the populations is printed directly.

@jobovy
jobovy / plot_distance_cohorts.py
Last active August 29, 2015 14:27
Some simple scripts to look at the distance distribution of APOGEE-1 stars in different parts of the Galaxy with different color cuts, in preparation for APOGEE-2
import sys
import numpy
from galpy.util import bovy_plot
import apogee.tools.read as apread
from matplotlib import pyplot
_DISTTAG= 'DISO_GAL'
def plot_distance_cohorts(plotfilename,region='inner'):
#Read the data
data= apread.allStar(adddist=True,distredux='v402',main=True)
#Cut the data to the relevant region
@jobovy
jobovy / README.rst
Last active August 29, 2015 14:27
Code for reproducing the figures in Bovy & Tremaine (2012) http://adsabs.harvard.edu/abs/2012ApJ...756...89B

These Python scripts can be used to reproduce the figures in Bovy & Tremaine (2012): On the local dark matter density.

Figure 1 is produced by:

python plot_dvcapprox.py

while Figure 2 is produced by:

python plot_sigmaz.py
@jobovy
jobovy / koposov10.py
Last active August 29, 2015 14:27
Data files and code to work with data from Koposov et al. (2010)
#Module to read and process the Koposov et al. (2010) data
import os
import numpy
from galpy.util import bovy_coords
_DATADIR='../data/'
# Koposov et al. (2010) transformation matrix
_TKOP= numpy.zeros((3,3))
_TKOP[0,:]= [-0.4776303088,-0.1738432154,0.8611897727]
_TKOP[1,:]= [0.510844589,-0.8524449229,0.111245042]
_TKOP[2,:]= [0.7147776536,0.4930681392,0.4959603976]
@jobovy
jobovy / post-commit
Last active October 3, 2016 17:10
Modified version of Andy Casey's (@andycasey) post-commit hook to run latexdiff between different revisions of a latex draft (see http://astrowizici.st/blog/2013/10/04/publishing-with-git); works on Macs and when the paper is in a sub-directory of the main git repository.
#!/bin/sh
# Post-commit hook for revision-awsm-ness
function gettempfilename()
{
tempfilename=$1-$RANDOM$RANDOM.tex
if [ -e $tempfilename ]
then
tempfilename=$(gettempfilename)
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.
@jobovy
jobovy / SimpleBarModel.ipynb
Created January 4, 2017 19:51
A very simple bar model for the Milky Way in galpy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.