diff --git a/clients/python/sliderule/ipysliderule.py b/clients/python/sliderule/ipysliderule.py index 184a2b16..db635a11 100644 --- a/clients/python/sliderule/ipysliderule.py +++ b/clients/python/sliderule/ipysliderule.py @@ -2508,14 +2508,12 @@ def plot(self, **kwargs): kwargs.setdefault('cycle', 0) kwargs.setdefault('RGT', 0) kwargs.setdefault('GT', 0) - kwargs.setdefault('LR', 0) - kwargs.setdefault('PT', 0) # variable to plot column = kwargs['column_name'] RGT = int(kwargs['RGT']) GT = int(kwargs['GT']) # skip plot creation if no values are entered - if (RGT == 0): + if (RGT == 0) or (GT == 0): return # create figure axis if kwargs['ax'] is None: @@ -2557,22 +2555,19 @@ def plot(self, **kwargs): ax.set_xlabel('Along-Track Distance [m]') ax.set_ylabel(f'SlideRule {column}') elif (kwargs['kind'] == 'scatter'): - # extract pair track parameters - LR = int(kwargs['LR']) - PT = int(kwargs['PT']) # extract orbital cycle parameters cycle = int(kwargs['cycle']) if (kwargs['atl03'] == 'dataframe'): # reduce entered data frame to RGT, ground track and cycle atl03 = self._gdf[(self._gdf['rgt'] == RGT) & - (self._gdf['track'] == PT) & - (self._gdf['pair'] == LR) & + (self._gdf['track'] == self.PT(GT)) & + (self._gdf['pair'] == self.LR(GT)) & (self._gdf['cycle'] == cycle)] elif (kwargs['atl03'] is not None): # reduce ATL03 data frame to RGT, ground track and cycle atl03 = kwargs['atl03'][(kwargs['atl03']['rgt'] == RGT) & - (kwargs['atl03']['track'] == PT) & - (kwargs['atl03']['pair'] == LR) & + (kwargs['atl03']['track'] == self.PT(GT)) & + (kwargs['atl03']['pair'] == self.LR(GT)) & (kwargs['atl03']['cycle'] == cycle)] if (kwargs['classification'] == 'atl08'): # noise, ground, canopy, top of canopy, unclassified @@ -2639,3 +2634,26 @@ def plot(self, **kwargs): if kwargs['ax'] is None: # show the figure plt.tight_layout() + + def ground_track(self, GT): + """extract the ground track name for a given Ground Track (GT) index + """ + ground_track_list = ['gt1l', 'gt1r', 'gt2l', 'gt2r', 'gt3l', 'gt3r'] + return ground_track_list[GT//10 - 1] + + def PT(self, GT): + """extract Pair Track (PT) index for a given Ground Track (GT) index + """ + # mapping between ground tracks and sliderule tracks + ground_track = self.ground_track(GT) + pair_track_dict = dict(gt1l=1,gt1r=1,gt2l=2,gt2r=2,gt3l=3,gt3r=3) + return pair_track_dict[ground_track] + + def LR(self, GT): + """extract Left-Right (LR) index for a given Ground Track (GT) index + """ + # mapping between ground tracks and sliderule tracks + ground_track = self.ground_track(GT) + lr_track_dict = dict(gt1l=0,gt1r=1,gt2l=0,gt2r=1,gt3l=0,gt3r=1) + return lr_track_dict[ground_track] +