terra.models.v2.activity

  1#  Copyright 2022 Terra Enabling Developers Limited
  2#
  3#  Licensed under the Apache License, Version 2.0 (the "License");
  4#  you may not use this file except in compliance with the License.
  5#  You may obtain a copy of the License at
  6#
  7#      http://www.apache.org/licenses/LICENSE-2.0
  8#
  9#  Unless required by applicable law or agreed to in writing, software
 10#  distributed under the License is distributed on an "AS IS" BASIS,
 11#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12#  See the License for the specific language governing permissions and
 13#  limitations under the License.
 14import dataclasses
 15import typing
 16
 17from terra.models import base_model
 18from terra.models.v2 import samples as samples_
 19
 20__all__ = ["Activity"]
 21
 22
 23@dataclasses.dataclass
 24class Metadata(base_model.TerraDataModel):
 25    name: typing.Optional[str] = dataclasses.field(default=None)
 26    type: typing.Optional[int] = dataclasses.field(default=None)
 27    summary_id: typing.Optional[str] = dataclasses.field(default=None)
 28    start_time: typing.Optional[str] = dataclasses.field(default=None)
 29    end_time: typing.Optional[str] = dataclasses.field(default=None)
 30    city: typing.Optional[str] = dataclasses.field(default=None)
 31    state: typing.Optional[str] = dataclasses.field(default=None)
 32    country: typing.Optional[str] = dataclasses.field(default=None)
 33    upload_type: typing.Optional[int] = dataclasses.field(default=None)
 34
 35
 36@dataclasses.dataclass
 37class LapData(base_model.TerraDataModel):
 38    laps: typing.List[samples_.LapSample] = dataclasses.field(default_factory=list)
 39
 40
 41@dataclasses.dataclass
 42class StrainData(base_model.TerraDataModel):
 43    strain_level: typing.Optional[float] = dataclasses.field(default=None)
 44
 45
 46@dataclasses.dataclass
 47class SwimmingSummary(base_model.TerraDataModel):
 48    num_laps: typing.Optional[int] = dataclasses.field(default=None)
 49    num_strokes: typing.Optional[int] = dataclasses.field(default=None)
 50    pool_length_meters: typing.Optional[int] = dataclasses.field(default=None)
 51
 52
 53@dataclasses.dataclass
 54class ElevationSummary(base_model.TerraDataModel):
 55    gain_planned_meters: typing.Optional[float] = dataclasses.field(default=None)
 56    gain_actual_meters: typing.Optional[float] = dataclasses.field(default=None)
 57    loss_actual_meters: typing.Optional[float] = dataclasses.field(default=None)
 58    min_meters: typing.Optional[float] = dataclasses.field(default=None)
 59    avg_meters: typing.Optional[float] = dataclasses.field(default=None)
 60    max_meters: typing.Optional[float] = dataclasses.field(default=None)
 61
 62
 63@dataclasses.dataclass
 64class DistanceDataSummary(base_model.TerraDataModel):
 65    distance_meters: typing.Optional[float] = dataclasses.field(default=None)
 66    steps: typing.Optional[int] = dataclasses.field(default=None)
 67    floors_climbed: typing.Optional[int] = dataclasses.field(default=None)
 68    swimming: SwimmingSummary = dataclasses.field(default_factory=SwimmingSummary)
 69    elevation: ElevationSummary = dataclasses.field(default_factory=ElevationSummary)
 70
 71
 72@dataclasses.dataclass
 73class DistanceDataDetailed(base_model.TerraDataModel):
 74    step_samples: typing.List[samples_.StepSample] = dataclasses.field(default_factory=list)
 75    distance_samples: typing.List[samples_.DistanceSample] = dataclasses.field(default_factory=list)
 76    elevation_samples: typing.List[samples_.ElevationSample] = dataclasses.field(default_factory=list)
 77    floors_climbed_samples: typing.List[samples_.FloorsClimbedSample] = dataclasses.field(default_factory=list)
 78
 79
 80@dataclasses.dataclass
 81class DistanceData(base_model.TerraDataModel):
 82    summary: DistanceDataSummary = dataclasses.field(default_factory=DistanceDataSummary)
 83    detailed: DistanceDataDetailed = dataclasses.field(default_factory=DistanceDataDetailed)
 84
 85
 86@dataclasses.dataclass
 87class PositionData(base_model.TerraDataModel):
 88    start_pos_lat_lng_deg: typing.List[float] = dataclasses.field(default_factory=list)
 89    center_pos_lat_lng_deg: typing.List[float] = dataclasses.field(default_factory=list)
 90    end_pos_lat_lng_deg: typing.List[float] = dataclasses.field(default_factory=list)
 91    position_samples: typing.List[samples_.PositionSample] = dataclasses.field(default_factory=list)
 92
 93
 94@dataclasses.dataclass
 95class ActiveDurationsData(base_model.TerraDataModel):
 96    activity_seconds: typing.Optional[float] = dataclasses.field(default=None)
 97    inactivity_seconds: typing.Optional[float] = dataclasses.field(default=None)
 98    rest_seconds: typing.Optional[float] = dataclasses.field(default=None)
 99    low_intensity_seconds: typing.Optional[float] = dataclasses.field(default=None)
