#!/usr/bin/env python
from __future__ import print_function
import sys
import os
from pprint import pprint
import numpy
from numpy import sqrt, array, diag, ones, zeros
from numpy import where, newaxis, exp, log
from numpy import newaxis
import yaml
import biggles

import fitsio

import ngmix
import nsim

import argparse
import esutil as eu
from esutil.numpy_util import between

import reredux

fclass=argparse.ArgumentDefaultsHelpFormatter
parser=argparse.ArgumentParser(formatter_class=fclass)

parser.add_argument('runs', nargs='+',help='runs to use in fit')

parser.add_argument('--chunksize',type=int,default=1000000,
                    help='size of chunks when reading')

parser.add_argument('--select',default=None,
                    help='string for selection, refer to data[field] etc.')
parser.add_argument('--select-from',default=None,
                    help='read the selection from the given yaml file')

parser.add_argument('-d',default=None,help='file is in a local dir')

parser.add_argument('--ntest',default=None,type=int,
                    help='work on a small subset for quick tests')

#parser.add_argument('--weights',default=None,help='type of weight to use, noise or s2n')
parser.add_argument(
    '--weighted',
    action='store_true',
)
parser.add_argument('--s2n-soft',type=float,default=10.0)
parser.add_argument('--shapenoise',type=float,default=0.20)

parser.add_argument('--show',action='store_true',help='show plot')
parser.add_argument('--yrange', help="yrange of plot")
parser.add_argument('--xrange', help="xrange of plot")

parser.add_argument('--fit-only',action='store_true',
                    help='get the means from the written file')


def main():
    args = parser.parse_args()

    conf=reredux.files.read_config(args.runs[0])
    if 'metacal-deconv' in conf['fitter_type']:
        summer=reredux.averaging.SummerDeconv(args)
    else:
        summer=reredux.averaging.SummerReredux(args)
    summer.go()

    summer.plot_fits()
    summer.plot_resid_hist()

    return

main()
'''
import numpy
from argparse import ArgumentParser
import reredux
import fitsio
import esutil as eu

parser = ArgumentParser()

parser.add_argument('run', help='run to use in fit')

parser.add_argument('--select', help="select to apply")
parser.add_argument('--select-cosmos', action='store_true',
                    help="select good cosmos galaxies")

parser.add_argument('--cols', default=None, help="extra cols to read")

parser.add_argument('--weights',help='weights to use')

parser.add_argument('--show',action='store_true',help='show plot')
parser.add_argument('--yrange', help="yrange of plot")
parser.add_argument('--xrange', help="xrange of plot")

parser.add_argument('--fit-only',action='store_true',
                    help='get the means from the written file')

parser.add_argument('--cache',action='store_true',
                    help=('cache the file subset locally; use the cache '
                          'if available'))

parser.add_argument('--ntest',default=None,type=int,
                    help='size of test')


def main():
    args = parser.parse_args()
    cls = reredux.averaging.AveragerRmean
    av=cls(
        args.run,
        weights=args.weights,
        show=args.show,
    )

    if not args.fit_only:
        data = av.read_data(
            cache=args.cache,
            ntest=args.ntest,
            select_cosmos=args.select_cosmos,
            select=args.select,
            extra_cols=args.cols,
        )
        av.do_averages(data)

    av.do_fits()
    av.doplot(args)

main()
'''

b430d64c5362b5b2adfd85e374e55cc3881a2e2f
<mask token>


def main():
    args = parser.parse_args()
    conf = reredux.files.read_config(args.runs[0])
    if 'metacal-deconv' in conf['fitter_type']:
        summer = reredux.averaging.SummerDeconv(args)
    else:
        summer = reredux.averaging.SummerReredux(args)
    summer.go()
    summer.plot_fits()
    summer.plot_resid_hist()
    return


<mask token>

<mask token>
parser.add_argument('runs', nargs='+', help='runs to use in fit')
parser.add_argument('--chunksize', type=int, default=1000000, help=
    'size of chunks when reading')
