Skip to content

Instantly share code, notes, and snippets.

@cpelley
cpelley / masked_transpose_bug.ipynb
Created March 29, 2016 17:17
numpy masked array transpose bug
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cpelley
cpelley / iris_user_build.sh
Last active September 26, 2016 13:07
Conda Iris user build script
# THE FOLLOWING SCRIPT IS TO BE PLACED AND RUN IN THE DOWNLOADED
# IRIS SOURCE DIRECTORY - https://github.com/SciTools/iris
#
# The script is for simply installing iris. For iris development
# see: https://gist.github.com/cpelley/35020289a28253116a82
#
# Assumes user is working with conda, if not please change
# 'ENVIRONMENT_PATH' to point to the directory of your choosen
# python interpreter.
set -e
@cpelley
cpelley / iris_dev_build.sh
Last active September 26, 2016 13:07
Conda Iris development build script
# THE FOLLOWING SCRIPT IS TO BE PLACED AND RUN IN THE CLONE OF
# THE IRIS REPOSITORY - https://github.com/SciTools/iris
#
# The script is for installing iris to make developments in iris.
# To install iris as simply a user of iris see:
# https://gist.github.com/cpelley/5a89f44cf9288308be3f
#
# Assumes user is working with conda, if not please change
# 'ENVIRONMENT_PATH' to point to the directory of your choosen
# python interpreter.
@cpelley
cpelley / calendar_bug.py
Last active December 10, 2015 14:42
iris.unit.Unit vs cf_units calendar bug
import iris
import iris.unit
import cf_units
tunit = iris.unit.Unit('hours since 1970-01-01 00:00:00', calendar='360_day')
tcoord = iris.coords.DimCoord(1, standard_name='time', units=tunit)
print 'iris.unit.Unit: {}'.format(repr(tcoord))
tunit = cf_units.Unit('hours since 1970-01-01 00:00:00', calendar='360_day')
@cpelley
cpelley / f2py_example_usage.ipynb
Created November 13, 2015 11:53
f2py example usage
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cpelley
cpelley / nump_mask_view_bug.txt
Created October 27, 2015 20:53
numpy masked array bug
>>> import numpy as np
>>> arr = np.ma.array([1, 2, 3, 4], mask=[False, True, False, True])
>>> arr2 = arr.reshape((2, 2))
>>> arr2
masked_array(data =
[[1 --]
[3 --]],
mask =
[[False True]
[False True]],
@cpelley
cpelley / svn
Created October 22, 2015 08:27
svn wrapper
#!/usr/bin/env python2.7
import subprocess
import sys
DEBUG = False
SVN_EXEC = '/usr/bin/svn'
class SVNError(Exception):
@cpelley
cpelley / extract_overlap.py
Last active August 29, 2015 14:24
extract_overlap
import iris
import numpy as np
from shapely.geometry import Polygon
def horizontal_grid(cube):
return cube.coord(axis='x'), cube.coord(axis='y')
def transform_bbox(points, src_crs, tgt_crs):
@cpelley
cpelley / 2stage_regrid.py
Last active August 29, 2015 14:23
2-stage-regrid - different coord system regrid
import warnings
import iris
import biggus
from iris.analysis._area_weighted import AreaWeightedRegridder \
as _AreaWeightedRegridder
from iris.experimental.regrid import regrid_weighted_curvilinear_to_rectilinear
import iris.experimental.regrid as eregrid
from iris.analysis._regrid import RectilinearRegridder
import numpy as np
@cpelley
cpelley / circular
Created April 14, 2015 15:45
circular lost
{
"metadata": {
"name": "",
"signature": "sha256:9e9b8e73d2e084ca27d4015fe246597f8a1595a35b0bee658170be3636d8c30a"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [