Пример #1
0
def main():
    options,args = parser.parse_args(sys.argv[1:])

    if len(args) < 3:
        parser.print_help()
        sys.exit(45)


    new_run_name=args[0]
    runs2average = args[1:]

    print 'new run name:',new_run_name
    print 'runs2average:',runs2average

    for i,run in enumerate(runs2average):
        fname=shapesim.get_averaged_url(run, 0)
        print fname
        data0=eu.io.read(fname)

        if i==0:
            data=data0
        else:
            do_sums(data, data0)

    do_avg(data)

    fout=shapesim.get_averaged_url(new_run_name, 0)
    eu.ostools.makedirs_fromfile(fout)
    print 'writing run average:',fout
    eu.io.write(fout, data, clobber=True)
Пример #2
0
def plot_run(plt, run, shear_true, symbol, color, linestyle, options,
             with_points=True, with_curve=True, method='BA13', with_lensfit=False):

    c = shapesim.read_config(run)
    label = c.get('label',c['run'])


    url=shapesim.get_averaged_url(run, 0)
    print url
    data=eu.io.read(url)

    s_name,scov_name=get_names(method)
    if s_name=='g_sum':
        shear=data['g_sum'][:,0]/data['nsum']
    else:
        shear=data[s_name][:,0]

    err=sqrt(data[scov_name][:,0,0])
    s2n_vals = data[options.s2n_field]

    if options.xrange is None:
        xrng=[0.75*s2n_vals[0], 1.25*s2n_vals[-1]]
    else:
        xrng=options.xrange.split(',')
        xrng=[float(xr) for xr in xrng]


    pts = biggles.Points(s2n_vals, 
                         shear/shear_true-1,
                         type=symbol,
                         size=2,
                         color=color)
    ep = biggles.SymmetricErrorBarsY(s2n_vals,
                                     shear/shear_true-1,
                                     err/shear_true,
                                     width=2,
                                     color=color)
    crv = biggles.Curve(s2n_vals, 
                        shear/shear_true-1,
                        type=linestyle,
                        width=2,
                        color=color)

    crv.label=label
    pts.label=label
    if with_points:
        plt.add(pts,ep)

    if with_curve and not with_lensfit:
        plt.add(crv)

    if with_lensfit and method != 'lensfit':
        crv_lensfit = biggles.Curve(s2n_vals, 
                                    data['shear_lensfit'][:,0]/shear_true-1,
                                    type=linestyle,
                                    width=2,
                                    color=color)
        plt.add(crv_lensfit)


    return xrng, crv, pts