Пример #1
0
def mkRO(dataset="", astrotype="", copy_input=False, args = None, argv = None):

    log = logutils.get_logger(__name__)
    
    rl = RecipeLibrary()
    if dataset != "":
        ad = AstroData(dataset)
        ro = rl.retrieve_reduction_object(ad)
    elif astrotype != "":
        ad = None
        ro = rl.retrieve_reduction_object(astrotype = astrotype)

    # using standard command clause supplied in RecipeLibrary module
    ro.register_command_clause(command_clause)
    rc = ReductionContext(adcc_mode="start_lazy")
    rc.ro = ro
    ro.context = rc
    reductionObject = ro
    
    # Override copy_input argument if passed in argv
    if argv is not None:
        if argv.has_key("copy_input"):
            copy_input = argv["copy_input"]

    # Add input passed in args
    if args:
        arglist = []
        for arg in args:
            if isinstance(arg,list):
                for subarg in arg:
                    if copy_input:
                        subarg = deepcopy(subarg)
                    arglist.append(subarg)
            else:
                if copy_input:
                    arg = deepcopy(arg)
                arglist.append(arg)
        rc.populate_stream(arglist)

    rc.initialize_inputs()
    rc.set_context("pif")
    rc.update({'logindent':logutils.SW})
    rc.update(argv)
    ro.init(rc)
    
    return reductionObject
Пример #2
0
def mkRO(dataset="", astrotype="", args=None, reuseRO=False):
    
    global reductionObject, adccpid
    
    if reductionObject == None or reuseRO == False:
        adccpid = Proxies.start_adcc()
        reduceServer = Proxies.ReduceServer()
        # Playing with module, should use access function
        ReductionObjects.prs = Proxies.PRSProxy.get_adcc(reduce_server=reduceServer)
        
        rl = RecipeLibrary()
        if dataset != "":
            ad = AstroData(dataset)
            ro = rl.retrieve_reduction_object(ad)
        elif astrotype != "":
            ad = None
            ro = rl.retrieve_reduction_object(astrotype = astrotype)

        # using standard command clause supplied in RecipeLibrary module
        ro.register_command_clause(command_clause)
        rc = ReductionContext()
        rc.ro = ro
        # rc.stackFile =  File("stackIndexFile", stkindfile)
        #if args:
        #    rc.add_input(ad)
        
        reductionObject = ro
    
    if reuseRO == True:
        ro = reductionObject
        rc = ro.context

    #if args:
    #    rc.addInputs(args)
    rc.update(argv)
    ro.init(rc)
    
    return reductionObject
Пример #3
0
            ad = None #danger of accidentally using this!

        try:
            assert(nl)
            allinputs = [nl]               # Why is allinputs blown away here?
        except AssertionError:
            msg = "No AstroData objects were created."
            log.warning(msg)
            raise IOError, msg

    # ------------------------------------------------------------------------ #
    #                              Local PRS Components
    # ------------------------------------------------------------------------ #
    # get RecipeLibrary

    rl = RecipeLibrary()
    numReductions = len(allinputs)
    i = 1
    log.info("About to process %d lists of datasets."% len(allinputs))

    for infiles in allinputs:    #for dealing with multiple sets of files.
        try:
            log.info("Starting Reduction on set #%d of %d" % (i, numReductions))
            title = "  Processing dataset(s):\n"
            title += "\n".join("\t"+ad.filename for ad in infiles)
            log.stdinfo("\n"+title+"\n")

            currentReductionNum = i
            i += 1

            # @@REFERENCEIMAGE: retrieve/build correct reduction object