Skip to content

Instantly share code, notes, and snippets.

@denis-bz
denis-bz / 0-HUSL-lch-is-not-CIELCh.md
Last active March 26, 2022 14:29
HUSL rgb_to_lch is not CIELCh

HUSL rgb_to_lch is for CIELuv, not CIELab

Keywords: color-space HUSL HSLuv CIELCh CIELuv CIELab max-chroma everyone-knows

Whenever something can be done in two ways, someone will be confused.

22mar-husl-wall-imshow2

There are two quite different color spaces: \

@denis-bz
denis-bz / 0-Windfarms-in-Germany.md
Last active July 23, 2022 09:28
Windfarms in Germany, from de.wikipedia 14 Nov 2021

Windfarms in Germany from de.wikipedia

Keywords: wind power, Germany, python, globalwindatlas

Purpose: collect data on wind farms in Germany in a single .csv file, from https://de.wikipedia.org/wiki/Liste_von_Windkraftanlagen_in_Bayern etc.

The file windfarms-in-Germany.csv looks like this:

MW MW/Rad Nrad Year N E Land Lkr Typ Ort

@denis-bz
denis-bz / 0-warp.md
Created November 7, 2021 17:00
Basic image warping or map reproject in python 7 Nov 2021

Warping maps or images

Keywords: image raster resize rescale reproject Manhattan-grid regular-grid

We have a picture (image, raster) A, an array of colored pixels, and want to warp it to a new picture O of a different size or shape. Examples: Map projection, flat maps <-> globe; Image scaling.
There are hundreds of cases of these, and zillions of programs

@denis-bz
denis-bz / 0-warp_raster_test.md
Last active September 13, 2021 11:02
rioxarray reproject UTM -> 4326 widens NaNs at the sides 13 Sep 2021

rioxarray reproject UTM -> 4326 widens NaNs at the sides

Keywords: rioxarray, rasterio, reproject, geotiff, testcase

This plot shows that rioxarray reproject UTM -> 4326, middle -> right, widens NaNs at the sides:

13sep-warp_raster_test_riox

@denis-bz
denis-bz / 0-German-energy.md
Last active July 12, 2021 12:32
Electricity in Germany from coal, wind etc.

Electricity in Germany from coal, wind etc.

Keywords: electricity, Germany, renewable, wind, python, pandas

Purpose: summarize data on electricity sources in Germany from the electricity market site smard.de:

total 502489 GWh  365 days, 2020-07-01 .. 2021-06-30:
                 GWh    %   GW

Braunkohle 96253.2 19.2 11.0

@denis-bz
denis-bz / rki_excel.py
Created June 10, 2021 14:43
Read German Corona data rki.de/.../Fallzahlen_Kum_Tab.xlsx in python pandas
#!/usr/bin/env python3
""" https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Fallzahlen_Kum_Tab.html .xlsx
-> python pandas read_excel
"""
# sheets, from openpyxl --
# 0 Erlaeuterungen 20 rows 1 cols
# 1 Fälle-Todesfälle-gesamt 509 rows 16384 cols ?!
# 2 BL_7-Tage-Fallzahlen (fixiert) 39 rows 396 cols
# 3 BL_7-Tage-Inzidenz (fixiert) 21 rows 396 cols
# 4 LK_7-Tage-Fallzahlen (fixiert) 419 rows 207 cols
@denis-bz
denis-bz / 0-fitting-1-over-x-with-polynomials.md
Last active February 28, 2022 19:19
Fitting 1 / x with polynomials in relative error

Fitting 1 / x with polynomials in relative error

Keywords, topics: approximation, relative error, inverse, Chebyshev polynomial, Krylov, python

23may-relfit-c1 1-d10-15-20-wend8

This plot shows polynomials of degrees 10, 15, 20 that fit 1 / x on the range 0.1 .. 2.1, shifted to fits of 1 / (1.1 + x) on -1 .. 1.

@denis-bz
denis-bz / 0-tri101-inverse.md
Last active April 3, 2021 09:25
A simple matrix with interesting inverse 31 Mar 2021

A simple matrix with interesting inverse

Keywords: sparse linear solver, python, scipy, testcase, matrix, GMRES, poisson, plot

2apr-tri101-inv

A simple testcase for GMRES

Wikipedia GMRES says

@denis-bz
denis-bz / 0-Mittelmann-ip-simplex.md
Last active January 26, 2021 16:50
Mittelmann interior-point and simplex benchmarks 24 Jan 2021

Mittelmann interior-point and simplex benchmarks from http://plato.asu.edu/bench.html

Keywords, tags: linear programming, benchmark, Mittelmann, HiGHS, python, scipy, sparse-matrix

26jan-Mittelmann-ip-simplex

This plot shows the runtimes of various LP interior-point and simplex programs on Mittelmann's benchmark problems.

To plot similar rows / similar columns near each other,

@denis-bz
denis-bz / 0-LP-benchmarks-Mittelmann-HiGHS.md
Last active January 21, 2021 14:28
A few Mittelmann LP benchmarks run with HiGHS-ipm 19 Jan 2021

A few Mittelmann LP benchmarks run with HiGHS-ipm

Keywords, tags: linear programming, benchmark, Mittelmann, HiGHS, python, scipy, sparse-matrix

Here are logfiles for a few of the Mittelmann linear programming benchmark problems, run with the HiGHS interior-point solver via python-scipy. lpbar