-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrite_output_metadata.py
More file actions
97 lines (90 loc) · 2.63 KB
/
write_output_metadata.py
File metadata and controls
97 lines (90 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
###############################################################################
# Create metadata file
# Originally taken from the CITYCAT project:
# https://github.com/OpenCLIM/citycat-dafni
#
# Robin Wardle
# May 2022
###############################################################################
import os
import pathlib
import datetime
##############################################################################
# Paths
###############################################################################
# Setup base path
platform = os.getenv("READ_EA_ENV")
if platform=="docker":
data_path = os.getenv("DATA_PATH", "/data")
else:
data_path = os.getenv("DATA_PATH", "./data")
# INPUT paths
in_path = data_path / pathlib.Path("inputs")
# OUTPUT paths
out_path = data_path / pathlib.Path("outputs")
###############################################################################
# Metadata definition
###############################################################################
app_title = "pyramid-read-ea"
app_description = "Environment Agency rainfall gauge data"
metadata = f"""{{
"@context": ["metadata-v1"],
"@type": "dcat:Dataset",
"dct:title": "{app_title}",
"dct:description": "{app_description}",
"dct:identifier":[],
"dct:subject": "Environment",
"dcat:theme":[],
"dct:language": "en",
"dcat:keyword": ["PYRAMID"],
"dct:conformsTo": {{
"@id": null,
"@type": "dct:Standard",
"label": null
}},
"dct:spatial": {{
"@id": null,
"@type": "dct:Location",
"rdfs:label": null
}},
"geojson": {{}},
"dct:PeriodOfTime": {{
"type": "dct:PeriodOfTime",
"time:hasBeginning": null,
"time:hasEnd": null
}},
"dct:accrualPeriodicity": null,
"dct:creator": [
{{
"@type": "foaf:Organization",
"@id": "http://www.ncl.ac.uk/",
"foaf:name": "Newcastle University",
"internalID": null
}}
],
"dct:created": "{datetime.datetime.now().isoformat()}Z",
"dct:publisher":{{
"@id": null,
"@type": "foaf:Organization",
"foaf:name": null,
"internalID": null
}},
"dcat:contactPoint": {{
"@type": "vcard:Organization",
"vcard:fn": "DAFNI",
"vcard:hasEmail": "support@dafni.ac.uk"
}},
"dct:license": {{
"@type": "LicenseDocument",
"@id": "https://creativecommons.org/licences/by/4.0/",
"rdfs:label": null
}},
"dct:rights": null,
"dafni_version_note": "created"
}}
"""
###############################################################################
# Write metadata file
###############################################################################
with open(os.path.join(out_path, 'EA', 'metadata.json'), 'w') as f:
f.write(metadata)