Skip to content
Snippets Groups Projects
Commit a82eb622 authored by Alexander Hinz's avatar Alexander Hinz
Browse files

reduce: replace LOGGER with DEVICE

parent d74f1676
No related branches found
No related tags found
2 merge requests!36Reduce,!23Major rework of the entire pipeline
This commit is part of merge request !36. Comments created here will be created in the context of that merge request.
......@@ -39,7 +39,7 @@ def readConfig(station):
config = config[
[CF.VARNAME, CF.EDDYPRO,
CF.UNIT, CF.LOGGER,
CF.UNIT, CF.DEVICE,
CF.STARTDATE, CF.ENDDATE]]
return config
......@@ -51,7 +51,7 @@ def getData(logger, station):
dfs = OrderedDict()
for devname, devconfig in config.groupby(by=CF.LOGGER):
for devname, devconfig in config.groupby(by=CF.DEVICE):
logger.debug(f"reading: {devname}")
data = (station
.getDevice(devname)
......
......@@ -79,7 +79,7 @@ class Device(object):
@property
def config(self):
if self._config is None:
self._config = readExcel(self.xls_sheets).dropna(subset=[CF.LOGGER, CF.DBNAME])
self._config = readExcel(self.xls_sheets).dropna(subset=[CF.DEVICE, CF.DBNAME])
return self._config
@property
......@@ -144,7 +144,7 @@ class Device(object):
key = key if key is not None else self.logger_key
try:
xls = self.readExcel(**kwargs)
out = xls.set_index(CF.LOGGER).loc[key, CF.STARTDATE].dropna().min()
out = xls.set_index(CF.DEVICE).loc[key, CF.STARTDATE].dropna().min()
return out
except (ValueError, KeyError):
return MINDATE
......@@ -153,7 +153,7 @@ class Device(object):
key = key if key is not None else self.logger_key
try:
xls = self.readExcel(**kwargs)
end_dates = xls.set_index(CF.LOGGER).loc[key, CF.ENDDATE]
end_dates = xls.set_index(CF.DEVICE).loc[key, CF.ENDDATE]
if pd.isnull(end_dates).any():
return date.today()
return end_dates.max()
......@@ -197,7 +197,7 @@ class Device(object):
"""
out = self.config
if filter is True:
out = out[out[CF.LOGGER] == self.logger_key]
out = out[out[CF.DEVICE] == self.logger_key]
return out
def getRemoteFiles(self, pattern=None):
......@@ -391,7 +391,7 @@ class SoilnetDeviceBase(Device):
"""
out = self.config
if filter is True:
device_names = out[CF.LOGGER].astype(int).map("Box{:02}".format)
device_names = out[CF.DEVICE].astype(int).map("Box{:02}".format)
out = out[device_names == self.logger_key]
return out
......
......@@ -175,10 +175,10 @@ class Station(object):
variables = _tupelize(variables)
config = config[config[CF.VARNAME]
.str.contains("|".join(variables))]
config = config.loc[:, [CF.VARNAME, CF.LOGGER]]
config = config.loc[:, [CF.VARNAME, CF.DEVICE]]
dfs = []
for device, device_config in config.groupby(CF.LOGGER):
for device, device_config in config.groupby(CF.DEVICE):
dev = self.getDevice(device)
data = dev.getDerivedData(
var,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment