Skip to content

Commit

Permalink
Update mtr_parser.py (#187)
Browse files Browse the repository at this point in the history
- time corrections
  • Loading branch information
shaunwbell authored Jul 13, 2022
1 parent ccd98dd commit 21dc9d4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/EcoFOCIpy/io/mtr_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,20 @@ def dic2df(self, data_dic):
df.index.rename('date_time',inplace=True)
df.rename(columns = {0:'temperature'}, inplace = True)

return df
return df

@staticmethod
def time_correction(rawdata_df,offset=None):
""" apply a linear time correction in seconds"""
samples = len(rawdata_df)
offsetpersample = round((offset / samples) * 1e9)
rawdata_df.index = rawdata_df.reset_index()['date_time'] + pd.timedelta_range(start=0,periods=len(rawdata_df),freq=f'{offsetpersample}ns').values

return (rawdata_df, offsetpersample)

@staticmethod
def time_offset_correction(rawdata_df,offset=None):
""" apply a time offset in seconds"""
rawdata_df.index = rawdata_df.index + pd.Timedelta(seconds=offset)

return (rawdata_df)

0 comments on commit 21dc9d4

Please sign in to comment.