Skip to content

Instantly share code, notes, and snippets.

@jiffyclub
jiffyclub / jdutil.py
Created Oct 18, 2011
Functions for converting dates to/from JD and MJD
View jdutil.py
"""
Functions for converting dates to/from JD and MJD. Assumes dates are historical
dates, including the transition from the Julian calendar to the Gregorian
calendar in 1582. No support for proleptic Gregorian/Julian calendars.
:Author: Matt Davis
:Website: http://github.com/jiffyclub
"""
@jiffyclub
jiffyclub / msky.py
Created Oct 25, 2011
Find modal sky on an array.
View msky.py
import numpy, pylab, scipy
from scipy import optimize
# Uses MEANCLIP from above
from meanclip import meanclip
def msky(inarray, do_plot=0, verbose=0, ptitle='', func=0):
"""
Find modal sky on an array.
@jiffyclub
jiffyclub / mytotal.py
Created Oct 25, 2011
Collapse 2-D array into one dimension.
View mytotal.py
import numpy
# Uses MEANCLIP from above
from meanclip import meanclip
def mytotal(inarray, axis, type='meanclip'):
"""
Collapse 2-D array in one dimension.
.. note:: MYTOTAL routine from ACS library.
@jiffyclub
jiffyclub / meanclip.py
Created Oct 25, 2011
Computes an iteratively sigma-clipped mean on a data set. Clipping is done about median, but mean is returned.
View meanclip.py
import numpy
def meanclip(indata, clipsig=3.0, maxiter=5, converge_num=0.02, verbose=0):
"""
Computes an iteratively sigma-clipped mean on a
data set. Clipping is done about median, but mean
is returned.
.. note:: MYMEANCLIP routine from ACS library.
@jiffyclub
jiffyclub / gist:1310949
Created Oct 25, 2011
Calculate a resistant estimate of the dispersion of a distribution. For an uncontaminated distribution, this is identical to the standard deviation.
View gist:1310949
import numpy
def robust_sigma(in_y, zero=0):
"""
Calculate a resistant estimate of the dispersion of
a distribution. For an uncontaminated distribution,
this is identical to the standard deviation.
Use the median absolute deviation as the initial
estimate, then weight points using Tukey Biweight.
@jiffyclub
jiffyclub / gausspsf2d.py
Created Oct 25, 2011
Simpler version of `PSF_GAUSSIAN` in IDL.
View gausspsf2d.py
"""
Simpler version of `PSF_GAUSSIAN` in IDL.
:Authors: Pey Lian Lim (Python)
:Organization: Space Telescope Science Institute
:History:
* 2010/08/17 PLL converted from IDL to Python.
"""
# External modules
import numpy
@jiffyclub
jiffyclub / homework5-3.py
Created Nov 18, 2011
AI Class Homework 5.3 Demo in Python
View homework5-3.py
"""
This script models the behavior of the agent in AI Class
Homework 5, Problem 3: http://youtu.be/212NkM6UCBc
The script prints the model grid and the total number of times a square was
visited by the agent over some number of simulations.
No actual TD-learning takes place in this script, the agent simply tries to
move from the start to the goal by moving to road squares on its preset path.
@jiffyclub
jiffyclub / hedit.py
Created Nov 25, 2011
Python 2.7+ compatible script for adding and modifying FITS header values. Can work on multiple files. This is a wrapper around pyfits.setval to make it accessible from the command line.
View hedit.py
#!/usr/bin/env python
"""
Add or modify a header value. Type hedit -h for help.
Requires pyfits and Python 2.7+.
Author
------
@jiffyclub
git.io/jiffyclub
@jiffyclub
jiffyclub / imhead.py
Created Nov 25, 2011
Python 2.7+ script for printing a FITS header. Accepts multiple files and, optionally, keywords. This is a wrapper around pyfits.getheader to make it accessible from the command line.
View imhead.py
#!/usr/bin/env python
"""
Print a FITS header or keyword. Type imhead -h for help.
Requires pyfits and Python 2.7+.
Author
------
@jiffyclub
git.io/jiffyclub
@jiffyclub
jiffyclub / hedit.py
Created Nov 28, 2011
Python 2.3+ compatible script for adding and modifying FITS header values. Can work on multiple files. This is a wrapper around pyfits.setval to make it accessible from the command line.
View hedit.py
#!/usr/bin/env python
"""
Add or modify a header value. Type hedit.py -h for help.
Requires pyfits.
Author
------
@jiffyclub
git.io/jiffyclub
You can’t perform that action at this time.