Comments (2)
@timronan already created this class but does not have permissions to branch from the code main branch to submit a a Pull request for review.
Class could be /mth5/mth5/utils/make_mth5.py
And to start would contain the code
from obspy import UTCDateTime
from mt_metadata.timeseries.stationxml import XMLInventoryMTExperiment
from mth5.mth5 import MTH5
from mth5.timeseries import RunTS
import os
class Make_MTH5():
def make_mth5_from_iris(network, station, starttime, endtime, path=None,
client='IRIS'):
if path is None:
path = str(os.getcwd()) + '/'
network = network
station = station
start = UTCDateTime(starttime)
end = UTCDateTime(endtime)
file_name = path + network + '_' + station + '_' + starttime + '.h5'
# need to know network, station, start and end times before hand
client = fdsn.Client(client)
# get the data
streams = client.get_waveforms(network, station, None, None, start, end)
# get the metadata
inventory = client.get_stations(
start, end, network=network, station=station, level="channel"
)
# translate obspy.core.Inventory to an mt_metadata.timeseries.Experiment
translator = XMLInventoryMTExperiment()
experiment = translator.xml_to_mt(inventory)
# initiate MTH5 file
m = MTH5()
m.open_mth5(r"" + file_name, "w")
# fill metadata
m.from_experiment(experiment)
station_group = m.get_station(station)
# runs can be split into channels with similar start times and sample rates
start_times = sorted(list(set([tr.stats.starttime.isoformat() for tr in streams])))
end_times = sorted(list(set([tr.stats.endtime.isoformat() for tr in streams])))
for index, times in enumerate(zip(start_times, end_times), 1):
run_stream = streams.slice(UTCDateTime(times[0]), UTCDateTime(times[1]))
run_ts_obj = RunTS()
run_ts_obj.from_obspy_stream(run_stream)
run_group = station_group.add_run(f"{index:03}")
run_group.from_runts(run_ts_obj)
print(file_name + " has been built.")
m.close_mth5()
return file_name
or similar.
from mth5.
Closed by merging branch enhancement_42
from mth5.
Related Issues (20)
- User Applied Filters and Custom Transformations HOT 1
- More permissive data storage in the FC Level
- Cannot filter on a RunTS dataset HOT 1
- channel summary df schema configurable
- fdsn client sometimes cannot get inventory
- Earthscope Bartington magnetometers Exceptions when building MTH5 HOT 3
- multi-station spectrogram HOT 2
- Ability to slice on an FC Dataset
- Downsampling zen data to 150 Hz does not work HOT 1
- Station summary fails if date time has no milliseconds HOT 1
- resampling not robust
- Extraction of a subset to another mth5 archive (export_subset)
- How to set survey metadata values for v0.1.0 data HOT 1
- ValueError: numpy.dtype size changed, may indicate binary incompatibility.
- mth5_type not written to mth5 channel dataset HOT 1
- Timestamps Stress Test
- Importable small test dataset with FCs
- FC Summary
- clarify synthetic data channel labels
- [MTH5] Inquiry on Processing Geophoenix MTU-5A Data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mth5.