예제 #1
0
    if arg.startswith("-"):
        control[arg[1:]] = False
    if arg.startswith("+"):
        control[arg[1:]] = True

def lineno():
    """Returns the current line number in our program."""
    return "line #%d" % inspect.currentframe().f_back.f_lineno
    
    
if os.path.exists("memtrack.latest"):
    os.remove("memtrack.latest")

line = 0;

mem.memtrack("testmemprofile", lineno()); line += 1

ad = AstroData("data/N20131223S0243.fits")

mem.memtrack("testmemprofile", lineno()); line += 1

if True:
    datas = []
    for ext in ad:
        mem.memtrack("data pull in %s,%d" % (ext.extname(), ext.extver()), line); line += 1
        #print np.median(ext.data)
        #malloc = np.ones((2000,2000), dtype = np.float32)
        datas.append(ext.data)
    
    
mem.memtrack("before ad.write(..)", lineno());
예제 #2
0
 def memtrack(self, primname = "unknown_point", msg = ""):
     from astrodata import memorytrack
     memorytrack.memtrack(primname, msg)
    def addToList(self, rc):
        """
        This primitive will update the lists of files to be stacked
        that have the same observationID with the current inputs.
        This file is cached between calls to reduce, thus allowing
        for one-file-at-a-time processing.
        
        :param purpose: 
        :type purpose: string
        
        """
        # Instantiate the log
        log = gemLog.getGeminiLog(logType=rc["logType"],
                                  logLevel=rc["logLevel"])
        
        from astrodata import memorytrack as mt
        
        mt.memtrack("addToList [inside]", "1")
        
        # Perform an update to the stack cache file (or create it) using the
        # current inputs in the reduction context
        purpose = rc["purpose"]
        if purpose is None:
            purpose = ""
        if purpose == "":
            suffix = "_list"
        else:
            suffix = "_%s" % purpose
            
        mt.memtrack("addToList [inside]", "2")
        
        # Update file names and write the files to disk to ensure the right
        # version is stored before adding it to the list.
        adoutput = []
        for ad in rc.get_inputs_as_astrodata():
            mt.memtrack("addToList [inside]", "3")
            ad.filename = gt.filename_updater(adinput=ad, suffix=suffix,
                                              strip=True)
            mt.memtrack("addToList [inside]", "3.1")
            log.stdinfo("Writing %s to disk" % ad.filename)
            mt.memtrack("addToList [inside]", "3.2")
            ad.write(clobber=True)
            mt.memtrack("addToList [inside]", "3.3")
            adoutput.append(ad)
            mt.memtrack("addtoList [inside]", "3.4")

        rc.report_output(adoutput)
        
        # Call the rq_stack_update method
        rc.rq_stack_update(purpose=purpose)
        mt.memtrack("addToList [inside]", "4")

        yield rc