Skip to content

Commit 293b659

Browse files
committed
updating docs
1 parent d8c11bb commit 293b659

File tree

2 files changed

+108
-102
lines changed

2 files changed

+108
-102
lines changed

docs/source/examples.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
Clients
1+
Examples of External Clients
22
---------------------------------------
33

4+
These are examples of downloading data from data services like
5+
FDSN and the Geomagnetic Observatory data supplied by the
6+
U.S. Geological Survey.
7+
48
.. toctree::
59
:maxdepth: 1
610

docs/source/file_readers.rst

Lines changed: 103 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -270,66 +270,66 @@ If you add a reader, you should also add a `Client`. This should inherit :class
270270
.. code-block:: python
271271
272272
class NewFileTypeClient(ClientBase):
273-
def __init__(
274-
self,
275-
data_path,
276-
save_path=None,
277-
mth5_filename="from_new_file_type.h5",
278-
**kwargs
279-
):
280-
super().__init__(
281-
data_path,
282-
save_path=save_path,
283-
sample_rates=[1],
284-
mth5_filename=mth5_filename,
285-
**kwargs
286-
)
287-
288-
self.collection = NewFileCollection(self.data_path)
289-
290-
def make_mth5_from_new_file_type(self, **kwargs):
291-
"""
292-
Create an MTH5 from the new file type using the newly create Collections
293-
object for the new file type.
294-
295-
:param **kwargs: DESCRIPTION
296-
:type **kwargs: TYPE
297-
:return: DESCRIPTION
298-
:rtype: TYPE
299-
300-
"""
301-
302-
for key, value in kwargs.items():
303-
if value is not None:
304-
setattr(self, key, value)
305-
306-
runs = self.get_run_dict()
307-
308-
with MTH5(**self.h5_kwargs) as m:
309-
m.open_mth5(self.save_path, "w")
310-
# here is where you put the code specific to your
311-
# new file type and how to get the data into an
312-
# mth5. It should be organized as runs with
313-
# logical names and use as much metadata as possible
314-
# from the data.
315-
survey_group = m.add_survey(self.collection.survey_id)
316-
317-
for station_id in runs.keys():
318-
station_group = survey_group.stations_group.add_station(
319-
station_id
320-
)
321-
for run_id, run_df in runs[station_id].items():
322-
run_group = station_group.add_run(run_id)
323-
run_ts = read_file(run_df.fn.to_list())
324-
run_ts.run_metadata.id = run_id
325-
run_group.from_runts(run_ts)
326-
station_group.metadata.update(run_ts.station_metadata)
327-
station_group.write_metadata()
328-
329-
# update survey metadata from input station
330-
survey_group.update_metadata()
331-
332-
return self.save_path
273+
def __init__(
274+
self,
275+
data_path,
276+
save_path=None,
277+
mth5_filename="from_new_file_type.h5",
278+
**kwargs
279+
):
280+
super().__init__(
281+
data_path,
282+
save_path=save_path,
283+
sample_rates=[1],
284+
mth5_filename=mth5_filename,
285+
**kwargs
286+
)
287+
288+
self.collection = NewFileCollection(self.data_path)
289+
290+
def make_mth5_from_new_file_type(self, **kwargs):
291+
"""
292+
Create an MTH5 from the new file type using the newly create Collections
293+
object for the new file type.
294+
295+
:param **kwargs: DESCRIPTION
296+
:type **kwargs: TYPE
297+
:return: DESCRIPTION
298+
:rtype: TYPE
299+
300+
"""
301+
302+
for key, value in kwargs.items():
303+
if value is not None:
304+
setattr(self, key, value)
305+
306+
runs = self.get_run_dict()
307+
308+
with MTH5(**self.h5_kwargs) as m:
309+
m.open_mth5(self.save_path, "w")
310+
# here is where you put the code specific to your
311+
# new file type and how to get the data into an
312+
# mth5. It should be organized as runs with
313+
# logical names and use as much metadata as possible
314+
# from the data.
315+
survey_group = m.add_survey(self.collection.survey_id)
316+
317+
for station_id in runs.keys():
318+
station_group = survey_group.stations_group.add_station(
319+
station_id
320+
)
321+
for run_id, run_df in runs[station_id].items():
322+
run_group = station_group.add_run(run_id)
323+
run_ts = read_file(run_df.fn.to_list())
324+
run_ts.run_metadata.id = run_id
325+
run_group.from_runts(run_ts)
326+
station_group.metadata.update(run_ts.station_metadata)
327+
station_group.write_metadata()
328+
329+
# update survey metadata from input station
330+
survey_group.update_metadata()
331+
332+
return self.save_path
333333
334334
335335
Adding to MakeMTH5
@@ -339,47 +339,49 @@ If you add a reader, you should also add the client to `MakeMTH5` for convenienc
339339

340340
.. code-block:: python
341341
342-
@classmethod
343-
def from_new_filetype(
344-
cls,
345-
data_path,
346-
mth5_filename=None,
347-
save_path=None,
348-
**kwargs,
349-
):
350-
"""
351-
Doc string
352-
353-
Any H5 file parameters like compression, shuffle, etc need to have a
354-
prefix of 'h5'. For example h5_compression='gzip'.
355-
356-
>>> MakeMTH5.from_lemi424(
357-
data_path, 'test', 'mt01', **{'h5_compression_opts': 1}
358-
)
359-
360-
361-
:param data_path: Directory where data files are, could be a single
362-
station or a full directory of stations.
363-
:type data_path: str or Path
364-
:param mth5_filename: filename for the H5, defaults to 'from_lemi424.h5'
365-
:type mth5_filename: str, optional
366-
:param save_path: path to save H5 file to, defaults to None which will
367-
place the file in `data_path`
368-
:type save_path: str or Path, optional
369-
:return: Path to MTH5 file
370-
:rtype: Path
371-
"""
372-
maker = cls(**kwargs)
373-
kw_dict = maker.get_h5_kwargs()
374-
375-
lemi_client = NewFileClient(
376-
data_path,
377-
save_path=save_path,
378-
mth5_filename=mth5_filename,
379-
**kw_dict,
380-
)
381-
382-
return lemi_client.make_mth5_from_new_file_type(**kwargs**)
342+
class MakeMTH5:
343+
...
344+
@classmethod
345+
def from_new_filetype(
346+
cls,
347+
data_path,
348+
mth5_filename=None,
349+
save_path=None,
350+
**kwargs,
351+
):
352+
"""
353+
Doc string
354+
355+
Any H5 file parameters like compression, shuffle, etc need to have a
356+
prefix of 'h5'. For example h5_compression='gzip'.
357+
358+
>>> MakeMTH5.from_lemi424(
359+
data_path, 'test', 'mt01', **{'h5_compression_opts': 1}
360+
)
361+
362+
363+
:param data_path: Directory where data files are, could be a single
364+
station or a full directory of stations.
365+
:type data_path: str or Path
366+
:param mth5_filename: filename for the H5, defaults to 'from_lemi424.h5'
367+
:type mth5_filename: str, optional
368+
:param save_path: path to save H5 file to, defaults to None which will
369+
place the file in `data_path`
370+
:type save_path: str or Path, optional
371+
:return: Path to MTH5 file
372+
:rtype: Path
373+
"""
374+
maker = cls(**kwargs)
375+
kw_dict = maker.get_h5_kwargs()
376+
377+
new_file_client = NewFileClient(
378+
data_path,
379+
save_path=save_path,
380+
mth5_filename=mth5_filename,
381+
**kw_dict,
382+
)
383+
384+
return new_file_client.make_mth5_from_new_file_type(**kwargs**)
383385
384386
385387

0 commit comments

Comments
 (0)