Skip to content

Instantly share code, notes, and snippets.

@cpelley
cpelley / gist:7097521
Created October 22, 2013 09:11
esmf + ESMPy install
# Specify tag release
export ESMPY='620_01b'
# Download archive if not done already
archive=ESMPy_${ESMPY}.tar.bz2
if [ ! -f ${archive} ]; then
echo 'Downoading archive'
wget http://www.earthsystemmodeling.org/python_releases/ESMPy_${ESMPY}/${archive}
fi
@cpelley
cpelley / .screenrc
Last active January 8, 2016 23:00
screenrc settings
# Turn off audible bell
vbell off
# Turn off startup message
startup_message off
hardstatus off
caption always "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"
@cpelley
cpelley / gist:7785812
Created December 4, 2013 11:02
Partial datetime benchmark
import timeit
import numpy as np
import iris
from iris.pdatetime import PartialDateTime
def _ret_cube():
cube = iris.cube.Cube(np.arange(4))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cpelley
cpelley / temporary_directory.py
Created August 26, 2014 14:40
Support for temporary directories in python2.7 as context managers (already available in python3.2+)
import shutil
import tempfile
class TemporaryDirectory(object):
"""
Context manager for tempfile.mkdtemp().
This class is available in python +v3.2.
@cpelley
cpelley / regrid_performance.ipynb
Created September 24, 2014 13:33
Regrid performance
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cpelley
cpelley / mosaic.py
Created September 26, 2014 12:24
Generator of slices which represent a mosaic indexing of an iterable object
def mosaic(iterable_shape, subdivided_shape):
"""
Return a generator of slices that represent a subdivided indexing of an iterable of specified shape.
"""
shape = subdivided_shape
if len(iterable_shape) != len(shape):
raise ValueError('Array shape and resulting shape mismatch, broadcasting not supported.')
# iterate through this array with shape (shape)
@cpelley
cpelley / BUG_save_load_coord_system
Created November 3, 2014 09:38
Bug with save-load sequence. Inverse flattening representation changes between save-load, resulting in a failled equality condition. Also demonstrates the lack of support for a scalar cube.
{
"metadata": {
"name": "",
"signature": "sha256:563b350202cce7ea8c83bbb25c227c1bdcef905445af72e7b040121fc52884b8"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [