Skip to content

Instantly share code, notes, and snippets.

View tenomoto's full-sized avatar

Takeshi Enomoto tenomoto

View GitHub Profile
@tenomoto
tenomoto / quarto-tufte.yaml
Created April 8, 2024 07:04
Quarto YAML header for Tufte-like handout in Japanese
title: 日本語タイトル
author: 榎本剛
date: 9 April 2024
format:
pdf: default
html:
grid:
margin-width: 350px
reference-location: margin
citation-location: margin
@tenomoto
tenomoto / Makevars
Created February 24, 2024 01:08
Makevars to install rstan on FreeBSD
CPPFLAGS+= -DTBB_INTERFACE_NEW=true
LDFLAGS+= -ltbb -ltbbmalloc
@tenomoto
tenomoto / carnot-es.R
Created September 28, 2023 08:10
Carnot cycle and satuation vapour pressure
eps <- 0.622
calc.es <- function(T) {
# WMO, JMA
exp(19.482-4303.4/(T-29.65))*100
}
pref <- 1e5
Rv <- 461 # J/K/kg
gm <- 7/5
t <- 288
@tenomoto
tenomoto / Makefile
Created September 21, 2023 08:22
FFTW test
.SUFFIXES:
.SUFFIXES: .o .f90
FC = gfortran12
LDLIBS = -lfftw3
LDFLAGS = -L/usr/local/lib
FFLAGS = -O2 -I/usr/local/include
SRCS = $(TARGET).f90
OBJS = $(SRCS:.f90=.o)
TARGET = fftw_test
@tenomoto
tenomoto / epmet.R
Last active September 6, 2023 08:50
Moist thermodynamic functions in Meteorology
eps <- 0.622
e2q <- function (e, p) {
eps*e/(p-(1.0-eps)*e)
}
q2e <- function(q, p) {
p*q/(eps+(1.-eps)*q)
}
@tenomoto
tenomoto / decode_temp_ship.py
Created August 27, 2023 00:19
Decode TEMP ship reports in TAC
import os
import sys
def decode_meta(rep):
dd = rep[2][:2]
hh = rep[2][2:4]
lat = int(rep[6][2:]) * 0.1
lon = int(rep[7][1:]) * 0.1
meta = {"dd":dd, "hh":hh, "vessel":rep[4], "lon":lon, "lat":lat}
@tenomoto
tenomoto / l63.cc
Created August 20, 2023 08:12
Autograd L63
#include <cstdio>
#include <random>
#include <chrono>
int enzyme_dup;
int enzyme_dupnoneed;
int enzyme_out;
int enzyme_const;
template < typename return_type, typename ... T >
@tenomoto
tenomoto / tab10.R
Last active June 6, 2023 00:06
tableau10 colour cycle in R
tab10 = c('#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf')
@tenomoto
tenomoto / quad1.c
Created February 25, 2023 06:45
serial quad in C
// C translation of https://www.nag-j.co.jp/fortran/coarray/code/quad1.f90
#include <stdio.h>
#include <stdlib.h>
double rectangle_rule(double (*f)(double), double from, double to, int nstep)
{
double integral;
double x1, x2, y, stepval;
int i;
@tenomoto
tenomoto / README.md
Last active February 4, 2023 08:09
Vandermonde interpolation in Swift and Python

Vandermonde Interpolation

Conduct interpolation using a Vandermonde matrix based on the articles in Apple Developer.

Differences

To allow compiliation without GUI, the original source is modified as follows.

  • solveLinearSystem is declared without static and called without ViewController.