Skip to content

Instantly share code, notes, and snippets.

@denis-bz
denis-bz / 0-Cosmopy.md
Last active April 23, 2024 15:02
Cosmopy: clip and regrid COSMO_REA6 wind data to python numpy
@denis-bz
denis-bz / Nd-testfuncs-python.md
Last active March 4, 2024 06:23
N-dimensional test functions for optimization, in Python
@denis-bz
denis-bz / Iterative-learning-control.py
Last active February 28, 2024 03:15
A simple example of ILC, Iterative learning control, for "learning" a control curve
""" a simple example of ILC
from Moore, Iterative learning control: a tutorial and big picture 2006 6p
"""
# https://en.wikipedia.org/wiki/Iterative_learning_control
# https://en.wikipedia.org/wiki/LTI_system_theory
from __future__ import division
import sys
import numpy as np
@denis-bz
denis-bz / 0-Shift-invert-in-pictures.md
Created July 2, 2020 16:39
How shift-invert finds eigenvalues, in pictures 2 Jul 2020

How shift-invert finds eigenvalues, in pictures

Keywords: eigenvalues, eigenvectors, shift-invert, ARPACK, scipy, python

Pictures first:

shiftinvert-randomsparse-n100

Background

@denis-bz
denis-bz / mst-2011.md
Created July 17, 2023 12:53
mst.py unionfind.py from 2011

Old mst.py with Kruskal's algorithm

mst.py is simple old (2011) code for MSTs using Kruskal's algorithm -- see the animation there.

Kleinberg-Tardos:

single-link k-clustering == MST k-1 most expensive edges

but min( max spacing ), Theorem 1, may be wrong or at least odd for k-clustering ?

@denis-bz
denis-bz / 0-COSMO_REA6-ERA5-Bayern.md
Last active June 24, 2023 16:11
Windspeeds in Bayern, COSMO_REA6 vs. ERA5

Windspeeds in Bayern, COSMO_REA6 vs. ERA5

Here are plots of average windspeeds in Bayern in January 2018 at 100m,
COSMO_REA6 on its ~ 6 × 6 km grid
ERA5 on its 0.25° × 0.25° grid.
We see big differences over the Alps in the south and over hilly areas in north Bayern.

24jun-WS_100m 2D 201801

24jun-era5-bayern-201801-100m

@denis-bz
denis-bz / 0-How-to-make-a-Python-package-for-other-people-to-use.md
Last active May 5, 2023 11:22
from Denis-iMac ~bz/py/plot/folium/git Fri 2023-05-05 May 11:20z

How to make a Python package for other people to use

Keywords, tags: python packaging setup.py setuptools

Purpose: describe how to make a "package" of a Python program for other people to use. This introduction builds on the excellent oa-packaging-guide-preview.readthedocs.io — read that first.

@denis-bz
denis-bz / firefox-cookies.py
Created January 15, 2016 10:28
List Firefox cookies, in python
#!/usr/bin/env python
''' In: a firefox cookies.sqlite file
default $HOME/Library/Application\ Support/Firefox/Profiles/*/cookies.sqlite
Out: urls in the file, one per line on stdout
modified https://linuxfreelancer.com/decoding-firefox-cookies-sqlite-cookies-viewer
'''
# google python sqlite3 "delete cookies" ? looks mttiw
@denis-bz
denis-bz / 0-ERA5-vs-globalwindatlas.md
Last active December 20, 2022 17:35
Wind speeds at 100m in Bayern, ERA5 vs. globalwindatlas 20 Dec 2022
@denis-bz
denis-bz / 0-Sun-wind-biomass-electricity-Germany.md
Last active November 17, 2022 11:06
How efficient are wind, sun, biomass in the German provinces in 2019 - 2020 13 Nov 2022

How efficient are wind, sun, biomass in the German provinces in 2019 - 2020 ?

Keywords: Renewable energy, wind energy, electricity, Germany

Purpose: look at the efficiency of electricity produced in the German provinces from sun, wind and biomass, with files from official data:
LAK, real: https://www.lak-energiebilanzen.de 2019, Länderarbeitskreis Energiebilanzen Bruttostromerzeugung nach Erneuerbaren Energieträgern
BMWK, max 31.12.2020,