Skip to content

Instantly share code, notes, and snippets.

View rsnemmen's full-sized avatar

Rodrigo Nemmen rsnemmen

View GitHub Profile
@rsnemmen
rsnemmen / linconf.py
Created April 1, 2015 19:19
Script illustrating how to do a linear regression and plot the confidence band of the fit
# See also http://astropython.blogspot.in/2011/12/script-illustrating-how-to-do-linear.html
import numpy, pylab, scipy
import nemmen
# Data taken from http://orion.math.iastate.edu/burkardt/data/regression/x01.txt.
# I removed the header from the file and left only the data in 'testdata.dat'.
xdata,ydata = numpy.loadtxt('testdata.dat',unpack=True,usecols=(1,2))
xdata=numpy.log10(xdata) # take the logs
ydata=numpy.log10(ydata)
@rsnemmen
rsnemmen / Darwin.gcc.defs
Created June 17, 2015 02:42
Pluto configuration file for OS X (corrected for supporting HDF5, assume MacPorts is installed)
########################################################################
#
# Configuration file for Mac Os X (Darwin, serial)
#
########################################################################
CC = gcc
CFLAGS = -c -fast -finline-functions -Winline -Wundef
LDFLAGS = -bind_at_load -lm
@rsnemmen
rsnemmen / array.f90
Last active April 4, 2016 22:57
Opens a datafile and reads the columns as arrays. Illustrates the use of dynamically allocated arrays.
! Opens a datafile and reads the columns as arrays.
! Illustrates the use of dynamic allocated arrays.
program test
implicit none
real, dimension(:), allocatable :: x, y
integer :: i,n
character(len=50) :: in
@rsnemmen
rsnemmen / md2tex.sh
Created April 4, 2016 22:56
Shell script that converts a text file written in Markdown syntax to LaTeX, generates PDF
#!/bin/sh
#
# Convert Markdown to LaTeX
#
# Run this inside your document folder:
# md2tex.sh <MARKDOWN FILE> <MAIN TEX FILE>
#
# where:
# - <MAIN TEX FILE>: main latex file of your project
# - <MARKDOWN FILE>: meat of text written in markdown
@rsnemmen
rsnemmen / writebin.f90
Created April 4, 2016 23:02
Generates array of random numbers. Saves it as an unformatted Fortran 90 binary file
! Generates arrays of random numbers. Saves them as binary
! unformatted files.
program test
implicit none
real, dimension(:,:), allocatable :: y
integer :: n
character(len=50) :: out
@rsnemmen
rsnemmen / stats example R interface.ipynb
Created February 27, 2017 20:39
Calling R from inside a Jupyter python notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rsnemmen
rsnemmen / stats example wavelet.ipynb
Created March 5, 2017 21:09
Remove Time-Localized Frequency Components using continuous wavelet transform (CWT) and Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rsnemmen
rsnemmen / bibtexFix.py
Created March 30, 2017 21:06
Replaces bibtexkey fields in BibTeX file: Silva14 => Silva2014 (e.g. \cite{Silva2014})
#!/usr/bin/env python
#
# Given a BibTeX file containing bibliographic references named
# `refs.bib`, this script changes all bibtexkey fields from the
# format "Yuan14" to "Yuan2014".
#
# Here, "Yuan" refers to the paper's first author surname and "14"
# refers to the two last digits of the year when the paper was
# published (the script follows precisely this pattern matching).
#
@rsnemmen
rsnemmen / Bayesian blocks.ipynb
Created May 3, 2017 13:19
Jupyter example of plotting histograms with Bayesian blocks (automatic binning)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rsnemmen
rsnemmen / arraydyn.c
Created June 9, 2017 03:35
Simple example illustrating how to dynamically allocate array in C. Number of elements in array provided via command-line argument.
/*
Gets a command-line argument that provides the number of
elements in an array. Dynamically allocates the array.
Generates random numbers and print them.
Usage:
args 10
will print out the 10 random numbers.