Skip to content

Commit

Permalink
Added time offset configuration to correct for non UTC time codes
Browse files Browse the repository at this point in the history
The WEG_L AWS is incorrectly transmitting UTC+2 timestamps.
  • Loading branch information
ladsmund committed Sep 20, 2023
1 parent e4ff5ed commit f299f14
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/pypromice/process/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"""
from importlib import metadata
import os, unittest, toml, datetime, uuid, pkg_resources
from typing import Optional

import numpy as np
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
Expand Down Expand Up @@ -304,8 +306,8 @@ def getConfig(config_file, inpath):
assert(field in conf[k].keys()), field+" not in config keys"
return conf

def getL0(infile, nodata, cols, skiprows, file_version,
delimiter=',', comment='#'):
def getL0(infile, nodata, cols, skiprows, file_version,
delimiter=',', comment='#', time_offset: Optional[float] = None) -> xr.Dataset:
''' Read L0 data file into pandas DataFrame object
Parameters
Expand All @@ -324,6 +326,8 @@ def getL0(infile, nodata, cols, skiprows, file_version,
String delimiter for L0 file
comment : str
Notifier of commented sections in L0 file
time_offset : Optional[float]
Time offset in hours for correcting for non utc time data.
Returns
-------
Expand Down Expand Up @@ -366,7 +370,9 @@ def getL0(infile, nodata, cols, skiprows, file_version,
print(e)
print('\n\t\t> Trying again removing apostrophes in timestamp (old files format)')
df.index = pd.to_datetime(df.index.str.replace("\"",""))


if time_offset is not None:
df.index = df.index + timedelta(hours=time_offset)

# Drop SKIP columns
for c in df.columns:
Expand Down

0 comments on commit f299f14

Please sign in to comment.