This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import warnings | |
import sys | |
import astropy.io.fits as pyfits | |
from astropy.table import Table | |
print("opening FITS file ...") | |
f = pyfits.open(sys.argv[1]) | |
print("extensions: ", [e.name for e in f]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from getdist.mcsamples import MCSamples | |
import getdist.chains | |
def highest_density_interval_from_samples(xsamples, xlo=None, xhi=None, probability_level=0.68): | |
""" | |
Compute the highest density interval (HDI) from posterior samples. | |
Parameters | |
---------- | |
xsamples : array_like |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sbpl(x, norm, lam1, lam2, x0, xbrk, Lambda): | |
"""Smoothly bending powerlaw | |
Parameterization from Ryde99 | |
https://ui.adsabs.harvard.edu/abs/1999ApL%26C..39..281R/abstract | |
Parameters | |
---------- | |
x: array of independent variable | |
xmax: only consider x values up to this value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib as mpl | |
import matplotlib.pyplot as plt | |
# make a colormap that can be used to look up colors | |
norm = mpl.colors.Normalize(vmin=0, vmax=3) | |
zcmap = plt.cm.ScalarMappable(norm=norm, cmap=plt.cm.viridis) | |
# use it to plot stuff | |
plt.errorbar( | |
x=1, xerr=0.1, y=2, yerr=0.2, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# | |
# SYNOPSIS: stripgif.py input.odp output.odp | |
# | |
# | |
import os | |
import sys | |
import zipfile | |
import lxml.etree as ET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Manage a group of processes, keeping only N running at a time. | |
Usage: | |
procmanage.py N STRING | |
Arguments: | |
N An integer representing the number of processes to send the CONT signal to. | |
STRING A string representing the full name to match against. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def interval_overlap(alo, ahi, blo, bhi): | |
# interval a: alo to ahi | |
# interval b: blo to bhi | |
return (blo < ahi and bhi > alo) or (alo < bhi and ahi > blo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run with: $ make | |
# or make -j4 to run in parallel | |
.PHONY: all help # rules that do not correspond to a output file | |
.SUFFIXES: # disable built-in rules | |
.SECONDARY: # do not delete intermediate products | |
# first rule is default | |
all: mytarget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Package a paper written in latex for arxiv. | |
Rationale | |
--------- | |
You may have figures and bibliography included from somewhere else in your file system with absolute paths. | |
This script makes a subdirectory package-mylatexfile.tex/ which contains the latex file, figures, .bib, input files referenced in the tex file | |
in the subdirectory, pdflatex mylatexfile.tex should work and not touch any files outside the subdirectory. | |
the subdirectory can then by tarred and uploaded to arxiv. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
def rebin( | |
Nbins = 40, | |
minimum = 0.1, | |
): | |
bins = np.linspace(0, 1, Nbins) | |
lam = minimum + 0 * bins | |
c = np.random.poisson(lam) |
NewerOlder