Skip to content

Commit 424d8cf

Browse files
committed
add dropsonde products
1 parent d83f8e5 commit 424d8cf

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

ipfs/hashes_products.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import subprocess
33
import ruamel.yaml
44
import sys
5+
import os
6+
from tqdm import tqdm
57

68
sys.path.append("./")
79
sys.path.append("../")
@@ -35,17 +37,32 @@ def path2ipfs(path):
3537
product_path = config["OPTIONAL"]["product_dir"]
3638
# %%
3739

38-
# add raw data to tree
39-
4040
# Ensure the structure exists and initialize empty dicts if they don't exist
4141
tree["products"]["HALO"].setdefault("dropsondes", {})
42-
43-
4442
if tree["products"]["HALO"]["dropsondes"] is None:
4543
tree["products"]["HALO"]["dropsondes"] = {}
46-
# add the hashes to the tree
47-
product_sonde = path2ipfs(product_path)
48-
tree["products"]["HALO"]["dropsondes"] = product_sonde
44+
45+
46+
# add product_data
47+
level_dirs = ["Level_1", "Level_2"]
48+
for level in level_dirs:
49+
print(level)
50+
tree["products"]["HALO"]["dropsondes"].setdefault(f"{level}", {})
51+
if tree["products"]["HALO"]["dropsondes"][f"{level}"] is None:
52+
tree["products"]["HALO"]["dropsondes"][f"{level}"] = {}
53+
fl_path = os.path.join(product_path, level)
54+
flight_ids = [f for f in sorted(os.listdir(fl_path)) if "HALO-" in f]
55+
for flight in tqdm(flight_ids):
56+
path_to_flight = os.path.join(fl_path, flight)
57+
lev_sonde = path2ipfs(path_to_flight)
58+
59+
tree["products"]["HALO"]["dropsondes"][f"{level}"][f"{flight}"] = lev_sonde
60+
61+
level_dirs = ["Level_3", "Level_4"]
62+
for level in tqdm(level_dirs):
63+
path2lev = os.path.join(product_path, level)
64+
lev_sonde = path2ipfs(path2lev)
65+
tree["products"]["HALO"]["dropsondes"][f"{level}"] = lev_sonde
4966

5067
# Save the updated tree back to the YAML file
5168
with open("../../ipfs_tools/tree.yaml", "w") as file:

0 commit comments

Comments
 (0)