@@ -200,9 +200,19 @@ def create_kernel_dataset(
200
200
def process_single_sample_rate (
201
201
self , sample_rate , config = None , kernel_dataset = None
202
202
):
203
- """Process data.
204
- :return: DESCRIPTION.
205
- :rtype: TYPE
203
+ """
204
+ Process a single sample rate
205
+
206
+ :param sample_rate: sample rate of time series data
207
+ :type sample_rate: float
208
+ :param config: configuration file, defaults to None
209
+ :type config: aurora.config, optional
210
+ :param kernel_dataset: Kerenel dataset to define what data to process,
211
+ defaults to None
212
+ :type kernel_dataset: mtpy.processing.KernelDataset, optional
213
+ :return: transfer function
214
+ :rtype: mtpy.MT
215
+
206
216
"""
207
217
208
218
if kernel_dataset is None :
@@ -235,35 +245,52 @@ def process(
235
245
merge = True ,
236
246
save_to_mth5 = True ,
237
247
):
238
- """If you provide just the sample rates, then at each sample rate a
248
+ """
249
+ Need to either provide a list of sample rates to process or
250
+ a processing dictionary.
251
+
252
+ If you provide just the sample rates, then at each sample rate a
239
253
KernelDataset will be created as well as a subsequent config object
240
254
which are then used to process the data.
241
255
242
256
If processing_dict is set then the processing will loop through the
243
257
dictionary and use the provided config and kernel datasets.
244
258
245
- process all runs for all sample rates and the combine the transfer
246
- function according to merge_dict.
259
+ The processing dict has the following form
247
260
248
- Need to figure out a way to adjust the config per sample rate. Maybe
249
- A dictionary of configs keyed by sample rate.
261
+ .. code_block:: python
250
262
251
- processing_dict = {sample_rate: {
252
- "config": config object,
253
- "kernel_dataset": KernelDataset object,
254
- }
255
- :param processing_dict:
256
- Defaults to None.
257
- :param sample_rates:
258
- Defaults to None.
259
- :param config: Dictionary of configuration keyed by sample rates.
260
- :type config: dictionary
261
- :param merge: DESCRIPTION, defaults to True.
262
- :type merge: TYPE, optional
263
- :param save_to_mth5: DESCRIPTION, defaults to True.
263
+ processing_dict = {sample_rate: {
264
+ "config": config object,
265
+ "kernel_dataset": KernelDataset object,
266
+ }
267
+
268
+ If merge is True then all runs for all sample rates are combined into
269
+ a single function according to merge_dict.
270
+
271
+ If `save_to_mth5` is True then the transfer functions are saved to
272
+ the local MTH5.
273
+
274
+
275
+ :param sample_rates: list of sample rates to process, defaults to None
276
+ :type sample_rates: float or list, optional
277
+ :param processing_dict: processing dictionary as described above,
278
+ defaults to None
279
+ :type processing_dict: dict, optional
280
+ :param merge: [ True | False ] True merges all sample rates into a
281
+ single transfer function according to the merge_dict, defaults to True
282
+ :type merge: bool, optional
283
+ :param save_to_mth5: [ True | False ] save transfer functions to the
284
+ local MTH5, defaults to True
264
285
:type save_to_mth5: TYPE, optional
265
- :return: DESCRIPTION.
266
- :rtype: TYPE
286
+ :raises ValueError: If neither sample rates nor processing dict are
287
+ provided
288
+ :raises TypeError: If the provided processing dictionary is not
289
+ the correct format
290
+ :return: dictionary of each sample rate processed in the form of
291
+ {sample_rate: {'processed': bool, 'tf': MT}}
292
+ :rtype: dict
293
+
267
294
"""
268
295
269
296
if sample_rates is None and processing_dict is None :
@@ -328,26 +355,15 @@ def process(
328
355
return processed
329
356
330
357
def _validate_config (self , config ):
331
- """Validate config.
332
- :param config: DESCRIPTION.
333
- :type config: TYPE
334
- :return: DESCRIPTION.
335
- :rtype: TYPE
336
- """
358
+ """Validate config."""
337
359
if not isinstance (config , Processing ):
338
360
raise TypeError (
339
361
"Config must be a aurora.config.metadata.Processing object. "
340
362
f"Got type { type (config )} "
341
363
)
342
364
343
365
def _validate_kernel_dataset (self , kernel_dataset ):
344
- """Validate kernel dataset.
345
- :param kernel_dataset:
346
- :param config: DESCRIPTION.
347
- :type config: TYPE
348
- :return: DESCRIPTION.
349
- :rtype: TYPE
350
- """
366
+ """Validate kernel dataset."""
351
367
if not isinstance (kernel_dataset , KernelDataset ):
352
368
raise TypeError (
353
369
"Config must be a mtpy.processing.KernelDataset object. "
@@ -356,10 +372,9 @@ def _validate_kernel_dataset(self, kernel_dataset):
356
372
357
373
def _validate_processing_dict (self , processing_dict ):
358
374
"""Validate the processing dict to make sure it is in the correct format.
359
- :param processing_dict: DESCRIPTION.
360
- :type processing_dict: TYPE
361
- :return: DESCRIPTION.
362
- :rtype: TYPE
375
+
376
+ :param processing_dict: processing dictionary
377
+ :type processing_dict: dict
363
378
"""
364
379
error_msg = "Format is {sample_rate: {'config': config object, "
365
380
"'kernel_dataset': KernelDataset object}"
@@ -388,10 +403,11 @@ def _validate_tf_processed_dict(self, tf_dict):
388
403
"""Pick out processed transfer functions from a given processed dict,
389
404
which may have some sample rates that did not process for whatever
390
405
reason.
391
- :param tf_dict: DESCRIPTION.
392
- :type tf_dict: TYPE
393
- :return: DESCRIPTION.
394
- :rtype: TYPE
406
+
407
+ :param tf_dict: dictionary of processed transfer functions.
408
+ :type tf_dict: dict
409
+ :return: dicionary of trasnfer functions for which processed=True
410
+ :rtype: dict
395
411
"""
396
412
397
413
new_dict = {}
@@ -405,10 +421,9 @@ def _validate_tf_processed_dict(self, tf_dict):
405
421
406
422
def _add_tf_to_local_mth5 (self , tf_dict ):
407
423
"""Add transfer function to MTH5.
408
- :param tf_dict: DESCRIPTION.
409
- :type tf_dict: TYPE
410
- :return: DESCRIPTION.
411
- :rtype: TYPE
424
+
425
+ :param tf_dict: dictionary of transfer functions
426
+ :type tf_dict: dict
412
427
"""
413
428
414
429
with MTH5 () as m :
@@ -418,10 +433,12 @@ def _add_tf_to_local_mth5(self, tf_dict):
418
433
419
434
def _get_merge_tf_list (self , tf_dict ):
420
435
"""Merge transfer functions according to merge dict.
421
- :param tf_dict: DESCRIPTION.
422
- :type tf_dict: TYPE
423
- :return: DESCRIPTION.
424
- :rtype: TYPE
436
+
437
+ :param tf_dict: dictionary of transfer functions.
438
+ :type tf_dict: dict
439
+ :return: list of transfer functions with appropriate min/max period
440
+ to merge
441
+ :rtype: list
425
442
"""
426
443
427
444
merge_df = self ._get_merge_df ()
@@ -446,11 +463,12 @@ def _get_merge_tf_list(self, tf_dict):
446
463
return merge_list
447
464
448
465
def merge_transfer_functions (self , tf_dict ):
449
- """Merge transfer functions.
450
- :param tf_dict: DESCRIPTION.
451
- :type tf_dict: TYPE
452
- :return: DESCRIPTION.
453
- :rtype: TYPE
466
+ """Merge transfer functions according to AuroraProcessing.merge_dict
467
+
468
+ :param tf_dict: dictionary of transfer functions
469
+ :type tf_dict: dict
470
+ :return: merged transfer function.
471
+ :rtype: mtpy.MT
454
472
"""
455
473
456
474
merge_list = self ._get_merge_tf_list (tf_dict )
0 commit comments