Skip to content

Instantly share code, notes, and snippets.

View sean0921's full-sized avatar

Sean Ho sean0921

View GitHub Profile
@sean0921
sean0921 / Oppenheimer1993_SW.P.mod.VG.gmt
Last active September 20, 2022 06:41
Compare the problem scripts in ( alomax/NonLinLoc #30 )
#!/usr/bin/env bash
#
#
set -ex
#
#
gmtset PAGE_ORIENTATION portrait X_ORIGIN 0.5 Y_ORIGIN 0.5
@sean0921
sean0921 / r4s.log
Created September 11, 2022 16:39
iperf3 test with virtual router on arm64 and amd64
### R4S (Rockchip RK3399, arm64 vm, 4core, 512M ram), client: an archlinux laptop
Connecting to host 192.168.0.104, port 5201
[ 5] local 192.168.1.229 port 60386 connected to 192.168.0.104 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 90.5 MBytes 759 Mbits/sec 0 1.56 MBytes
[ 5] 1.00-2.00 sec 95.0 MBytes 797 Mbits/sec 0 3.08 MBytes
[ 5] 2.00-3.00 sec 87.5 MBytes 734 Mbits/sec 131 2.33 MBytes
[ 5] 3.00-4.00 sec 87.5 MBytes 734 Mbits/sec 0 2.51 MBytes
[ 5] 4.00-5.00 sec 87.5 MBytes 734 Mbits/sec 0 2.66 MBytes
[ 5] 5.00-6.00 sec 91.2 MBytes 765 Mbits/sec 0 2.79 MBytes
@sean0921
sean0921 / README.md
Created July 22, 2022 02:26
nvim config backup
@sean0921
sean0921 / README.md
Last active July 11, 2022 05:12
Redraw GrowClust Algorithm (Trugman and Shearer, 2017)

Redraw GrowClust Algorithm (Trugman and Shearer, 2017) by GMT6 bash script

  • Reference: Trugman, D. T., & Shearer, P. M. (2017). GrowClust: A hierarchical clustering algorithm for relative earthquake relocation, with application to the Spanish Springs and Sheldon, Nevada, earthquake sequences. Seismological Research Letters, 88(2A), 379-391.
  • GrowClust GitHub repository: https://github.com/dttrugman/GrowClust

圖片

@sean0921
sean0921 / linear_magnitude_estimate.py
Created June 15, 2022 09:27
Linear Magnitude Estimation (assume that distance is almost equal)
#!/usr/bin/env python3
from obspy import read
from glob import glob
from numpy import mean,array,float32,polyfit,poly1d
from sys import exit
from matplotlib import pyplot as plt
from math import log
from scipy import stats
import pandas as pd
@sean0921
sean0921 / pfile_to_ellipse.py
Last active November 16, 2021 02:53
CWB P-file (HYPO71) to HYPOELLIPSE format trasnformer
#!/usr/bin/env python3
#This is free and unencumbered software released into the public domain.
#
#Anyone is free to copy, modify, publish, use, compile, sell, or
#distribute this software, either in source code form or as a compiled
#binary, for any purpose, commercial or non-commercial, and by any
#means.
#
#In jurisdictions that recognize copyright laws, the author or authors
@sean0921
sean0921 / toYearFraction.py
Last active June 15, 2021 14:46
How to convert Python datetime dates to decimal/float years
#!/usr/bin/env python3
# -- usage: from toYearFraction import toYearFraction
# source: https://stackoverflow.com/questions/6451655/
from datetime import datetime as dt
import time
def toYearFraction(date):
def sinceEpoch(date): # returns seconds since epoch
return time.mktime(date.timetuple())
@sean0921
sean0921 / gmt6_polar.bash
Created June 12, 2021 09:55
gmt6 polar test
#!/usr/bin/env bash
## GMT version: 6 (modern mode required)
GMT=/usr/bin/gmt
${GMT} begin mypolar_ex1 png,pdf,ps
${GMT} set PROJ_LENGTH_UNIT inch MAP_TICK_LENGTH_PRIMARY 0.075i MAP_FRAME_WIDTH 0.1i \
MAP_ORIGIN_X 2.5c MAP_ORIGIN_Y 1.3i FONT_TITLE 18p
${GMT} meca -R85/89/25/50 -JX7i -M -Sa4i -N -L -G150 `#-T0` << EOF
@sean0921
sean0921 / dataprocess.py
Last active June 7, 2021 11:43
SAC data pre-processing with obspy for ISOLA
#!/usr/bin/env python3
from obspy import read
from glob import glob
from pathlib import Path
from sys import exit,argv
datadir = argv[1]
filelist = sorted(glob(f'{datadir}/*.sac'))
#filelist = glob(f'{datadir}/*.SAC')
@sean0921
sean0921 / pygmt_project.py
Last active September 13, 2021 08:52
Draft for testing PyGMT project module
from pygmt.clib import Session
from pygmt.helpers import GMTTempFile
from io import StringIO
import pandas as pd
def sean_pygmt_project(project_arguments: str) -> pd.DataFrame:
with Session() as ses:
with GMTTempFile() as fout:
ses.call_module('project',f'{project_arguments} ->{fout.name}')
session_output_string=fout.read().strip()