code: def define_layer(self, layer_path):
          
          scenario_dir = self.source_directory.text()
          joined_path = os.path.join(scenario_dir, layer_path)
          full_path = os.path.normpath(joined_path)
          file_name = os.path.split(layer_path)[-1]
  
          # get extension and basename to create layer
          base_name, extension = os.path.splitext(file_name)
  
          # load layer in scenario
          layer = QgsRasterLayer(full_path, base_name)
          if layer.isValid():
              return layer
          else:
              layer = QgsVectorLayer(full_path, base_name, 'ogr')
              if layer.isValid():
                  return layer
              # if layer is not vector nor raster
              else:
                  LOGGER.warning('Input in scenario is not recognized/supported')
                  return
docs: Create QGIS layer (either vector or raster) from file path input.
  
          :param layer_path: Full path to layer file.
          :type layer_path: str
  
          :return: QGIS layer.
          :rtype: QgsMapLayer