Skip to content

Instantly share code, notes, and snippets.

View earthinversion's full-sized avatar
💭
I may be slow to respond.

Utpal Kumar earthinversion

💭
I may be slow to respond.
View GitHub Profile
@earthinversion
earthinversion / vscode-macos-context-menu.md
Created October 21, 2023 03:49 — forked from idleberg/vscode-macos-context-menu.md
“Open in Visual Studio Code” in macOS context-menu

Open in Visual Studio Code

  • Open Automator
  • Create a new document
  • Select Quick Action
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
    • your default shell should already be selected, otherwise use /bin/zsh for macOS 10.15 (”Catalina”) or later
    • older versions of macOS use /bin/bash
  • if you're using something else, you probably know what to do 😉
@earthinversion
earthinversion / convert_km_degree.c
Last active May 14, 2022 20:09
Utility program to convert epicentral distances in km to degrees and vice-versa
#include <stdio.h> //perror
#include <stdlib.h> //atof, exit, EXIT_FAILURE
#include <dlfcn.h> // dlopen, RTLD_LAZY, dlsym
#include <libgen.h> // basename
#include <getopt.h> // struct option, getopt_long, optarg
void print_usage(const char *name)
{
printf("Usage: %s -[k|d] <epicentral distance in km/deg>\n"
@earthinversion
earthinversion / support.c
Created May 14, 2022 19:26
library to convert epicentral distance in km and degrees
float convertKMtoDegree(float c)
{
return (c / 111.1);
}
float convertDegreetoKM(float c)
{
return (c * 111.1);
}
@earthinversion
earthinversion / autoDRM-canadian-seismic-network.txt
Created March 9, 2022 19:28
Instructions on requesting the waveform data using AutoDRM from the Canadian National Data Centre for Earthquake Seismology and Nuclear Explosion Monitoring (CNDC) for the exchange of seismic and other geophysical data
AutoDRM is an automatic, electronic mail-based message handling system
developed and maintained by the Canadian National Data Centre for Earthquake
Seismology and Nuclear Explosion Monitoring (CNDC) for the exchange of
seismic and other geophysical data. It has been in continuous operation
since April 1994. AutoDRM uses a command language that represents an
amalgam of the command set and structure of the original Swiss autodrm and
the GSE2.0 and IMS1.0 command sets (see below). While every effort has been
made to allow the old commands to function fully, users are encouraged to
adopt the GSE/IMS command set since it is more powerful and flexible and is
an International Standard. More information on GSE/IMS formats and
network,station,channel,stla,stlo,stel,evla,evlo,evdp,starttime,endtime,samplingRate,dist,baz
TW,GWUB,HHZ,24.5059,121.1131,2159.0,-58.5981,-26.4656,164.66,2018-12-11T02:25:32.000002Z,2018-12-11T03:56:31.990002Z,100.0,15445.41,205.14
TW,LXIB,HHZ,24.0211,121.4133,1327.0,-58.5981,-26.4656,164.66,2018-12-11T02:25:32.000000Z,2018-12-11T03:56:31.990000Z,100.0,15409.58,204.75
TW,VCHM,HHZ,23.2087,119.4295,60.0,-58.5981,-26.4656,164.66,2018-12-11T02:25:32.000000Z,2018-12-11T03:56:31.990000Z,100.0,15242.27,205.4
TW,VDOS,HHZ,20.701,116.7306,5.0,-58.5981,-26.4656,164.66,2018-12-11T02:25:32.000000Z,2018-12-11T03:56:31.990000Z,100.0,14871.63,205.6
TW,VNAS,HHZ,10.3774,114.365,2.0,-58.5981,-26.4656,164.66,2018-12-11T02:25:32.000000Z,2018-12-11T03:56:31.990000Z,100.0,13726.26,203.23
TW,VWDT,HHZ,23.7537,121.1412,2578.0,-58.5981,-26.4656,164.66,2018-12-11T02:25:32.000000Z,2018-12-11T03:56:31.990000Z,100.0,15371.08,204.77
TW,VWUC,HHZ,24.9911,119.4492,42.0,-58.5981,-26.4656,164.66,2018-12-11T02:25:32.000000Z,2018-12-11T03:56:31.9
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import pygmt
import pandas as pd
# 1995-07-05 17:33:48.600 24.8313 122.1158 27 4.87
data = pd.read_csv('evtlist.dat', names=['SN','year','time','latitude','longitude','depth_km','magnitude'], delimiter='\s+')
minlon, maxlon = 119.5, 124.0
minlat, maxlat = 19.8, 26.0
# Load sample earth relief data
grid = pygmt.datasets.load_earth_relief(resolution="03s", region=[minlon, maxlon, minlat, maxlat])
@earthinversion
earthinversion / write_gcmt.py
Created November 7, 2021 13:10
Use Obspy to read the catalog and format the information and write it into a CSV file
import sys
import subprocess
import numpy as np
import os
import glob
from obspy import read_events, UTCDateTime
import dask.dataframe as dd
# Path to CMT catalog (ndk file)
path_to_CMT_cat = 'https://www.ldeo.columbia.edu/~gcmt/projects/CMT/catalog/jan76_dec20.ndk'
@earthinversion
earthinversion / parse_yaml.sh
Created August 17, 2021 08:41 — forked from pkuczynski/LICENSE
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
@earthinversion
earthinversion / earthquake-data-on-a-topographic-map.py
Created August 4, 2021 03:01
Read the earthquake data from a csv file and overlay on a topographic map using PyGMT.
import pygmt
import pandas as pd
# this file is retrieved from the pygmt dataset
data = pd.read_csv('my_events_data.csv')
# Set the region
region = [
data.longitude.min() - 1,
data.longitude.max() + 1,