Skip to content

Commit 17db90c

Browse files
clevinsonclevinson
andauthored
feat: update v1 Experiment schema to include Intervention and Tracer Study classes (#4)
* checkin .mise.toml * add tracer info details * add support for other in feedstock_type * add line as possible field in GeoShape * add Tracer and Intervention classes with use of mixins * updated artifacts * update person schema, add support for researcher id type enum * add support for qudt unit ontology * Add explicit SpatialCoverage and DosingLocation classes * remove vertical coverage from project-level * add supplemental scripts and files for unit conversion * refactor permits * update project_id description * gen project from project desc updates * update public_comment to be freetext field * update descriptions * make vertical coverage optional --------- Co-authored-by: clevinson <cory@soundcloud.com>
1 parent 355911e commit 17db90c

18 files changed

Lines changed: 90785 additions & 552 deletions

.mise.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tools]
2+
python = "3.12"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Extract QUDT units with hasQuantityKind quantitykind:MassConcentration from local ontology file.
4+
This is a lightweight replacement for vskit for the specific MassConcentration use case.
5+
"""
6+
7+
import yaml
8+
from pathlib import Path
9+
import re
10+
11+
def load_vskit_config(config_path="vskit-config.yaml"):
12+
"""Load vskit config to find the local unit.ttl path."""
13+
with open(config_path, 'r') as f:
14+
config = yaml.safe_load(f)
15+
16+
# Get the path for qudt:unit
17+
unit_path = config['resource_resolvers']['qudt:unit']['shorthand']
18+
return unit_path
19+
20+
def extract_mass_concentration_units(ttl_path):
21+
"""
22+
Extract all units that have qudt:hasQuantityKind quantitykind:MassConcentration.
23+
Returns a list of unit identifiers in the format "unit:____".
24+
"""
25+
units = []
26+
current_unit = None
27+
28+
with open(ttl_path, 'r', encoding='utf-8') as f:
29+
for line in f:
30+
line = line.strip()
31+
32+
# Look for unit definitions (e.g., "unit:KiloGM-PER-M3")
33+
if line.startswith('unit:'):
34+
# Extract the unit identifier
35+
match = re.match(r'^(unit:\S+)', line)
36+
if match:
37+
current_unit = match.group(1)
38+
39+
# Look for hasQuantityKind quantitykind:MassConcentration
40+
elif 'hasQuantityKind quantitykind:MassConcentration' in line and current_unit:
41+
# Add the unit if we haven't already (avoid duplicates)
42+
if current_unit not in units:
43+
units.append(current_unit)
44+
45+
return sorted(set(units))
46+
47+
def main():
48+
# Load the vskit config to find the local ontology path
49+
unit_path = load_vskit_config()
50+
51+
# Extract units
52+
units = extract_mass_concentration_units(unit_path)
53+
54+
# Print results (one per line, ready for LinkML enum)
55+
print("# Mass Concentration Units from QUDT")
56+
print(f"# Found {len(units)} units with hasQuantityKind quantitykind:MassConcentration")
57+
print()
58+
for unit in units:
59+
print(unit)
60+
61+
if __name__ == "__main__":
62+
main()

0 commit comments

Comments
 (0)