Apply t-SNE to galaxy spectra from two different simulations.
First import some modules
import numpy as np
%matplotlib inline
""" | |
Taken from https://stackoverflow.com/questions/22840092/unpickling-data-from-python-2-with-unicode-strings-in-python-3 | |
Updated for numpy bytes_ object | |
""" | |
import numpy as np | |
def bytes_to_unicode(ob): | |
t = type(ob) |
#!/bin/bash | |
# Clear output file | |
> out.csv | |
while read f; do | |
# read in line to array, comma delimited | |
arrIn=(${f//,/ }) |
from scipy.stats import binned_statistic | |
import random | |
def resample_distribution(x, y, k=300, bin_limits=None): | |
""" | |
Resample y to fit distribution of x | |
Args: | |
x, y (array) distributions | |
k (int) number of samples |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Mondrian Generator</title> | |
<script src="https://d3js.org/d3.v4.js" charset="utf-8"></script> | |
<style> | |
</style> | |
</head> | |
<body> |
$ git filter-branch --tag-name-filter cat --index-filter 'git rm -r --cached --ignore-unmatch filename' --prune-empty -f -- --all | |
$ rm -rf .git/refs/original/ | |
$ git reflog expire --expire=now --all | |
$ git gc --prune=now | |
$ git gc --aggressive --prune=now | |
$ git push origin --force --all | |
$ git push origin --force --tags |
To use this stylesheet, you need to put it inside your mplconfig_dir
. By default, mpl_configdir
should be ~/.config/matplotlib
, but you can check where yours is with matplotlib.get_configdir()
. You can then import it with styleuse('sm')
.
Based on work by Monica L. Turner, http://space.mit.edu/~turnerm/python.html (accessed 5/7/2016)
library(MASS) | |
# generate a million lognormal samples | |
n <- 1000000 | |
dat <- rlnorm(n, meanlog = 0, sdlog = 1) | |
# add some noise (optional) | |
dat <- dat + runif(n, 0, 1) | |
# create a vector of histogram breaks |
from IPython.display import HTML | |
# Youtube | |
HTML('<iframe width="560" height="315" src="https://www.youtube.com/embed/S_f2qV2_U00?rel=0&controls=0&showinfo=0" frameborder="0" allowfullscreen></iframe>') | |
# Vimeo | |
HTML('<iframe src="https://player.vimeo.com/video/26763844?title=0&byline=0&portrait=0" width="700" height="394" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe><p><a href="https://vimeo.com/26763844">BAXTER DURY - CLAIRE (Dir Cut)</a> from <a href="https://vimeo.com/dannysangra">Danny Sangra</a> on <a href="https://vimeo.com">Vimeo</a>.</p>') |
library(FITSio) | |
library(sphereplot) | |
library(cosmoFns) | |
library(devtools) | |
## Data | |
data <- FITSio::readFITS("WP8_photoz_XMM_LSS.fits", hdu = 2) | |
dt <- data.frame(data$col) |