original_docstring: 
          General purpose function for performing line assignments using local catalog and line data. The two main ways
          of running this function is to either provide a linelist or filepath argument. The type of linelist will be
          checked to determine how the catalog data will be processed: if it's a string, it will be used to use
  
  
          Parameters
          ----------
          name: str, optional
              Name of the molecule being assigned. This should be specified when providing a new line list, which then
              gets added to the experiment.
          formula: str, optional
              Chemical formula for the molecule being assigned. Should be added in conjuction with name.
          filepath: str, optional
              If a linelist is not given, a filepath can be specified corresponding to a .cat or .lin file, which will
              be used to create a LineList object.
          linelist: str or LineList, optional
              Can be the name of a molecule or LineList object; the former is specified as a string which looks up the
              experiment line_list attribute for an existing LineList object. If a LineList object is provided, the
              function will use this directly.
          auto: bool, optional
              Specifies whether the assignment procedure works without intervention. If False, the user will be prompted
              to provide a candidate index.
          thres: float, optional
              log Intensity cut off used to screen candidates.
          progressbar: bool, optional
              If True, a tqdm progressbar will indicate assignment progress.
          tol: float, optional
              Tolerance for making assignments. If None, the function will default to the session-wide values of
              freq_abs and freq_prox to determine the tolerance.
          kwargs
              Kwargs are passed to the Transition object update when assignments are made.
          
docstring: General purpose function for performing line assignments using local catalog and line data. The two main ways
  of running this function is to either provide a linelist or filepath argument. The type of linelist will be
  checked to determine how the catalog data will be processed: if it's a string, it will be used to use
  
  Parameters
  
  str, optional
  Name of the molecule being assigned. This should be specified when providing a new line list, which then
  gets added to the experiment.
  formula: str, optional
  Chemical formula for the molecule being assigned. Should be added in conjuction with name.
  filepath: str, optional
  If a linelist is not given, a filepath can be specified corresponding to a .cat or .lin file, which will
  be used to create a LineList object.
  linelist: str or LineList, optional
  Can be the name of a molecule or LineList object; the former is specified as a string which looks up the
  experiment line_list attribute for an existing LineList object. If a LineList object is provided, the
  function will use this directly.
  auto: bool, optional
  Specifies whether the assignment procedure works without intervention. If False, the user will be prompted
  to provide a candidate index.
  thres: float, optional
  log Intensity cut off used to screen candidates.
  progressbar: bool, optional
  If True, a tqdm progressbar will indicate assignment progress.
  tol: float, optional
  Tolerance for making assignments. If None, the function will default to the session-wide values of
  freq_abs and freq_prox to determine the tolerance.
  kwargs
  Kwargs are passed to the Transition object update when assignments are made.
docstring_tokens: General purpose function for performing line assignments using local catalog and line data . The two main ways of running this function is to either provide a linelist or filepath argument . The type of linelist will be checked to determine how the catalog data will be processed : if it ' s a string it will be used to use Parameters str optional Name of the molecule being assigned . This should be specified when providing a new line list which then gets added to the experiment . formula : str optional Chemical formula for the molecule being assigned . Should be added in conjuction with name . filepath : str optional If a linelist is not given a filepath can be specified corresponding to a . cat or . lin file which will be used to create a LineList object . linelist : str or LineList optional Can be the name of a molecule or LineList object ; the former is specified as a string which looks up the experiment line_list attribute for an existing LineList object . If a LineList object is provided the function will use this directly . auto : bool optional Specifies whether the assignment procedure works without intervention . If False the user will be prompted to provide a candidate index . thres : float optional log Intensity cut off used to screen candidates . progressbar : bool optional If True a tqdm progressbar will indicate assignment progress . tol : float optional Tolerance for making assignments . If None the function will default to the session - wide values of freq_abs and freq_prox to determine the tolerance . kwargs Kwargs are passed to the Transition object update when assignments are made .
code: def process_linelist(
          self,
          name=None,
          formula=None,
          filepath=None,
          linelist=None,
          auto=True,
          thres=-10.0,
          progressbar=True,
          tol=None,
          **kwargs,
      ):
          """
          General purpose function for performing line assignments using local catalog and line data. The two main ways
          of running this function is to either provide a linelist or filepath argument. The type of linelist will be
          checked to determine how the catalog data will be processed: if it's a string, it will be used to use
  
  
          Parameters
          ----------
          name: str, optional
              Name of the molecule being assigned. This should be specified when providing a new line list, which then
              gets added to the experiment.
          formula: str, optional
              Chemical formula for the molecule being assigned. Should be added in conjuction with name.
          filepath: str, optional
              If a linelist is not given, a filepath can be specified corresponding to a .cat or .lin file, which will
              be used to create a LineList object.
          linelist: str or LineList, optional
              Can be the name of a molecule or LineList object; the former is specified as a string which looks up the
              experiment line_list attribute for an existing LineList object. If a LineList object is provided, the
              function will use this directly.
          auto: bool, optional
              Specifies whether the assignment procedure works without intervention. If False, the user will be prompted
              to provide a candidate index.
          thres: float, optional
              log Intensity cut off used to screen candidates.
          progressbar: bool, optional
              If True, a tqdm progressbar will indicate assignment progress.
          tol: float, optional
              Tolerance for making assignments. If None, the function will default to the session-wide values of
              freq_abs and freq_prox to determine the tolerance.
          kwargs
              Kwargs are passed to the Transition object update when assignments are made.
          """
          # First case is if linelist is provided as a string corresponding to the key in the line_lists attribute
          self.logger.info(f"Processing local catalog for molecule {name}.")
          if type(linelist) == str:
              linelist = self.line_lists[linelist]
          # In the event that linelist is an actual LineList object
          elif type(linelist) == LineList:
              if linelist.name not in self.line_lists:
                  self.line_lists[linelist.name] = linelist
          elif filepath:
              # If a catalog is specified, create a LineList object with this catalog. The parser is inferred from the
              # file extension.
              if ".cat" in filepath:
                  func = LineList.from_catalog
              elif ".lin" in filepath:
                  func = LineList.from_lin
              else:
                  raise Exception(
                      "File extension for reference line list not recognized!"
                  )
              linelist = func(
                  name=name,
                  formula=formula,
                  filepath=filepath,
                  min_freq=self.data[self.freq_col].min(),
                  max_freq=self.data[self.freq_col].max(),
              )
              if name not in self.line_lists:
                  self.line_lists[name] = linelist
          else:
              raise Exception("Please specify an internal or external line list!")
          if linelist is not None:
              nassigned = 0
              # Sort the LineList by intensity if possible. If the strongest line isn't
              # there, the other lines shouldn't be there
              if linelist.source in ["Splatalogue", "Catalog"]:
                  linelist.transitions = sorted(
                      linelist, key=lambda line: line.catalog_intensity
                  )[::-1]
              # Filter out out-of-band stuff, but with some small tolerance extending
              # out just in case it's close
              max_freq = max(self.line_lists["Peaks"].get_frequencies()) * 1.001
              min_freq = min(self.line_lists["Peaks"].get_frequencies()) * 0.999
              # Make sure we're only assigning with in-band, has a suitable uncertainty,
              # and that the lower state energy is within range
              transitions = [
                  transition
                  for transition in linelist.transitions
                  if all(
                      [
                          min_freq <= transition.catalog_frequency <= max_freq,
                          transition.uncertainty <= self.session.max_uncertainty,
                          transition.lstate_energy <= self.t_threshold,
                      ]
                  )
              ]
              # Loop over the LineList lines
              if progressbar is True:
                  iterator = tqdm(transitions)
                  iterator = enumerate(iterator)
              else:
                  iterator = enumerate(transitions)
              # Loop over all of the U-lines
              for index, transition in iterator:
                  # Control the flow so that we're not wasting time looking for lines if the strongest
                  # transitions are not seen
                  # if (index > 5) and (nassigned == 0) and (linelist.source in ["Catalog", "Splatalogue"]):
                  #    self.logger.info(
                  #    "Searched for five strongest transitions in {linelist.name}, and nothing; aborting."
                  #    )
                  #    break
                  # If no value of tolerance is provided, determine from the session
                  if tol is None:
                      if self.session.freq_abs is True:
                          tol = self.session.freq_prox
                      else:
                          tol = (1.0 - self.session.freq_prox) * transition.frequency
                  # Log the search
                  self.logger.info(
                      f"Searching for frequency {transition.catalog_frequency:,.4f}"
                      f" with tolerances: {self.t_threshold:.2f} K, "
                      f" +/-{tol:.4f} MHz, {thres} intensity."
                  )
                  # Find transitions in the peak list that might match
                  can_pkg = self.line_lists["Peaks"].find_candidates(
                      transition.catalog_frequency,
                      lstate_threshold=self.t_threshold,
                      freq_tol=tol,
                      int_tol=thres,
                  )
                  # If there are actual candidates instead of NoneType, we can process it.
                  if can_pkg is not None:
                      candidates, weighting = can_pkg
                      ncandidates = len(candidates)
                      self.logger.info(f"Found {ncandidates} possible matches.")
                      make_assignment = True
                      # If auto mode or if there's just one candidate, just take the highest weighting
                      if auto is True:
                          chosen = candidates[weighting.argmax()]
                          if chosen.uline is False:
                              # If this line has previously been assigned, then we
                              # fill up the multiple "buffer"
                              if not chosen.check_molecule(transition):
                                  if transition not in chosen.multiple:
                                      # Only add more transitions if this is a
                                      # different molecule and it's not already in
                                      # the list
                                      chosen.multiple.append(transition)
                              make_assignment = False
                      elif auto is False:
                          for cand_idx, candidate in enumerate(candidates):
                              print(cand_idx, candidate)
                          chosen_idx = int(
                              input("Please specify the candidate index.   ")
                          )
                          chosen = candidates[chosen_idx]
                      if make_assignment is True:
                          self.logger.info(
                              f"Assigning {transition.name}"
                              f" (catalog {transition.catalog_frequency:,.4f})"
                              f" to peak {index} at {chosen.frequency:,.4f}."
                          )
                          # Create a copy of the Transition data from the LineList
                          assign_dict = copy(transition.__dict__)
                          # Update with the measured frequency and intensity
                          assign_dict["frequency"] = chosen.frequency
                          assign_dict["intensity"] = chosen.intensity
                          assign_dict["experiment"] = chosen.experiment
                          assign_dict["velocity"] = self.session.velocity
                          assign_dict["peak_id"] = chosen.peak_id
                          assign_dict["uline"] = False
                          # Add any other additional kwargs
                          assign_dict.update(**kwargs)
                          # Copy over the information from the assignment, and update
                          # the experimental peak information with the assignment
                          chosen.__dict__.update(**assign_dict)
                          nassigned += 1
              self.logger.info(
                  f"Assigned {nassigned} new transitions to {linelist.name}."
              )
          else:
              self.logger.warning("LineList was empty, and no lines were assigned.")
code_tokens: def process_linelist ( self , name = None , formula = None , filepath = None , linelist = None , auto = True , thres = - 10.0 , progressbar = True , tol = None , ** kwargs , ) : self . logger . info ( f"Processing local catalog for molecule {name}." ) if type ( linelist ) == str : linelist = self . line_lists [ linelist ] elif type ( linelist ) == LineList : if linelist . name not in self . line_lists : self . line_lists [ linelist . name ] = linelist elif filepath : if ".cat" in filepath : func = LineList . from_catalog elif ".lin" in filepath : func = LineList . from_lin else : raise Exception ( "File extension for reference line list not recognized!" ) linelist = func ( name = name , formula = formula , filepath = filepath , min_freq = self . data [ self . freq_col ] . min ( ) , max_freq = self . data [ self . freq_col ] . max ( ) , ) if name not in self . line_lists : self . line_lists [ name ] = linelist else : raise Exception ( "Please specify an internal or external line list!" ) if linelist is not None : nassigned = 0 if linelist . source in [ "Splatalogue" , "Catalog" ] : linelist . transitions = sorted ( linelist , key = lambda line : line . catalog_intensity ) [ : : - 1 ] max_freq = max ( self . line_lists [ "Peaks" ] . get_frequencies ( ) ) * 1.001 min_freq = min ( self . line_lists [ "Peaks" ] . get_frequencies ( ) ) * 0.999 transitions = [ transition for transition in linelist . transitions if all ( [ min_freq <= transition . catalog_frequency <= max_freq , transition . uncertainty <= self . session . max_uncertainty , transition . lstate_energy <= self . t_threshold , ] ) ] if progressbar is True : iterator = tqdm ( transitions ) iterator = enumerate ( iterator ) else : iterator = enumerate ( transitions ) for index , transition in iterator : if tol is None : if self . session . freq_abs is True : tol = self . session . freq_prox else : tol = ( 1.0 - self . session . freq_prox ) * transition . frequency self . logger . info ( f"Searching for frequency {transition.catalog_frequency:,.4f}" f" with tolerances: {self.t_threshold:.2f} K, " f" +/-{tol:.4f} MHz, {thres} intensity." ) can_pkg = self . line_lists [ "Peaks" ] . find_candidates ( transition . catalog_frequency , lstate_threshold = self . t_threshold , freq_tol = tol , int_tol = thres , ) if can_pkg is not None : candidates , weighting = can_pkg ncandidates = len ( candidates ) self . logger . info ( f"Found {ncandidates} possible matches." ) make_assignment = True if auto is True : chosen = candidates [ weighting . argmax ( ) ] if chosen . uline is False : if not chosen . check_molecule ( transition ) : if transition not in chosen . multiple : chosen . multiple . append ( transition ) make_assignment = False elif auto is False : for cand_idx , candidate in enumerate ( candidates ) : print ( cand_idx , candidate ) chosen_idx = int ( input ( "Please specify the candidate index.   " ) ) chosen = candidates [ chosen_idx ] if make_assignment is True : self . logger . info ( f"Assigning {transition.name}" f" (catalog {transition.catalog_frequency:,.4f})" f" to peak {index} at {chosen.frequency:,.4f}." ) assign_dict = copy ( transition . __dict__ ) assign_dict [ "frequency" ] = chosen . frequency assign_dict [ "intensity" ] = chosen . intensity assign_dict [ "experiment" ] = chosen . experiment assign_dict [ "velocity" ] = self . session . velocity assign_dict [ "peak_id" ] = chosen . peak_id assign_dict [ "uline" ] = False assign_dict . update ( ** kwargs ) chosen . __dict__ . update ( ** assign_dict ) nassigned += 1 self . logger . info ( f"Assigned {nassigned} new transitions to {linelist.name}." ) else : self . logger . warning ( "LineList was empty, and no lines were assigned." )
short_docstring: General purpose function for performing line assignments using local catalog and line data.
short_docstring_tokens: General purpose function for performing line assignments using local catalog and line data .
comment: """
          General purpose function for performing line assignments using local catalog and line data. The two main ways
          of running this function is to either provide a linelist or filepath argument. The type of linelist will be
          checked to determine how the catalog data will be processed: if it's a string, it will be used to use
  
  
          Parameters
          ----------
          name: str, optional
              Name of the molecule being assigned. This should be specified when providing a new line list, which then
              gets added to the experiment.
          formula: str, optional
              Chemical formula for the molecule being assigned. Should be added in conjuction with name.
          filepath: str, optional
              If a linelist is not given, a filepath can be specified corresponding to a .cat or .lin file, which will
              be used to create a LineList object.
          linelist: str or LineList, optional
              Can be the name of a molecule or LineList object; the former is specified as a string which looks up the
              experiment line_list attribute for an existing LineList object. If a LineList object is provided, the
              function will use this directly.
          auto: bool, optional
              Specifies whether the assignment procedure works without intervention. If False, the user will be prompted
              to provide a candidate index.
          thres: float, optional
              log Intensity cut off used to screen candidates.
          progressbar: bool, optional
              If True, a tqdm progressbar will indicate assignment progress.
          tol: float, optional
              Tolerance for making assignments. If None, the function will default to the session-wide values of
              freq_abs and freq_prox to determine the tolerance.
          kwargs
              Kwargs are passed to the Transition object update when assignments are made.
          """$SEP$# First case is if linelist is provided as a string corresponding to the key in the line_lists attribute$SEP$# In the event that linelist is an actual LineList object$SEP$# If a catalog is specified, create a LineList object with this catalog. The parser is inferred from the$SEP$# file extension.$SEP$# Sort the LineList by intensity if possible. If the strongest line isn't$SEP$# there, the other lines shouldn't be there$SEP$# Filter out out-of-band stuff, but with some small tolerance extending$SEP$# out just in case it's close$SEP$# Make sure we're only assigning with in-band, has a suitable uncertainty,$SEP$# and that the lower state energy is within range$SEP$# Loop over the LineList lines$SEP$# Loop over all of the U-lines$SEP$# Control the flow so that we're not wasting time looking for lines if the strongest$SEP$# transitions are not seen$SEP$# if (index > 5) and (nassigned == 0) and (linelist.source in ["Catalog", "Splatalogue"]):$SEP$#    self.logger.info($SEP$#    "Searched for five strongest transitions in {linelist.name}, and nothing; aborting."$SEP$#    )$SEP$#    break$SEP$# If no value of tolerance is provided, determine from the session$SEP$# Log the search$SEP$# Find transitions in the peak list that might match$SEP$# If there are actual candidates instead of NoneType, we can process it.$SEP$# If auto mode or if there's just one candidate, just take the highest weighting$SEP$# If this line has previously been assigned, then we$SEP$# fill up the multiple "buffer"$SEP$# Only add more transitions if this is a$SEP$# different molecule and it's not already in$SEP$# the list$SEP$# Create a copy of the Transition data from the LineList$SEP$# Update with the measured frequency and intensity$SEP$# Add any other additional kwargs$SEP$# Copy over the information from the assignment, and update$SEP$# the experimental peak information with the assignment