parser.add_argument('--select', default=None, help=
    'string for selection, refer to data[field] etc.')
parser.add_argument('--select-from', default=None, help=
    'read the selection from the given yaml file')
parser.add_argument('-d', default=None, help='file is in a local dir')
parser.add_argument('--ntest', default=None, type=int, help=
    'work on a small subset for quick tests')
parser.add_argument('--weighted', action='store_true')
parser.add_argument('--s2n-soft', type=float, default=10.0)
parser.add_argument('--shapenoise', type=float, default=0.2)
parser.add_argument('--show', action='store_true', help='show plot')
parser.add_argument('--yrange', help='yrange of plot')
parser.add_argument('--xrange', help='xrange of plot')
parser.add_argument('--fit-only', action='store_true', help=
    'get the means from the written file')


def main():
    args = parser.parse_args()
    conf = reredux.files.read_config(args.runs[0])
    if 'metacal-deconv' in conf['fitter_type']:
        summer = reredux.averaging.SummerDeconv(args)
    else:
        summer = reredux.averaging.SummerReredux(args)
    summer.go()
    summer.plot_fits()
    summer.plot_resid_hist()
    return


main()
<mask token>

<mask token>
fclass = argparse.ArgumentDefaultsHelpFormatter
parser = argparse.ArgumentParser(formatter_class=fclass)
parser.add_argument('runs', nargs='+', help='runs to use in fit')
parser.add_argument('--chunksize', type=int, default=1000000, help=
    'size of chunks when reading')
parser.add_argument('--select', default=None, help=
    'string for selection, refer to data[field] etc.')
parser.add_argument('--select-from', default=None, help=
    'read the selection from the given yaml file')
parser.add_argument('-d', default=None, help='file is in a local dir')
parser.add_argument('--ntest', default=None, type=int, help=
    'work on a small subset for quick tests')
parser.add_argument('--weighted', action='store_true')
parser.add_argument('--s2n-soft', type=float, default=10.0)
parser.add_argument('--shapenoise', type=float, default=0.2)
parser.add_argument('--show', action='store_true', help='show plot')
parser.add_argument('--yrange', help='yrange of plot')
parser.add_argument('--xrange', help='xrange of plot')
parser.add_argument('--fit-only', action='store_true', help=
    'get the means from the written file')


def main():
    args = parser.parse_args()
    conf = reredux.files.read_config(args.runs[0])
    if 'metacal-deconv' in conf['fitter_type']:
        summer = reredux.averaging.SummerDeconv(args)
    else:
        summer = reredux.averaging.SummerReredux(args)
    summer.go()
    summer.plot_fits()
    summer.plot_resid_hist()
    return


main()
<mask token>

from __future__ import print_function
import sys
import os
from pprint import pprint
import numpy
from numpy import sqrt, array, diag, ones, zeros
from numpy import where, newaxis, exp, log
from numpy import newaxis
import yaml
import biggles
import fitsio
import ngmix
import nsim
import argparse
import esutil as eu
from esutil.numpy_util import between
import reredux
fclass = argparse.ArgumentDefaultsHelpFormatter
parser = argparse.ArgumentParser(formatter_class=fclass)
parser.add_argument('runs', nargs='+', help='runs to use in fit')
parser.add_argument('--chunksize', type=int, default=1000000, help=
    'size of chunks when reading')
parser.add_argument('--select', default=None, help=
    'string for selection, refer to data[field] etc.')
parser.add_argument('--select-from', default=None, help=
    'read the selection from the given yaml file')
parser.add_argument('-d', default=None, help='file is in a local dir')
parser.add_argument('--ntest', default=None, type=int, help=
    'work on a small subset for quick tests')
parser.add_argument('--weighted', action='store_true')
parser.add_argument('--s2n-soft', type=float, default=10.0)
parser.add_argument('--shapenoise', type=float, default=0.2)
parser.add_argument('--show', action='store_true', help='show plot')
parser.add_argument('--yrange', help='yrange of plot')
parser.add_argument('--xrange', help='xrange of plot')
parser.add_argument('--fit-only', action='store_true', help=
    'get the means from the written file')


