def calibrate_and_model_mixed(uvdata, horizon=1.0, min_dly=0.0, offset=0.0, ant_dly=0.0, include_autos=False, verbose=False, red_tol=1.0, red_tol_freq=0.5, n_angle_bins=200, notebook_progressbar=False, use_redundancy=False, use_tensorflow_to_derive_modeling_comps=False, eigenval_cutoff=1e-10, dtype_matinv=np.float64, require_exact_angle_match=True, angle_match_tol=0.001, grp_size_threshold=5, model_comps_dict=None, save_dict_to=None, **fitting_kwargs):
    "Simultaneously solve for gains and model foregrounds with a mix of DPSS vectors\n        for baselines with no frequency redundancy and simple_cov components for\n        groups of baselines that have some frequency redundancy.\n\n\n    Parameters\n    ----------\n    uvdata: UVData object.\n        dataset to calibrate and filter.\n    horizon: float, optional\n        fraction of baseline delay length to model with dpss modes\n        unitless.\n        default is 1.\n    min_dly: float, optional\n        minimum delay to model with dpss models.\n        in units of ns.\n        default is 0.\n    offset: float optional\n        offset off of horizon wedge to include in dpss delay range.\n        in units of ns.\n        default is 0.\n    ant_dly: float, optional\n        intrinsic chromaticity of each antenna element\n        in units of ns.\n        default is 0.\n    include_autos: bool, optional\n        if true, include autocorrelations in fitting.\n        default is False.\n    verbose: bool, optional\n        lots of text output\n        default is False.\n    red_tol: float, optional\n        tolerance for treating baselines as redundant (meters)\n        default is 1.0\n    red_tol_freq: float, optional\n        tolerance for treating two baselines as having some\n        frequency redundancy. When frequency redundancy exists, baselines\n        will be modeled jointly.\n    n_angle_bins: int, optional\n        number of angular bins to use between -pi and pi to compare baselines\n        default is 200\n    notebook_progressbar: bool, optional\n        if True, show graphical notebook progress bar that looks good in jupyter.\n        default is False.\n    use_redundancy: bool, optional\n        If True, model all baselines within each redundant group with the same components\n        If False, model each baseline within each redundant group with sepearate components.\n        default is False.\n    use_tensorflow_to_derive_modeling_comps: bool, optional\n        Use tensorflow methods to derive multi-baseline modeling components.\n        recommended if you have a GPU with enough memory to perform spectral decomposition\n        of multi-baseline covariance matrices.\n    eigenval_cutoff: float, optional\n        threshold of eigenvectors to include in modeling components.\n    dtype_matinv: numpy.dtype, optional\n        data type to use for deriving modeling components.\n        default is np.float64 (need higher precision for cov-mat like calculation)\n    grp_size_threshold: int, optional\n      groups with number of elements less then this value are split up into single baselines.\n      default is 5.\n    model_comps_dict: dict, optional\n        dictionary mapping fitting groups to numpy.ndarray see modeling.yield_mixed_comps\n        for more specifics.\n        default is None -> compute fitting groups automatically.\n    save_dict_to: str, optional\n        save model_comps_dict to hdf5 container if True\n        default is False.\n    fitting_kwargs: kwarg dict\n        additional kwargs for calibrate_and_model_tensor.\n        see docstring of calibrate_and_model_tensor.\n\n    Returns\n    -------\n    model: UVData object\n        uvdata object containing DPSS model of intrinsic foregrounds.\n    resid: UVData object\n        uvdata object containing residuals after subtracting model times gains and applying gains.\n    gains: UVCal object\n        uvcal object containing fitted gains.\n    fit_history:\n        dictionary containing fit history for each time-step and polarization in the data with fields:\n        'loss_history': list of values of the loss function in each minimization iteration.\n    "
    (fitting_grps, blvecs, _, _) = modeling.get_uv_overlapping_grps_conjugated(uvdata, red_tol=red_tol, include_autos=include_autos, red_tol_freq=red_tol_freq, n_angle_bins=n_angle_bins, notebook_progressbar=notebook_progressbar, require_exact_angle_match=require_exact_angle_match, angle_match_tol=angle_match_tol)
    if (model_comps_dict is None):
        model_comps_dict = modeling.yield_mixed_comps(fitting_grps, blvecs, uvdata.freq_array[0], eigenval_cutoff=eigenval_cutoff, use_tensorflow=use_tensorflow_to_derive_modeling_comps, ant_dly=ant_dly, horizon=horizon, offset=offset, min_dly=min_dly, verbose=verbose, dtype=dtype_matinv, notebook_progressbar=notebook_progressbar, grp_size_threshold=grp_size_threshold)
    if (save_dict_to is not None):
        np.save(save_dict_to, model_comps_dict)
    (model, resid, gains, fitted_info) = calibrate_and_model_tensor(uvdata=uvdata, fg_model_comps_dict=model_comps_dict, include_autos=include_autos, verbose=verbose, notebook_progressbar=notebook_progressbar, use_redundancy=use_redundancy, **fitting_kwargs)
    return (model, resid, gains, fitted_info)
