def select_data(data_src, result_mng, variable_name=None, **kwargs):
    """Select variable from data source, copy it, reorder regions,
    drop components and transpose, if possible.

    :param data_src: Training set input data source.
    :param result_mng: Result manager.
    :param variable_name: Variable to select from data source.
      Default is `None`, in which case `result_mng.result_name`
      is used instead.
    :type data_src: :py:class:`..data_source.DataSourceBase`
    :type result_mng: :py:class:`..component.ResultManager`
    :type variable_name: str

    :returns: Input and output data arrays.
    :rtype: :py:class:`tuple` containing two
      :py:class:`xarray.DataArray`'s
    """
    component_mng = result_mng.component_mng
    variable_name = variable_name or result_mng.result_name
    da = data_src[variable_name].copy(deep=True)
    try:
        da = da.sel(region=component_mng.place_names)
    except ValueError:
        pass
    try:
        da = da.sel(component=component_mng.component_name, drop=True)
    except ValueError:
        pass
    try:
        da = da.drop('component')
    except ValueError:
        pass
    try:
        da = da.transpose('time', 'region')
    except ValueError:
        pass
    return da
