예제 #1
0
파일: make-c-wq.py 프로젝트: esheldon/espy
def main():
    options,args = parser.parse_args(sys.argv[1:])

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

    run=args[0]

    c = shapesim.read_config(run)

    run         = c['run']
    sim_config  = c['sim_config']
    mcmc_config = c['mcmc_config']
    s2n_vals    = c['s2n_vals']

    ns2n = len(s2n_vals)

    d = shapesim.get_wq_dir(run, bytrial=True, fs='local')
    if not os.path.exists(d):
        os.makedirs(d)
    d = shapesim.get_output_dir(run, sub='bytrial')
    if not os.path.exists(d):
        os.makedirs(d)


    groups=''
    if options.groups is not None:
        groups = 'group: [%s]' % options.groups

    smax=numpy.iinfo('i8').max
    for is2n in xrange(ns2n):

        s2n = s2n_vals[is2n]

        npair, nsplit = get_npair_nsplit(c, is2n)

        for isplit in xrange(nsplit):
            job_name='%s-%03i-%03i' % (run,is2n,isplit)

            # note the wq logs are local
            wqurl = shapesim.get_wq_url(run,0,is2n,itrial=isplit,fs='local')
            output = shapesim.get_output_url(run, 0, is2n, itrial=isplit)

            seed = numpy.random.randint(smax)

            wlog("writing wq script:",wqurl)
            with open(wqurl,'w') as fobj:
                d={'job_name':job_name,
                   'version':options.version,
                   'groups':groups,
                   'pri':options.priority,
                   'sim_config':sim_config,
                   'mcmc_config':mcmc_config,
                   's2n':s2n,
                   'npair':npair,
                   'seed':seed,
                   'output':output}
                wqscript=_wqtemplate % d
                fobj.write(wqscript)
예제 #2
0
def main():
    options,args = parser.parse_args(sys.argv[1:])

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

    run=args[0]

    c = shapesim.read_config(run)
    cs = shapesim.read_config(c['sim'])

    group=options.group
    if group is not None:
        group = 'group: ['+group+']'
    else:
        group=''

    mode=''
    if options.bynode:
        mode='mode: bynode'

    extra=''
    if options.extra is not None:
        extra='\n'.join( options.extra.split(';') )

    wqd = shapesim.get_wq_dir(run, combine=True)
    if not os.path.exists(wqd):
        os.makedirs(wqd)

    if run[0:8] == 'gmix-fit':
        rstr=run.replace('gmix-fit','gmix')
    else:
        rstr=run
 
    n1 = cs['nums2']

    runtype = c['runtype']
    if runtype == 'byellip':
        n2 = cs['nume']
    else:
        n2 = shapesim.get_nums2n(c)

    for i1 in xrange(n1):
        for i2 in xrange(n2):
            job_name='%s-combine-%03i-%03i' % (rstr,i1,i2)

            wqurl = shapesim.get_wq_url(run,i1,i2,combine=True)

            wlog("writing wq script:",wqurl)
            with open(wqurl,'w') as fobj:
                wqscript=_wqtemplate % {'job_name':job_name,
                                        'run':run, 
                                        'i1':i1,
                                        'i2':i2,
                                        'group':group,
                                        'mode':mode,
                                        'extra':extra,
                                        'pri':options.priority}
                fobj.write(wqscript)
예제 #3
0
파일: make-wq.py 프로젝트: esheldon/espy
def main():
    options,args = parser.parse_args(sys.argv[1:])

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

    run=args[0]

    c = shapesim.read_config(run)
    cs = shapesim.read_config(c['sim'])


    if options.bytrial:
        if 'stack-' in run:
            ntrial=c['nsplit']
        else:
            orient=cs.get('orient','rand')
            if orient == 'ring':
                ntrial = cs['nsplit']
            else:
                ntrial = cs['ntrial']


    wqd = shapesim.get_wq_dir(run, bytrial=options.bytrial)
    if not os.path.exists(wqd):
        os.makedirs(wqd)

    extra=''
    if options.bynode:
        extra='mode: bynode\nN: 1'
    elif options.ncores is not None:
        ncores=int(options.ncores)
        extra='mode: bycore1\nN: %d' % ncores

    if run[0:8] == 'gmix-fit':
        rstr=run.replace('gmix-fit','gmix')
    else:
        rstr=run

    n1 = shapesim.get_numT(cs)

    runtype = c['runtype']
    if runtype == 'byellip':
        n2 = cs['nume']
    else:
        n2 = shapesim.get_nums2n(c)



    for i1 in xrange(n1):
        for i2 in xrange(n2):
            groups=''
            if options.i2new is not None and i2 <= int(options.i2new):
                groups='group: [new,new2]'
            elif options.i2new1 is not None and i2 <= int(options.i2new1):
                groups='group: [new]'
            elif options.i2new2 is not None and i2 <= int(options.i2new2):
                groups='group: [new2]'
            elif options.groups is not None:
                groups = 'group: [%s]' % options.groups

            if options.bytrial:
                for itrial in xrange(ntrial):
                    job_name='%s-%03i-%03i-%02i' % (rstr,i1,i2,itrial)
                    wqurl = shapesim.get_wq_url(run,i1,i2,itrial=itrial)
                    wlog("writing wq script:",wqurl)
                    with open(wqurl,'w') as fobj:
                        d={'job_name':job_name,
                           'run':run, 
                           'i1':i1,
                           'i2':i2,
                           'itrial':itrial,
                           'groups':groups,
                           'extra':extra,
                           'pri':options.priority}
                        wqscript=_wqtemplate_bytrial % d
                        fobj.write(wqscript)


            else:
                job_name='%s-%03i-%03i' % (rstr,i1,i2)
                wqurl = shapesim.get_wq_url(run,i1,i2)

                wlog("writing wq script:",wqurl)
                with open(wqurl,'w') as fobj:
                    wqscript=_wqtemplate % {'job_name':job_name,
                                            'run':run, 
                                            'i1':i1,
                                            'i2':i2,
                                            'groups':groups,
                                            'extra':extra,
                                            'pri':options.priority}
                    fobj.write(wqscript)