Skip to content

Instantly share code, notes, and snippets.

View yudhastyawan's full-sized avatar
💭
Computational Geophysics

Yudha Styawan yudhastyawan

💭
Computational Geophysics
View GitHub Profile
@yudhastyawan
yudhastyawan / gmtgrid1.sh
Created January 9, 2020 07:32
Convert a *.grid file to ASCII using GMT 5 (Tracking Mode)
#!/bin/bash
inputgrd='data.grd'
start=100/-2
end=93/5
gmt project -C$start -E$end -G1 -Q | gmt grdtrack -G$inputgrd > data.xyz
awk '{print $1, $2, $4}' data.xyz > datarev.xyz
@yudhastyawan
yudhastyawan / timer.cpp
Created January 27, 2020 05:32
Check your C++ code performance (speed time)
#include <iostream>
#include <chrono>
class Timer
{
public:
Timer()
{
m_StartTimePoint = std::chrono::high_resolution_clock::now();
}
@yudhastyawan
yudhastyawan / cout.cpp
Created January 27, 2020 05:44
An example of costumizing std::cout in C++
#include <iostream>
#include <ostream>
struct Vector
{
int x, y;
Vector(int X, int Y) : x(X), y(Y) {}
};
std::ostream& operator<<(std::ostream& stream, const Vector& other)
@yudhastyawan
yudhastyawan / mpltopyqt.py
Created January 29, 2020 12:22
An example of Matplotlib embedding to PyQt5
import sys
import numpy as np
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import \
FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import \
NavigationToolbar2QT as NavigationToolbar
@yudhastyawan
yudhastyawan / Makefile(SWIG)
Created February 3, 2020 05:13
A Makefile example for SWIG (standard)
CXX = gcc
INCLUDES = -I./
COMPFLAGS = -c -Wall -fPIC
PYINC = /home/yudha/applications/miniconda3/include/python3.7m
SWIG = /usr/bin/swig
PACKAGE = example
OPT = -O2
# BUILD_DIR = ./buildpack
BINARIES = $(PACKAGE).o _$(PACKAGE).so $(PACKAGE)_wrap.o $(PACKAGE)_wrap.c
BINARIESEND = $(PACKAGE).o $(PACKAGE)_wrap.o $(PACKAGE)_wrap.c
@yudhastyawan
yudhastyawan / Makefile(Multiple)
Created February 3, 2020 06:06
Work with multiple directories (Makefile)
all: do
do:
@for a in *; do \
if [ -d $$a ]; then if [ -f $$a/Makefile ]; then \
echo $$a && cd $$a && make && cd ..; \
fi; fi; \
done;
@yudhastyawan
yudhastyawan / contoh_tut1.txt
Last active April 21, 2021 09:22
GMT Tutorial
3,2
4,4
3,3
@yudhastyawan
yudhastyawan / headersac.csv
Created April 21, 2021 19:43
SAC Tutorial and Case Study
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
Word Type NAMES o o o o
0 F DELTA DEPMIN DEPMAX SCALE ODELTA
5 F B E O A INTERNAL
10 F T0 T1 T2 T3 T4
15 F T5 T6 T7 T8 T9
20 F F RESP0 RESP1 RESP2 RESP3
25 F RESP4 RESP5 RESP6 RESP7 RESP8
30 F RESP9 STLA STLO STEL STDP
35 F EVLA EVLO EVEL EVDP MAG
40 F USER0 USER1 USER2 USER3 USER4
@yudhastyawan
yudhastyawan / cfunc.c
Last active April 25, 2021 04:55
homework 3: embedded fortran and C in Python
#include <stdio.h>
#include "cfunc.h"
void c_add(double* a, double* b, double* c)
{
*c = *a + *b;
}
@yudhastyawan
yudhastyawan / running_tables.ipynb
Last active May 1, 2021 21:08
Jupyter notebooks and labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.