From f299f1425f5929861ef9e5a04a05ad32455647e7 Mon Sep 17 00:00:00 2001 From: Mads Christian Lund Date: Wed, 20 Sep 2023 13:01:44 +0200 Subject: [PATCH] Added time offset configuration to correct for non UTC time codes The WEG_L AWS is incorrectly transmitting UTC+2 timestamps. --- src/pypromice/process/aws.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pypromice/process/aws.py b/src/pypromice/process/aws.py index 9b2a80c2..bdd70c02 100644 --- a/src/pypromice/process/aws.py +++ b/src/pypromice/process/aws.py @@ -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) @@ -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 @@ -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 ------- @@ -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: