Skip to content

Instantly share code, notes, and snippets.

View gabraganca's full-sized avatar
🚀
going above and beyond

Gustavo Bragança gabraganca

🚀
going above and beyond
View GitHub Profile
from pyraf import iraf
def sep_spec(spec, aperture):
"""Separate the multi spectrum in its orders"""
nslits = int(iraf.imhead(spec, Stdout=1)[0].split(',')[1])
for i in xrange(1, nslits+1):
spec_in = spec+'[*,'+str(i)+','+aperture+']'
if i<10:
spec_out = './'+spec.split('.fits')[0]+'_000'+str(i)+'.fits'
from subprocess import Popen, PIPE
def run_idl(inp, do_log = False):
"""Run IDL"""
if do_log:
with open('idl.log', 'w') as log:
idl = Popen(['nice','-n0','idl'],stdin = PIPE, \
stdout=log,stderr=log)
idl.communicate(inp)
To get Git to diff between your odt/odp/ods files you will need to do the following things:
Install a conversion tool
$ sudo yum install odt2txt
Create your git config info directory if it's not already there
$ mkdir -p ~/.config/git/info
Add in attributes (you can paste this straight in or edit the file accordingly)
$ cat > ~/.config/git/info/attributes <<DELIM
@gabraganca
gabraganca / contour_plot
Last active December 17, 2015 12:59
Do a contour plot on a 3D array
import scipy.stats as st
import numpy as np
import matplotlib.pytlot as plt
def contour_plot(array3d, **kwargs):
"""
Do the contour plot of a X, Y, Z vector.
Parameters
----------
import numpy as np
def create_list(list1, list2):
"""
list1 : N-dimensional list
list2 : 1-dimensional list
"""
return np.array([np.append(np.array(i), j) for i in list1 for j in list2])
def append(xs, yss):
return [[x] + ys for x in xs for ys in yss]
def make_lists(*xss):
if len(xss) == 1:
return [[x] for x in xss[0]]
h, t = xss[0], xss[1:]
return append(h, make_lists(*t))
#!/usr/bin/env python
"""
Script for running and save notebooks from command line.
How to use: `ipynb_run_save.py foo.ipynb
Some tweaks over ipydoctest.py from minrk
by @damianavila
"""
@gabraganca
gabraganca / ipynb_rc.py
Last active December 20, 2015 20:08
Resources for the Ipython notebook
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = 16, 12 # that's default image size for this interactive session
plt.rcParams['figure.dpi'] = 100
plt.rcParams['axes.titlesize'] = 22
plt.rcParams['axes.labelsize'] = 18
plt.rcParams['lines.linewidth'] = 2
plt.rcParams['lines.markersize'] = 8
plt.rcParams['xtick.labelsize'] = 14
plt.rcParams['ytick.labelsize'] = 14
@gabraganca
gabraganca / gist:7011378
Created October 16, 2013 17:13
Odd behavior with the ipython notebook and the matplotlib. When I call `%matplotlib inline` it overrides the size of of `figure.figsize' of my matplotlibrc.
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{