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 / templates.ipynb
Last active April 21, 2020 21:36
Template for .ipynb, things to import or load at the beginning
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@astro313
astro313 / nH.py
Created July 25, 2019 21:23
check nHden from cloudy output hden and saved grid param file
gridfile = '/mnt/home/daisyleung/Downloads/SIGAME_dev/sigame/temp/z6_data_files/cloud_models/GMC/grids/GMCgrid_abun_z6_em.models'
import glob
import pandas as pd
import numpy as np
gridsDF = pd.read_pickle(gridfile)
nHmw = gridsDF['nHmw']
nHmin = gridsDF['nHmin']
#
@astro313
astro313 / DeepSpace.md
Created July 1, 2019 17:13 — forked from jakgel/DeepSpace.md
Some notes about marrying astrophysics with modern machine learning with particular focus on deep learning.

Machine learning and deep learning in astronomy:

Machine learning has a long history in astronomy, but deep learning (DL) only got traction since arount 2016. Here I will list current DL effords:

The main field of ML applications in astrophysics is object classification. With source counts now ranging into the 107-108 for most surveys, machine learning is put to use to allow the classification of a large number of sources which would otherwise need an infeasible amount of manpower:

@astro313
astro313 / kde.py
Last active January 31, 2019 03:47
kde plot
import numpy as np
import matplotlib.pyplot as pl
import scipy.stats as st
data = np.random.multivariate_normal((0, 0), [[0.8, 0.05], [0.05, 0.7]], 100)
x = data[:, 0]
y = data[:, 1]
xmin, xmax = -3, 3
ymin, ymax = -3, 3
if [ -f ~/.bash_profile ]; then
. ~/.bash_profile
fi
@astro313
astro313 / clump_handling.py
Last active September 7, 2018 21:41
yt bug fix clump finder for Kavli project
"""
DL and AP's edit to yt clump_finder to fix bugs and make it work, in order to do science with the Kavli project.
Last mod: July 17th 2018
PATH: blah blah (ipython installation path)/lib/python2.7/site-packages/yt/analysis_modules/level_sets/
Clump finding helper classes
@astro313
astro313 / mpl_symbols.py
Last active August 24, 2018 18:11
list of colors and symbols for MPL
import matplotlib.cm as cm
max_color = 15.0 #Set maximum color index
color_gradient = cm.jet(arange(max_color)/max_color) #Set up color list from a canned color bar found in python
color_list = ['black','gray','darkorange','blue','red','green','orange','magenta','darkgoldenrod','purple','deeppink','darkolivegreen', 'cyan','yellow','beige']
symbol_list = ['o','v','8','x','s','*','h','D','^','8','1','o','o','o','o','o','o','o'] #Symbol list for rotation ladders on black and white Boltzmann plot
#for c in matplotlib.colors.cnames:
#color_list.append(c)
@astro313
astro313 / cloudMassCDF.py
Created July 18, 2018 00:10
Cloud mass CDF
# --- Cloud mass distribution, of clouds ID across all snapshots -----
fig = plt.figure()
ax = fig.add_subplot(111)
allmasses = []
for snap in ss.iterkeys():
for snapleafs in ss[snap].iterkeys():
allmasses.append(ss[snap][snapleafs].mass_Msun)
@astro313
astro313 / massFunc.py
Created July 17, 2018 22:34
Mass function
def mass_function(data, logged=False,
nbins=35, verbose=True):
"""
Calculates a mass function from data, using 3 methods.
Parameters
----------
data: array
logged: boolean
@astro313
astro313 / price.rb
Created October 21, 2017 17:33
Get latest stock price using Ruby, enter symbol as argument
'''
from https://gist.github.com/IndianGuru/1192249
Working, as of 21 Oct 2017
'''