code: def generate_model(self, model_name=None, outfile=None):
          
  
          if model_name is not None:
              model_name = os.path.splitext(model_name)[0]
  
          if model_name is None or model_name == '':
              srcmdl = self.files['srcmdl']
          else:
              srcmdl = self.get_model_path(model_name)
  
          if not os.path.isfile(srcmdl):
              raise Exception("Model file does not exist: %s", srcmdl)
  
          if model_name is None:
              suffix = self.config['file_suffix']
          else:
              suffix = '_%s%s' % (model_name, self.config['file_suffix'])
  
          outfile = os.path.join(self.config['fileio']['workdir'],
                                 'mcube%s.fits' % (suffix))
  
          # May consider generating a custom source model file
          if not os.path.isfile(outfile):
  
              kw = dict(srcmaps=self.files['srcmap'],
                        srcmdl=srcmdl,
                        bexpmap=self.files['bexpmap'],
                        outfile=outfile,
                        expcube=self.files['ltcube'],
                        irfs=self.config['gtlike']['irfs'],
                        evtype=self.config['selection']['evtype'],
                        edisp=bool(self.config['gtlike']['edisp']),
                        outtype='ccube',
                        chatter=self.config['logging']['chatter'])
  
              run_gtapp('gtmodel', self.logger, kw)
          else:
              self.logger.info('Skipping gtmodel')
docs: Generate a counts model map from an XML model file using
          gtmodel.
  
          Parameters
          ----------
          model_name : str
              Name of the model.  If no name is given it will use the
              baseline model.
  
          outfile : str
              Override the name of the output model file.