Skip to content

Instantly share code, notes, and snippets.

View benjaminrose's full-sized avatar

Benjamin Rose benjaminrose

View GitHub Profile
@benjaminrose
benjaminrose / ScatterToContour.py
Last active August 29, 2015 13:59
Creating a function that takes two vectors used to make a scatter plot and converts them into the three arrays need for a contour plot.
import numpy as np
import matplotlib.pyplot as plt
def ScatterToContour(x,y, bins=[10,10]):
'''
x is the x location of the points
y is the y location of the points
len(x) needs to equal len(y)
bins determins the refinement of the histogram and line edges.
All contour plot perameters (levels, ect.) are defined outside
@benjaminrose
benjaminrose / scale_conversion.py
Created January 2, 2015 17:47
Convert [0,36-) to [-180,180)
'this still needs better testing, espcially to work with numpy'
'needs to work with degrees and radians'
def convert(x):
'x is a list, would like it to work with numpy'
ind = x>180
for i,j in enumerate(ind):
if j:
l[i]-=360
return x
@benjaminrose
benjaminrose / AllSky.py
Created February 19, 2015 19:51
An example of using all sky projections in matplotlib.pyplot.
import matplotlib.pyplot as plt
import numpy as np #casue it rocks
# get random values to plot
#needs to be in radians from (-pi,pi) & (-pi/2, pi/2)
a = np.random.rand(100)*2*np.pi - np.pi
d = np.random.rand(100)*np.pi - np.pi/2
#todo(make values astropy.cooridnates and use wrap_at(180*u.degree). Allows for more varriable data.
#make figure
@benjaminrose
benjaminrose / ApJ-template.tex
Last active August 29, 2015 14:25
A templates for my latex documents
% \documentclass[apj, iop]{emulateapj}
% use for a preview of the final version
\documentclass[manuscript]{aastex}
%[manuscript] = defualt, and how you submit
%[preprint] = one-column, single-spaced document
%[preprint2] = double-column, single-spaced document
\usepackage{graphicx}% Include figure files
\usepackage{color}%for preprints
\usepackage{hyperref}
@benjaminrose
benjaminrose / save_data.py
Last active June 2, 2021 23:24
This is an useful example of how I like to save my data using numpy and savetxt.
import numpy as np
#create random data
data1 = np.random.rand(10)
data2 = np.random.rand(10)
data3 = np.random.rand(10)
#stack data into one ojbect
data_list = np.dstack((data1, data2, data3))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@benjaminrose
benjaminrose / Understanding seps ellipical scaling.ipynb
Last active May 23, 2016 14:21
This was a notebook I made trying to understand `sep` and `Source Extractor`'s scaling of elliptical parameters.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@benjaminrose
benjaminrose / sep.mask_ellipse vs matplotlib ellipse.ipynb
Created June 15, 2016 19:31
An example of how to use `sep.mask_ellipse` with `matplotlib.patches.Ellipse`.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.