Skip to content

Commit fa7e6c2

Browse files
committed
Add example script
1 parent 48a855c commit fa7e6c2

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

write_drillcore.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import argparse, os, json
2+
import s3fs
3+
from caltechdata_api import caltechdata_write
4+
5+
# Get access token as environment variable
6+
token = os.environ["RDMTOK"]
7+
8+
metaf = open("h790j-6ar55.json", "r")
9+
metadata = json.load(metaf)
10+
11+
drill_holes = ["BA1B", "BA3A", "BA4A"]
12+
methods = ["VNIR", "SWIR"]
13+
14+
endpoint = "https://caltech2.osn.mghpcc.org"
15+
s3 = s3fs.S3FileSystem(anon=True, client_kwargs={"endpoint_url": endpoint})
16+
17+
for hole in drill_holes:
18+
for method in methods:
19+
metadata["metadata"]["title"] = (
20+
f"Hole {hole} - {method} Imaging spectroscopy of the Oman Drilling Project mantle"
21+
)
22+
if method == "VNIR":
23+
image = "visible and near-infrared (VNIR)"
24+
if method == "SWIR":
25+
image = "shortwave infrared (SWIR)"
26+
metadata["metadata"]["description"] = f"""This record contains {image} data of the
27+
archive halves of the borehole {hole} core recovered by the Integrated
28+
International Continental Scientific Drilling Project (ICDP) Oman Drilling Project (OmanDP; Kelemen et al., 2020).
29+
30+
For additional details, see the full record for this project at
31+
https://doi.org/10.22002/h790j-6ar55. Please cite this DOI is you use
32+
this dataset.
33+
34+
Available data are data cubes as described in Kelemen et al. (2020) processed
35+
to reflectance (Mandon et al., 2026, JGR: Solid Earth). Data are paired
36+
.img and .hdr files."""
37+
38+
files = s3.ls(f"caltechdata-public/h790j-6ar55/{hole}/{method}")
39+
file_links = [f"{endpoint}/{f}" for f in files]
40+
41+
production = True
42+
publish = False
43+
44+
response = caltechdata_write(
45+
metadata,
46+
token,
47+
production=production,
48+
publish=publish,
49+
file_links=file_links,
50+
)
51+
print(response)

0 commit comments

Comments
 (0)