Coverage for C: \ Users \ peaco \ OneDrive \ Documents \ GitHub \ mth5 \ mth5 \ __init__.py: 100%

29 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-27 20:09 -0800

1"""Top-level package for MTH5.""" 

2 

3# ============================================================================= 

4# Imports 

5# ============================================================================= 

6import sys 

7import numpy as np 

8import xarray as xr 

9import h5py 

10from loguru import logger 

11 

12from mth5.io.reader import read_file 

13import mth5.timeseries.scipy_filters 

14 

15# # Register xarray accessors 

16# import mth5.timeseries.channel_dataset_accessor 

17 

18# ============================================================================= 

19# Package Variables 

20# ============================================================================= 

21 

22__author__ = """Jared Peacock""" 

23__email__ = "jpeacock@usgs.gov" 

24__version__ = "0.6.1" 

25 

26 

27# ============================================================================= 

28# Initialize Loggers 

29# ============================================================================= 

30config = { 

31 "handlers": [ 

32 { 

33 "sink": sys.stdout, 

34 "level": "INFO", 

35 "colorize": True, 

36 "format": "<level>{time} | {level: <3} | {name} | {function} | line: {line} | {message}</level>", 

37 }, 

38 ], 

39 "extra": {"user": "someone"}, 

40} 

41logger.configure(**config) 

42# logger.disable("mth5") 

43 

44# need to set this to make sure attributes of data arrays and data sets 

45# are kept when doing xarray computations like merge. 

46xr.set_options(keep_attrs=True) 

47 

48# ============================================================================= 

49# Defualt Parameters 

50# ============================================================================= 

51CHUNK_SIZE = 8196 

52ACCEPTABLE_FILE_TYPES = ["mth5", "MTH5", "h5", "H5"] 

53ACCEPTABLE_FILE_SUFFIXES = [f".{x}" for x in ACCEPTABLE_FILE_TYPES] 

54ACCEPTABLE_FILE_VERSIONS = ["0.1.0", "0.2.0"] 

55ACCEPTABLE_DATA_LEVELS = [0, 1, 2, 3] 

56 

57### transfer function summary table dtype 

58TF_DTYPE_LIST = [ 

59 ("station", "S30"), 

60 ("survey", "S50"), 

61 ("latitude", float), 

62 ("longitude", float), 

63 ("elevation", float), 

64 ("tf_id", "S30"), 

65 ("units", "S60"), 

66 ("has_impedance", bool), 

67 ("has_tipper", bool), 

68 ("has_covariance", bool), 

69 ("period_min", float), 

70 ("period_max", float), 

71 ("hdf5_reference", h5py.ref_dtype), 

72 ("station_hdf5_reference", h5py.ref_dtype), 

73] 

74 

75TF_DTYPE = np.dtype(TF_DTYPE_LIST) 

76 

77### Channel summary table dtype 

78CHANNEL_DTYPE_LIST = [ 

79 ("survey", "S30"), 

80 ("station", "S30"), 

81 ("run", "S20"), 

82 ("latitude", float), 

83 ("longitude", float), 

84 ("elevation", float), 

85 ("component", "S20"), 

86 ("start", "S36"), 

87 ("end", "S36"), 

88 ("n_samples", np.int64), 

89 ("sample_rate", float), 

90 ("measurement_type", "S30"), 

91 ("azimuth", float), 

92 ("tilt", float), 

93 ("units", "S60"), 

94 ("has_data", bool), 

95 ("hdf5_reference", h5py.ref_dtype), 

96 ("run_hdf5_reference", h5py.ref_dtype), 

97 ("station_hdf5_reference", h5py.ref_dtype), 

98] 

99 

100CHANNEL_DTYPE = np.dtype(CHANNEL_DTYPE_LIST) 

101 

102### Fourier coefficient summary table dtype 

103FC_DTYPE_LIST = [ 

104 ("survey", "S30"), 

105 ("station", "S30"), 

106 ("run", "S20"), 

107 ("decimation_level", "S44"), 

108 ("latitude", float), 

109 ("longitude", float), 

110 ("elevation", float), 

111 ("component", "S20"), 

112 ("start", "S36"), 

113 ("end", "S36"), 

114 ("n_samples", np.int64), 

115 ("sample_rate", float), 

116 ("measurement_type", "S30"), 

117 ("units", "S60"), 

118 ("hdf5_reference", h5py.ref_dtype), 

119 ("decimation_level_reference", h5py.ref_dtype), 

120 ("run_hdf5_reference", h5py.ref_dtype), 

121 ("station_hdf5_reference", h5py.ref_dtype), 

122] 

123 

124FC_DTYPE = np.dtype(FC_DTYPE_LIST) 

125### Run summary table dtype 

126 

127RUN_SUMMARY_LIST = [ 

128 ("channel_scale_factors", float), 

129 ("duration", float), 

130 ("end", str), 

131 ("has_data", bool), 

132 ("input_channels", list), 

133 ("mth5_path", str), 

134 ("n_samples", int), 

135 ("output_channels", list), 

136 ("run", str), 

137 ("sample_rate", float), 

138 ("start", str), 

139 ("station", str), 

140 ("survey", str), 

141 ("run_hdf5_reference", object), 

142 ("station_hdf5_reference", object), 

143] 

144 

145RUN_SUMMARY_DTYPE = np.dtype(RUN_SUMMARY_LIST) 

146 

147RUN_SUMMARY_COLUMNS = [entry[0] for entry in RUN_SUMMARY_LIST] 

148 

149### Standards dtype 

150STANDARDS_DTYPE_LIST = [ 

151 ("attribute", "S72"), 

152 ("type", "S15"), 

153 ("required", bool), 

154 ("style", "S72"), 

155 ("units", "S32"), 

156 ("description", "S300"), 

157 ("options", "S150"), 

158 ("alias", "S72"), 

159 ("example", "S72"), 

160 ("default", "S72"), 

161] 

162STANDARDS_DTYPE = np.dtype(STANDARDS_DTYPE_LIST)