100    moderate_intensity_seconds: typing.Optional[float] = dataclasses.field(default=None)
101    vigorous_intensity_seconds: typing.Optional[float] = dataclasses.field(default=None)
102    num_continuous_inactive_periods: typing.Optional[int] = dataclasses.field(default=None)
103    activity_levels_samples: typing.List[samples_.ActivityLevelSample] = dataclasses.field(default_factory=list)
104
105
106@dataclasses.dataclass
107class METData(base_model.TerraDataModel):
108    avg_level: typing.Optional[float] = dataclasses.field(default=None)
109    num_inactive_minutes: typing.Optional[float] = dataclasses.field(default=None)
110    num_low_intensity_minutes: typing.Optional[float] = dataclasses.field(default=None)
111    num_moderate_intensity_minutes: typing.Optional[float] = dataclasses.field(default=None)
112    num_high_intensity_minutes: typing.Optional[float] = dataclasses.field(default=None)
113    MET_samples: typing.List[samples_.METSample] = dataclasses.field(default_factory=list)
114
115
116@dataclasses.dataclass
117class MovementData(base_model.TerraDataModel):
118    avg_speed_meters_per_second: typing.Optional[float] = dataclasses.field(default=None)
119    max_speed_meters_per_second: typing.Optional[float] = dataclasses.field(default=None)
120    normalized_speed_meters_per_second: typing.Optional[float] = dataclasses.field(default=None)
121    avg_pace_minutes_per_kilometer: typing.Optional[float] = dataclasses.field(default=None)
122    max_pace_minutes_per_kilometer: typing.Optional[float] = dataclasses.field(default=None)
123    avg_velocity_meters_per_second: typing.Optional[float] = dataclasses.field(default=None)
124    max_velocity_meters_per_second: typing.Optional[float] = dataclasses.field(default=None)
125    avg_cadence_rpm: typing.Optional[float] = dataclasses.field(default=None)
126    max_cadence_rpm: typing.Optional[float] = dataclasses.field(default=None)
127    avg_torque_newton_meters: typing.Optional[float] = dataclasses.field(default=None)
128    max_torque_newton_meters: typing.Optional[float] = dataclasses.field(default=None)
129    cadence_samples: typing.List[samples_.CadenceSample] = dataclasses.field(default_factory=list)
130    speed_samples: typing.List[samples_.SpeedSample] = dataclasses.field(default_factory=list)
131
132
133@dataclasses.dataclass
134class CaloriesData(base_model.TerraDataModel):
135    net_activity_calories: typing.Optional[float] = dataclasses.field(default=None)
136    BMR_calories: typing.Optional[float] = dataclasses.field(default=None)
137    total_burned_calories: typing.Optional[float] = dataclasses.field(default=None)
138    net_intake_calories: typing.Optional[float] = dataclasses.field(default=None)
139    calorie_samples: typing.List[samples_.CalorieSample] = dataclasses.field(default_factory=list)
140
141
142@dataclasses.dataclass
143class WorkData(base_model.TerraDataModel):
144    work_kilojoules: typing.Optional[float] = dataclasses.field(default=None)
145
146
147@dataclasses.dataclass
148class PowerData(base_model.TerraDataModel):
149    avg_watts: typing.Optional[float] = dataclasses.field(default=None)
150    max_watts: typing.Optional[float] = dataclasses.field(default=None)
151    power_samples: typing.List[samples_.PowerSample] = dataclasses.field(default_factory=list)
152
153
154@dataclasses.dataclass
155class EnergyData(base_model.TerraDataModel):
156    energy_kilojoules: typing.Optional[float] = dataclasses.field(default=None)
157    energy_planned_kilojoules: typing.Optional[float] = dataclasses.field(default=None)
158
159
160@dataclasses.dataclass
161class TSSData(base_model.TerraDataModel):
162    TSS_samples: typing.List[samples_.TSSSample] = dataclasses.field(default_factory=list)
163
164
165@dataclasses.dataclass
166class HeartRateZone(base_model.TerraDataModel):
167    zone: typing.Optional[int] = dataclasses.field(default=None)
168    start_percentage: typing.Optional[float] = dataclasses.field(default=None)
169    end_percentage: typing.Optional[float] = dataclasses.field(default=None)
170    name: typing.Optional[str] = dataclasses.field(default=None)
171    duration_seconds: typing.Optional[float] = dataclasses.field(default=None)
172
173    def __post_init__(self) -> None:
174        if not any((self.start_percentage, self.end_percentage, self.name)):
175            self.start_percentage, self.end_percentage, self.name = (None, None, None)
176
177
178@dataclasses.dataclass
179class HeartRateDataSummary(base_model.TerraDataModel):
180    avg_hr_bpm: typing.Optional[float] = dataclasses.field(default=None)
181    max_hr_bpm: typing.Optional[float] = dataclasses.field(default=None)
182    min_hr_bpm: typing.Optional[float] = dataclasses.field(default=None)
183    avg_hrv_rmssd: typing.Optional[float] = dataclasses.field(default=None)
184    avg_hrv_sdnn: typing.Optional[float] = dataclasses.field(default=None)
185    user_max_hr_bpm: typing.Optional[float] = dataclasses.field(default=None)
186    resting_hr_bpm: typing.Optional[float] = dataclasses.field(default=None)
187    hr_zone_data: typing.List[HeartRateZone] = dataclasses.field(default_factory=list)
188
189
190@dataclasses.dataclass
191class HeartRateDataDetailed(base_model.TerraDataModel):
192    hr_samples: typing.List[samples_.HeartRateDataSample] = dataclasses.field(default_factory=list)
193    hrv_samples_rmssd: typing.List[samples_.HeartRateVariabilityDataSampleRMSSD] = dataclasses.field(
194        default_factory=list
195    )
196    hrv_samples_sdnn: typing.List[samples_.HeartRateVariabilityDataSampleSDNN] = dataclasses.field(default_factory=list)
197
198
199@dataclasses.dataclass
200class HeartRateData(base_model.TerraDataModel):
201    summary: HeartRateDataSummary = dataclasses.field(default_factory=HeartRateDataSummary)
202    detailed: HeartRateDataDetailed = dataclasses.field(default_factory=HeartRateDataDetailed)
203
204
205@dataclasses.dataclass
206class OxygenData(base_model.TerraDataModel):
207    vo2max_ml_per_min_per_kg: typing.Optional[float] = dataclasses.field(default=None)
208    avg_saturation_percentage: typing.Optional[float] = dataclasses.field(default=None)
209    saturation_samples: typing.List[samples_.OxygenSaturationSample] = dataclasses.field(default_factory=list)
210    vo2_samples: typing.List[samples_.Vo2MaxSample] = dataclasses.field(default_factory=list)
211
212
213@dataclasses.dataclass
214class PolylineMapData(base_model.TerraDataModel):
215    summary_polyline: typing.Optional[str] = dataclasses.field(default=None)
216
217
218@dataclasses.dataclass
219class DeviceData(base_model.TerraDataModel):
220    name: typing.Optional[str] = dataclasses.field(default=None)
221    activation_timestamp: typing.Optional[str] = dataclasses.field(default=None)
222    manufacturer: typing.Optional[str] = dataclasses.field(default=None)
223    serial_number: typing.Optional[str] = dataclasses.field(default=None)
224    software_version: typing.Optional[str] = dataclasses.field(default=None)
225    hardware_version: typing.Optional[str] = dataclasses.field(default=None)
226    other_devices: typing.List[samples_.OtherDeviceData] = dataclasses.field(default_factory=list)
227
228
229@dataclasses.dataclass
230class Activity(base_model.TerraDataModel):
231    metadata: Metadata = dataclasses.field(default_factory=Metadata)
232    lap_data: LapData = dataclasses.field(default_factory=LapData)
233    distance_data: DistanceData = dataclasses.field(default_factory=DistanceData)
234    position_data: PositionData = dataclasses.field(default_factory=PositionData)
235    active_durations_data: ActiveDurationsData = dataclasses.field(default_factory=ActiveDurationsData)
236    MET_data: METData = dataclasses.field(default_factory=METData)
237    movement_data: MovementData = dataclasses.field(default_factory=MovementData)
238    calories_data: CaloriesData = dataclasses.field(default_factory=CaloriesData)
239    work_data: WorkData = dataclasses.field(default_factory=WorkData)
240    power_data: PowerData = dataclasses.field(default_factory=PowerData)
241    energy_data: EnergyData = dataclasses.field(default_factory=EnergyData)
242    TSS_data: TSSData = dataclasses.field(default_factory=TSSData)
243    heart_rate_data: HeartRateData = dataclasses.field(default_factory=HeartRateData)
244    strain_data: StrainData = dataclasses.field(default_factory=StrainData)
245    oxygen_data: OxygenData = dataclasses.field(default_factory=OxygenData)
246    polyline_map_data: PolylineMapData = dataclasses.field(default_factory=PolylineMapData)
247    device_data: DeviceData = dataclasses.field(default_factory=DeviceData)
@dataclasses.dataclass
class Activity(terra.models.base_model.TerraDataModel):
230@dataclasses.dataclass
231class Activity(base_model.TerraDataModel):
232    metadata: Metadata = dataclasses.field(default_factory=Metadata)
233    lap_data: LapData = dataclasses.field(default_factory=LapData)
234    distance_data: DistanceData = dataclasses.field(default_factory=DistanceData)
235    position_data: PositionData = dataclasses.field(default_factory=PositionData)
236    active_durations_data: ActiveDurationsData = dataclasses.field(default_factory=ActiveDurationsData)
237    MET_data: METData = dataclasses.field(default_factory=METData)
238    movement_data: MovementData = dataclasses.field(default_factory=MovementData)
239    calories_data: CaloriesData = dataclasses.field(default_factory=CaloriesData)
240    work_data: WorkData = dataclasses.field(default_factory=WorkData)
241    power_data: PowerData = dataclasses.field(default_factory=PowerData)
242    energy_data: EnergyData = dataclasses.field(default_factory=EnergyData)
243    TSS_data: TSSData = dataclasses.field(default_factory=TSSData)
244    heart_rate_data: HeartRateData = dataclasses.field(default_factory=HeartRateData)
245    strain_data: StrainData = dataclasses.field(default_factory=StrainData)
246    oxygen_data: OxygenData = dataclasses.field(default_factory=OxygenData)
247    polyline_map_data: PolylineMapData = dataclasses.field(default_factory=PolylineMapData)
248    device_data: DeviceData = dataclasses.field(default_factory=DeviceData)

