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 python | |
# encoding: utf-8 | |
from os.path import splitext | |
from argparse import ArgumentParser | |
from markdown import markdown | |
from weasyprint import HTML | |
parser = ArgumentParser(description='Write a markdown file to PDF.') |
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
wl = [(3, 'Fizz'), | |
(5, 'Buzz'), | |
(7, 'Qux')] | |
for i in range(0, 101): | |
print ''.join([w for n, w in wl if not i % n]) or i |
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
!!! write spectra to fits | |
@p:header | |
!!! read in and select data | |
file in class_022.smt | |
set source "RhoOphE" | |
set line "HTCOP" | |
set telescope SMT-FQM-* | |
find |
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
""" | |
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 |
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
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): |
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
# if you haven't setup a ~/.gitconfig, make one with these lines: | |
git config --global user.name "Your Name" | |
git config --global user.email "[email protected]" | |
# 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: |
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 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 |
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 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: |
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
" settings | |
let barposition = "bottom" | |
let scrollstep = 150 | |
let mapleader = "," | |
" options | |
set nosmoothscroll | |
set scalehints | |
set linkanimations | |
set numerichints |
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 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 |
OlderNewer