Skip to content

Instantly share code, notes, and snippets.

@denis-bz
denis-bz / 0-HUSL-lch-is-not-CIELCh.md
Last active Mar 26, 2022
HUSL rgb_to_lch is not CIELCh
View 0-HUSL-lch-is-not-CIELCh.md

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-globalwindatlas-linear.md
Last active Feb 28, 2022
Are windspeeds and capacity factors from https://globalwindatlas.info linearly related ? 24 Dec 2021
View 0-globalwindatlas-linear.md

Are windspeeds and capacity factors from https://globalwindatlas.info linearly related ?

Keywords: wind power, Germany, python, globalwindatlas

24dec-regress-wind

I'd appreciate hearing from anyone who knows how globalwindatlas calculates its data.

@denis-bz
denis-bz / 0-Windpower-Weibullmodel.md
Created Nov 30, 2021
How does wind power vary with wind speed, Weibull model ? 30 Nov 2021
View 0-Windpower-Weibullmodel.md

How does wind power vary with wind speed, Weibull model ?

Keywords: wind power, wind energy, model, Weibull, python

Purpose: a simple model of wind power, power curve × Weibull wind curves.

Look at the map of windspeeds in Germany under globalwindatlas.info: set the height to 150m and windspeeds to say 6 to 9 m/s in the sidebars. (I'd show it here, but it's copyrighted.)

@denis-bz
denis-bz / 0-Windfarms-in-Germany.md
Last active Feb 28, 2022
Windfarms in Germany, from de.wikipedia 14 Nov 2021
View 0-Windfarms-in-Germany.md

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 Nov 7, 2021
Basic image warping or map reproject in python 7 Nov 2021
View 0-warp.md

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 Sep 13, 2021
rioxarray reproject UTM -> 4326 widens NaNs at the sides 13 Sep 2021
View 0-warp_raster_test.md

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 Jul 12, 2021
Electricity in Germany from coal, wind etc.
View 0-German-energy.md

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 Jun 10, 2021
Read German Corona data rki.de/.../Fallzahlen_Kum_Tab.xlsx in python pandas
View rki_excel.py
#!/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 Feb 28, 2022
Fitting 1 / x with polynomials in relative error
View 0-fitting-1-over-x-with-polynomials.md

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 Apr 3, 2021
A simple matrix with interesting inverse 31 Mar 2021
View 0-tri101-inverse.md

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