Skip to content

Instantly share code, notes, and snippets.

View astro313's full-sized avatar

T. K. Daisy Leung astro313

  • New York, NY
View GitHub Profile
@astro313
astro313 / binary.py
Created October 21, 2017 15:59
Binary search function
import math
def binary_search(array, search):
m = 0
i = 0
z = len(array) - 1
while i<= z:
m = math.floor(i + ((z - i) / 2))
if array[m] == search:
return m
@astro313
astro313 / pbcor.py
Last active July 25, 2019 21:25
calculate pb correction factor
import astropy.coordinates as coord
import astropy.units as u
from astropy.io import fits
import numpy as np
nobs = 2
RA = ["04:36:57.01063", "04:36:57.03377"]
Dec = ["-54:38:08.36884", "-54:38:09.77425"]
@astro313
astro313 / plotBWcoverage.py
Last active February 25, 2017 21:03
for zsearch project -- show the spectral coverage for different SGs to identify overlapping ones
'''
show the spectral coverage for different SGs to identify overlapping ones...
Last mod: 25 Feb 2017
'''
import numpy as np
@astro313
astro313 / vdispRE.py
Created February 3, 2017 22:32
convert between vdisp, R_E, M_E
'''Convert between R_E to vdisp and M_E
one z_lens, one z_source, one R_E at a time
'''
import numpy
#HELMS59
@astro313
astro313 / FFT_img.py
Created December 29, 2016 00:16
testing fft residual
#! /usr/bin/env python
'''
Reads in image data from a FITS file. It transforms the image using FFT.
Plot the original image, the real part and the imaginary part of the transform, and the inverse transform -- real part, which should be equal to the original image, and a imaginary part.
The last panel = residual, and shows the quality of the FFT = original image - real part of the inverse FFT image.
@astro313
astro313 / emcee_indSample.py
Created September 20, 2016 02:23
use emcee to generate ~N ind. samples
import emcee
import numpy as np
# TODO:
# write something using sampler.sample() instead of predefined niter to ensure we have enough uncorrelated sample after run..
nindependent = 0
nind = 500
niter = 1000
attempts = 10
counter = 0
@astro313
astro313 / galLunchRand.py
Created September 8, 2016 20:57
Pick people for gal lunch randomly
import random
peeps = [
'Dominik',
'Martha',
'Gordon',
'Thomas',
'Henrik',
'Tyler',
'Luke',
@astro313
astro313 / memReport.py
Created August 29, 2016 15:50
Check mem status
#!/usr/bin/python
'''
from http://apple.stackexchange.com/questions/4286/is-there-a-mac-os-x-terminal-version-of-the-free-command-in-linux-systems
'''
import subprocess
import re
# Get process info
@astro313
astro313 / bash-cheatsheet.sh
Created June 14, 2016 08:26 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@astro313
astro313 / DaisyInteLumTest.py
Last active May 6, 2016 17:39
testing IR luminosity based on SED models in .txt
'''
Just integrating a model SED in observed frame from mbb & RP's output
Last Modified: 05 May 2016
'''
from astropy.cosmology import WMAP9
import numpy as np