maximilianherde
commited on
Commit
•
d0eadc4
1
Parent(s):
13dea61
Update assemble_data.py
Browse files- assemble_data.py +12 -12
assemble_data.py
CHANGED
@@ -54,18 +54,18 @@ def assemble_data(input_dir, output_file):
|
|
54 |
variable = nc.variables[nc_file.split("_")[0]]
|
55 |
out_nc[nc_file.split("_")[0]][samples[i] : samples[i + 1]] = variable[:]
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
70 |
print(f"Saved data to {output_file}")
|
71 |
|
|
|
54 |
variable = nc.variables[nc_file.split("_")[0]]
|
55 |
out_nc[nc_file.split("_")[0]][samples[i] : samples[i + 1]] = variable[:]
|
56 |
|
57 |
+
samples = [0]
|
58 |
+
for nc_file in c_files:
|
59 |
+
with Dataset(os.path.join(input_dir, nc_file), "r") as nc:
|
60 |
+
samples.append(nc.dimensions["sample"].size)
|
61 |
+
for i in range(1, len(samples)):
|
62 |
+
samples[i] += samples[i - 1]
|
63 |
+
|
64 |
+
for i, c_file in enumerate(c_files):
|
65 |
+
with Dataset(os.path.join(input_dir, c_file), "r") as nc:
|
66 |
+
print(f"Processing {os.path.join(input_dir, c_file)}")
|
67 |
+
variable = nc.variables[c_file.split("_")[0]]
|
68 |
+
out_nc[c_file.split("_")[0]][samples[i] : samples[i + 1]] = variable[:]
|
69 |
|
70 |
print(f"Saved data to {output_file}")
|
71 |
|