Skip to content

Commit 3522056

Browse files
committed
updated extract_h5_dataset utility to use utils
1 parent 5ef5cb6 commit 3522056

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

utils/extract_h5_dataset.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
#
44

55
import sys
6-
import logging
76
from sliderule import icesat2
8-
from utils import parse_command_line
7+
from utils import parse_command_line, initialize_client
98

109
###############################################################################
1110
# MAIN
@@ -14,33 +13,26 @@
1413
if __name__ == '__main__':
1514

1615
# set script defaults
17-
cfg = {
18-
"url": 'localhost',
19-
"organization": None,
20-
"asset": 'atlas-local',
16+
local = {
2117
"dataset": '/gt2l/heights/h_ph',
22-
"resource": 'ATL03_20181017222812_02950102_005_01.h5',
2318
"col": 0,
2419
"startrow": 0,
2520
"numrows": -1
2621
}
2722

28-
# parse configuration parameters
29-
parse_command_line(sys.argv, cfg)
30-
31-
# Configure Logging #
32-
logging.basicConfig(level=logging.INFO)
23+
# Initialize Client
24+
parms, cfg = initialize_client(sys.argv)
3325

34-
# Configure SlideRule #
35-
icesat2.init(cfg["url"], True, organization=cfg["organization"])
26+
# parse configuration parameters
27+
parse_command_line(sys.argv, local)
3628

3729
# Read Dataset #
38-
datasets = [ {"dataset": cfg["dataset"], "col": cfg["col"], "startrow": cfg["startrow"], "numrows": cfg["numrows"]} ]
30+
datasets = [ {"dataset": local["dataset"], "col": local["col"], "startrow": local["startrow"], "numrows": local["numrows"]} ]
3931
rawdata = icesat2.h5p(datasets, cfg["resource"], cfg["asset"])
4032
print(rawdata)
4133

4234
# Write Dataset to File #
43-
filename = cfg["dataset"][cfg["dataset"].rfind("/")+1:]
35+
filename = local["dataset"][local["dataset"].rfind("/")+1:]
4436
f = open(filename + ".bin", 'w+b')
45-
f.write(bytearray(rawdata[cfg["dataset"]]))
37+
f.write(bytearray(rawdata[local["dataset"]]))
4638
f.close()

utils/utils.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def initialize_client(args):
7878
"maxi": 1,
7979
"atl03_geo_fields": [],
8080
"atl03_ph_fields": [],
81-
"samples": [],
8281
"profile": True,
8382
"verbose": True,
8483
"timeout": 0,
@@ -120,10 +119,6 @@ def initialize_client(args):
120119
if len(cfg['atl03_ph_fields']) > 0:
121120
parms['atl03_ph_fields'] = cfg['atl03_ph_fields']
122121

123-
# Add Rasters to Sample
124-
if len(cfg['samples']) > 0:
125-
parms['samples'] = cfg['samples']
126-
127122
# Add ATL08 Classification
128123
if len(cfg['atl08_class']) > 0:
129124
parms['atl08_class'] = cfg['atl08_class']

0 commit comments

Comments
 (0)