Skip to content

Instantly share code, notes, and snippets.

Avatar

Mahé Perrette perrette

View GitHub Profile
View Raster mask on regular grid from shapely Polygon
import numpy as np
def outline_to_mask(line, x, y):
"""Create mask from outline contour
Parameters
----------
line: array-like (N, 2)
x, y: 1-D grid coordinates (input for meshgrid)
@perrette
perrette / catchment_basin.ipynb
Last active May 27, 2016
Catchment basin determination using Barnes' priority flood algorithm. Python bindings added at https://github.com/perrette/Barnes2013-Depressions
View catchment_basin.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@perrette
perrette / concave_hull_and_smoothed_outline.ipynb
Created May 27, 2016
Draw concave hull of an outline with scipy and shapely. Also explore smoothing methods.
View concave_hull_and_smoothed_outline.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View mask_and_outline.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View catchment_basin.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Makefile
# requires: https://github.com/jameskermode/f90wrap
# basically this is a wrapper around f2py...:
# - the fortran code is rewritten by f90wrap into a f90wrap_module.f90
# so that there is no type defined (which are not supported by f2py break)
# - the same step also produces a python module that wraps the newly written f90wrap_module.f90 into fortran
# - compile the fortran wrapper with a few nice additions such as
# handling optional arguments, and defining the f90wrap_abort() function to raise an error in python
# without crashing the program...
# name of python module to be created
View 2015-06-22-first-attempt.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@perrette
perrette / lib.f90
Last active Jun 3, 2017
conflict between fortran+iso_c_binding (via ctypes or cython) and matplotlib when reading namelist
View lib.f90
module mylib
use iso_c_binding, only: c_double
implicit none
double precision :: g
contains