original_docstring: 
          Special implementation of the stacked_plot from the figurefactory module, adapted
          for AssignmentSession. In this version, the assigned/u-lines are also indicated.
  
          This function will generate a Plotly figure that stacks up the spectra as subplots,
          with increasing frequencies going up the plot. This function was written primarily
          to identify harmonically related lines, which in the absence of centrifugal distortion
          should line up perfectly in the center of the plot.
  
          Due to limitations with Plotly, there is a maximum of ~8 plots that can stacked
          and will return an Exception if > 8 frequencies are provided.
  
           frequencies: list of floats, corresponding to center frequencies
           freq_range: float percentage value of each center frequency to use as cutoffs
          :return: Plotly Figure object
          
docstring: Special implementation of the stacked_plot from the figurefactory module, adapted
  for AssignmentSession. In this version, the assigned/u-lines are also indicated.
  
  This function will generate a Plotly figure that stacks up the spectra as subplots,
  with increasing frequencies going up the plot. This function was written primarily
  to identify harmonically related lines, which in the absence of centrifugal distortion
  should line up perfectly in the center of the plot.
  
  Due to limitations with Plotly, there is a maximum of ~8 plots that can stacked
  and will return an Exception if > 8 frequencies are provided.
  
  list of floats, corresponding to center frequencies
  freq_range: float percentage value of each center frequency to use as cutoffs
docstring_tokens: Special implementation of the stacked_plot from the figurefactory module adapted for AssignmentSession . In this version the assigned / u - lines are also indicated . This function will generate a Plotly figure that stacks up the spectra as subplots with increasing frequencies going up the plot . This function was written primarily to identify harmonically related lines which in the absence of centrifugal distortion should line up perfectly in the center of the plot . Due to limitations with Plotly there is a maximum of ~8 plots that can stacked and will return an Exception if > 8 frequencies are provided . list of floats corresponding to center frequencies freq_range : float percentage value of each center frequency to use as cutoffs
code: def stacked_plot(self, frequencies: List[float], int_col=None, freq_range=0.05):
          """
          Special implementation of the stacked_plot from the figurefactory module, adapted
          for AssignmentSession. In this version, the assigned/u-lines are also indicated.
  
          This function will generate a Plotly figure that stacks up the spectra as subplots,
          with increasing frequencies going up the plot. This function was written primarily
          to identify harmonically related lines, which in the absence of centrifugal distortion
          should line up perfectly in the center of the plot.
  
          Due to limitations with Plotly, there is a maximum of ~8 plots that can stacked
          and will return an Exception if > 8 frequencies are provided.
  
           frequencies: list of floats, corresponding to center frequencies
           freq_range: float percentage value of each center frequency to use as cutoffs
          :return: Plotly Figure object
          """
          if int_col is None:
              int_col = self.int_col
          # Update the peaks table
          ulines = self.line_lists["Peaks"].get_ulines()
          self.peaks = pd.DataFrame(
              data=[[uline.frequency, uline.intensity] for uline in ulines],
              columns=["Frequency", "Intensity"],
          )
          dataframe = self.data.copy()
          # Want the frequencies in ascending order, going upwards in the plot
          indices = np.where(
              np.logical_and(
                  dataframe[self.freq_col].min() <= frequencies,
                  frequencies <= dataframe[self.freq_col].max(),
              )
          )
          # Plot only frequencies within band
          frequencies = np.asarray(frequencies)[indices]
          # Sort frequencies such that plots are descending in frequency
          frequencies = np.sort(frequencies)[::-1]
          delta = min(frequencies) * freq_range
          nplots = len(frequencies)
          if nplots > 5:
              raise Exception("Too many requested frequencies; I can't stack them all!")
          titles = tuple(f"{frequency:,.0f} MHz" for frequency in frequencies)
          fig = figurefactory.init_plotly_subplot(
              nrows=nplots,
              ncols=1,
              **{
                  "subplot_titles": titles,
                  "vertical_spacing": 0.15,
                  "shared_xaxes": True,
              },
          )
          for index, frequency in enumerate(frequencies):
              # Calculate the offset frequency
              dataframe["Offset " + str(index)] = dataframe[self.freq_col] - frequency
              # Range as a fraction of the center frequency
              freq_cutoff = freq_range * frequency
              max_freq = frequency + freq_cutoff
              min_freq = frequency - freq_cutoff
              sliced_df = dataframe.loc[
                  dataframe[f"Offset {index}"].between(-delta, delta)
              ]
              sliced_peaks = self.peaks.loc[
                  self.peaks["Frequency"].between(min_freq, max_freq)
              ]
              sliced_peaks["Offset Frequency"] = sliced_peaks["Frequency"] - frequency
              sliced_assignments = self.table.loc[
                  self.table["frequency"].between(min_freq, max_freq)
              ]
              sliced_assignments["offset_frequency"] = (
                  sliced_assignments["frequency"] - frequency
              )
              # Plot the data
              traces = list()
              # Spectrum plot
              traces.append(
                  go.Scattergl(
                      x=sliced_df["Offset " + str(index)],
                      y=sliced_df[self.int_col],
                      mode="lines",
                      opacity=0.6,
                      marker={"color": "rgb(5,113,176)"},
                  )
              )
              traces.append(
                  go.Bar(
                      x=sliced_assignments["offset_frequency"],
                      y=sliced_assignments["intensity"],
                      width=1.0,
                      hoverinfo="text",
                      text=sliced_assignments["name"]
                      + "-"
                      + sliced_assignments["r_qnos"].apply(str),
                      name="Assignments",
                      marker={"color": "rgb(253,174,97)"},
                  )
              )
              traces.append(
                  go.Bar(
                      x=sliced_peaks["Offset Frequency"],
                      y=sliced_peaks["Intensity"],
                      width=1.0,
                      name="U-lines",
                      marker={"color": "rgb(26,150,65)"},
                      hoverinfo="text",
                      text=sliced_peaks["Frequency"],
                  )
              )
              # Plotly indexes from one because they're stupid
              fig.add_traces(traces, [index + 1] * 3, [1] * 3)
              fig["layout"]["xaxis1"].update(
                  range=[-freq_cutoff, freq_cutoff],
                  title="Offset frequency (MHz)",
                  showgrid=True,
              )
              fig["layout"]["yaxis" + str(index + 1)].update(showgrid=False)
          fig["layout"].update(autosize=True, height=1000, width=900, showlegend=False)
          return fig
code_tokens: def stacked_plot ( self , frequencies : List [ float ] , int_col = None , freq_range = 0.05 ) : if int_col is None : int_col = self . int_col ulines = self . line_lists [ "Peaks" ] . get_ulines ( ) self . peaks = pd . DataFrame ( data = [ [ uline . frequency , uline . intensity ] for uline in ulines ] , columns = [ "Frequency" , "Intensity" ] , ) dataframe = self . data . copy ( ) indices = np . where ( np . logical_and ( dataframe [ self . freq_col ] . min ( ) <= frequencies , frequencies <= dataframe [ self . freq_col ] . max ( ) , ) ) frequencies = np . asarray ( frequencies ) [ indices ] frequencies = np . sort ( frequencies ) [ : : - 1 ] delta = min ( frequencies ) * freq_range nplots = len ( frequencies ) if nplots > 5 : raise Exception ( "Too many requested frequencies; I can't stack them all!" ) titles = tuple ( f"{frequency:,.0f} MHz" for frequency in frequencies ) fig = figurefactory . init_plotly_subplot ( nrows = nplots , ncols = 1 , ** { "subplot_titles" : titles , "vertical_spacing" : 0.15 , "shared_xaxes" : True , } , ) for index , frequency in enumerate ( frequencies ) : dataframe [ "Offset " + str ( index ) ] = dataframe [ self . freq_col ] - frequency freq_cutoff = freq_range * frequency max_freq = frequency + freq_cutoff min_freq = frequency - freq_cutoff sliced_df = dataframe . loc [ dataframe [ f"Offset {index}" ] . between ( - delta , delta ) ] sliced_peaks = self . peaks . loc [ self . peaks [ "Frequency" ] . between ( min_freq , max_freq ) ] sliced_peaks [ "Offset Frequency" ] = sliced_peaks [ "Frequency" ] - frequency sliced_assignments = self . table . loc [ self . table [ "frequency" ] . between ( min_freq , max_freq ) ] sliced_assignments [ "offset_frequency" ] = ( sliced_assignments [ "frequency" ] - frequency ) traces = list ( ) traces . append ( go . Scattergl ( x = sliced_df [ "Offset " + str ( index ) ] , y = sliced_df [ self . int_col ] , mode = "lines" , opacity = 0.6 , marker = { "color" : "rgb(5,113,176)" } , ) ) traces . append ( go . Bar ( x = sliced_assignments [ "offset_frequency" ] , y = sliced_assignments [ "intensity" ] , width = 1.0 , hoverinfo = "text" , text = sliced_assignments [ "name" ] + "-" + sliced_assignments [ "r_qnos" ] . apply ( str ) , name = "Assignments" , marker = { "color" : "rgb(253,174,97)" } , ) ) traces . append ( go . Bar ( x = sliced_peaks [ "Offset Frequency" ] , y = sliced_peaks [ "Intensity" ] , width = 1.0 , name = "U-lines" , marker = { "color" : "rgb(26,150,65)" } , hoverinfo = "text" , text = sliced_peaks [ "Frequency" ] , ) ) fig . add_traces ( traces , [ index + 1 ] * 3 , [ 1 ] * 3 ) fig [ "layout" ] [ "xaxis1" ] . update ( range = [ - freq_cutoff , freq_cutoff ] , title = "Offset frequency (MHz)" , showgrid = True , ) fig [ "layout" ] [ "yaxis" + str ( index + 1 ) ] . update ( showgrid = False ) fig [ "layout" ] . update ( autosize = True , height = 1000 , width = 900 , showlegend = False ) return fig
short_docstring: Special implementation of the stacked_plot from the figurefactory module, adapted
  for AssignmentSession.
short_docstring_tokens: Special implementation of the stacked_plot from the figurefactory module adapted for AssignmentSession .
comment: """
          Special implementation of the stacked_plot from the figurefactory module, adapted
          for AssignmentSession. In this version, the assigned/u-lines are also indicated.
  
          This function will generate a Plotly figure that stacks up the spectra as subplots,
          with increasing frequencies going up the plot. This function was written primarily
          to identify harmonically related lines, which in the absence of centrifugal distortion
          should line up perfectly in the center of the plot.
  
          Due to limitations with Plotly, there is a maximum of ~8 plots that can stacked
          and will return an Exception if > 8 frequencies are provided.
  
           frequencies: list of floats, corresponding to center frequencies
           freq_range: float percentage value of each center frequency to use as cutoffs
          :return: Plotly Figure object
          """$SEP$# Update the peaks table$SEP$# Want the frequencies in ascending order, going upwards in the plot$SEP$# Plot only frequencies within band$SEP$# Sort frequencies such that plots are descending in frequency$SEP$# Calculate the offset frequency$SEP$# Range as a fraction of the center frequency$SEP$# Plot the data$SEP$# Spectrum plot$SEP$# Plotly indexes from one because they're stupid