def setup(self): #I don't have the default policy in the correct place yet policyFile = pexPolicy.DefaultPolicyFile( "meas_pipeline", # package name "WcsDeterminationStageDictionary.paf", # default. policy "policy" # dir containing policies ) defaultPolicy = pexPolicy.Policy.createPolicy( policyFile, policyFile.getRepositoryPath()) #The stage can be called with an optional local policy file, which overrides the defaults #merge defaults policyFile = pexPolicy.DefaultPolicyFile( "meas_pipeline", "WcsDeterminationStageDictionary.paf", "policy") defPolicy = pexPolicy.Policy.createPolicy( policyFile, policyFile.getRepositoryPath(), True) if self.policy is None: self.policy = defaultPolicy else: self.policy.mergeDefaults(defaultPolicy) #Setup the astrometry solver path = os.path.join(os.environ['ASTROMETRY_NET_DATA_DIR'], "metadata.paf") self.solver = astromNet.GlobalAstrometrySolution(path) # self.solver.allowDistortion(self.policy.get('allowDistortion')) self.solver.setMatchThreshold(self.policy.get('matchThreshold')) #Setup the log self.log = Debug(self.log, "WcsDeterminationStageParallel") self.log.setThreshold(Log.DEBUG) self.log.log(Log.INFO, "Finished setup of WcsDeterminationStageParallel")
def makeCameraFromPolicy(filename, writeRepo=False, outputDir=None, doClobber=False, ccdToUse=None, shortNameMethod=lambda x: x): """ Make a Camera from a paf file @param filename: name of policy file to read @param writeRepo: write out repository files? @param outputDir: output directory to write files into @param doClobber: clobber any files existing in the repository? @param ccdToUse: Type of ccd to use, otherwise use ccd specified in the paf @param shortNameMethod: Method to compactify ccd names into names easily used in paths @return Camera object """ #This is all fragile as the CameraGeomDictionary.paf will go away. policyFile = pexPolicy.DefaultPolicyFile("afw", "CameraGeomDictionary.paf", "policy") defPolicy = pexPolicy.Policy.createPolicy(policyFile, policyFile.getRepositoryPath(), True) polFile = pexPolicy.DefaultPolicyFile("obs_cfht", filename) geomPolicy = pexPolicy.Policy.createPolicy(polFile) geomPolicy.mergeDefaults(defPolicy.getDictionary()) ampParams = makeAmpParams(geomPolicy) ccdParams = makeCcdParams(geomPolicy, ampParams) ccdInfoDict = parseCcds(geomPolicy, ccdParams, ccdToUse) camConfig = parseCamera(geomPolicy) camConfig.detectorList = dict([(i, ccdInfo) for i, ccdInfo in enumerate(ccdInfoDict['ccdInfo'])]) if writeRepo: if outputDir is None: raise ValueError("Need output directory for writting") def makeDir(dirPath, doClobber=False): """Make a directory; if it exists then clobber or fail, depending on doClobber @param[in] dirPath: path of directory to create @param[in] doClobber: what to do if dirPath already exists: if True and dirPath is a dir, then delete it and recreate it, else raise an exception @throw RuntimeError if dirPath exists and doClobber False """ if os.path.exists(dirPath): if doClobber and os.path.isdir(dirPath): print "Clobbering directory %r" % (dirPath,) shutil.rmtree(dirPath) else: raise RuntimeError("Directory %r exists" % (dirPath,)) print "Creating directory %r" % (dirPath,) os.makedirs(dirPath) # write data products makeDir(dirPath=outputDir, doClobber=doClobber) camConfigPath = os.path.join(outputDir, "camera.py") with open(camConfigPath, 'w') as outfile: outfile.write("#!!!!This file is auto generated.----Do not edit!!!!\n"+\ "#!!!!Edit input file and regenerate with $OBS_CFHT_DIR/bin/genCameraRepository.py\n") camConfig.saveToStream(outfile) for detectorName, ampTable in ccdInfoDict['ampInfo'].iteritems(): shortDetectorName = shortNameMethod(detectorName) ampInfoPath = os.path.join(outputDir, shortDetectorName + ".fits") ampTable.writeFits(ampInfoPath) return makeCameraFromCatalogs(camConfig, ccdInfoDict['ampInfo'])
def __init__(self, inputPolicy=None, **kwargs): policyFile = pexPolicy.DefaultPolicyFile(self.packageName, "LsstSimMapper.paf", "policy") policy = pexPolicy.Policy(policyFile) self.doFootprints = False if inputPolicy is not None: for kw in inputPolicy.paramNames(True): if kw == "doFootprints": self.doFootprints = True else: kwargs[kw] = inputPolicy.get(kw) super(LsstSimMapper, self).__init__(policy, policyFile.getRepositoryPath(), **kwargs) self.filterIdMap = { 'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5, 'i2': 5 } # The LSST Filters from L. Jones 04/07/10 afwImageUtils.defineFilter('u', 364.59) afwImageUtils.defineFilter('g', 476.31) afwImageUtils.defineFilter('r', 619.42) afwImageUtils.defineFilter('i', 752.06) afwImageUtils.defineFilter('z', 866.85) afwImageUtils.defineFilter('y', 971.68, alias=['y4']) # official y filter
def testSingleExposure(self): policyFile = pexPolicy.DefaultPolicyFile( "ip_pipeline", "CrRejectStageDictionary.paf", "policy") defPolicy = pexPolicy.Policy.createPolicy( policyFile, policyFile.getRepositoryPath(), True) policy = pexPolicy.Policy( os.path.join(eups.productDir("ip_pipeline"), "tests", "crReject_policy.paf")) policy.mergeDefaults(defPolicy) stage = ipPipe.CrRejectStage(policy) tester = SimpleStageTester(stage) clipboard = pexClipboard.Clipboard() clipboard.put(policy.get("inputKeys.exposure"), self.exposure) if display: ds9.mtv(self.exposure, frame=0, title="Input") # # Do the work # outWorker = tester.runWorker(clipboard) outPolicy = policy.get("outputKeys") self.assertTrue(outWorker.contains(outPolicy.get("exposure"))) self.assertEqual(outWorker.get("nCR"), 25) if display: ds9.mtv(outWorker.get(outPolicy.get("exposure")), frame=1, title="CR removed")
def setUp(self): SuprimecamGeomTestCase.ampSerial = [ 0 ] # an array so we pass the value by reference policyFile = pexPolicy.DefaultPolicyFile("afw", "CameraGeomDictionary.paf", "policy") defPolicy = pexPolicy.Policy.createPolicy( policyFile, policyFile.getRepositoryPath(), True) polFile = pexPolicy.DefaultPolicyFile("obs_subaru", "Full_Suprimecam_geom.paf", "suprimecam") self.geomPolicy = pexPolicy.Policy.createPolicy(polFile) self.geomPolicy.mergeDefaults(defPolicy.getDictionary())
def setUp(self): random.seed(1369) ##Load sample input from disk path = os.path.join(eups.productDir("meas_pipeline"), "tests") srcSet = readSourceSet(os.path.join(path, "v695833-e0-c000.xy.txt")) #Make a copy, with different positions #The exact choice doesn't matter ,we just want to make sure the code returns an answer catSet = [] for s in srcSet: s1 = afwDet.Source(s) s1.setXAstrom(s1.getXAstrom() + random.uniform(-.1, .1)) catSet.append(s1) #Make a SourceMatch object maxDist = 1 / 3600. #matches must be this close together srcMatchSet = afwDet.matchXy(catSet, srcSet, maxDist) #Put them on the clipboard filename = pexPolicy.DefaultPolicyFile( "meas_pipeline", "WcsVerificationStageDictionary.paf", "policy") self.policy = pexPolicy.Policy.createPolicy(filename) self.clipboard = pexClipboard.Clipboard() self.clipboard.put(self.policy.get("sourceMatchSetKey"), srcMatchSet) self.clipboard.put(self.policy.get("inputExposureKey"), afwImage.ExposureF(afwGeom.Extent2I(4000, 4000)))
def __init__(self, inputPolicy=None, **kwargs): policyFile = pexPolicy.DefaultPolicyFile(self.packageName, "monocamMapper.paf", "policy") policy = pexPolicy.Policy(policyFile) CameraMapper.__init__(self, policy, policyFile.getRepositoryPath(), **kwargs) # Ensure each dataset type of interest knows about the full range of keys available from the registry keys = {'visit': int, 'ccd': int, 'filter': str, 'date': str, 'expTime': float, 'object': str, 'imageType': str, } for name in ("raw", "raw_amp", # processCcd outputs "postISRCCD", "calexp", "postISRCCD", "src", "icSrc", "srcMatch", ): self.mappings[name].keyDict.update(keys) # @merlin, you should swap these out for the filters you actually intend to use. self.filterIdMap = {'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5} # The LSST Filters from L. Jones 04/07/10 afwImageUtils.defineFilter('u', 364.59) afwImageUtils.defineFilter('g', 476.31, alias=["SDSSG"]) afwImageUtils.defineFilter('r', 619.42, alias=["SDSSR"]) afwImageUtils.defineFilter('i', 752.06, alias=["SDSSI"]) afwImageUtils.defineFilter('z', 866.85, alias=["SDSSZ"]) afwImageUtils.defineFilter('y', 971.68, alias=['y4']) # official y filter afwImageUtils.defineFilter('NONE', 0.0, alias=['no_filter', "OPEN"])
def setUp(self): ##Load sample input from disk path = os.path.join(eups.productDir("meas_pipeline"), "tests") srcSet = readSourceSet(os.path.join(path, "v695833-e0-c000.xy.txt")) #Make a copy, with different fluxes. #The exact choice doesn't matter ,we just want to make sure the code returns an answer #Also need to specify that each source is a star catSet = [] flags = malgUtil.getDetectionFlags() goodFlag = flags['BINNED1'] | flags['STAR'] for s in srcSet: s1 = afwDet.Source(s) s1.setPsfFlux(s1.getPsfFlux() * .281) catSet.append(s1) s.setFlagForDetection(goodFlag) #Make a SourceMatch object maxDist = 1 / 3600. #matches must be this close together srcMatchSet = afwDet.matchXy(catSet, srcSet, maxDist) #Put them on the clipboard filename = pexPolicy.DefaultPolicyFile("meas_pipeline", "PhotoCalStageDictionary.paf", "policy") self.policy = pexPolicy.Policy.createPolicy(filename) self.clipboard = pexClipboard.Clipboard() self.clipboard.put(self.policy.get("sourceMatchSetKey"), srcMatchSet) self.clipboard.put(self.policy.get("inputExposureKey"), afwImage.ExposureF(afwGeom.Extent2I(10, 10)))
def main(cmdline): """ run the script with the given command line @param cmdline an OptionParser instance with command-line options defined """ cl = cmdline (cl.opts, cl.args) = cl.parse_args() pexLog.Log.getDefaultLog().setThreshold( \ run.verbosity2threshold(cl.opts.verb, 0)) mdPolicyFileName = cl.opts.mdpolicy if mdPolicyFileName is None: mpf = pexPolicy.DefaultPolicyFile("ctrl_mospipe", "mosEventMetadataPolicy.paf", "pipeline") metadataPolicy = pexPolicy.Policy.createPolicy(mpf, mpf.getRepositoryPath()) else: metadataPolicy = pexPolicy.Policy.createPolicy(mdPolicyFileName) dataPolicy = pexPolicy.Policy.createPolicy(cl.args[1]) if not EventFromInputfile(cl.args[0], dataPolicy, metadataPolicy, cl.opts.topic, cl.opts.broker): # EventFromInputfile will print error message sys.exit(3)
def __init__(self, inputPolicy=None, **kwargs): policyFile = pexPolicy.DefaultPolicyFile(self.packageName, "ctio0m9Mapper.paf", "policy") policy = pexPolicy.Policy(policyFile) CameraMapper.__init__(self, policy, policyFile.getRepositoryPath(), **kwargs) filter_pairings = [ 'NONE+SEMROCK', # list of all filter pairings found in data 'NONE+RONCHI200', 'RONCHI200+SEMROCK', 'NONE+NONE', 'NONE+g', 'NONE+r', 'NONE+i', 'NONE+z', 'RONCHI200+z', 'RONCHI200+g', 'FGB37+RONCHI200', 'NONE+RONCHI400', 'FGC715S+RONCHI400', 'FGC715S+RONCHI200' ] # default no-filter name used for biases and darks - must appear afwImageUtils.defineFilter('NONE', 0.0, alias=[]) for pairing in filter_pairings: afwImageUtils.defineFilter(pairing, 0.0, alias=[])
def testSingleExposure(self): policyFile = pexPolicy.DefaultPolicyFile("ip_pipeline", "DiffImStageDictionary.paf", "policy") policy = pexPolicy.Policy.createPolicy(policyFile, policyFile.getRepositoryPath(), True) self.subBackground(policy.get("diffImPolicy").get("backgroundPolicy")) stage = ipPipe.DiffImStage(policy) tester = SimpleStageTester(stage) #print policy clipboard = pexClipboard.Clipboard() clipboard.put(policy.get("inputKeys.templateExposureKey"), self.templateExposure) clipboard.put(policy.get("inputKeys.scienceExposureKey"), self.scienceExposure) outWorker = tester.runWorker(clipboard) outPolicy = policy.get("outputKeys") #print outPolicy self.assertTrue(outWorker.contains(outPolicy.get("differenceExposureKey"))) self.assertTrue(outWorker.contains(outPolicy.get("psfMatchingKernelKey"))) self.assertTrue(outWorker.contains(outPolicy.get("backgroundFunctionKey"))) # also check types diffExposure = outWorker.get(outPolicy.get("differenceExposureKey")) matchingKernel = outWorker.get(outPolicy.get("psfMatchingKernelKey")) background = outWorker.get(outPolicy.get("backgroundFunctionKey")) self.assertTrue(isinstance(diffExposure, afwImage.ExposureF)) self.assertTrue(isinstance(matchingKernel, afwMath.LinearCombinationKernel)) self.assertTrue(isinstance(background, afwMath.Function2D)) if display: ds9.mtv(outWorker.get(outPolicy.get("differenceExposureKey")), frame=5)
def testFilters(self): """Test that the coadd filter is set correctly """ filterPolicyFile = pexPolicy.DefaultPolicyFile("afw", "SdssFilters.paf", "tests") filterPolicy = pexPolicy.Policy.createPolicy( filterPolicyFile, filterPolicyFile.getRepositoryPath(), True) imageUtils.defineFiltersFromPolicy(filterPolicy, reset=True) unkFilter = afwImage.Filter() gFilter = afwImage.Filter("g") rFilter = afwImage.Filter("r") calexpPath = os.path.join(AfwdataDir, SimCalexpSubpath) inExp = afwImage.ExposureF(calexpPath, afwGeom.Box2I(afwGeom.Point2I(0, 0), afwGeom.Extent2I(10, 10)), afwImage.PARENT) coadd = coaddUtils.Coadd( bbox=inExp.getBBox(), wcs=inExp.getWcs(), badMaskPlanes=("NO_DATA", "BAD"), ) inExp.setFilter(gFilter) coadd.addExposure(inExp) self.assertEqualFilters(coadd.getCoadd().getFilter(), gFilter) self.assertEqualFilterSets(coadd.getFilters(), (gFilter,)) coadd.addExposure(inExp) self.assertEqualFilters(coadd.getCoadd().getFilter(), gFilter) self.assertEqualFilterSets(coadd.getFilters(), (gFilter,)) inExp.setFilter(rFilter) coadd.addExposure(inExp) self.assertEqualFilters(coadd.getCoadd().getFilter(), unkFilter) self.assertEqualFilterSets(coadd.getFilters(), (gFilter, rFilter))
def testSingleExposure(self): file = pexPolicy.DefaultPolicyFile("meas_pipeline", "backgroundEstimation_policy.paf", "tests") policy = pexPolicy.Policy.createPolicy(file) stage = measPipe.BackgroundEstimationStage(policy) tester = SimpleStageTester(stage) clipboard = pexClipboard.Clipboard() clipboard.put(policy.get("inputKeys.exposure"), self.exposure) if display: ds9.mtv(self.exposure, frame=0, title="Input") # # Do the work # outWorker = tester.runWorker(clipboard) outPolicy = policy.get("outputKeys") assert(outWorker.contains(outPolicy.get("backgroundSubtractedExposure"))) assert(outWorker.contains(outPolicy.get("background"))) if display: ds9.mtv(outWorker.get(outPolicy.get("backgroundSubtractedExposure")), frame=1, title="Subtracted")
def setUp(self): #Load sample input from disk srcSet = readSourceSet( os.path.join(eups.productDir("meas_pipeline"), "tests", "v695833-e0-c000.xy.txt")) exp = afwImg.ExposureF(2048, 4612) #Put them on the clipboard fileName = pexPolicy.DefaultPolicyFile( "meas_pipeline", "WcsDeterminationStageDictionary.paf", "policy") self.policy = pexPolicy.Policy.createPolicy(fileName) self.clipboard = pexClipboard.Clipboard() self.clipboard.put(self.policy.get("inputExposureKey"), exp) self.clipboard.put(self.policy.get("inputSourceSetKey"), srcSet) # Set up local astrometry_net_data adnDB = 'testTagAlong' datapath = os.path.join(eups.productDir("meas_pipeline"), 'tests', 'astrometry_net_data', adnDB) # scons doesn't set $HOME, so make sure it's set os.environ['HOME'] = os.environ.get("HOME", os.path.expanduser("~")) eupsObj = eups.Eups(root=datapath) ok, version, reason = eupsObj.setup('astrometry_net_data') if not ok: raise ValueError( "Need %s version of astrometry_net_data (from path: %s): %s" % (adnDN, datapath, reason))
def main(): # First create a tester. For convenience, we use our special AreaStage # factory class (which is defined below) to configure the tester. # file = pexPolicy.DefaultPolicyFile( "pex_harness", "examples/simpleStageTest/AreaStagePolicy.paf") stagePolicy = pexPolicy.Policy.createPolicy(file) tester = SimpleStageTester(AreaStage(stagePolicy)) # set the verbosity of the logger. If the level is at least 5, you # will see debugging messages from the SimpleStageTester wrapper. tester.setDebugVerbosity(5) # if you want to see all log message properties (including the DATE) # uncomment this line: # tester.showAllLogProperties(True) # create a simple dictionary with the data expected to be on the # stage's input clipboard. If this includes images, you will need to # read in and create the image objects yourself. clipboard = dict(width=1.0, height=2.0) # you can either test the stage as part of a Master slice (which runs # its preprocess() and postprocess() functions)... outMaster = tester.runMaster(clipboard) # ...or you can test it as part of a Worker. Note that in the current # implementation, the output clipboard is the same instance as the input # clipboard. clipboard = dict(width=1.0, height=2.0) outWorker = tester.runWorker(clipboard) print "Area =", outWorker.get("area")
def makeCameraFromPolicy(filename, cameraname, writeRepo=False, outputDir=None, doClobber=False, shortNameMethod=lambda x: x): """Make a camera repository suitable for reading by the butler using a policy file @param[in] filename Name of the policy file to open. @param[in] cameraname Name of the camera being used @param[in] writeRepo Write the repository to disk? Default is False @param[in] outputDir Directory to write to. @param[in] doClobber Clobber existing repository? @param[in] shortNameMethod Method to generate short, filename-like names for sensors @return a Camera object. """ policyFile = pexPolicy.DefaultPolicyFile("afw", "CameraGeomDictionary.paf", "policy") defPolicy = pexPolicy.Policy.createPolicy(policyFile, policyFile.getRepositoryPath(), True) polFile = pexPolicy.DefaultPolicyFile("obs_subaru", filename) geomPolicy = pexPolicy.Policy.createPolicy(polFile) geomPolicy.mergeDefaults(defPolicy.getDictionary()) ampParams = makeAmpParams(geomPolicy) ccdParams = makeCcdParams(geomPolicy, ampParams) ccdToUse = None ccdInfoDict = parseCcds(geomPolicy, ccdParams, ccdToUse) camConfig = parseCamera(geomPolicy, cameraname) camConfig.detectorList = dict([ (i, ccdInfo) for i, ccdInfo in enumerate(ccdInfoDict['ccdInfo']) ]) if writeRepo: if outputDir is None: raise ValueError("Need output directory for writting") # write data products makeDir(dirPath=outputDir, doClobber=doClobber) camConfigPath = os.path.join(outputDir, "camera.py") camConfig.save(camConfigPath) for detectorName, ampTable in ccdInfoDict['ampInfo'].iteritems(): shortDetectorName = shortNameMethod(detectorName) ampInfoPath = os.path.join(outputDir, shortDetectorName + ".fits") ampTable.writeFits(ampInfoPath) return makeCameraFromCatalogs(camConfig, ccdInfoDict['ampInfo'])
def testNullWarpExposure(self, interpLength=10): """Test that warpExposure maps an image onto itself. Note: - NO_DATA and off-CCD pixels must be ignored - bad mask pixels get smeared out so we have to excluded all bad mask pixels from the output image when comparing masks. """ filterPolicyFile = pexPolicy.DefaultPolicyFile("afw", "SdssFilters.paf", "tests") filterPolicy = pexPolicy.Policy.createPolicy( filterPolicyFile, filterPolicyFile.getRepositoryPath(), True) imageUtils.defineFiltersFromPolicy(filterPolicy, reset=True) originalExposure = afwImage.ExposureF(originalExposurePath) originalFilter = afwImage.Filter("i") originalCalib = afwImage.Calib() originalCalib.setFluxMag0(1.0e5, 1.0e3) originalExposure.setFilter(originalFilter) originalExposure.setCalib(originalCalib) afwWarpedExposure = afwImage.ExposureF(originalExposure.getBBox(), originalExposure.getWcs()) warpingControl = afwMath.WarpingControl("lanczos4", "", 0, interpLength) afwMath.warpExposure(afwWarpedExposure, originalExposure, warpingControl) if SAVE_FITS_FILES: afwWarpedExposure.writeFits("afwWarpedExposureNull.fits") self.assertEqual(afwWarpedExposure.getFilter().getName(), originalFilter.getName()) self.assertEqual(afwWarpedExposure.getCalib().getFluxMag0(), originalCalib.getFluxMag0()) afwWarpedMaskedImage = afwWarpedExposure.getMaskedImage() afwWarpedMask = afwWarpedMaskedImage.getMask() noDataBitMask = afwWarpedMask.getPlaneBitMask("NO_DATA") afwWarpedMaskedImageArrSet = afwWarpedMaskedImage.getArrays() afwWarpedMaskArr = afwWarpedMaskedImageArrSet[1] # compare all non-DATA pixels of image and variance, but relax specs a bit # because of minor noise introduced by bad pixels noDataMaskArr = afwWarpedMaskArr & noDataBitMask msg = "afw null-warped MaskedImage (all pixels, relaxed tolerance)" self.assertMaskedImagesAlmostEqual(afwWarpedMaskedImage, originalExposure.getMaskedImage(), doMask=False, skipMask=noDataMaskArr, atol=1e-5, msg=msg) # compare good pixels (mask=0) of image, mask and variance using full # tolerance msg = "afw null-warped MaskedImage (good pixels, max tolerance)" self.assertMaskedImagesAlmostEqual(afwWarpedMaskedImage, originalExposure.getMaskedImage(), skipMask=afwWarpedMask, msg=msg)
def __init__(self, outputRoot=None, **kwargs): policyFile = pexPolicy.DefaultPolicyFile("obs_sst", "SstMapper.paf", "policy") policy = pexPolicy.Policy(policyFile) super(SstMapper, self).__init__(policy, policyFile.getRepositoryPath(), **kwargs) afwImageUtils.defineFilter('OPEN', lambdaEff=650)
def setup(self): self.log = Log(self.log, "simpleDiffImStage - parallel") policyFile = pexPolicy.DefaultPolicyFile("ip_pipeline", "SimpleDiffImStageDictionary.paf", "policy") defPolicy = pexPolicy.Policy.createPolicy(policyFile, policyFile.getRepositoryPath(), True) if self.policy is None: self.policy = pexPolicy.Policy() self.policy.mergeDefaults(defPolicy.getDictionary())
def setup(self): #self.log = Log(self.log, "TransformMetadataStage - parallel") policyFile = pexPolicy.DefaultPolicyFile("ip_pipeline", "TransformMetadataStageDictionary.paf", "policy") defPolicy = pexPolicy.Policy.createPolicy(policyFile, policyFile.getRepositoryPath()) if self.policy is None: self.policy = pexPolicy.Policy() self.policy.mergeDefaults(defPolicy)
def clipboardIoTest(self): file = pexPolicy.DefaultPolicyFile( "meas_pipeline", "tests/sourceDetection0_policy.paf") detectPolicy = pexPolicy.Policy.createPolicy(file) file = pexPolicy.DefaultPolicyFile( "meas_pipeline", "tests/sourceMeasurement0_policy.paf") measurePolicy = pexPolicy.Policy.createPolicy(file) file = pexPolicy.DefaultPolicyFile( "meas_pipeline", "tests/psfDetermination0_policy.paf") psfPolicy = pexPolicy.Policy.createPolicy(file) tester = SimpleStageTester() tester.addStage(measPipe.SourceDetectionStage(detectPolicy)) tester.addStage(measPipe.SourceMeasurementStage(measurePolicy)) tester.addStage(measPipe.PsfDeterminationStage(psfPolicy)) clipboard = pexClipboard.Clipboard() filename = os.path.join(eups.productDir("afwdata"), "CFHT", "D4", "cal-53535-i-797722_1") # test only a portion of the exposure to speed up testing bbox = afwGeom.Box2I(afwGeom.Point2I(32, 32), afwGeom.Extent2I(512, 512)) testExp = afwImage.ExposureF(filename, 0, bbox, afwImage.LOCAL) # test full image # testExp = afImage.ExposureF(filename) clipboard = pexClipboard.Clipboard() clipboard.put(detectPolicy.get("inputKeys.exposure"), testExp) outWorker = tester.runWorker(clipboard) assert (outWorker.contains(psfPolicy.get("data.outputPsfKey"))) assert (outWorker.contains(psfPolicy.get("data.outputCellSetKey"))) del outWorker del testExp del clipboard del tester print >> sys.stderr, "at end of test"
def __init__(self, outputRoot=None, **kwargs): policyFile = pexPolicy.DefaultPolicyFile("obs_wiyn", "WhircMapper.paf", "policy") policy = pexPolicy.Policy(policyFile) # print policyFile.getRepositoryPath() super(WhircMapper, self).__init__(policy, policyFile.getRepositoryPath(), **kwargs) afwImageUtils.defineFilter('OPEN', lambdaEff=1750) # nm afwImageUtils.defineFilter('J' , lambdaEff=1250) afwImageUtils.defineFilter('H' , lambdaEff=1650) afwImageUtils.defineFilter('KS', lambdaEff=2175, alias=['Ks'])
def testSingleInputExposure(self): tester = SimpleStageTester() clipboard = pexClipboard.Clipboard() # policy = pexPolicy.Policy.createPolicy(pexPolicy.DefaultPolicyFile("meas_pipeline", "sourceDetection0_policy.paf", "tests")) tester.addStage(measPipe.SourceDetectionStage(policy)) clipboard.put(policy.get("inputKeys.exposure"), self.exposure) # policy = pexPolicy.Policy.createPolicy(pexPolicy.DefaultPolicyFile("meas_pipeline", "sourceMeasurement0_policy.paf", "tests")) tester.addStage(measPipe.SourceMeasurementStage(policy)) # policy = pexPolicy.Policy.createPolicy(pexPolicy.DefaultPolicyFile("meas_pipeline", "psfDetermination_stagePolicy.paf", "tests")) tester.addStage(measPipe.PsfDeterminationStage(policy)) if display: frame = 0 ds9.mtv(self.exposure, frame=frame, title="Input"); frame += 1 # # Do the work # outClipboard = tester.runWorker(clipboard) # # See if we got it right # if display: ds9.mtv(self.exposure, frame=frame, title="Detected"); frame += 1 psf = outClipboard.get(policy.get("outputKeys.psf")) psfCellSet = outClipboard.get(policy.get("outputKeys.cellSet")) if display: maUtils.showPsf(psf, frame=frame); frame += 1 maUtils.showPsfMosaic(self.exposure, psf, frame=frame); frame += 1 mos = maUtils.showPsfCandidates(self.exposure, psfCellSet, frame=frame); frame += 1 del clipboard del outClipboard
def setup(self): self.log = Log(self.log, "ComputeSourceSkyCoordsStage - parallel") policyFile = pexPolicy.DefaultPolicyFile( "meas_pipeline", "ComputeSourceSkyCoordsStageDictionary.paf", "policy") defPolicy = pexPolicy.Policy.createPolicy( policyFile, policyFile.getRepositoryPath(), True) if self.policy is None: self.policy = pexPolicy.Policy() self.policy.mergeDefaults(defPolicy.getDictionary())
def setup(self): self.log = pexLog.Log(self.log, self.__class__.__name__) policyFile = pexPolicy.DefaultPolicyFile(self.packageName, self.policyDictionaryName, "policy") defPolicy = pexPolicy.Policy.createPolicy( policyFile, policyFile.getRepositoryPath(), True) if self.policy is None: self.policy = pexPolicy.Policy() self.policy.mergeDefaults(defPolicy.getDictionary())
def __init__(self, outputRoot=None, **kwargs): policyFile = pexPolicy.DefaultPolicyFile("obs_decam", "DecamMapper.paf", "policy") policy = pexPolicy.Policy(policyFile) super(DecamMapper, self).__init__(policy, policyFile.getRepositoryPath(), **kwargs) afwImageUtils.defineFilter('u', lambdaEff=350) afwImageUtils.defineFilter('g', lambdaEff=450) afwImageUtils.defineFilter('r', lambdaEff=600) afwImageUtils.defineFilter('i', lambdaEff=750) afwImageUtils.defineFilter('z', lambdaEff=900) afwImageUtils.defineFilter('y', lambdaEff=1000, alias='Y') # Urgh!
def setup(self): self.log = Log(self.log, "CcdAssembly -- Parallel") policyFile = pexPolicy.DefaultPolicyFile( "ip_pipeline", "IsrCcdAssemblyStageDictionary.paf", "policy") defPolicy = pexPolicy.Policy.createPolicy( policyFile, policyFile.getRepositoryPath()) if self.policy is None: self.policy = pexPolicy.Policy() self.policy.mergeDefaults(defPolicy)
def createQuadSpherePixelization(policy=None): policyFile = pexPolicy.DefaultPolicyFile( "skypix", "QuadSpherePixelizationDictionary.paf", "policy") defaults = pexPolicy.Policy.createPolicy(policyFile, policyFile.getRepositoryPath()) if policy is None: policy = pexPolicy.Policy() policy.mergeDefaults(defaults) # Obtain resolution and padding from policy resolution = policy.get('resolutionPix') padding = math.radians(policy.get('paddingArcsec') / 3600.0) return QuadSpherePixelization(resolution, padding)
def setup(self): self.log = Log(self.log, "ApertureCorrectionApplyStage - parallel") # aperture correction policy apCorrPolicyFile = pexPolicy.DefaultPolicyFile("meas_pipeline", "ApertureCorrectionApplyStageDictionary.paf", "policy") defPolicy = pexPolicy.Policy.createPolicy(apCorrPolicyFile, apCorrPolicyFile.getRepositoryPath(), True) if self.policy is None: self.policy = pexPolicy.Policy() self.policy.mergeDefaults(defPolicy.getDictionary())
def testSingleInputExposure(self): polFile = pexPolicy.DefaultPolicyFile("meas_pipeline", "sourceDetection0_policy.paf", "tests") detectPolicy = pexPolicy.Policy.createPolicy(polFile) polFile = pexPolicy.DefaultPolicyFile("meas_pipeline", "sourceMeasurement0_policy.paf", "tests") measurePolicy = pexPolicy.Policy.createPolicy(polFile) tester = SimpleStageTester() tester.addStage(measPipe.SourceDetectionStage(detectPolicy)) tester.addStage(measPipe.SourceMeasurementStage(measurePolicy)) clipboard = pexClipboard.Clipboard() clipboard.put(detectPolicy.get("inputKeys.exposure"), self.exposure) if display: ds9.mtv(self.exposure, frame=0, title="Input") # # Do the work # outClipboard = tester.runWorker(clipboard) # # See if we got it right # if display: ds9.mtv(outClipboard.get( detectPolicy.get("outputKeys.backgroundSubtractedExposure")), frame=1, title="Detected") sources = measurePolicy.get("outputKeys.sources") assert (outClipboard.contains(sources)) if False: assert (outClipboard.contains("persistable_" + sources)) del clipboard del outClipboard