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 / file.pro
Last active September 13, 2021 09:11
Embedded matplotlib inside Qt5 C++
######################################################################
# Automatically generated by qmake (3.1) Mon Sep 13 15:29:11 2021
######################################################################
TEMPLATE = app
TARGET = embedded
INCLUDEPATH += .
INCLUDEPATH += /home/yudha/Miniconda/envs/pyqt5/include/python3.9
# The following define makes your compiler warn you if you use any
@yudhastyawan
yudhastyawan / c_penjumlahan.f90
Created May 24, 2021 12:49
embed Fortran in Python using Cython
module penjumlahan_interface
use iso_c_binding, only: c_double
use penjumlahan_module, only: penjumlahan
implicit none
contains
subroutine c_penjumlahan(a, b, c) bind(c)
real(c_double), intent(in) :: a, b
real(c_double), intent(out) :: c
call penjumlahan(a, b, c)
@yudhastyawan
yudhastyawan / multiplexml2sacpz.py
Last active August 12, 2021 05:24
convert xml data to polezeros using obspy
import os
import glob
import shutil
from obspy import read_inventory
xmlFiles = glob.glob("./*.xml")
for xmlFile in xmlFiles:
print(xmlFile)
inventory = read_inventory(xmlFile)
@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.
@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 / 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 / contoh_tut1.txt
Last active April 21, 2021 09:22
GMT Tutorial
3,2
4,4
3,3
@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 / 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 / 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