Skip to content

Instantly share code, notes, and snippets.

View jhamman's full-sized avatar
🔨
Building something new!

Joe Hamman jhamman

🔨
Building something new!
View GitHub Profile
@jhamman
jhamman / check_for_vic_nans.bash
Created September 26, 2014 19:07
check_for_vic_nans.bash
#!/usr/bin/env bash
# Test VIC output for nans
branch="upstream/develop"
testdir="...path with global file..."
vic_repo="...path to /src/ directory in VIC repo..."
cd $vic_repo
# set number of commits to loop through
@jhamman
jhamman / cmap_discretize.py
Last active August 29, 2015 14:09
pcolor subplots using matplotlib.basemap
import numpy as np
import matplotlib as mpl
from matplotlib import cm
def cmap_discretize(cmap, N=10):
cmap = cm.get_cmap(eval(cmap))
colors_i = np.concatenate((np.linspace(0, 1., N), (0.,0.,0.,0.)))
colors_rgba = cmap(colors_i)
indices = np.linspace(0, 1., N+1)
@jhamman
jhamman / monseasmean.py
Created January 22, 2015 02:36
Seasonal means from monthly data
import datetime
import xray
import pandas as pd
import numpy as np
from collections import OrderedDict
dpm = {'noleap': [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
'365_day': [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
'standard': [0, 31, 28.25, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
'gregorian': [0, 31, 28.25, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
@jhamman
jhamman / 0.Summary (RACM.33-fixed)
Last active August 29, 2015 14:23
Fixed Atmospheric Decoupling VIC Changes in RACM.33
Fixing the land-atmosphere coupling in RACM 33
========
To "fix" the surface layer in RACM. We need to add an upper stability limit to the aerodynamic resistance calculation in both `Fixed calc_surf_energy_bal.c` and `SnowPackEnergyBalance`.
These changes, along with the addition of the constant limit in `vicNl_def.h` are shown here.
@jhamman
jhamman / 1.Summary (RASM.1.0-broken)
Last active August 29, 2015 14:23
Atmospheric Decoupling VIC Changes: RASM.1.0
Breaking the land-atmosphere coupling in RASM.1.0
========
To "break" the surface layer in RASM, we need to remove the upper stability limit to the aerodynamic resistance calculation in both `Fixed calc_surf_energy_bal.c` and `SnowPackEnergyBalance`.
This limit was established c.RACM33.
These changes are shown here.
@jhamman
jhamman / header.h
Last active August 29, 2015 14:26
VIC python driver preprocessed header
typedef float float_t;
typedef double double_t;
extern int __math_errhandling(void);
extern int __fpclassifyf(float);
extern int __fpclassifyd(double);
extern int __fpclassifyl(long double);
extern __inline __attribute__((__gnu_inline__)) __attribute__ ((__always_inline__)) int __inline_isfinitef(float);
extern __inline __attribute__((__gnu_inline__)) __attribute__ ((__always_inline__)) int __inline_isfinited(double);
extern __inline __attribute__((__gnu_inline__)) __attribute__ ((__always_inline__)) int __inline_isfinitel(long double);
@jhamman
jhamman / find_nearest.py
Created February 4, 2013 22:38
Simple way to find the 1D index location of a single value in a numpy array. I often use this to find the location of a lat/lon pair in numpy arrays.
#!/usr/local/bin/python
import numpy as np
##################################################################################
## Find Indicies
## Given an input lat or lon, the function returns the nearest index location
##################################################################################
def find_nearest(array,value):
""" Find the index location in (array) with value nearest to (value)"""
idx = (np.abs(array-value)).argmin()
@jhamman
jhamman / read_netcdf.py
Last active December 12, 2015 03:59
A simple way to read in all (or some) variables from a netcdf file.
#!/usr/local/bin/python
import numpy as np
from netCDF4 import Dataset
##################################################################################
## Read netCDF Inputs
## Read data from input netCDF.
##################################################################################
def read_netcdf(ncFile,vars = [],coords = False, verbose = False):
This file has been truncated, but you can view the full file.
{
"metadata": {
"name": "rasm_cpl_plots"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{

IPython Notebook on an SGE cluster

This guide documents how we set up an easy workflow for using the IPython Notebook on our compute cluster managed with Sun Grid Engine (SGE).

Summary: We provide a script to the cluster users that runs qrsh to schedule an ipython notebook job using SSL and password protection.

Installing IPython