code: def find_model_dat():
      
  
      # model.dat is in $HEADAS/../spectral
  
      headas_env = os.environ.get("HEADAS")
  
      assert headas_env is not None, ("You need to setup the HEADAS variable before importing this module."
                                      " See Heasoft documentation.")
  
      # Expand all variables and other things like ~
      headas_env = os.path.expandvars(os.path.expanduser(headas_env))
  
      # Lazy check that it exists
  
      assert os.path.exists(headas_env), "The HEADAS env. variable point to a non-existent directory: %s" % (headas_env)
  
      # Get one directory above HEADAS (i.e., $HEADAS/..)
  
      inferred_path = os.path.dirname(headas_env)
  
      # Now model.dat should be in $HEADAS/../spectral/manager
  
      final_path = os.path.join(inferred_path, 'spectral', 'manager', 'model.dat')
  
      # Check that model.dat exists
  
      assert os.path.exists(final_path), "Cannot find Xspec model definition file %s" % (final_path)
  
      return os.path.abspath(final_path)
docs: Find the file containing the definition of all the models in Xspec
      (model.dat) and return its path