Skip to content

Instantly share code, notes, and snippets.

View calum-chamberlain's full-sized avatar

Calum Chamberlain calum-chamberlain

View GitHub Profile
@calum-chamberlain
calum-chamberlain / Geonet_workaround.py
Created February 22, 2016 22:37
Current work-around for GeoNet event query
from obspy.clients.fdsn import Client
publicIDs=['2016p008122', '2016p008353', '2016p008155', '2016p008194']
client = Client("GEONET")
catalog = Catalog()
for publicID in publicIDs:
data_stream = client._download('http://quakeml.geonet.org.nz/' +
'quakeml/1.2/' + publicID)
data_stream.seek(0, 0)
@calum-chamberlain
calum-chamberlain / Inventory_to_station0.py
Last active October 19, 2016 21:11
Simple code to take obspy Inventory objects and write out station locations formatted for seisan STATION0.HYP files.
def inventory_to_seisan(inventory, filename):
"""
Write station co-ordinates from an inventory object to STATION0.HYP format.
:type inventory: :class:`~obspy.core.inventory.Inventory`
:param inventory: Inventory to write co-ordinated from.
:type filename: str
:param filename: Filename to output to, will overwrite file is present
.. note::
from eqcorrscan.core import match_filter, lag_calc
from eqcorrscan.utils import pre_processing
from eqcorrscan.utils.plotting import detection_multiplot
from obspy import read, Catalog
import glob
import os
outfile = open("failed_days", "w")
# Read in the templates
def normxcorr1(template, search_window):
"""
Normlized cross-correlation using scipy - contributed by d-chambers.
:type template: :class:`numpy.ndarray`
:param template: 1D numpy array to use as template
:type search_window: :class: `numpy.ndarray`
:param search_window: 1D numpy array to search for the template within.
:rtype: :class: `numpy.ndarray`
@calum-chamberlain
calum-chamberlain / multi_normxcorr.py
Created March 1, 2017 01:01
A re-write of match_filter internals to use script rather than openCV
from __future__ import division, print_function, absolute_import
import bottleneck
import threading
import numpy as np
import time
from scipy._lib._version import NumpyVersion
from scipy.signal.signaltools import _centered
from scipy import fftpack
@calum-chamberlain
calum-chamberlain / obspy_event_io.ipynb
Last active October 9, 2017 00:58
Test of Obspy IO times
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calum-chamberlain
calum-chamberlain / obspy_normxcorr.ipynb
Created January 7, 2018 20:34
Demonstration of normalisation using obspy correlate functions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calum-chamberlain
calum-chamberlain / attach_geonet_mt.py
Last active January 24, 2018 04:21
Simple function to attach available moment-tensor information to a given catalogue by downloading and integrating John Ristau's mt solutions.
def get_geonet_moment_tensor(catalog):
"""
Get the moment tensor info for a given set of events, and add them to the
events.
Use John Ristau's MT catalog here:
`https://raw.githubusercontent.com/GeoNet/data/master/moment-tensor/GeoNet_CMT_solutions.csv`
which does not include all events, if events are not in the database they
will warn that they are not found.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.