-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Included a separated library of functions for the temperature
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
__author__ = "Nicolas Gutierrez" | ||
|
||
# Standard libraries | ||
from typing import Tuple | ||
# Third party libraries | ||
import pandas as pd | ||
import numpy as np | ||
# Custom libraries | ||
|
||
|
||
def calculate_temp_and_ref(dfs_dict: pd.Series) -> Tuple[float, float]: | ||
# Time study | ||
final_time = dfs_dict.index.to_pydatetime()[-1] | ||
delta_time = dfs_dict.index.to_pydatetime()-final_time | ||
helper = np.vectorize(lambda x: x.total_seconds()/3600) | ||
delta_time_hours = helper(delta_time) | ||
|
||
# Fitting a line | ||
z = np.polyfit( | ||
delta_time_hours, | ||
dfs_dict.to_numpy().astype(float), | ||
1 | ||
) | ||
|
||
# Returning values for the indicator + delta | ||
current_value = float(dfs_dict.iloc[-1]) | ||
reference_value = current_value - np.around(z[0][0], 2) | ||
|
||
return current_value, reference_value |