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
while true | |
do | |
rsync -avz ./ user@host:remote/directory/ | |
inotifywait -r ./ | |
done |
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
# Help create a pyproject.toml from a setup.py file | |
# | |
# USAGE: | |
# 1) | |
# replace "from [a-z.]* import setup" in your setup.py | |
# with "from convert_setup_py_to_pyproject_toml import setup" | |
# 2) | |
# run the resulting script with python, with this script in the PYTHONPATH | |
# | |
# The above can be achieved on Linux, for example, with: |
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
""" | |
Progress bar for rsync | |
======================== | |
Shows file progress and total progress as a progress bar. | |
Usage | |
--------- | |
Run rsync with -P and pipe into this program. Example:: |
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
import sys, os | |
import joblib | |
import subprocess | |
mem = joblib.Memory('.', verbose=False) | |
@mem.cache | |
def run_cmd(args, env): | |
process = subprocess.run(args, capture_output=True, text=True) | |
return process.stdout, process.stderr, process.returncode |
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. |
NewerOlder