PhoREAL / SlideRule Example¶
Demonstrate running the PhoREAL algorithm in SlideRule to produce canopy metrics over the Grand Mesa, Colorado region.
Imports¶
In [1]:
import warnings
warnings.filterwarnings("ignore") # suppress warnings
In [2]:
import matplotlib.pyplot as plt
import matplotlib
import geopandas
import logging
import sliderule
from sliderule import icesat2
Initialize Client¶
- Organization currently set to "utexas"; if you want to be a member of the utexas SlideRule organization, make a request through the SlideRule provisioning system (https://ps.slideruleearth.io); otherwise, remove the organization parameter to default to the public SlideRule cluster.
- Notebook only processes one granule, so one desired_node is sufficient
In [3]:
icesat2.init("slideruleearth.io", verbose=True, loglevel=logging.INFO)
Processing parameters¶
- 100m segments stepped every 100m
- Subsetted to the Grand Mesa region
- Time range is one day, Nov 14, 2019
- Only processing ground, canopy, and top of canopy photons
- Request the "h_dif_ref" variable as an ancillary field to be included in the results
- Running PhoREAL algorithm using a binsize of 1m, and geolocating each segment at the center of the segment
- Sending reconstructed waveforms along with metrics (for diagnostics and demonstration purposes only)
In [4]:
parms = {
"poly": sliderule.toregion('grandmesa.geojson')['poly'],
"t0": '2019-11-14T00:00:00Z',
"t1": '2019-11-15T00:00:00Z',
"srt": icesat2.SRT_LAND,
"len": 100,
"res": 100,
"pass_invalid": True,
"atl08_class": ["atl08_ground", "atl08_canopy", "atl08_top_of_canopy"],
"atl08_fields": ["h_dif_ref"],
"phoreal": {"binsize": 1.0, "geoloc": "center", "use_abs_h": False, "send_waveform": True}
}
Make Atl08 Request¶
In [5]:
atl08 = icesat2.atl08p(parms, keep_id=True)
Identified 1 resources to process Starting proxy for atl08 to process 1 resource(s) with 1 thread(s) request <AppServer.129> processing initialized on ATL03_20191114034331_07370502_006_01.h5 ... Successfully completed processing resource [1 out of 1]: ATL03_20191114034331_07370502_006_01.h5
Print Resulting GeoDataFrame¶
In [6]:
atl08
Out[6]:
h_canopy | h_mean_canopy | ph_count | landcover | gnd_ph_count | x_atc | extent_id | rgt | snowcover | canopy_h_metrics | ... | cycle | spot | segment_id | h_te_median | gt | geometry | waveform | num_bins | binsize | h_dif_ref | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
time | |||||||||||||||||||||
2019-11-14 03:46:36.935118336 | 2.261719 | 1.156670 | 102 | 30 | 75 | -6.882999e+10 | 3319153278633115650 | 737 | 1 | (1.479736328125, 1.479736328125, 1.47973632812... | ... | 5 | 6 | 215507 | 1958.305542 | 10 | POINT (-108.12262 38.83912) | [0.20588235557079315, 0.05882352963089943] | 2 | 1.0 | 0.963623 |
2019-11-14 03:46:36.949218304 | 3.137817 | 1.304013 | 113 | 30 | 54 | -6.882593e+10 | 3319153278633115654 | 737 | 1 | (1.4913330078125, 1.4913330078125, 1.491333007... | ... | 5 | 6 | 215512 | 1964.416748 | 10 | POINT (-108.12272 38.84002) | [0.3362831771373749, 0.1592920422554016, 0.026... | 3 | 1.0 | -3.216064 |
2019-11-14 03:46:36.963318272 | 4.442627 | 1.834195 | 103 | 30 | 49 | -6.882186e+10 | 3319153278633115658 | 737 | 1 | (1.5015869140625, 1.5015869140625, 1.501586914... | ... | 5 | 6 | 215517 | 1976.178833 | 10 | POINT (-108.12283 38.84092) | [0.2330097109079361, 0.1650485396385193, 0.097... | 4 | 1.0 | -5.043213 |
2019-11-14 03:46:36.977417984 | 5.067871 | 2.465483 | 103 | 30 | 35 | -6.881773e+10 | 3319153278633115662 | 737 | 1 | (1.7940673828125, 1.7940673828125, 1.794067382... | ... | 5 | 6 | 215522 | 1991.423218 | 10 | POINT (-108.12295 38.84182) | [0.20388349890708923, 0.27184465527534485, 0.1... | 6 | 1.0 | 2.426270 |
2019-11-14 03:46:36.980918016 | 5.811401 | 2.816030 | 114 | 20 | 19 | -6.927786e+10 | 3319153279706857474 | 737 | 1 | (1.5048828125, 1.5048828125, 1.5048828125, 1.5... | ... | 5 | 4 | 215529 | 1822.414673 | 30 | POINT (-108.08651 38.84583) | [0.1666666716337204, 0.21052631735801697, 0.21... | 8 | 1.0 | 5.912720 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2019-11-14 03:46:42.293068288 | 8.225342 | 3.273977 | 322 | 30 | 192 | -6.805046e+10 | 3319153278633117075 | 737 | 1 | (1.5029296875, 1.5029296875, 1.5029296875, 1.5... | ... | 5 | 5 | 217288 | 1786.887939 | 20 | POINT (-108.16125 39.15930) | [0.14596273005008698, 0.043478261679410934, 0.... | 8 | 1.0 | -3.731567 |
2019-11-14 03:46:42.293818368 | 0.000000 | NaN | 272 | 40 | 272 | -6.828026e+10 | 3319153279706858887 | 737 | 1 | (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... | ... | 5 | 3 | 217294 | 1709.912354 | 40 | POINT (-108.12461 39.16313) | [0.0] | 1 | 1.0 | -0.086914 |
2019-11-14 03:46:42.295218176 | 10.701416 | 4.089300 | 202 | 40 | 191 | -6.851079e+10 | 3319153280780600667 | 737 | 1 | (0.8890380859375, 0.8890380859375, 0.889038085... | ... | 5 | 1 | 217301 | 1716.896362 | 60 | POINT (-108.08792 39.16696) | [0.024752475321292877, 0.0, 0.0049504949711263... | 11 | 1.0 | -2.204712 |
2019-11-14 03:46:42.302418176 | 0.000000 | NaN | 51 | 40 | 51 | -6.827817e+10 | 3319153279706858891 | 737 | 1 | (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... | ... | 5 | 3 | 217299 | 1707.600586 | 40 | POINT (-108.12468 39.16368) | [0.0] | 1 | 1.0 | -0.086914 |
2019-11-14 03:46:42.304318208 | 1.410645 | 0.724375 | 174 | 20 | 161 | -6.804797e+10 | 3319153278633117079 | 737 | 1 | (1.41064453125, 1.41064453125, 1.41064453125, ... | ... | 5 | 5 | 217293 | 1784.938721 | 20 | POINT (-108.16134 39.16002) | [0.07471264153718948] | 1 | 1.0 | -1.957886 |
2112 rows × 25 columns
Plot Canopy Height¶
In [7]:
canopy_gt1l = atl08[atl08['gt'] == icesat2.GT1L]
canopy_gt1l.plot.scatter(x='x_atc', y='h_canopy')
Out[7]:
<Axes: xlabel='x_atc', ylabel='h_canopy'>
Plot Landcover¶
In [8]:
atl08.plot('landcover')
Out[8]:
<Axes: >
Create and Plot 75th percentile Across All Ground Tracks¶
In [9]:
atl08['75'] = atl08.apply(lambda row : row["canopy_h_metrics"][icesat2.P['75']], axis = 1)
atl08.plot.scatter(x='x_atc', y='75')
Out[9]:
<Axes: xlabel='x_atc', ylabel='75'>
Create Sample Waveform Plots¶
In [10]:
num_plots = 5
waveform_index = [96, 97, 98, 100, 101]
fig,ax = plt.subplots(num=1, ncols=num_plots, sharey=True, figsize=(12, 6))
for x in range(num_plots):
ax[x].plot([x for x in range(len(canopy_gt1l['waveform'][waveform_index[x]]))], canopy_gt1l['waveform'][waveform_index[x]], zorder=1, linewidth=1.0, color='mediumseagreen')
plt.show()
Make Atl06 Request¶
- Below we run an ATL06-SR processing request on the same source data using the same parameters. Because the
keep_id
argument is set to true here and above when we made the ATL08 request, we can merge the resulting dataframes and have a single table of both elevation data using the customized ATL06-SR algorithm, and vegatation data using the PhoREAL algorithm.
In [11]:
atl06 = icesat2.atl06p(parms, keep_id=True)
Identified 1 resources to process Starting proxy for atl06 to process 1 resource(s) with 1 thread(s) request <AppServer.130> processing initialized on ATL03_20191114034331_07370502_006_01.h5 ... request <AppServer.130> processing of ATL03_20191114034331_07370502_006_01.h5 complete (691067/0/0) request <AppServer.130> processing complete (2112/1/2112/0) Successfully completed processing resource [1 out of 1]: ATL03_20191114034331_07370502_006_01.h5
Merge Atl06 and Atl08 GeoDataFrames¶
In [12]:
gdf = geopandas.pd.merge(atl08, atl06, on='extent_id', how='left', suffixes=('.atl08','.atl06')).set_axis(atl08.index)
gdf
Out[12]:
h_canopy | h_mean_canopy | ph_count | landcover | gnd_ph_count | x_atc.atl08 | extent_id | rgt.atl08 | snowcover | canopy_h_metrics | ... | rms_misfit | x_atc.atl06 | spot.atl06 | cycle.atl06 | rgt.atl06 | dh_fit_dx | h_mean | y_atc | geometry.atl06 | h_dif_ref.atl06 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
time | |||||||||||||||||||||
2019-11-14 03:46:36.935118336 | 2.261719 | 1.156670 | 102 | 30 | 75 | -6.882999e+10 | 3319153278633115650 | 737 | 1 | (1.479736328125, 1.479736328125, 1.47973632812... | ... | 0.699817 | 4321857.0 | 6 | 5 | 737 | 0.164871 | 1958.905980 | 3224.564941 | POINT (-108.12262 38.83912) | 0.062566 |
2019-11-14 03:46:36.949218304 | 3.137817 | 1.304013 | 113 | 30 | 54 | -6.882593e+10 | 3319153278633115654 | 737 | 1 | (1.4913330078125, 1.4913330078125, 1.491333007... | ... | 1.607597 | 4321957.0 | 6 | 5 | 737 | 0.043268 | 1965.811905 | 3224.207520 | POINT (-108.12272 38.84002) | -1.459010 |
2019-11-14 03:46:36.963318272 | 4.442627 | 1.834195 | 103 | 30 | 49 | -6.882186e+10 | 3319153278633115658 | 737 | 1 | (1.5015869140625, 1.5015869140625, 1.501586914... | ... | 2.103739 | 4322057.0 | 6 | 5 | 737 | 0.123389 | 1976.876691 | 3224.200439 | POINT (-108.12283 38.84092) | -4.185234 |
2019-11-14 03:46:36.977417984 | 5.067871 | 2.465483 | 103 | 30 | 35 | -6.881773e+10 | 3319153278633115662 | 737 | 1 | (1.7940673828125, 1.7940673828125, 1.794067382... | ... | 2.184336 | 4322157.5 | 6 | 5 | 737 | 0.266099 | 1991.758298 | 3224.361816 | POINT (-108.12295 38.84182) | -0.171245 |
2019-11-14 03:46:36.980918016 | 5.811401 | 2.816030 | 114 | 20 | 19 | -6.927786e+10 | 3319153279706857474 | 737 | 1 | (1.5048828125, 1.5048828125, 1.5048828125, 1.5... | ... | 3.317562 | 4322298.0 | 4 | 5 | 737 | 0.288814 | 1829.816771 | 33.340397 | POINT (-108.08651 38.84583) | 5.809160 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2019-11-14 03:46:42.293068288 | 8.225342 | 3.273977 | 322 | 30 | 192 | -6.805046e+10 | 3319153278633117075 | 737 | 1 | (1.5029296875, 1.5029296875, 1.5029296875, 1.5... | ... | 2.215102 | 4357558.0 | 5 | 5 | 737 | -0.059700 | 1788.645095 | 3146.364502 | POINT (-108.16125 39.15931) | -3.117488 |
2019-11-14 03:46:42.293818368 | 0.000000 | NaN | 272 | 40 | 272 | -6.828026e+10 | 3319153279706858887 | 737 | 1 | (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... | ... | 0.159687 | 4357678.5 | 3 | 5 | 737 | -0.040557 | 1709.930448 | -46.399494 | POINT (-108.12461 39.16314) | -0.178279 |
2019-11-14 03:46:42.295218176 | 10.701416 | 4.089300 | 202 | 40 | 191 | -6.851079e+10 | 3319153280780600667 | 737 | 1 | (0.8890380859375, 0.8890380859375, 0.889038085... | ... | 0.388871 | 4357818.5 | 1 | 5 | 737 | -0.052055 | 1715.391574 | -3243.738037 | POINT (-108.08794 39.16714) | -2.204712 |
2019-11-14 03:46:42.302418176 | 0.000000 | NaN | 51 | 40 | 51 | -6.827817e+10 | 3319153279706858891 | 737 | 1 | (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ... | ... | 0.000000 | 4357778.5 | 3 | 5 | 737 | -0.034187 | 1706.306431 | -46.261078 | POINT (-108.12472 39.16404) | -0.086914 |
2019-11-14 03:46:42.304318208 | 1.410645 | 0.724375 | 174 | 20 | 161 | -6.804797e+10 | 3319153278633117079 | 737 | 1 | (1.41064453125, 1.41064453125, 1.41064453125, ... | ... | 0.302310 | 4357658.0 | 5 | 5 | 737 | -0.082557 | 1783.404110 | 3146.425537 | POINT (-108.16136 39.16020) | -2.475322 |
2112 rows × 43 columns
In [ ]: