Skip to content

Instantly share code, notes, and snippets.

View autocorr's full-sized avatar

Brian Svoboda autocorr

View GitHub Profile
@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 / 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',
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 / read_cds_table.py
Created March 19, 2016 22:15
Reading a CDS fixed width table into a pandas dataframe
import pandas as pd
from astropy import table
# use the astropy table reader method to read the file and convert
# to a `pandas.DataFrame`
df = table.Table.read('table1.txt', format='ascii.cds').to_pandas()
df.to_csv('table1.csv', index=False)
# when reading the files, remember to set the index column for
# matching and other things
@autocorr
autocorr / cvimrc
Last active February 11, 2016 00:59
" settings
let barposition = "bottom"
let scrollstep = 150
let mapleader = ","
" options
set nosmoothscroll
set scalehints
set linkanimations
set numerichints
@autocorr
autocorr / gist:c64020fd24e8ed2062aa
Last active August 29, 2015 14:21
simple prime checker
#!/usr/bin/env python2
def is_prime(x):
assert type(x) == int
assert x > 0
if x == 2:
return True
for n in xrange(2, x / 2 + 1):
if not x % n:
@autocorr
autocorr / dark.py
Last active August 29, 2015 14:14
Something dark
def make_dark(infilen, targetfilen, outfilen='masterdark'):
# step 1: median stack the darks
darklist = open(infilen,'r')
darklist = darklist.readlines()
n = len(darklist)
fits = pyfits.open(darklist[0])
darkheader = fits[0].header
imdark = fits[0].data
@autocorr
autocorr / essential_git
Created January 28, 2015 00:43
Essential git
# if you haven't setup a ~/.gitconfig, make one with these lines:
git config --global user.name "Your Name"
git config --global user.email "you@email.com"
# first enter the directory you want to version-control and initialize the repository
git init
# git works by storing the changes to files rather than the files themselves,
# so you first have to add the files, or start tracking them
# add all files in the current directory:
@autocorr
autocorr / gist:4f5568d853acd7024e04
Last active August 29, 2015 14:11
Some OOP things
class BaseFitter(object):
# Put everything common to all fitting routines in this class
def __init__(self, *args):
# handle the arguments
pass
def interpolate(self):
pass
def calc_covariance(self):
@autocorr
autocorr / factory.py
Last active August 29, 2015 14:11
A factory function
"""
An example of a class and a factory function.
"""
import model_fit # fit_func lives here
class Fitter(object):
# This would be the starting point for your fit routine,
# and the different methods could do different parts. You could