Skip to content
Snippets Groups Projects

Transfer ICOS data to level 1

Merged Martin Quanz requested to merge (removed):ICOS into master
1 unresolved thread
2 files
+ 11
14
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 5
4
@@ -421,14 +421,15 @@ def readCaldataICOS(path):
# Extract fname, start date & box by fname.
fdict = {"fname": [], "start": [], "box": []}
pattern = re.compile(r"([0-9]+).csv$")
date_pattern = re.compile(r"([0-9]+).csv$")
box_pattern = re.compile(r"ICOS(..)")
for f in os.listdir(path):
m = pattern.search(f)
m = date_pattern.search(f)
if m:
fdict["fname"].append(os.path.join(path, f))
fdict["start"].append(
datetime.strptime(m.group(1), "%Y%m%d%H%M"))
fdict["box"].append(f.split("_")[1][4:])
fdict["box"].append(box_pattern.search(f).group(1))
# Get end date as last occurrence grouped by box.
cal = pd.DataFrame(data=fdict).sort_values(by=["box", "start"])
@@ -467,7 +468,7 @@ def readSoilnetL0ICOS(fnames, calpath):
# Load data and find header
content = _readSoilnetL0File(fname)
df = pd.read_csv(StringIO(content), sep=",", header=None)
box = "4" + fname.split("_")[-2][2:3]
box = "4" + re.compile(r"[0-9]+_L.(.)").search(fname).group(1)
mindate = datetime.strptime(str(df[[0]].min()[0]), "%Y%m%d%H%M")
header = findHeaderICOS(cal, variables, box, mindate)
# Rename columns, skip empty data.
Loading