def fitting_argparser():
    ap = input_output_parser()
    sp = ap.add_argument_group('General Fitting Arguments.')
    sp.add_argument('--tol', type=float, default=1e-14, help='Stop gradient descent after cost function converges to within this value.')
    sp.add_argument('--optimizer', type=str, default='Adamax', help='First order optimizer to use for gradient descent.')
    sp.add_argument('--maxsteps', type=int, default=10000, help='Max number of steps to iterate during optimization.')
    sp.add_argument('--verbose', default=False, action='store_true', help='lots of text ouputs.')
    sp.add_argument('--use_min', default=False, action='store_true', help='Use params for mimimum cost function derived. Otherwise, use the params last visited by the descent. Avoids momentum overshoot.')
    sp.add_argument('--use_redundancy', default=False, action='store_true', help='Model redundant visibilities with the same set of foreground parameters.')
    sp.add_argument('--correct_model', default=True, action='store_true', help='Remove gain effects from foreground model.')
    sp.add_argument('--correct_resid', default=False, action='store_true', help='Apply fitted gains to the fitted residuals.')
    sp.add_argument('--graph_mode', default=False, action='store_true', help='Pre-compile computational graph before running gradient descent. Not reccomended for GPUs.')
    sp.add_argument('--init_guesses_from_previous_time_step', default=False, action='store_true', help='initialize gain and foreground guesses from previous time step when calibrating multiple times.')
    sp.add_argument('--learning_rate', type=float, default=0.01, help='gradient descent learning rate.')
    sp.add_argument('--red_tol', type=float, default=1.0, help='Tolerance for determining redundancy between baselines [meters].')
    sp.add_argument('--skip_threshold', type=float, default=0.5, help='Skip and flag time/polarization if more then this fractionf of data is flagged.')
    sp.add_argument('--model_regularization', type=str, default='post_hoc')
    sp.add_argument('--nsamples_in_weights', default=False, action='store_true', help='Weight contributions to MSE by nsamples.')
    sp.add_argument('--use_model_snr_weights', default=False, action='store_true', help='If True, weight contributions to MSE as proportional to SNR.')
    sp.add_argument('--use_autocorrs_in_weights', default=False, action='store_true', help='If True, use autocorrelations to derive relative SNR weights.')
    return ap
def fitting_argparser():
    ap = input_output_parser()
    sp = ap.add_argument_group('General Fitting Arguments.')
    sp.add_argument('--tol', type=float, default=1e-14, help='Stop gradient descent after cost function converges to within this value.')
    sp.add_argument('--optimizer', type=str, default='Adamax', help='First order optimizer to use for gradient descent.')
    sp.add_argument('--maxsteps', type=int, default=10000, help='Max number of steps to iterate during optimization.')
    sp.add_argument('--verbose', default=False, action='store_true', help='lots of text ouputs.')
    sp.add_argument('--use_min', default=False, action='store_true', help='Use params for mimimum cost function derived. Otherwise, use the params last visited by the descent. Avoids momentum overshoot.')
    sp.add_argument('--use_redundancy', default=False, action='store_true', help='Model redundant visibilities with the same set of foreground parameters.')
    sp.add_argument('--correct_model', default=True, action='store_true', help='Remove gain effects from foreground model.')
    sp.add_argument('--correct_resid', default=False, action='store_true', help='Apply fitted gains to the fitted residuals.')
    sp.add_argument('--graph_mode', default=False, action='store_true', help='Pre-compile computational graph before running gradient descent. Not reccomended for GPUs.')
    sp.add_argument('--init_guesses_from_previous_time_step', default=False, action='store_true', help='initialize gain and foreground guesses from previous time step when calibrating multiple times.')
    sp.add_argument('--learning_rate', type=float, default=0.01, help='gradient descent learning rate.')
    sp.add_argument('--red_tol', type=float, default=1.0, help='Tolerance for determining redundancy between baselines [meters].')
    sp.add_argument('--skip_threshold', type=float, default=0.5, help='Skip and flag time/polarization if more then this fractionf of data is flagged.')
    sp.add_argument('--model_regularization', type=str, default='post_hoc')
    sp.add_argument('--nsamples_in_weights', default=False, action='store_true', help='Weight contributions to MSE by nsamples.')
    sp.add_argument('--use_model_snr_weights', default=False, action='store_true', help='If True, weight contributions to MSE as proportional to SNR.')
    sp.add_argument('--use_autocorrs_in_weights', default=False, action='store_true', help='If True, use autocorrelations to derive relative SNR weights.')
    return ap