anss-formats 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anss-formats
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Python implementation of the library used to communicate seismic event detection information between systems
5
5
  License: CC0-1.0
6
6
  Keywords: anss,earthquakes,formats,detection
@@ -13,17 +13,18 @@ Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Provides-Extra: pycurl
15
15
  Requires-Dist: certifi (>=2024.07.04,<2025.0.0)
16
- Requires-Dist: cryptography (>=44.0.1,<45.0.0)
16
+ Requires-Dist: cryptography (>=42.0.5)
17
17
  Requires-Dist: docutils (!=0.21.post1)
18
18
  Requires-Dist: dparse (>=0.6.2,<0.7.0)
19
19
  Requires-Dist: pydantic (>=2.6.0,<3.0.0)
20
20
  Requires-Dist: requests (>=2.32.2,<3.0.0)
21
21
  Requires-Dist: twine (>=5.1.1,<6.0.0)
22
+ Requires-Dist: urllib3 (>=2.6.0,<3.0.0)
22
23
  Project-URL: Homepage, https://gitlab.com/anss-netops/anss-data-formats
23
24
  Project-URL: Repository, https://gitlab.com/anss-netops/anss-data-formats
24
25
  Description-Content-Type: text/markdown
25
26
 
26
- # ANSS Data Formats
27
+ # Python 3 ANSS Formats Library
27
28
 
28
29
  This is the Python implementation of the library used to generate and parse the
29
30
  ANSS Formats.
