Skip to content

Instantly share code, notes, and snippets.

View j08lue's full-sized avatar

Jonas j08lue

View GitHub Profile
@j08lue
j08lue / struct.py
Last active July 2, 2023 04:10
Struct class
class Struct():
"""Create a custom class from a dictionary
Usage
-----
Initialize empty, with a dictionary, and/or
with any number of key=value pairs
Note
----
@j08lue
j08lue / ttkcalendar.py
Last active September 6, 2022 22:12
Simple calendar using ttk Treeview together with calendar and datetime classes - from http://svn.python.org/projects/sandbox/trunk/ttk-gsoc/samples/ttkcalendar.py
"""Simple calendar using ttk Treeview together with calendar and datetime
classes.
Credits
-------
http://svn.python.org/projects/sandbox/trunk/ttk-gsoc/samples/ttkcalendar.py
"""
import calendar
try:
@j08lue
j08lue / mpl_animations_from_static_3d.py
Created May 26, 2014 09:45
Animate your 3D plots with Python’s Matplotlib
"""Recipe from http://zulko.wordpress.com/2012/09/29/animate-your-3d-plots-with-pythons-matplotlib/"""
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import axes3d
import os, sys
import numpy as np
##### TO CREATE A SERIES OF PICTURES
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@j08lue
j08lue / fiona-transform-crs-issue.ipynb
Last active May 29, 2018 20:30
Fiona issue with transform_geom and rasterio CRS
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@j08lue
j08lue / xr-decode-times-roundoff.ipynb
Created January 25, 2018 12:48
xarray 0.10.0 time decoding round-off error
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@j08lue
j08lue / llc-windows.ipynb
Created October 26, 2017 05:58
LLC fmin example fails on Windows
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@j08lue
j08lue / rasterio_reproject.py
Created October 5, 2017 12:21
rasterio reproject array to array and write to disk
dst_crs = ...
nbands, height, width = data.shape
dst_transform, width, height = rasterio.warp.calculate_default_transform(
src_crs=src_crs,
dst_crs=dst_crs,
width=width, height=height,
resolution=resolution,
**bounds)
@j08lue
j08lue / array_resample_py2_fails.ipynb
Created June 20, 2017 09:43
Rasterio array resampling in Python 2 - fails
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@j08lue
j08lue / stack_band_files.py
Created May 1, 2017 12:36
Stack band files with rasterio
def stack_band_files(infiles, outfile, creation_options={}):
"""Stack single-band files into one
Parameters
----------
infiles : list of str
paths to input files
outfile : str
path to output file
creation_options : dict