Simultaneously solve for gains and model foregrounds with a mix of DPSS vectors
    for baselines with no frequency redundancy and simple_cov components for
    groups of baselines that have some frequency redundancy.


Parameters
----------
uvdata: UVData object.
    dataset to calibrate and filter.
horizon: float, optional
    fraction of baseline delay length to model with dpss modes
    unitless.
    default is 1.
min_dly: float, optional
    minimum delay to model with dpss models.
    in units of ns.
    default is 0.
offset: float optional
    offset off of horizon wedge to include in dpss delay range.
    in units of ns.
    default is 0.
ant_dly: float, optional
    intrinsic chromaticity of each antenna element
    in units of ns.
    default is 0.
include_autos: bool, optional
    if true, include autocorrelations in fitting.
    default is False.
verbose: bool, optional
    lots of text output
    default is False.
red_tol: float, optional
    tolerance for treating baselines as redundant (meters)
    default is 1.0
red_tol_freq: float, optional
    tolerance for treating two baselines as having some
    frequency redundancy. When frequency redundancy exists, baselines
    will be modeled jointly.
n_angle_bins: int, optional
    number of angular bins to use between -pi and pi to compare baselines
    default is 200
notebook_progressbar: bool, optional
    if True, show graphical notebook progress bar that looks good in jupyter.
    default is False.
use_redundancy: bool, optional
    If True, model all baselines within each redundant group with the same components
    If False, model each baseline within each redundant group with sepearate components.
    default is False.
use_tensorflow_to_derive_modeling_comps: bool, optional
    Use tensorflow methods to derive multi-baseline modeling components.
    recommended if you have a GPU with enough memory to perform spectral decomposition
    of multi-baseline covariance matrices.
eigenval_cutoff: float, optional
    threshold of eigenvectors to include in modeling components.
dtype_matinv: numpy.dtype, optional
    data type to use for deriving modeling components.
    default is np.float64 (need higher precision for cov-mat like calculation)
grp_size_threshold: int, optional
  groups with number of elements less then this value are split up into single baselines.
  default is 5.
model_comps_dict: dict, optional
    dictionary mapping fitting groups to numpy.ndarray see modeling.yield_mixed_comps
    for more specifics.
    default is None -> compute fitting groups automatically.
save_dict_to: str, optional
    save model_comps_dict to hdf5 container if True
    default is False.
fitting_kwargs: kwarg dict
    additional kwargs for calibrate_and_model_tensor.
    see docstring of calibrate_and_model_tensor.

Returns
-------
model: UVData object
    uvdata object containing DPSS model of intrinsic foregrounds.
resid: UVData object
    uvdata object containing residuals after subtracting model times gains and applying gains.
gains: UVCal object
    uvcal object containing fitted gains.
fit_history:
    dictionary containing fit history for each time-step and polarization in the data with fields:
    'loss_history': list of values of the loss function in each minimization iteration.
