Skip to content

Commit

Permalink
♻️ Rename basic_calculation to preprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
dalonsoa committed Aug 4, 2023
1 parent c0e24f4 commit 0817b30
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions validated/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def verify_validated(
return matches_time["_merge"] == "both"


def basic_calculations(
def preprocessing(
station: Station,
variable: Variable,
start_time: Union[datetime, str],
Expand All @@ -420,7 +420,14 @@ def basic_calculations(
minimum: Minimum value expected for the variable.
Returns:
Returns a tuple with the following Dataframes and processed data:
- measurement: DataFrame with the raw measurement data in the interval.
- validated: Dataframe with the validated data in the interval.
- selected_full: All validated data and that still to be validated,
without duplicate timestamps.
- selected: Selected data without duplicate time stamps.
- tx_period (Decimal): The expected period for the measurements.
- value_fields: Data fields that are expected in this data.
"""
tx_period = DeltaT.objects.get(station__station_id=station.station_id).delta_t

Expand Down Expand Up @@ -477,7 +484,7 @@ def daily_report(station, variable, start_time, end_time, minimum, maximum):
selected,
tx_period,
value_fields,
) = basic_calculations(station, variable, start_time, end_time, minimum, maximum)
) = preprocessing(station, variable, start_time, end_time, minimum, maximum)

daily_group_all = selected_full.groupby("date")
daily_group = selected.groupby("date")
Expand Down Expand Up @@ -769,7 +776,7 @@ def detail_list(station_id, variable_id, date, minimum, maximum):
selected,
tx_period,
value_fields,
) = basic_calculations(station, variable, start_time, end_time, minimum, maximum)
) = preprocessing(station, variable, start_time, end_time, minimum, maximum)

if "average" in value_fields:
value_column = "average"
Expand Down Expand Up @@ -934,7 +941,7 @@ def save_to_validated(changes_list, variable, station, conditions, minimum, maxi
selected,
tx_period,
value_fields,
) = basic_calculations(station, variable, start_date, end_date, minimum, maximum)
) = preprocessing(station, variable, start_date, end_date, minimum, maximum)
if len(conditions["where_delete"]) > 0:
where_delete = conditions["where_delete"].replace("'", "").split(",")
for _date in where_delete:
Expand Down

0 comments on commit 0817b30

Please sign in to comment.