Skip to content

Instantly share code, notes, and snippets.

View tenomoto's full-sized avatar

Takeshi Enomoto tenomoto

View GitHub Profile
import pygmt
fig = pygmt.Figure()
#https://docs.generic-mapping-tools.org/dev/cookbook/map-projections.html#js
#https://www.pygmt.org/latest/api/generated/pygmt.Figure.coast.html#pygmt.Figure.coast
# region="xlleft/ylleft/xuright/yuright+r"
# projection="Slon0/lat0/horizon/width"
fig.coast(region="-70/-50/135/15+r", projection="S0/45/120/11c", frame="20g",
resolution="l", area_thresh=250, land="darkbrown", shorelines="thinnest",
@tenomoto
tenomoto / README.md
Last active March 18, 2022 07:55
Select a tropical cyclone in JMA besttrack and print in y,m,d,h,lon,lat,slp

Python

  • process_bst.py

AWK

  1. RSMC Best Track Dataから1951-2021 (ALL)をダウンロードして解凍。
  2. AWKで台風を切り出す。 最初のフィールドが66666が各台風のタイトル。行番号(NR),番号,名前を抽出。
@tenomoto
tenomoto / eq2png
Created March 14, 2022 08:24
Generate png from LaTeX equation
#!/bin/sh
TEMP=temp.tex
TMPDIR=/tmp/$(openssl rand -hex 8)
mkdir ${TMPDIR}
FNAME=$(echo $@ | awk '{print $NF}')
cp ${FNAME} ${TMPDIR}
if [ ! -f ${FNAME} ]; then
echo "${FNAME} not found"
exit
fi
@tenomoto
tenomoto / arrow.py
Created August 20, 2021 03:55
Draw arrows for axes in matplotlib
# https://3diagramsperpage.wordpress.com/2014/05/25/arrowheads-for-axis-in-matplotlib/
import matplotlib.pyplot as plt
ax.tick_params(left=False, bottom=False, labelleft=False, labelbottom=False)
ax.spines[:].set_visible(False)
xmin, xmax = ax.get_xlim()
ymin, ymax = ax.get_ylim()
dx = (xmax - xmin)
dy = (ymax - ymin)
lw = 1.0
@tenomoto
tenomoto / cd.ncl
Last active November 30, 2020 02:08
Date conversions
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_inv_string.ncl"
valid = cd_inv_string("2019101212", "%Y%N%D%H")
init = cd_inv_calendar(2019, 10, 9, 12, 0, 0.0, valid@units, 0)
fth = valid - init
yyyymmddhh = cd_calendar(time, -3)
@tenomoto
tenomoto / x11-openssh.ps1
Created October 21, 2020 04:52
X11 forwarding from Windows 10 OpenSSH client in PowerShell
# Add the following in $profile
# OpenSSH-Win64 installed in Program Files
#$env:PATH += "$env:ProgramFiles/OpenSSH-Win64;"
# Windows 10 OpenSSH client
$env:PATH += "$env:SystemRoot/System32/OpenSSH;"
# X11
$env:DISPLAY = "localhost:0.0"
@tenomoto
tenomoto / maclike.ahk
Created March 1, 2020 20:45
Autohotkey script to send _ withouth shift and en/em dash with alt/alt+shift+-
SC073::_
; en-dash and em-dash
; https://my.wealthyaffiliate.com/pamdemonium/blog/how-to-create-em-dash-shortcut-using-autohotkey-on-windows
; conflicts with sending <- with alt+- in RStudio
!-::Send {U+2013}
+!-::Send {U+2014}
@tenomoto
tenomoto / install_owl_freebsd.md
Last active August 22, 2019 02:48
Install OCaml and Owl on FreeBSD

This gist describes steps to install the latest version of OCaml and Owl on FreeBSD. Tested with FreeBSD 12.0-RELEASE-p9 on Hyper-V/Windows 10 Pro 1903.

Install opam

Install opam as described How to install opan. EDIT the first line may not work. Install opam with pkg.

sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)
opam init
eval $(opam env)
@tenomoto
tenomoto / units.markdown
Created July 12, 2019 08:32
Install R package units on Mac
  • udunits2 is installed with MacPorts
$ curl -O https://mran.microsoft.com/snapshot/2018-08-01/src/contrib/units_0.6-0.tar.gz
$ sudo R CMD INSTALL units_0.6-0.tar.gz --configure-args='--with-udunits2-include=/opt/local/include/udunits2 --with-udunits2-lib=/opt/local/lib'
@tenomoto
tenomoto / nmdash.ahk
Created February 17, 2019 06:03
Send en- and em-dash
!-::Send {U+2013}
+!-::Send {U+2014}