def calibrate_and_model_mixed(uvdata, horizon=1.0, min_dly=0.0, offset=0.0, ant_dly=0.0, include_autos=False, verbose=False, red_tol=1.0, red_tol_freq=0.5, n_angle_bins=200, notebook_progressbar=False, use_redundancy=False, use_tensorflow_to_derive_modeling_comps=False, eigenval_cutoff=1e-10, dtype_matinv=np.float64, require_exact_angle_match=True, angle_match_tol=0.001, grp_size_threshold=5, model_comps_dict=None, save_dict_to=None, **fitting_kwargs):
    "Simultaneously solve for gains and model foregrounds with a mix of DPSS vectors\n        for baselines with no frequency redundancy and simple_cov components for\n        groups of baselines that have some frequency redundancy.\n\n\n    Parameters\n    ----------\n    uvdata: UVData object.\n        dataset to calibrate and filter.\n    horizon: float, optional\n        fraction of baseline delay length to model with dpss modes\n        unitless.\n        default is 1.\n    min_dly: float, optional\n        minimum delay to model with dpss models.\n        in units of ns.\n        default is 0.\n    offset: float optional\n        offset off of horizon wedge to include in dpss delay range.\n        in units of ns.\n        default is 0.\n    ant_dly: float, optional\n        intrinsic chromaticity of each antenna element\n        in units of ns.\n        default is 0.\n    include_autos: bool, optional\n        if true, include autocorrelations in fitting.\n        default is False.\n    verbose: bool, optional\n        lots of text output\n        default is False.\n    red_tol: float, optional\n        tolerance for treating baselines as redundant (meters)\n        default is 1.0\n    red_tol_freq: float, optional\n        tolerance for treating two baselines as having some\n        frequency redundancy. When frequency redundancy exists, baselines\n        will be modeled jointly.\n    n_angle_bins: int, optional\n        number of angular bins to use between -pi and pi to compare baselines\n        default is 200\n    notebook_progressbar: bool, optional\n        if True, show graphical notebook progress bar that looks good in jupyter.\n        default is False.\n    use_redundancy: bool, optional\n        If True, model all baselines within each redundant group with the same components\n        If False, model each baseline within each redundant group with sepearate components.\n        default is False.\n    use_tensorflow_to_derive_modeling_comps: bool, optional\n        Use tensorflow methods to derive multi-baseline modeling components.\n        recommended if you have a GPU with enough memory to perform spectral decomposition\n        of multi-baseline covariance matrices.\n    eigenval_cutoff: float, optional\n        threshold of eigenvectors to include in modeling components.\n    dtype_matinv: numpy.dtype, optional\n        data type to use for deriving modeling components.\n        default is np.float64 (need higher precision for cov-mat like calculation)\n    grp_size_threshold: int, optional\n      groups with number of elements less then this value are split up into single baselines.\n      default is 5.\n    model_comps_dict: dict, optional\n        dictionary mapping fitting groups to numpy.ndarray see modeling.yield_mixed_comps\n        for more specifics.\n        default is None -> compute fitting groups automatically.\n    save_dict_to: str, optional\n        save model_comps_dict to hdf5 container if True\n        default is False.\n    fitting_kwargs: kwarg dict\n        additional kwargs for calibrate_and_model_tensor.\n        see docstring of calibrate_and_model_tensor.\n\n    Returns\n    -------\n    model: UVData object\n        uvdata object containing DPSS model of intrinsic foregrounds.\n    resid: UVData object\n        uvdata object containing residuals after subtracting model times gains and applying gains.\n    gains: UVCal object\n        uvcal object containing fitted gains.\n    fit_history:\n        dictionary containing fit history for each time-step and polarization in the data with fields:\n        'loss_history': list of values of the loss function in each minimization iteration.\n    "
    (fitting_grps, blvecs, _, _) = modeling.get_uv_overlapping_grps_conjugated(uvdata, red_tol=red_tol, include_autos=include_autos, red_tol_freq=red_tol_freq, n_angle_bins=n_angle_bins, notebook_progressbar=notebook_progressbar, require_exact_angle_match=require_exact_angle_match, angle_match_tol=angle_match_tol)
    if (model_comps_dict is None):
        model_comps_dict = modeling.yield_mixed_comps(fitting_grps, blvecs, uvdata.freq_array[0], eigenval_cutoff=eigenval_cutoff, use_tensorflow=use_tensorflow_to_derive_modeling_comps, ant_dly=ant_dly, horizon=horizon, offset=offset, min_dly=min_dly, verbose=verbose, dtype=dtype_matinv, notebook_progressbar=notebook_progressbar, grp_size_threshold=grp_size_threshold)
    if (save_dict_to is not None):
        np.save(save_dict_to, model_comps_dict)
    (model, resid, gains, fitted_info) = calibrate_and_model_tensor(uvdata=uvdata, fg_model_comps_dict=model_comps_dict, include_autos=include_autos, verbose=verbose, notebook_progressbar=notebook_progressbar, use_redundancy=use_redundancy, **fitting_kwargs)
    return (model, resid, gains, fitted_info)