Skip to content

Instantly share code, notes, and snippets.

View J535D165's full-sized avatar

Jonathan de Bruin J535D165

View GitHub Profile
@J535D165
J535D165 / crop_resize.py
Created January 7, 2018 11:28
crop and resize numpy array
from scipy import interpolate
def crop_and_resample_2darray(arr, x_crop, y_crop, resample, *args, **kwargs):
"""Crop a 2darray and resize the data"""
len_x_crop = x_crop[1]-x_crop[0]
len_y_crop = y_crop[1]-y_crop[0]
arr_crop = arr[x_crop[0]:x_crop[1], y_crop[0]:y_crop[1]]
f = interpolate.interp2d(np.arange(len_y_crop),
@J535D165
J535D165 / python_re.py
Last active March 6, 2017 08:48
Python Regular Expressions
# Dutch zip code matcher
r"[\bNL-]*(?P<pc4>\d{4})\s*(?P<pc6>[A-Za-z]{2})\b"
# Email matcher
r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"