Skip to content

Instantly share code, notes, and snippets.

@JohannesBuchner
JohannesBuchner / publishPython.sh
Created September 20, 2013 17:00
tool for publishing sphinx documentation on github and releasing packages on PyPI
#!/bin/bash
# Author: Johannes Buchner (C) 2013
# tool for publishing sphinx documentation on github
# and releasing packages on PyPI
case "$1" in
doc)
# see https://help.github.com/articles/creating-project-pages-manually
make -C doc/ html &&
git checkout gh-pages &&
@JohannesBuchner
JohannesBuchner / sample_broken_powerlaw.py
Last active December 2, 2018 23:52
Draw random numbers from broken powerlaw (broken code ATM)
import numpy
# Sampling from a broken powerlaw or powerlaw segments
# Reference material:
# http://mathworld.wolfram.com/RandomNumber.html
# The strategy is to draw from each powerlaw segment, and make sure the proportions are right based on the segment integrals
# This code does not work correctly, improvements are welcome
@JohannesBuchner
JohannesBuchner / uncertaincolors.py
Created April 6, 2018 15:05
Make maps with uncertainties
# based on http://spatial-analyst.net/wiki/index.php?title=Uncertainty_visualization
import numpy
import colorsys
from matplotlib.colors import hsv_to_rgb
def to_rgb(value, error):
z = value
f1 = -90 - z*300
@JohannesBuchner
JohannesBuchner / smf-fit.py
Created May 16, 2017 16:31
Fitting of stellar mass function with only two, uncertain data points
import matplotlib.pyplot as plt
import numpy
from numpy import log, exp
import scipy.misc
import scipy.optimize
# see Buchner et al (2015), Appendix A, for details on the method
# http://adsabs.harvard.edu/abs/2015ApJ...802...89B
Nsamples = 1000
@JohannesBuchner
JohannesBuchner / statistics-minimal.rst
Last active July 31, 2016 08:47
ArXiV minimal statistics checklist

ArXiV minimal statistics checklist

This checklist help you identify and fix common errors/misinterpretation in your analysis, or of a paper you are refereeing.

  1. If you use p-values (from a KS test, Pearson correlation, etc.).
  1. What do you think a low p-value says?
  1. You have absolutely disproved the null hypothesis (e.g. "no correlation" is ruled out, the data are not sampled from this model, there is no difference between the population means).
@JohannesBuchner
JohannesBuchner / install.rst
Last active December 29, 2015 22:19
Prepare VirtualBox image

Installation notes for Virtual machine

Contains

  • BXA
  • MultiNest
  • PyMultiNest
  • Sherpa
  • Xspec
@JohannesBuchner
JohannesBuchner / howlong.py
Last active December 27, 2015 17:29
ETA from external programs
"""Estimate Time until completion of a process.
Usage: <statusprog> | howlong.py <n>
<statusprog> is a program that writes a line to stdout from time to time.
The line is the number of items completed so far.
<n> is the total number of items to complete.
Example:
for((i=0;i<20;i++)); do echo $i; sleep 1; done | python howlong.py 20
@JohannesBuchner
JohannesBuchner / updateGentoo.sh
Created October 9, 2013 11:05
update Gentoo Linux
#!/bin/bash
#rm /usr/portage/distfiles/*
renice +20 -p $$
ionice -c3 -p $$
pgrep emerge >/dev/null || rm /var/tmp/portage/*-* -rf
emerge-webrsync && eix-update
ARGS="--quiet-build --load-average=10 --jobs=3"
@JohannesBuchner
JohannesBuchner / runProcess.py
Last active December 24, 2015 16:19
launch process
import subprocess
def runscript(name):
args = ('./interact', name,)
p = subprocess.Popen(args)
# p.communicate() # set stdin/stdout/stderr=subprocess.PIPE
if p.wait() != 0:
raise Exception('return value of startup script was non-zero')
@JohannesBuchner
JohannesBuchner / thunderbird_build_notes.txt
Last active December 24, 2015 10:09
Thunderbird/Mozilla build notes
Follow https://developer.mozilla.org/en-US/docs/Simple_Thunderbird_build
comm-central/.mozconfig:
ac_add_options --enable-application=mail
ac_add_options --with-ccache=/usr/bin/ccache
ac_add_options --enable-calendar
#ac_add_options --disable-debug
ac_add_options --enable-debug