2
2
from datetime import date
3
3
from sliderule import ipxapi
4
4
from sliderule import icesat2
5
+ import matplotlib .pyplot as plt
5
6
import icepyx
6
7
7
8
###############################################################################
@@ -15,7 +16,7 @@ def parse_command_line(args, cfg):
15
16
if args [i ] == '--' + entry :
16
17
if type (cfg [entry ]) is str :
17
18
cfg [entry ] = args [i + 1 ]
18
- elif type (cfg [entry ]) is list :
19
+ elif ( type (cfg [entry ]) is list ) or ( cfg [ entry ] is None ) :
19
20
l = []
20
21
while (i + 1 ) < len (args ) and args [i + 1 ].isnumeric ():
21
22
l .append (int (args [i + 1 ]))
@@ -37,7 +38,7 @@ def parse_command_line(args, cfg):
37
38
38
39
# set script defaults
39
40
scfg = {
40
- "url" : [ '127.0.0.1' ] ,
41
+ "url" : '127.0.0.1' ,
41
42
"asset" : 'atlas-local'
42
43
}
43
44
@@ -46,8 +47,8 @@ def parse_command_line(args, cfg):
46
47
"short_name" : 'ATL03' ,
47
48
"spatial_extent" : 'valgrande.shp' ,
48
49
"date_range" : ['2018-01-01' , "{}-{}-{}" .format (today .year , today .month , today .day )],
49
- "cycles" : [] ,
50
- "tracks" : []
50
+ "cycles" : None ,
51
+ "tracks" : None
51
52
}
52
53
53
54
# set processing parameter defaults
@@ -66,27 +67,30 @@ def parse_command_line(args, cfg):
66
67
parse_command_line (sys .argv , scfg )
67
68
parse_command_line (sys .argv , parms )
68
69
69
- # massage command line parameters
70
- if len (icfg ["cycles" ]) == 0 :
71
- icfg ["cycles" ] = None
72
- if len (icfg ["tracks" ]) == 0 :
73
- icfg ["tracks" ] = None
70
+ # bypass service discovery if url is localhost
71
+ if scfg ["url" ] == '127.0.0.1' :
72
+ scfg ["url" ] = ['127.0.0.1' ]
74
73
75
74
# create icepx region
76
75
iregion = icepyx .Query (icfg ["short_name" ], icfg ["spatial_extent" ], icfg ["date_range" ], cycles = icfg ["cycles" ], tracks = icfg ["tracks" ])
77
76
78
77
# visualize icepx region
79
- iregion .visualize_spatial_extent ()
78
+ # iregion.visualize_spatial_extent()
80
79
81
80
# display summary information
82
81
iregion .product_summary_info ()
83
- print ("Available Granules:" , iregion .avail_granules ())
84
- print ("Available Granule IDs:" , iregion .avail_granules (ids = True ))
82
+ # print("Available Granules:", iregion.avail_granules())
83
+ # print("Available Granule IDs:", iregion.avail_granules(ids=True))
85
84
86
85
# initialize sliderule api
87
86
icesat2 .init (scfg ["url" ], verbose = True )
88
87
89
88
# generate sliderule atl06 elevations
90
- parms ["poly" ] = icesat2 .toregion (icfg ["spatial_extent" ])
91
- ipxapi .atl06p (iregion , parms , scfg ["asset" ])
92
-
89
+ parms ["poly" ] = icesat2 .toregion (icfg ["spatial_extent" ])[0 ]
90
+ atl06_sr = ipxapi .atl06p (iregion , parms , scfg ["asset" ])
91
+
92
+ # Create Plot
93
+ f , ax = plt .subplots ()
94
+ vmin , vmax = atl06_sr ['h_mean' ].quantile ((0.02 , 0.98 ))
95
+ atl06_sr .plot (ax = ax , column = 'h_mean' , cmap = 'inferno' , s = 0.1 , vmin = vmin , vmax = vmax )
96
+ plt .show ()
0 commit comments