Activity(metadata: terra.models.v2.activity.Metadata = , lap_data: terra.models.v2.activity.LapData = , distance_data: terra.models.v2.activity.DistanceData = , position_data: terra.models.v2.activity.PositionData = , active_durations_data: terra.models.v2.activity.ActiveDurationsData = , MET_data: terra.models.v2.activity.METData = , movement_data: terra.models.v2.activity.MovementData = , calories_data: terra.models.v2.activity.CaloriesData = , work_data: terra.models.v2.activity.WorkData = , power_data: terra.models.v2.activity.PowerData = , energy_data: terra.models.v2.activity.EnergyData = , TSS_data: terra.models.v2.activity.TSSData = , heart_rate_data: terra.models.v2.activity.HeartRateData = , strain_data: terra.models.v2.activity.StrainData = , oxygen_data: terra.models.v2.activity.OxygenData = , polyline_map_data: terra.models.v2.activity.PolylineMapData = , device_data: terra.models.v2.activity.DeviceData = )

Activity( metadata: terra.models.v2.activity.Metadata = <factory>, lap_data: terra.models.v2.activity.LapData = <factory>, distance_data: terra.models.v2.activity.DistanceData = <factory>, position_data: terra.models.v2.activity.PositionData = <factory>, active_durations_data: terra.models.v2.activity.ActiveDurationsData = <factory>, MET_data: terra.models.v2.activity.METData = <factory>, movement_data: terra.models.v2.activity.MovementData = <factory>, calories_data: terra.models.v2.activity.CaloriesData = <factory>, work_data: terra.models.v2.activity.WorkData = <factory>, power_data: terra.models.v2.activity.PowerData = <factory>, energy_data: terra.models.v2.activity.EnergyData = <factory>, TSS_data: terra.models.v2.activity.TSSData = <factory>, heart_rate_data: terra.models.v2.activity.HeartRateData = <factory>, strain_data: terra.models.v2.activity.StrainData = <factory>, oxygen_data: terra.models.v2.activity.OxygenData = <factory>, polyline_map_data: terra.models.v2.activity.PolylineMapData = <factory>, device_data: terra.models.v2.activity.DeviceData = <factory>)