Skip to content

Instantly share code, notes, and snippets.

View boada's full-sized avatar

Steven Boada boada

View GitHub Profile
from glob import glob
from astropy import table
import h5py as hdf
from os.path import exists
files = glob('*.fit')
for f in files[:2]:
print f, '.....',
if not exists(f.replace('fit', 'hdf5')):
from glob import glob
from astropy import table
from astropy.io import fits
from os.path import exists
files = glob('*.fit')
for f in files:
print f, '.....',
if not exists(f.replace('fit', 'hdf5')):
import numpy as np
data = np.loadtxt('testfile, delimiter=',')
data = np.loadtxt('testfile', delimiter=',')
data = np.genfromtxt('testfile', delimiter=',')
data
x = -np.ones(6)
x
bad = np.isnan(data)
bad
x[~bad] = data[~bad]
@boada
boada / gist:d6b2ed39c58de74f4cfb
Last active August 29, 2015 14:25
Gist of im_scale.py
import numpy
import math
def sky_median_sig_clip(input_arr, sig_fract, percent_fract, max_iter=100):
"""Estimating sky value for a given number of iterations
@type input_arr: numpy array
@param input_arr: image data array
@type sig_fract: float
@param sig_fract: fraction of sigma clipping
@boada
boada / gist:ab8abde12c07faf411ea
Last active October 13, 2015 21:25
mk_thumbs
from astLib import astImages
from astLib import astWCS
def mk_thumb_wcs(header,data,ra,dec,window,output):
try:
wcs = astWCS.WCS(header,mode='pyfits')
except:
wcs = astWCS.WCS(header,mode='pyfits',extensionName='SCI')
#File: get_band_phot.py
#Created: Sun 14 Oct 2012 02:54:10 PM CDT
#Last Change: Sat Feb 2 14:40:52 2013
#Author: Steven Boada
# This script returns a magnitude in the provided
# bandpass of the given spectrum. Make sure that
# wavelength units are the same for both inputs.
#
# flux units must be: FLUX / Angstrom
#
def mk_thumb_wcs(header,data,ra,dec,window,output):
try:
wcs = astWCS.WCS(header,mode='pyfits')
except:
wcs = astWCS.WCS(header,mode='pyfits',extensionName='SCI')
imdict = astImages.clipImageSectionWCS(data, wcs, ra, dec,
window, returnWCS=True)
thumb = imdict['data'] #data array
from __future__ import division
from scipy import stats
import numpy as np
def mklogMass(theta):
''' Makes Log10 Mass from a given richness following the simet2016
mass-richness relationship.
'''
m0, alpha, lambda0 = theta
import astroplan
from astroplan import Observer, FixedTarget
from astropy.coordinates import SkyCoord
from astropy.time import Time, TimeDelta
from astroplan.constraints import AtNightConstraint, AirmassConstraint
import pandas as pd
import numpy as np
def mst2utc(time):
''' Converts from MST to UTC '''
@boada
boada / mk_RGB.py
Last active November 28, 2018 15:21
def make_RGB(self, newfirm=False, conf='stiff-common.conf'):
try:
print()
check_exe('stiff')
except FileNotFoundError:
return
_conf = os.path.join(pipeline, 'confs', conf)