- class enhydris.telemetry.models.Telemetry¶
Information about how to automatically fetch data.
Telemetryhas a OneToOneField to
Station. Every minute Celery Beat runs a task that iterates through the records of
Telemetry; for each record, if the time for fetching data has arrived, it fetches the data by calling the
Telemetryobjects have the following attributes, properties and methods:
- type: CharField¶
The type of the API, such as
Metrica MeteoView2. See Telemetry API types for more information.
- data_time_zone: CharField¶
Enhydris has the requirement that all time stamps in
TimeseriesRecordmust be stored in the same offset from UTC, i.e. without switching to Daylight Saving Time (DST). This offset is specified by
It is recommended that data loggers also do not switch to DST. However, if they do, Enhydris can convert their time stamps as needed. If, for example,
data_time_zoneis set to
Europe/Athens, then any DST offset will be removed before storing in
data_time_zoneis used only in order to know when the DST switches occur. The timestamp, after removing any DST, is entered as is. There is no conversion from
enhydris.models.TimeseriesGroup.time_zone. Therefore, whether
Europe/Berlin, the effect will be exactly the same, since Athens and Berlin (as of 2021) switch to DST in exactly the same dates.
Enhydris assumes that the time change occurs exactly when it is supposed to occur, not a few hours earlier or later. For the switch towards DST, things are simple. For the switch from DST to winter time, things are more complicated, because there’s an hour that appears twice. If the ambiguous hour occurs twice, Enhydris will usually do the correct thing; it will consider that the second occurence is after the switch and the first is before the switch. If according to the system’s clock the switch hasn’t occurred yet, any references to the ambiguous hour are considered to have occurred before the switch.
- fetch_interval_minutes: PositiveSmallIntegerField¶
This can be, e.g., 60 to fetch data every 60 minutes, 1440 to fetch data once a day, etc.
- fetch_offset_minutes: PositiveSmallIntegerField¶
fetch_interval_minutesis 10 and
fetch_offset_minutesis 2, then data will be fetched at :02, :12, :22, etc. If
fetch_interval_minutesis 1440 and
fetch_offset_minutesis 125, then data will be fetched every day at 02:05 in the morning. Generally
fetch_offset_minutescounts from midnight.
- fetch_offset_time_zone: CharField¶
- configuration: JSONField¶
Any additional configuration. The exact contents depend on the API
configurationcontains (among other things) a
timeserieskey, which is a list. See
Telemetry.wizard_stepsfor more information.
- property is_due: Boolean¶
Telemetry API types¶
Each API type is one Python file in the
enhydris/telemetry/types. The Python file must contain a
Telemetry class with all required functionality to retrieve
data from the API.
When it starts, Enhydris scans the
directory and imports all Python files it contains. The result of this
scanning goes to
A dictionary that contains all
Telemetryclasses imported from the
enhydris/telemetry/typesdirectory. Each dictionary item maps the telemetry type’s slug (the base name of the Python file) to the
- class Telemetry(telemetry_model)¶
Should inherit from
enhydris.telemetry.TelemetryBase. The base class
__init__()method initializes the object with a
enhydris.telemetry.models.Telemetryobject, which becomes the
Telemetryclasses must define following attributes, methods and properties:
- name: string¶
The name of the API, such as
Metrica MeteoView2. This is what is stored in
- wizard_steps: list¶
When the user wants to configure telemetry for a station, we show him a wizard. The first step essentially asks what type of telemetric system there is for the station at hand, i.e. asks the user to select a value for
enhydris.telemetry.models.Telemetry.type. The wizard then continues with steps that are specific to the chosen telemetry type.
wizard_steps, a class attribute, is a list of
django.forms.Formsubclasses, containing the forms for these steps. These forms are instantiated with the configuration specified so far as their
initialparameter, and the configuration is updated with the
cleaned_dataonce the form is posted.