def main():
    args = parser.parse_args()
    conf = reredux.files.read_config(args.runs[0])
    if 'metacal-deconv' in conf['fitter_type']:
        summer = reredux.averaging.SummerDeconv(args)
    else:
        summer = reredux.averaging.SummerReredux(args)
    summer.go()
    summer.plot_fits()
    summer.plot_resid_hist()
    return


main()
<mask token>

#!/usr/bin/env python
from __future__ import print_function
import sys
import os
from pprint import pprint
import numpy
from numpy import sqrt, array, diag, ones, zeros
from numpy import where, newaxis, exp, log
from numpy import newaxis
import yaml
import biggles

import fitsio

import ngmix
import nsim

import argparse
import esutil as eu
from esutil.numpy_util import between

import reredux

fclass=argparse.ArgumentDefaultsHelpFormatter
parser=argparse.ArgumentParser(formatter_class=fclass)

parser.add_argument('runs', nargs='+',help='runs to use in fit')

parser.add_argument('--chunksize',type=int,default=1000000,
                    help='size of chunks when reading')

parser.add_argument('--select',default=None,
                    help='string for selection, refer to data[field] etc.')
parser.add_argument('--select-from',default=None,
                    help='read the selection from the given yaml file')

parser.add_argument('-d',default=None,help='file is in a local dir')

parser.add_argument('--ntest',default=None,type=int,
                    help='work on a small subset for quick tests')

#parser.add_argument('--weights',default=None,help='type of weight to use, noise or s2n')
parser.add_argument(
    '--weighted',
    action='store_true',
)
parser.add_argument('--s2n-soft',type=float,default=10.0)
parser.add_argument('--shapenoise',type=float,default=0.20)

parser.add_argument('--show',action='store_true',help='show plot')
parser.add_argument('--yrange', help="yrange of plot")
parser.add_argument('--xrange', help="xrange of plot")

parser.add_argument('--fit-only',action='store_true',
                    help='get the means from the written file')


def main():
    args = parser.parse_args()

    conf=reredux.files.read_config(args.runs[0])
    if 'metacal-deconv' in conf['fitter_type']:
        summer=reredux.averaging.SummerDeconv(args)
    else:
        summer=reredux.averaging.SummerReredux(args)
    summer.go()

    summer.plot_fits()
    summer.plot_resid_hist()

    return

main()
'''
import numpy
from argparse import ArgumentParser
import reredux
import fitsio
import esutil as eu

parser = ArgumentParser()

parser.add_argument('run', help='run to use in fit')

parser.add_argument('--select', help="select to apply")
parser.add_argument('--select-cosmos', action='store_true',
                    help="select good cosmos galaxies")

parser.add_argument('--cols', default=None, help="extra cols to read")

parser.add_argument('--weights',help='weights to use')

parser.add_argument('--show',action='store_true',help='show plot')
parser.add_argument('--yrange', help="yrange of plot")
parser.add_argument('--xrange', help="xrange of plot")

parser.add_argument('--fit-only',action='store_true',
                    help='get the means from the written file')

parser.add_argument('--cache',action='store_true',
                    help=('cache the file subset locally; use the cache '
                          'if available'))

parser.add_argument('--ntest',default=None,type=int,
                    help='size of test')


def main():
    args = parser.parse_args()
    cls = reredux.averaging.AveragerRmean
    av=cls(
        args.run,
        weights=args.weights,
        show=args.show,
    )

    if not args.fit_only:
        data = av.read_data(
            cache=args.cache,
            ntest=args.ntest,
            select_cosmos=args.select_cosmos,
            select=args.select,
            extra_cols=args.cols,
        )
        av.do_averages(data)

    av.do_fits()
    av.doplot(args)

main()
'''
