Skip to content

Instantly share code, notes, and snippets.

David W. Hogg davidwhogg

Block or report user

Report or block davidwhogg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@davidwhogg
davidwhogg / Galah-demo.ipynb
Created Jul 18, 2018 — forked from adrn/Galah-demo.ipynb
Galah-for-Hogg.ipynb
View Galah-demo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Get_all_the_TGAS_data_by_curl.sh
#!/bin/bash
curl -O http://cdn.gea.esac.esa.int/Gaia/tgas_source/fits/TgasSource_000-000-000.fits
curl -O http://cdn.gea.esac.esa.int/Gaia/tgas_source/fits/TgasSource_000-000-001.fits
curl -O http://cdn.gea.esac.esa.int/Gaia/tgas_source/fits/TgasSource_000-000-002.fits
curl -O http://cdn.gea.esac.esa.int/Gaia/tgas_source/fits/TgasSource_000-000-003.fits
curl -O http://cdn.gea.esac.esa.int/Gaia/tgas_source/fits/TgasSource_000-000-004.fits
curl -O http://cdn.gea.esac.esa.int/Gaia/tgas_source/fits/TgasSource_000-000-005.fits
curl -O http://cdn.gea.esac.esa.int/Gaia/tgas_source/fits/TgasSource_000-000-006.fits
curl -O http://cdn.gea.esac.esa.int/Gaia/tgas_source/fits/TgasSource_000-000-007.fits
curl -O http://cdn.gea.esac.esa.int/Gaia/tgas_source/fits/TgasSource_000-000-008.fits
View weighted_median.py
import numpy as np
from scipy.interpolate import interp1d
def weighted_median(xs, ws=None):
if ws is None:
ws = np.ones_like(xs)
totalw = np.sum(ws)
sindx = np.argsort(xs) # expensive
cs = np.cumsum(ws[sindx]) / totalw
symcumsum = 0.5 * (cs + np.append(0., cs[0:-1]))
View hoggsumexp
import numpy as np
def hoggsumexp(qns, dqn_dams, diag=False):
"""
# purpose:
- Computes L = log(sum(exp(qns, axis=-1))).
- Also computes its M-dimensional gradient components dL / da_m.
# input
- qns: ndarray of shape [n1, n2, n3, ..., nD, N]
View make random hashes for M-S DSE Summit
import numpy as np
def int_string(x, base, digits):
xx = x + 0
str = ""
for i in range(digits):
str = (xx % base).__str__() + str
xx /= base
return str
@davidwhogg
davidwhogg / beliefs.py
Last active Aug 29, 2015
testing Hogg's linear algebra beliefs
View beliefs.py
import numpy as np
import scipy.linalg as la
# create data matrix and design matrices A (for sinusoids) and B (for nuisances) and M (for both)
y = np.random.normal(size=(100)) # data
A = np.random.normal(size=(2, 100)) # components we care about
B = np.random.normal(size=(10, 100)) # nuisance components
M = np.vstack((B, A))
C = np.diag(0.25 * np.ones(100))
Cinv = np.diag(4.00 * np.ones(100))
View gist:11275291
import numpy as np
import time as tt
def main():
timing = np.array([])
log2N = np.arange(6) + 8
for N in 2 ** log2N:
uu = np.random.normal(size=(N, N+2))
matrix = np.dot(uu, uu.T)
print matrix.shape
View gist:4719653
<img width="20" height="20" align="absmiddle" src="http://octodex.github.com/images/nyantocat.gif" class="emoji" alt=":nyantocat:">
@davidwhogg
davidwhogg / README.md
Created Nov 15, 2012 — forked from dfm/README.md
Get some stars.
View README.md

First install the Python module:

pip install casjobs

Then set the environment variables:

export CAS_DR9_WSID="1234567890" # get yours here: http://skyserver.sdss3.org/CasJobs/ChangeDetails.aspx
@davidwhogg
davidwhogg / gist:3875572
Created Oct 11, 2012
I don't really know what a gist is, but here is one
View gist:3875572
echo Hello World
You can’t perform that action at this time.