Skip to content

Instantly share code, notes, and snippets.

@denis-bz
denis-bz / 0-windspeeds-Netherlands-wikipedia-KNMI-GWA.md
Created October 31, 2022 10:28
Wind speeds and capacity factors in the Netherlands from wikipedia, KNMI and globalwindatlas 31 Oct 2022

Windspeeds and capacity factors in the Netherlands from wikipedia, KNMI and globalwindatlas

Keywords: wind, wind farm, wind speed, capacity factor, onshore, Netherlands, globalwindatlas, GWA, KNMI

What I want to do is show my neighbors around Munich that windfarms make more sense where there's more wind. GWA has a nice GUI, which everyone can understand. But are their wind speed and capacity factors accurate enough to convince anyone ?

nl.wikipedia Windturbines_in_Nederland,

@denis-bz
denis-bz / 0-Introduction-to-Netherlands-wind-data-with-xarray.md
Created August 30, 2022 14:08
Introduction to Netherlands wind data with xarray

Introduction to Netherlands wind data with xarray

Keywords: Netherlands, wind, wind speed, KNMI, python, xarray, data-carpentry

Purpose: introduce Netherlands wind data from KNMI, the Royal Netherlands$ Meteorological Institute, with the steps:

  1. download 2 \.nc files by hand, one day and one gridpoint
  2. look at them in xarray
@denis-bz
denis-bz / 0-Windspeeds-and-windfarms-in-Bayern.md
Created July 23, 2022 14:30
Windspeeds and windfarms in Bayern 23 Jul 2022

Windspeeds and windfarms in Bayern

Keywords: wind power, Germany, Bayern, globalwindatlas, GWA

Purpose: I'm trying to show my neighbors around Munich that windfarms make more sense where there's more wind. To this end, here's a map of GWA windspeeds at 150m, together with the sites of 202 windfarms in Bayern:

21jul-Bayern-windfarms

@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-Poisson-matrices.md
Last active July 5, 2022 11:48
Poisson2 - 4 I: nice test matrices for linear solvers and eigensolvers 25 Jun 2022

Poisson2 - 4 I: nice test matrices for linear solvers and eigensolvers

Purpose: a simple generator of test matrices for linear solvers and eigensolvers

Keywords: sparse-matrix, linear-solver, eigensolver, arpack, nullspace, python

poisson2( n ) below generates sparse $n^2 \ x \ n^2$ matrices $A$ with $A$ symmetric (aka Hermitian) and positive-definite; solving $A \ x = b$ is then relatively easy. $A_4 = A - 4 I$ is more interesting: there are $n$ vectors $z_i$

@denis-bz
denis-bz / ssquery.py
Created June 21, 2022 16:01
One-line queries of the SuiteSparse matrix collection 21 Jun 2022
#!/usr/bin/env python3
""" Usage:
python3 ssquery.py '(posdef == 1) & (1000 <= rows <= 20000)' posdef.csv
reads http://sparse.tamu.edu/files/ssstats.csv
queries it
writes "posdef.csv" like
# SuiteSparse posdef & (1000 <= rows <= 20000)
id,group,name,rows,cols,nnz,real,bool,is2d3d,posdef,symm,nsymm,kind
29156,Boeing,msc01050,1050,1050,26198,1,0,1,1,1.0,1.0,structural
@denis-bz
denis-bz / Compare-timeseries.md
Last active May 16, 2022 12:21
Compare timeseries in python

Comparing time series in Python

The task: you have a hundred pairs of time series, say A1 .. A100 and B1 .. B100, e.g. temperature data at 100 cities in two different years. All the time series are say 365 long, but many days are missing (NA or NaN). Some pairs are quite similar, some not. You want to rank them from most similar .. least similar, 0 .. 100, in order to describe and understand how A and B differ.

(The $64 question: does it matter ?

@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-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-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