Coverage for C: \ Users \ peaco \ OneDrive \ Documents \ GitHub \ mt_metadata \ mt_metadata \ features \ feature_fc_run.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-10 00:11 -0800
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-10 00:11 -0800
1# =====================================================
2# Imports
3# =====================================================
4from typing import Annotated
6from pydantic import Field, field_validator, ValidationInfo
8from mt_metadata.base import MetadataBase
9from mt_metadata.common import Comment, TimePeriod
12# =====================================================
13class FeatureFCRun(MetadataBase):
14 id: Annotated[
15 str,
16 Field(
17 default="",
18 description="Suggested Run ID should be sample rate followed by a number or character. Characters should only be used if the run number is small, if the run number is high consider using digits with zeros. For example if you have 100 runs the run ID could be 001 or sr{sample_rate}_001. Should be the same as the time series run ID.",
19 alias=None,
20 pattern="^[a-zA-Z0-9_]*$",
21 json_schema_extra={
22 "units": None,
23 "required": True,
24 "examples": ["001"],
25 },
26 ),
27 ]
29 sample_rate: Annotated[
30 float,
31 Field(
32 default=0.0,
33 description="Digital sample rate for the run",
34 alias=None,
35 json_schema_extra={
36 "units": "samples per second",
37 "required": True,
38 "examples": ["100"],
39 },
40 ),
41 ]
43 comments: Annotated[
44 Comment,
45 Field(
46 default_factory=lambda: Comment(), # type: ignore
47 description="Any comments about the feature",
48 alias=None,
49 json_schema_extra={
50 "units": None,
51 "required": False,
52 "examples": ["estimated using hilburt transform."],
53 },
54 ),
55 ]
57 time_period: Annotated[
58 TimePeriod,
59 Field(
60 default_factory=lambda: TimePeriod(), # type: ignore
61 description="The time period over which the feature was calculated.",
62 alias=None,
63 json_schema_extra={
64 "units": None,
65 "required": True,
66 "examples": ["2020-01-01T00:00:00"],
67 },
68 ),
69 ]
71 @field_validator("comments", mode="before")
72 @classmethod
73 def validate_comments(cls, value, info: ValidationInfo) -> Comment:
74 if isinstance(value, str):
75 return Comment(value=value)
76 return value