Skip to content

Instantly share code, notes, and snippets.

View autocorr's full-sized avatar

Brian Svoboda autocorr

View GitHub Profile
from __future__ import print_function
import glob
from os import path
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from astropy import units as u
from astropy import constants as c
@autocorr
autocorr / tmoji
Last active September 18, 2023 12:29
A python script to send parse emoji keywords into unicode and send to tmux
#!/usr/bin/env python3
import argparse
import difflib
import subprocess
EMOJI_UNICODE = {
'+1': '\U0001F44D',
'-1': '\U0001F44E',
@autocorr
autocorr / dpdf_histogram.py
Last active November 9, 2017 17:50
Create histograms of DPDFs
# Here we import the numpy module to use arrays, and matplotlib for plotting.
# Pyplot is a sub-module of matplotlib designed to be a good interface for
# interactive plotting, matplotlib in general contains many sub-modules defining
# all sorts of behavior, from colors, fonts, to how tickmarks are rendered. We
# use the "as" keyword to give the modules an alias, so we don't import literally
# thousands of function names into the scope of the program (in IPython just type
# "np.<tab>" to see how many symbols are defined.
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
@autocorr
autocorr / ripple_tank_demos.txt
Last active June 7, 2021 18:13
Ripple tank demos for radio astronomy and interferometry
# Ripple Tank Demos
Website available at: http://www.falstad.com/ripple/ . Copy and paste the following entries
by going under "File -> Import From Text...", beginning from the "$" until the blank line.
One can use the two check-boxes on the right to stop the simulation and visualize the
amplitdues in 3D. The sliders on the right can be used to adjust the rate/speed of the
simulation and wavelength/frequency of the wave (under "Source Frequency").
Single point source. Point source limits to plane wave.
$ 1 512 64 10 0 668 0.048828125
s 2 257 45 0 0.466666 0 10 100 1 0
@autocorr
autocorr / sparse_argus_map.py
Created February 4, 2020 20:10
Hacky coverage analysis for GBT/Argus
#!/usr/bin/env python3
import itertools
import numpy as np
from matplotlib import patches
from matplotlib import pyplot as plt
from astropy import units as u
@autocorr
autocorr / test_getregion_leak.py
Last active April 29, 2021 03:28
CASA v5 script to test memory leak in `ia.getregion`
#!/usr/bin/env python
"""
Execute tests to reproduce memory leaks from `ia.getregion`. See the functions
under the "Tests" banner near the bottom of the module for the tests to run.
Images with diameters in pixels greater than or equal to 3500 appear to cause
memory leaks. By default 50 calls are made to `ia.getregion`. The call itself
selects a bounding box encompassing the full image and selects one channel (the
second channel).
This file is meant to be run using `execfile` under CASA v5 and Python v2.7.
@autocorr
autocorr / noise_and_heat.py
Created March 28, 2023 23:06
Create a concatenated colorbar. Useful for "grayscale plus heat."
# By Eric Koch
def half_table(table1_name, table2_name,
reverse1=False, reverse2=False,
pivot=0.5):
"""
Splice together two matplotlib color tables.
"""
n_col = 256
cmap1 = cm.get_cmap(table1_name, n_col)
@autocorr
autocorr / hopper_race.ini
Last active June 19, 2023 21:12
Fairy-Stockfish variant file for Hopper Race.
[hopperrace]
maxRank = 8
maxFile = 8
gold = g
silver = s
queen = f # flag piece used for mandatory promotion
customPiece1 = l:mfFmfWmgQ # non-capturing hopper
customPiece2 = p:fFmfW # breakthrough pawn
startFen = 1slggls1/8/1pppppp1/8/8/1PPPPPP1/8/1SLGGLS1 w - - 0 1
extinctionValue = loss
@autocorr
autocorr / hopperrace.epd
Created June 17, 2023 02:49
Opening book in EPD format generated for Hopper Race
This file has been truncated, but you can view the full file.
1slggls1/8/1pppppp1/8/8/1PPPPPP1/8/1SLGGLS1 w - - 0 1
1slggls1/8/1pppppp1/8/5P2/1PPPPP2/8/1SLGGLS1 b - - 1 1
2lggls1/2s5/1pppppp1/8/5P2/1PPPPP2/8/1SLGGLS1 w - - 2 2
2lggls1/2s5/1pppppp1/8/5P2/1PPPPP2/2S5/2LGGLS1 b - - 3 2
2l1gls1/2s1g3/1pppppp1/8/5P2/1PPPPP2/2S5/2LGGLS1 w - - 4 3
2lggls1/2s5/1pp1ppp1/3p4/5P2/1PPPPP2/2S5/2LGGLS1 w - - 4 3
2lggls1/2s5/1ppp1pp1/4p3/5P2/1PPPPP2/2S5/2LGGLS1 w - - 4 3
2lggls1/2s5/1pppppp1/8/5P2/1PPPPP2/5S2/1SLGGL2 b - - 3 2
2lggl2/2s2s2/1pppppp1/8/5P2/1PPPPP2/5S2/1SLGGL2 w - - 4 3
@autocorr
autocorr / rotate_svgs
Created August 17, 2023 19:24
Rotate a set of SVGs by 180 degrees using Inkscape.
#!/bin/bash
for input_file in *.svg
do
stem="${input_file%%.*}"
outname="${stem}_r"
inkscape --actions "select-all;transform-rotate:180;export-filename:${outname}.svg;export-do" $input_file
done