import time
import matplotlib.pyplot as plt
from sliderule import gedi
from sliderule import earthdata
import sliderule
# initialize client (notebook only processes one granule, so one node is sufficient)
gedi.init("slideruleearth.io", verbose=True)
# Specify region of interest from geojson
poly_fn = 'grandmesa.geojson'
region = sliderule.toregion(poly_fn)
granules = earthdata.cmr(short_name="GEDI01_B", polygon=region["poly"])
# Build GEDI Request Parameters
parms = {
"poly": region["poly"],
"beam": 0
}
# Latch Start Time
perf_start = time.perf_counter()
# Request GEDI Data
gedi01b = gedi.gedi01bp(parms, resources=['GEDI01_B_2019109210809_O01988_03_T02056_02_005_01_V002.h5'])
# Latch Stop Time
perf_stop = time.perf_counter()
# Display Statistics
perf_duration = perf_stop - perf_start
print("Completed in {:.3f} seconds of wall-clock time".format(perf_duration))
print("Received {} footprints".format(gedi01b.shape[0]))
if len(gedi01b) > 0:
print("Beams: {}".format(gedi01b["beam"].unique()))
gedi01b
# plot elevations
f, ax = plt.subplots(1, 2, figsize=[12,8])
ax[0].set_title("Elevation of First Bin")
ax[0].set_aspect('equal')
gedi01b.plot(ax=ax[0], column='elevation_start', cmap='inferno', s=0.1)
ax[1].set_title("Elevation of Last Bin")
ax[1].set_aspect('equal')
gedi01b.plot(ax=ax[1], column='elevation_stop', cmap='inferno', s=0.1)