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 / 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-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,

@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-Poisson-matrices.md
Last active June 11, 2024 15:27
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