@@ -35,6 +36,19 @@ Dependencies
35
36
  * ANSS Formats uses [poetry](https://python-poetry.org/) for
36
37
  Package, dependency and environment management.
37
38
 
39
+ Building
40
+ ------
41
+ The steps to get and use the python ANSS-formats are as follows:
42
+
43
+ 1. Clone ANSS-formats.
44
+ 2. Open a command window and change directories to /python/
45
+ 3. To run unit tests, run the command `poetry run pytest --cov=anssformats --junitxml junit.xml`
46
+
47
+ Using
48
+ -----S
49
+ Once you have the python distribution, simply import anssformats
50
+
51
+ # ANSS Data Formats
38
52
  The US Geological Survey (USGS) Advanced National Seismic System (ANSS) defines a number of data exchange formats to communicate seismic event detection information between processing systems. These formats are defined using objects as defined in the [JSON standard](http://www.json.org).
39
53
 
40
54
  The purpose of this project is to:
@@ -49,19 +63,20 @@ seismic event detections.
49
63
  * [Pick](format-docs/Pick.md) Format - A format for unassociated picks from a waveform arrival time picking algorithm.
50
64
  * [Detection](format-docs/Detection.md) Format - A format for an earthquake detection picks from a seismic detection algorithm.
51
65
 
66
+
52
67
  ## Supporting format objects:
53
68
 
54
69
  * [Amplitude](format-docs/Amplitude.md) Object - An object that contains information about an amplitude as part of a pick.
55
- * [Associated](format-docs/Associated.md) Object - An object that contains associated information if a pick is included in a detection.
70
+ * [Analytics](format-docs/Analytics.md) Object - An object that holds extensible information from model outputs or other processing tags.
71
+ * [Association](format-docs/Association.md) Object - An object that contains associated information if a pick is included in a detection.
56
72
  * [Channel](format-docs/Channel.md) Object - A geoJSON object that contains channel/location information as part of a pick.
57
- * [EventType](format-docs/EventType.md) Object - An object that defines the event type for MachineLearning info.
73
+ * [EventType](format-docs/EventType.md) Object - An object that defines the event type for a detection.
58
74
  * [Filter](format-docs/Filter.md) Object - An object that contains filter information as part of a pick.
59
75
  * [Hypocenter](format-docs/Hypocenter.md) Object - A geoJSON object that contains the hypocentral location, arrival time, and error information as part of a detection.
60
- * [MachineLearning](format-docs/MachineLearning.md) Object - An object that defines the machine learning information for a pick.
61
- * [Magnitude](format-docs/Magnitude.md) Object - An object that defines an earthquake magnitude estimation, as part of a Machine Learning classification or earthquake detection.
62
- * [Quality](format-docs/Quality.md) Object - An object that defines the data quality of a pick.
76
+ * [Magnitude](format-docs/Magnitude.md) Object - An object that defines an earthquake magnitude estimation for a detection.
63
77
  * [Source](format-docs/Source.md) Object - An object that defines the creator/source of a pick.
64
78
 
79
+
65
80
  # Amplitude Object Specification
66
81
 
67
82
  ## Description
@@ -96,12 +111,86 @@ amplitude.
96
111
  * period - A decimal number containing the amplitude period.
97
112
  * snr - A decimal number containing the signal to noise ratio, capped at 1E9.
98
113
 
114
+
115
+ # Analytics Object Specification
116
+
117
+ ## Description
118
+
119
+ The Analytics object is an extensible format to encode model outputs for a [Pick](Pick.md).
120
+ Model outputs are stored as a list of [Predictions](#Prediction-Object).
121
+ Suitable for retaining output of pickers, analytical models, AI/ML predictors, etc.
122
+ Analytics uses the [JSON standard](http://www.json.org).
123
+
124
+ ## Usage
125
+
126
+ Analytics is intended for use as part of the [Pick](Pick.md) format in
127
+ seismic data messaging between seismic applications and organizations.
128
+
129
+ ## Output
130
+
131
+ ```json
132
+ {
133
+ "predictions": [
134
+ {
135
+ "label": String,
136
+ "value": String | Number | Array | Object,
137
+ "probability": Number,
138
+ "metrics": {
139
+ // Flexible structure for uncertainty quantification
140
+ },
141
+ "modelID": String,
142
+ "modelVersion": String,
143
+ "source": {
144
+ "agencyID": String,
145
+ "author": String
146
+ }
147
+ }
148
+ ],
149
+ "extensions": {
150
+ // Custom key-value pairs for experimental data
151
+ }
152
+ }
153
+ ```
154
+
155
+ ## Glossary
156
+
157
+ **Optional Values:**
158
+
159
+ * `predictions` - An optional array of Prediction objects. Each prediction represents output from an analytical model.
160
+ * `extensions` - An optional object containing custom key-value pairs for experimental or debug data.
161
+
162
+ ## Prediction Object
163
+
164
+ * `label` (required) - A string identifying what is being predicted.
165
+ * Standard seismological labels: "phase", "magnitude", "eventType", "distance", "depth", "backAzimuth"
166
+ * Custom labels: any string (e.g., "pick_quality", "noise_level", "voorwerp_level")
167
+
168
+ * `value` (required) - The predicted value. Can be:
169
+ * String (e.g., "P", "Earthquake")
170
+ * Number (e.g., 2.5, 0.94)
171
+ * Array (e.g., `[0.1, 0.3, 0.8]`)
172
+ * Object (e.g., `{"type": "Mb", "value": 2.5}`)
173
+
174
+ * `probability` - A decimal number [0.0-1.0] containing the probability of this prediction
175
+
176
+ * `metrics` - An object containing other model/pick information. Structure is flexible and can include things like:
177
+ * `std` - Standard deviation
178
+ * `range` - Array of [min, max] values
179
+ * `halfWidth` - Half-width of uncertainty range
180
+ * `sigma` - Sigma value for probability distribution
181
+ * Any other model-specific quantification metrics
182
+
183
+ * `modelID` - A string identifying which model made this prediction
184
+ * `modelVersion` - A string containing the version of the model
185
+ * `source` - An object containing the source/author of the model, see [Source](Source.md)
186
+
187
+
99
188
  # Association Object Specification
100
189
 
101
190
  ## Description
102
191
 
103
- The Association object is an object designed to encode information provided when
104
- a [Pick](Pick.md). Association uses the [JSON standard](http://www.json.org).
192
+ The Association object is an object designed to encode information provided when a group of [Pick](Pick.md) are associated for an event.
193
+ Association uses the [JSON standard](http://www.json.org).
105
194
 
106
195
  ## Usage
107
196
 
@@ -132,16 +221,16 @@ association.
132
221
  * residual - A decimal number containing residual in seconds of the data if Association.
133
222
  * sigma - A decimal number reflecting the number of standard deviations of the data from the calculated value if Association.
134
223
 
135
- # Site Object Specification
224
+ # Channel Object Specification
136
225
 
137
226
  ## Description
138
227
 
139
- The Site object is an object designed to define the seismic station used to
140
- produce a [Pick](Pick.md) message. Site uses the [JSON](https://www.json.org) and [GeoJSON](https://geojson.org/) standards.
228
+ The Channel object is an object designed to define the seismic station used to produce a [Pick](Pick.md) message.
229
+ Channel uses the [JSON](https://www.json.org) and [GeoJSON](https://geojson.org/) standards.
141
230
 
142
231
  ## Usage
143
232
 
144
- Site is intended for use as part of the [Pick](Pick.md) Format in seismic data messaging between seismic applications and organizations.
233
+ Channel is intended for use as part of the [Pick](Pick.md) Format in seismic data messaging between seismic applications and organizations.
145
234
 
146
235
  ## Output
147
236
 
@@ -236,7 +325,7 @@ applications.
236
325
  "detector" : String,
237
326
  "pickData" : [Pick Objects],
238
327
  "magnitudeData" :
239
- [
328
+ [
240
329
  {
241
330
  "type" : String,
242
331
  "id" : String,
@@ -245,11 +334,27 @@ applications.
245
334
  {
246
335
  "agencyID" : String,
247
336
  "author" : String
248
- },
337
+ },
249
338
  "error" : Number,
250
339
  "probability" : Number
251
340
  }, ...
252
- ]
341
+ ],
342
+ "analyticsInfo" :
343
+ {
344
+ "predictions" : [ {
345
+ "label" : String,
346
+ "value" : String | Number | Object | Array,
347
+ "probability" : Number,
348
+ "metrics" : Object,
349
+ "modelID" : String,
350
+ "modelVersion" : String,
351
+ "source" : {
352
+ "agencyID" : String,
353
+ "author" : String
354
+ }
355
+ }, ...],
356
+ "extensions" : Object
357
+ }
253
358
  }
254
359
  ```
255
360
 
@@ -277,18 +382,18 @@ The following are supplementary values that **may or may not** be provided as pa
277
382
  * detector - A string identifying the detection grid, algorithm, or other information.
278
383
  * pickData - An array of [Pick](Pick.md) objects used to generate this Detection.
279
384
  * magnitudeData - An array of [Magnitude](Magnitude.md) objects for this Detection.
385
+ * analyticsInfo - An object containing analytical information from one or more models/algorithms, see [Analytics](Analytics.md).
280
386
 
281
387
  # EventType Object Specification
282
388
 
283
389
  ## Description
284
390
 
285
- The EventType object is an object designed to define the originating seismic
286
- organization that produced a [MachineLearning](MachineLearning.md) object.
287
- Site uses the [JSON standard](http://www.json.org).
391
+ The EventType object is an object designed to define the phenomena causing a seismic detection.
392
+ EventType uses the [JSON standard](http://www.json.org).
288
393
 
289
394
  ## Usage
290
395
 
291
- EventType is intended for use as part of the [PicMachineLearningk](MachineLearning.md) Oject in seismic data
396
+ EventType is intended for use as part of the [Detection](Detection.md) object in seismic data
292
397
  messaging between seismic applications and organizations.
293
398
 
294
399
  ## Output
@@ -406,96 +511,12 @@ various algorithms.
406
511
  * depthError - A decimal number that identifies the depth error of this hypocenter in kilometers.
407
512
  * originTimeError - A decimal number that identifies the error of the origin time in seconds.
408
513
 
409
- # MachineLearning Object Specification
410
-
411
- ## Description
412
-
413
- The MachineLearning object is an object designed to encode value added
414
- information available for a [Pick](Pick.md) from advanced algorithms such as
415
- machine learning. MachineLearning uses the [JSON standard](http://www.json.org).
416
-
417
- ## Usage
418
-
419
- MachineLearning is intended for use as part of the [Pick](Pick.md) Format in
420
- seismic data messaging between seismic
421
- applications and organizations.
422
-
423
- ## Output
424
-
425
- ```json
426
- {
427
- "phase" : String,
428
- "phaseProbability" : Number,
429
- "distance" : Number,
430
- "distanceProbability" : Number,
431
- "distanceRangeHalfWidth" : Number,
432
- "distanceRangeSigma" : Number,
433
- "backAzimuth" : Number,
434
- "backAzimuthProbability" : Number,
435
- "magnitude" :
436
- {
437
- "type" : String,
438
- "id" : String,
439
- "value" : Number,
440
- "source" :
441
- {
442
- "agencyID" : String,
443
- "author" : String
444
- },
445
- "error" : Number,
446
- "probability" : Number
447
- },
448
- "depth" : Number,
449
- "depthProbability" : Number,
450
- "eventType" :
451
- {
452
- "type" : String,
453
- "certainty" : String
454
- },
455
- "eventTypeProbability" : Number,
456
- "repickShift" : Number,
457
- "repickSTD" : Number,
458
- "repickCredibleIntervalLower" : Number,
459
- "repickCredibleIntervalUpper" : Number,
460
- "source" :
461
- {
462
- "agencyID" : String,
463
- "author" : String
464
- }
465
- }
466
- ```
467
-
468
- ## Glossary
469
-
470
- **Optional Values:**
471
-
472
- The following are values that **may or may not** be provided as part of MachineLearning.
473
-
474
- * phase - A string that identifies the seismic phase for this data
475
- * phaseProbability - A decimal number containing the probability of the phase identification
476
- * distance - A decimal number containing a distance estimation in degrees
477
- * distanceProbability - A decimal number containing the probability of the distance estimation
478
- * distanceRangeHalfWidth - A decimal number containing the half-width of a distance range centered at Distance (e.g. Distance is 15 deg +/- 10 deg)
479
- * distanceRangeSigma - A decimal number containing the standard deviation for a probability PDF curve for Distance (e.g. Distance is 15 deg +/- 3 * DistanceRangeSigma where DistanceProbability is modified by the PDF probability, lowering as it gets further from Distance ). DistanceRangeSigma is mutually exclusive of DistanceRangeHalfWidth, and if both are provided DistanceRangeSigma should be used.
480
- * backAzimuth - A decimal number containing a backazimuth estimation in degrees
481
- * backAzimuthProbability - A decimal number containing the probability of the backazimuth estimation
482
- * magnitude - A [Magnitude](Magnitude.md) object containing the machine learning magnitude estimation
483
- * depth - A decimal number containing a depth estimation in kilometers
484
- * depthProbability - A decimal number containing the probability of the depth estimation
485
- * eventType - An object containing the event type, see [EventType](EventType.md).
486
- * eventTypeProbability - A decimal number containing the probability of the event type estimation
487
- * repickShift - A decimal number containing the repick shift in seconds (to regenerate the initial Pick.Time, subtract this value from the current Pick.Time)
488
- * repickSTD - A decimal number containing the repick shift standard deviation
489
- * repickCredibleIntervalLower - A decimal number containing the repick shift credible interval lower
490
- * repickCredibleIntervalUpper - A decimal number containing the repick shift credible interval upper
491
- * source - An object containing the source of the MachineLearning, see [Source](Source.md).
492
-
493
514
  # Magnitude Object Specification
494
515
 
495
516
  ## Description
496
517
 
497
- The Magnitude object is an object designed to hold data quality for a [Detection](Detection.md) message.
498
- Site uses the [JSON standard](http://www.json.org).
518
+ The Magnitude object is an object designed to hold information about a magnitude assigned to a [Detection](Detection.md).
519
+ Magnitude uses the [JSON standard](http://www.json.org).
499
520
 
500
521
  ## Usage
501
522
 
@@ -599,48 +620,21 @@ applications and organizations.
599
620
  "residual" : Number,
600
621
  "sigma" : Number
601
622
  },
602
- "qualityInfo" : [ {
603
- "standard": String,
604
- "value": Number
605
- }, ...],
606
- "machineLearningInfo" :
623
+ "analyticsInfo" :
607
624
  {
608
- "phase" : String,
609
- "phaseProbability" : Number,
610
- "distance" : Number,
611
- "distanceProbability" : Number,
612
- "distanceRangeHalfWidth" : Number,
613
- "distanceRangeSigma" : Number,
614
- "backAzimuth" : Number,
615
- "backAzimuthProbability" : Number,
616
- "magnitude" :
617
- {
618
- "type" : String,
619
- "id" : String,
620
- "value" : Number,
621
- "source" :
622
- {
623
- "agencyID" : String,
624
- "author" : String
625
- },
626
- "error" : Number,
627
- "probability" : Number
628
- },
629
- "depth" : Number,
630
- "depthProbability" : Number,
631
- "eventType" : {
632
- "type" : String,
633
- "certainty" : String
634
- },
635
- "eventTypeProbability" : Number,
636
- "repickShift" : Number,
637
- "repickSTD" : Number,
638
- "repickCredibleIntervalLower" : Number,
639
- "repickCredibleIntervalUpper" : Number,
640
- "source" : {
625
+ "predictions" : [ {
626
+ "label" : String,
627
+ "value" : String | Number | Object | Array,
628
+ "probability" : Number,
629
+ "metrics" : Object,
630
+ "modelID" : String,
631
+ "modelVersion" : String,
632
+ "source" : {
641
633
  "agencyID" : String,
642
634
  "author" : String
643
- }
635
+ }
636
+ }, ...],
637
+ "extensions" : Object,
644
638
  }
645
639
  }
646
640
  ```
@@ -668,39 +662,8 @@ various picking algorithms.
668
662
  * pickerType - A string describing the type of picker; "manual", "raypicker", "filterpicker", "earthworm", or "other".
669
663
  * filter - An array of objects containing the filter frequencies when the pick was made, see [Filter](Filter.md).
670
664
  * amplitude - An object containing the amplitude associated with the pick, see [Amplitude](Amplitude.md).
671
- * associationInfo - An object containing the association information if this pick is used as data in a Detection, see [Associated](Associated.md).
672
- * machineLearningInfo - An object containing the machine learning information of this pick, see [MachineLearning](MachineLearning.md).
673
- * qualityInfo - An array of objects containing the containing the quality metric information for this pick, see [Quality](Quality.md).
674
-
675
- # Quality Object Specification
676
-
677
- ## Description
678
-
679
- The Quality object is an object designed to hold data quality for a [Pick](Pick.md) message.
680
- Site uses the [JSON standard](http://www.json.org).
681
-
682
- ## Usage
683
-
684
- Quality is intended for use as part of the [Pick](Pick.md) Format in seismic data
685
- messaging between seismic applications and organizations.
686
-
687
- ## Output
688
-
689
- ```json
690
- {
691
- "standard": String,
692
- "value": Number
693
- }
694
- ```
695
-
696
- ## Glossary
697
-
698
- **Required Values:**
699
-
700
- These are the values **required** to define a Quality
701
-
702
- * standard - A string containing the name of the quality standard.
703
- * value - A string containing numarical value of the quality standard.
665
+ * associationInfo - An object containing the association information if this pick is used as data in a Detection, see [Association](Association.md).
666
+ * analyticsInfo - An object containing analytical information from one or more models/algorithms, see [Analytics](Analytics.md).
704
667
 
705
668
  # Source Object Specification
706
669
 
@@ -708,7 +671,7 @@ These are the values **required** to define a Quality
708
671
 
709
672
  The Source object is an object designed to define the originating seismic
710
673
  organization that produced a [Pick](Pick.md) message.
711
- Site uses the [JSON standard](http://www.json.org).
674
+ Source uses the [JSON standard](http://www.json.org).
712
675
 
713
676
  ## Usage
714
677
 
@@ -1,18 +1,17 @@
1
- anssformats/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1
+ anssformats/__init__.py,sha256=1HsV_uIEBuKIhoa8jBHOD4bX6eMOfQ-57KvbHYTie8g,686
2
2
  anssformats/amplitude.py,sha256=DCtkc6siT8dj0C3ynBM01rfaSpKOeHTc-51CDmspELg,647
3
+ anssformats/analytics.py,sha256=ROUq_SNq69tUKDFCYjqgElO3185_-XAsIZguN4ItA-s,3125
3
4
  anssformats/association.py,sha256=UjDmr213kSzCCIWHMDce06Xjzut3-l1IYKexxJR_C_I,1173
4
5
  anssformats/channel.py,sha256=z4sQGpJwSySSuzKCca_UovS6_DbPaP_j4BAZpX-Cqwc,1169
5
- anssformats/detection.py,sha256=dR76eFRmBp5fKyZoOm70bWcrYhc7Eo1f0mtWQI0u8lw,2015
6
+ anssformats/detection.py,sha256=-UlR7tv5szgXsg5kY2NLxu3fAn_5ROUogM7H7W4EgQY,2201
6
7
  anssformats/eventType.py,sha256=6DHjovVVGug5AU1WRKX3RxQbrnwSPlg2KNtH2sLX1Q0,1216
7
8
  anssformats/filter.py,sha256=uOAUteSWeBvDcB12_9E_9sqe0wb6iR_lHZdjLv5agNM,675
8
9
  anssformats/formatbasemodel.py,sha256=mUKwY0jiHrcr8jdZLCQhzSx3qBg16FEUytRgB5wiuIY,2044
9
10
  anssformats/geojson.py,sha256=xjm_9ZxX9P8lzQKDBDO6L-ai1y7PQofVMJ5FwEIAVjU,1244
10
11
  anssformats/hypocenter.py,sha256=QkXfQkRzjHbefF4G3TaOTwD5PYcvFkX5dvxjeVS3yfs,1552
11
- anssformats/machineLearning.py,sha256=YJbnzv4JbJwr_UaE3TAaidKpGHfaM5dOmlAOqbnv32w,3008
12
12
  anssformats/magnitude.py,sha256=ncMmwMoj_Lv0kSzjjtQVZ5_41mSkCYFxgExxiaeSqao,993
13
- anssformats/pick.py,sha256=ME3vnE06jsrQHST9gXwXzn0z_bUX7V5G7QbYzk0c1I8,2682
14
- anssformats/quality.py,sha256=PK5sPAoJTUgCrmQkiWTerEB2klWbR1ECAU-qIABpcjA,389
13
+ anssformats/pick.py,sha256=UpLcqxPx2BZScpMIAlk9E-QOWVPJsT9jVP-DtkZtij0,2427
15
14
  anssformats/source.py,sha256=G78YUwY2fimi8Uy0d1mKjaIIsEDUue50wdHpACQsSMU,398
16
- anss_formats-0.1.0.dist-info/METADATA,sha256=Dx1lfOeuCkIaYUfdOp2NfhTVSRpuMf5mXO1VgAtTajs,24969
17
- anss_formats-0.1.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
18
- anss_formats-0.1.0.dist-info/RECORD,,
15
+ anss_formats-0.1.2.dist-info/METADATA,sha256=egAG6t9oNSSeP5KnVM-MUMmUU-8lz1YNxhxD9kNvLyQ,22831
16
+ anss_formats-0.1.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
17
+ anss_formats-0.1.2.dist-info/RECORD,,
anssformats/__init__.py CHANGED
@@ -0,0 +1,26 @@
1
+ from anssformats.pick import Pick
2
+ from anssformats.source import Source
3
+ from anssformats.amplitude import Amplitude
4
+ from anssformats.analytics import Analytics, Prediction
5
+ from anssformats.association import Association
6
+ from anssformats.detection import Detection
7
+ from anssformats.hypocenter import Hypocenter
8
+ from anssformats.magnitude import Magnitude
9
+ from anssformats.channel import Channel
10
+ from anssformats.filter import Filter
11
+ from anssformats.eventType import EventType
12
+
13
+ __all__ = [
14
+ "Pick",
15
+ "Source",
16
+ "Amplitude",
17
+ "Analytics",
18
+ "Prediction",
19
+ "Association",
20
+ "Detection",
21
+ "Hypocenter",
22
+ "Magnitude",
23
+ "Channel",
24
+ "Filter",
25
+ "EventType",
26
+ ]
@@ -0,0 +1,82 @@
1
+ from typing import Optional, Union, List
2
+
3
+ from pydantic import Field
4
+
5
+ from anssformats.formatbasemodel import FormatBaseModel
6
+ from anssformats.source import Source as SourceFormat
7
+
8
+
9
+ class Prediction(FormatBaseModel):
10
+ """A generic prediction from an analytical model (AI/ML, statistical, rule-based, etc.)
11
+
12
+ This class provides a flexible structure for representing any type of prediction
13
+ with associated metrics and model provenance.
14
+
15
+ Attributes
16
+ ----------
17
+ label: string identifying what is being predicted (e.g., "phase", "magnitude",
18
+ "eventType", "custom_attribute")
19
+
20
+ value: the predicted value - can be string, number, or structured object
21
+
22
+ probability: optional float [0.0-1.0] containing the probability of this prediction
23
+
24
+ metrics: optional dict containing additional prediction metrics such as confidence,
25
+ uncertainty quantification (std, ranges, credible intervals), entropy, etc.
26
+ Structure is flexible to support any model-specific metrics.
27
+
28
+ modelID: optional string identifying which model made this prediction
29
+
30
+ modelVersion: optional string containing the version of the model
31
+
32
+ source: optional Source object containing the source/author of the
33
+ """
34
+
35
+ label: str = Field(
36
+ ...,
37
+ description="What is being predicted (e.g., phase, magnitude, eventType, distance)",
38
+ )
39
+ value: Union[str, float, int, list, dict] = Field(
40
+ ..., description="The predicted value"
41
+ )
42
+ probability: Optional[float] = Field(
43
+ None, ge=0.0, le=1.0, description="Probability of this prediction [0.0-1.0]"
44
+ )
45
+ metrics: Optional[dict] = Field(
46
+ None,
47
+ description="Additional prediction metrics (confidence, uncertainty, entropy, etc.)",
48
+ )
49
+ modelID: Optional[str] = Field(
50
+ None, description="Identifier for the model that made this prediction"
51
+ )
52
+ modelVersion: Optional[str] = Field(None, description="Version of the model")
53
+ source: Optional[SourceFormat] = Field(
54
+ None, description="Source/author of the model"
55
+ )
56
+
57
+
58
+ class Analytics(FormatBaseModel):
59
+ """A conversion class used to create, parse, and validate analytical information
60
+ from models such as pickers, analytical models, AI/ML, etc.
61
+
62
+ This class provides an extensible structure supporting multiple models, arbitrary
63
+ prediction labels, and custom extensions.
64
+
65
+ Attributes
66
+ ----------
67
+
68
+ predictions: optional list of Prediction objects containing predictions from one
69
+ or more models. Each prediction can represent any type of analytical output
70
+ with associated confidence metrics and model provenance.
71
+
72
+ extensions: optional dict containing custom key-value pairs for experimental code and debugging.
73
+
74
+ """
75
+
76
+ predictions: Optional[List[Prediction]] = Field(
77
+ None, description="Array of predictions from one or more analytical models"
78
+ )
79
+
80
+ extensions: Optional[dict] = Field(
81
+ None, description="Custom key-value pairs for experimental or debuging data"
82
+ )
anssformats/detection.py CHANGED
@@ -9,6 +9,7 @@ from anssformats.hypocenter import Hypocenter, HypocenterProperties
9
9
  from anssformats.source import Source
10
10
  from anssformats.pick import Pick
11
11
  from anssformats.magnitude import Magnitude
12
+ from anssformats.analytics import Analytics
12
13
 
13
14
 
14
15
  class Detection(FormatBaseModel):
@@ -41,7 +42,7 @@ class Detection(FormatBaseModel):
41
42
  pickData: optional list of either Pick objects used to generate
42
43
  this detection
43
44
 
44
-
45
+ analyticsInfo: optional analytics object containing model output attached to this detection
45
46
  """
46
47
 
47
48
  type: Literal["Detection"]
@@ -64,3 +65,5 @@ class Detection(FormatBaseModel):
64
65
  pickData: Optional[List[Pick]] = None
65
66
 
66
67
  magnitudeData: Optional[List[Magnitude]] = None
68
+
69
+ analyticsInfo: Optional[Analytics] = None
anssformats/pick.py CHANGED
@@ -4,12 +4,11 @@ from pydantic import Field
4
4
 
5
5
  from anssformats.amplitude import Amplitude
6
6
  from anssformats.association import Association
7
- from anssformats.machineLearning import MachineLearning
7
+ from anssformats.analytics import Analytics
8
8
  from anssformats.filter import Filter
9
9
  from anssformats.formatbasemodel import CustomDT, FormatBaseModel
10
10
  from anssformats.channel import Channel, ChannelProperties
11
11
  from anssformats.source import Source
12
- from anssformats.quality import Quality
13
12
 
14
13
 
15
14
  class Pick(FormatBaseModel):
@@ -39,17 +38,12 @@ class Pick(FormatBaseModel):
39
38
  filterInfo: optional list of Filter objects containing the filter frequencies when the
40
39
  pick was made
41
40
 
42
- amplitude: optional Amplitude object containing the amplitude associated with the
43
- pick
41
+ amplitude: optional Amplitude object containing the amplitude associated with the pick
44
42
 
45
43
  associationInfo: optional Association object containing the association information
46
44
  if this pick is used as data in a Detection
47
45
 
48
- machineLearningInfo: optional machineLearning object containing the machineLearning
49
- information of this pick
50
-
51
- qualityInfo: optional quality object containing the quality
52
- information of this pick
46
+ AnalyticsInfo: optional analytics object containing model output attached to this pick
53
47
  """
54
48
 
55
49
  type: Literal["Pick"]
@@ -70,5 +64,4 @@ class Pick(FormatBaseModel):
70
64
  amplitudeInfo: Optional[Amplitude] = None
71
65
 
72
66
  associationInfo: Optional[Association] = None
73
- machineLearningInfo: Optional[MachineLearning] = None
74
- qualityInfo: Optional[List[Quality]] = None
67
+ analyticsInfo: Optional[Analytics] = None
@@ -1,83 +0,0 @@
1
- from typing import Optional
2
-
3
- from pydantic import Field
4
-
5
- from anssformats.eventType import EventType as EventTypeFormat
6
- from anssformats.formatbasemodel import FormatBaseModel
7
- from anssformats.source import Source as SourceFormat
8
- from anssformats.magnitude import Magnitude
9
-
10
-
11
- class MachineLearning(FormatBaseModel):
12
- """A conversion class used to create, parse, and validate value added MachineLearning
13
- data from advanced algorithms such as machine learning as part of detection formats
14
- data.
15
-
16
- Attributes
17
- ----------
18
-
19
- phase: optional string containing MachineLearning phase name
20
-
21
- phaseProbability: optional float containing the probability of the MachineLearning
22
- phase name
23
-
24
- distance: optional float containing the MachineLearning distance in degrees
25
-
26
- distanceProbability: optional float containing the probability of the MachineLearning
27
- distance
28
-
29
- backAzimuth: optional float containing the MachineLearning back azimuth in degrees
30
-
31
- backAzimuthProbability: optional float containing the probability of the
32
- MachineLearning back azimuth
33
-
34
- magnitude: optional Magnitude object containing the MachineLearning magnitude
35
-
36
- depth: optional float containing the MachineLearning depth in kilometers
37
-
38
- depthProbability: optional float containing the probability of the MachineLearning
39
- depth
40
-
41
- eventType: optional EventType object containing the MachineLearning event type
42
-
43
- eventTypeProbability: optional float containing the probability of the
44
- MachineLearning event type
45
-
46
- repickShift: optional float containing the repick shift value in seconds
47
-
48
- repickSTD: optional float containing the repick shift standard deviation
49
-
50
- repickCredibleIntervalLower: optional float containing the repick shift lower credible interval
51
-
52
- repickCredibleIntervalUpper: optional float containing the repick shift upper credible interval
53
-
54
- source: optional Source object containing the source of the MachineLearning
55
- information
56
- """
57
-
58
- phase: Optional[str] = Field(None, pattern=r"^[A-Za-z]+$")
59
- phaseProbability: Optional[float] = None
60
-
61
- distance: Optional[float] = Field(None, ge=0.0)
62
- distanceProbability: Optional[float] = None
63
-
64
- backAzimuth: Optional[float] = Field(None, ge=0.0)
65
- backAzimuthProbability: Optional[float] = None
66
-
67
- magnitude: Optional[Magnitude] = None
68
-
69
- depth: Optional[float] = Field(None, ge=-100.0, le=1500.0)
70
- depthProbability: Optional[float] = None
71
-
72
- eventType: Optional[EventTypeFormat] = None
73
- eventTypeProbability: Optional[float] = None
74
-
75
- distanceRangeHalfWidth: Optional[float] = None
76
- distanceRangeSigma: Optional[float] = None
77
-
78
- repickShift: Optional[float] = None
79
- repickSTD: Optional[float] = None
80
- repickCredibleIntervalLower: Optional[float] = None
81
- repickCredibleIntervalUpper: Optional[float] = None
82
-
83
- source: Optional[SourceFormat] = None
anssformats/quality.py DELETED
@@ -1,17 +0,0 @@
1
- from anssformats.formatbasemodel import FormatBaseModel
2
-
3
-
4
- class Quality(FormatBaseModel):
5
- """A conversion class used to create, parse, and validate Quality data as part of
6
- detection data.
7
-
8
- Attributes
9
- ----------
10
-
11
- standard: string containing the name of the quality standard used
12
-
13
- value: float containing the Quality value
14
- """
15
-
16
- standard: str
17
- value: float