Skip to content

Instantly share code, notes, and snippets.

@hertzsprung
hertzsprung / post.sh
Created June 15, 2016 22:28
tempestmodel post-processing
#!/bin/tcsh
setenv CASE /glade/scratch/jashaw/supercell/15
setenv EXTRACT_SURFACE $HOME/work/tempestmodel/util/ExtractSurface/ExtractSurface
ncrcat --overwrite $CASE/outU7.0000-*.nc $CASE/outU7.all.nc
bsub -K -q tutorial -W "0:05" -n 1 -P SCIS0006 mpirun.lsf $EXTRACT_SURFACE --in $CASE/outU7.all.nc --out $CASE/outU7.all.5km.nc --var 'W,Rho,RhoQr' --z 5000
ncl plot_supercell_5km_xsec.ncl
@hertzsprung
hertzsprung / gist:b714e54926abb4793038998f8781c20b
Last active May 20, 2016 09:36
PDF metadata for LaTeX documents
\makeatletter
\AtBeginDocument{
\hypersetup{
pdftitle = {\@title},
pdfauthor = {\@author}
}
}
\makeatother
@hertzsprung
hertzsprung / animate-gnuplot.sh
Last active March 17, 2016 11:38
Visualising a least squares fit of a polynomial surface to 12 data points in 2D space
#/bin/bash
set -e
rm -f plot*.png plot.gif
for i in $(seq 0 119);
do
./surface-fit-visualisation.py 60 $((30 + $i * 3)) $(printf "%03g" $i) | gnuplot5
done
for i in $(seq 0 30);
#!/usr/bin/env python3
from numpy.linalg import pinv
from numpy import diag
from numpy import transpose
from numpy import dot
import numpy as np
# a 3x3 stencil with centroids between (-1.5,1) and (0.5,1)
# to interp onto face at (0,0)
# upwind cell first, then downwind cell, then top row L-R, bottom row L-R, then left-most cell in middle row
@hertzsprung
hertzsprung / msc-computing.md
Created July 29, 2015 10:38
MSc computing notes

Work through an exercise of processing a CSV file containing time series data on amount of sunshine.

Exercise requirements

TODO

On the day

  1. Plan conceptual steps together to create a flowchart on whiteboard
  • how to find and use existing code
@hertzsprung
hertzsprung / Makefile
Last active August 29, 2015 14:21
SDL2/cairo cross compiler test with mingw
PKG_CONFIG := pkg-config
#SDL_CONFIG := sdl2-config
SDL_CONFIG := /usr/x86_64-w64-mingw32/bin/sdl2-config
SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
SDL_LDFLAGS := $(shell $(SDL_CONFIG) --libs)
CAIRO_CFLAGS := $(shell $(PKG_CONFIG) cairo --cflags)
CAIRO_LDFLAGS := $(shell $(PKG_CONFIG) cairo --libs)
cairotest: cairotest.c
clang $(SDL_CFLAGS) $(SDL_LDFLAGS) $(CAIRO_CFLAGS) $(CAIRO_LDFLAGS) -o cairotest cairotest.c
@hertzsprung
hertzsprung / check_netcdf.py
Created September 14, 2014 14:27
Check NetCDF installation
from netCDF4 import Dataset
from mpl_toolkits.basemap import Basemap
@hertzsprung
hertzsprung / NestedProvidersTest.java
Created April 5, 2013 18:04
Attempting to nest custom providers
import com.sun.jersey.api.core.DefaultResourceConfig;
import com.sun.jersey.core.spi.component.ComponentContext;
import com.sun.jersey.spi.inject.Injectable;
import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider;
import com.sun.jersey.test.framework.JerseyTest;
import com.sun.jersey.test.framework.LowLevelAppDescriptor;
import com.sun.jersey.test.framework.spi.container.TestContainerException;
import org.junit.Test;
import javax.ws.rs.GET;
@hertzsprung
hertzsprung / AllOfTestCase.java
Created March 12, 2013 10:18
Hamcrest AllOf diagnostics
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasProperty;
import org.junit.Test;
import java.util.Arrays;
import java.util.Iterator;
@hertzsprung
hertzsprung / gist:4716775
Created February 5, 2013 19:04
Silly bit twiddling for berlin clock
public class BerlinClock {
public static String[] print(Time time) {
char seconds = (char) (89 - 10 * (time.second & 1));
char our = (char) (79 + 3 * (time.hour & 1));
/*
000 00000000 00000000 00000000 00000000
001 00000000 00000000 00000000 10000000