本文整理汇总了Python中lsst.daf.base.PropertySet类的典型用法代码示例。如果您正苦于以下问题:Python PropertySet类的具体用法?Python PropertySet怎么用?Python PropertySet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PropertySet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeit
def makeit(prefs, context, saveWcs=False, plot=dict()):
"""This is the python wrapper for the original psfex that reads SExtractor outputs
"""
# Create an array of PSFs (one PSF for each extension)
if prefs.getVerboseType() != prefs.QUIET:
print("----- %d input catalogues:" % prefs.getNcat())
if saveWcs: # only needed for making plots
wcssList = []
fields = psfexLib.vectorField()
for cat in prefs.getCatalogs():
field = psfexLib.Field(cat)
wcss = []
wcssList.append(wcss)
with fits.open(cat) as pf:
for hdu in pf:
if hdu.name == "PRIMARY":
pass
elif hdu.name == "LDAC_IMHEAD":
hdr = hdu.data[0][0] # the fits header from the original fits image
md = PropertySet()
for line in hdr:
try:
md.set(*splitFitsCard(line))
except AttributeError:
continue
if not md.exists("CRPIX1"): # no WCS; try WCSA
for k in md.names():
if re.search(r"A$", k):
md.set(k[:-1], md.getScalar(k))
wcs = afwGeom.makeSkyWcs(md)
naxis1, naxis2 = md.getScalar("NAXIS1"), md.getScalar("NAXIS2")
elif hdu.name == "LDAC_OBJECTS":
nobj = len(hdu.data)
assert wcs, "LDAC_OBJECTS comes after LDAC_IMHEAD"
field.addExt(wcs, naxis1, naxis2, nobj)
if saveWcs:
wcss.append((wcs, naxis1, naxis2))
wcs = None
field.finalize()
fields.append(field)
sets = psfexLib.vectorSet()
for set in load_samples(prefs, context, plot=plot):
sets.append(set)
psfexLib.makeit(fields, sets)
ret = [[f.getPsfs() for f in fields], sets]
if saveWcs:
ret.append(wcssList)
return ret
示例2: stopWorkflow
def stopWorkflow(self, urgency):
log.debug("VanillaCondorWorkflowMonitor:stopWorkflow")
transmit = events.EventTransmitter(self._eventBrokerHost, self._shutdownTopic)
root = PropertySet()
root.setInt("level",urgency)
root.setString("STATUS","shut things down")
event = events.CommandEvent(self.runid, self.originatorId, 0, root)
transmit.publishEvent(event)
示例3: testProcessDataEvent
def testProcessDataEvent(self):
with self.joboffice.bb.queues:
self.assertEquals(self.joboffice.bb.queues.dataAvailable.length(), 0)
ps = PropertySet()
ps.set("pipelineName", "PostISR")
ps.set("STATUS", "available")
ds = self.testDatasetFromProperty()
ps.add("dataset", serializePolicy(ds.toPolicy()))
for i in xrange(1,4):
ds = copy.deepcopy(ds)
ds.ids["ampid"] += 1
ps.add("dataset", serializePolicy(ds.toPolicy()))
devent = StatusEvent("testing", originatorId, ps)
# pdb.set_trace()
self.joboffice.processDataEvent(devent)
with self.joboffice.bb.queues:
self.assertEquals(self.joboffice.bb.queues.dataAvailable.length(), 4)
self.assertEquals(self.joboffice.bb.queues.jobsPossible.length(), 1)
job = self.joboffice.bb.queues.jobsPossible.get(0)
self.assertEquals(job.getName(), "Job-1")
self.assertEquals(job.triggerHandler.getNeededDatasetCount(), 12)
示例4: finalMessageReceived
def finalMessageReceived(self, propSet):
log = propSet.get("LOGGER")
if log != "orca.control":
return False
status = propSet.get("STATUS")
if status != "eol":
return False
eventSystem = events.EventSystem.getDefaultEventSystem()
id = eventSystem.createOriginatorId()
root = PropertySet()
root.setString("logger.status", "done")
root.setInt("logger.pid", os.getpid())
event = events.StatusEvent(self.runid, id, root)
self.transmitter.publishEvent(event)
return True
示例5: testReceiveReadyPipelines
def testReceiveReadyPipelines(self):
with self.joboffice.bb.queues:
self.assertEquals(self.joboffice.bb.queues.pipelinesReady.length(),0)
ps = PropertySet()
ps.set("pipelineName", "PostISR")
ps.set("STATUS", "job:ready")
pevent = StatusEvent("testing", originatorId, ps)
trx = EventTransmitter(brokerhost, "CcdAssemblyJob")
trx.publishEvent(pevent)
time.sleep(2.0)
self.joboffice.receiveReadyPipelines()
with self.joboffice.bb.queues:
self.assertEquals(self.joboffice.bb.queues.pipelinesReady.length(),1)
示例6: process
def process(self):
clipboard = self.inputQueue.getNextDataset()
eventName = self._policy.get("inputEvent")
event = clipboard.get(eventName)
visitId = event.get("visitId")
exposureId = event.get("exposureId")
ccdId = clipboard.get("ccdId")
ampId = clipboard.get("ampId")
fpaExposureId = (long(visitId) << 1) + exposureId
ccdExposureId = (fpaExposureId << 8) + ccdId
ampExposureId = (ccdExposureId << 6) + ampId
clipboard.put("visitId", visitId)
exposureMetadata = PropertySet()
exposureMetadata.setInt("filterId",
self.lookupFilterId(event.get("filter")))
exposureMetadata.setLongLong("fpaExposureId", fpaExposureId)
exposureMetadata.setLongLong("ccdExposureId", ccdExposureId)
exposureMetadata.setLongLong("ampExposureId", ampExposureId)
clipboard.put("exposureMetadata" + str(exposureId), exposureMetadata)
self.outputQueue.addDataset(clipboard)
示例7: testSubst
def testSubst(self):
ad = PropertySet()
ad.set("foo", "bar")
ad.setInt("x", 3)
LogicalLocation.setLocationMap(ad)
l = LogicalLocation("%(foo)xx")
self.assertEqual(l.locString(), "barxx")
l = LogicalLocation("%(x)foo")
self.assertEqual(l.locString(), "3foo")
l = LogicalLocation("yy%04d(x)yy")
self.assertEqual(l.locString(), "yy0003yy")
ad2 = PropertySet()
ad2.set("foo", "baz")
ad2.setInt("y", 2009)
l = LogicalLocation("%(foo)%(x)%(y)", ad2)
self.assertEqual(l.locString(), "bar32009")
LogicalLocation.setLocationMap(PropertySet())
l = LogicalLocation("%(foo)%3d(y)", ad2)
self.assertEqual(l.locString(), "baz2009")
示例8: sendEvent
def sendEvent(self, broker, topic):
trans = events.EventTransmitter(broker, topic)
root = PropertySet()
root.set(events.Event.TOPIC,topic)
root.set("myname","myname")
root.set(events.Event.STATUS, "my special status")
root.set(events.Event.RUNID,"srptestrun")
event = events.Event("srptestrun", root)
# wait a short time so we can see the difference between the time
# the event is created and the time it is published
time.sleep(2)
# ok...now publish it
trans.publishEvent(event)
示例9: __init__
def __init__(self, runid, props=None):
"""
create a generic event factor
"""
self.runid = runid
if isinstance(props, PropertySet):
self.props = props
else:
self.props = PropertySet()
if isinstance(props, dict):
for key in props.keys():
self.props.set(key, props[key])
示例10: testToPipelineQueueItem
def testToPipelineQueueItem(self):
pipelineName = "ccdassembly"
ps = PropertySet()
ps.set("pipelineName", pipelineName)
ps.set("STATUS", "done")
ps.set("RUNID", "testing")
pevent = StatusEvent("testing", originatorId, ps)
item = self.joboffice.toPipelineQueueItem(pevent)
self.assertEquals(item.getName(), pipelineName)
self.assertEquals(item.getProperty("status"), "done")
self.assertEquals(item.getRunId(), "testing")
示例11: _EventFactory
class _EventFactory(object):
def __init__(self, runid, props=None):
"""
create a generic event factor
"""
self.runid = runid
if isinstance(props, PropertySet):
self.props = props
else:
self.props = PropertySet()
if isinstance(props, dict):
for key in props.keys():
self.props.set(key, props[key])
def create(self):
"""create a new instance of the event"""
return ev.Event(self.runid, self.props)
def setRunId(self, id):
"""set the Run ID"""
self.runid = runid
def getRunId(self):
"""set the Run ID"""
return self.runid
def setProperty(self, name, val):
"""set the value of a named property"""
self.props.set(name, val)
def getProperty(self, name):
"""get the value of a named property"""
return self.props.getString(name)
def addDataset(self, propname, ds):
"""add a dataset to the event"""
self.props.add(propname, serializeDataset(ds))
def getDatasets(self, propname):
"""return the datasets attached to the event"""
return unserializeDatasetList(self.props.getArrayString(propname))
示例12: testProcessJobDoneEvents
def testProcessJobDoneEvents(self):
with self.joboffice.bb.queues:
self.assertEquals(self.joboffice.bb.queues.jobsInProgress.length(),0)
self.assertEquals(self.joboffice.bb.queues.jobsDone.length(),0)
self.testAllocateJobs()
with self.joboffice.bb.queues:
self.assertEquals(self.joboffice.bb.queues.jobsInProgress.length(),1)
self.assertEquals(self.joboffice.bb.queues.jobsDone.length(),0)
ps = PropertySet()
ps.set("pipelineName", "PostISR")
ps.set("STATUS", "job:done")
ps.set("success", True)
pevent = StatusEvent("testing", originatorId, ps)
trx = EventTransmitter(brokerhost, "CcdAssemblyJob")
trx.publishEvent(pevent)
time.sleep(2.0)
self.joboffice.processDoneJobs()
with self.joboffice.bb.queues:
self.assertEquals(self.joboffice.bb.queues.jobsInProgress.length(),0)
self.assertEquals(self.joboffice.bb.queues.jobsDone.length(),1)
示例13: testProcessJobDoneEvent
def testProcessJobDoneEvent(self):
with self.joboffice.bb.queues:
self.assertEquals(self.joboffice.bb.queues.jobsInProgress.length(),0)
self.assertEquals(self.joboffice.bb.queues.jobsDone.length(),0)
ps = PropertySet()
ps.set("pipelineName", "PostISR")
ps.set("STATUS", "job:done")
ps.set("success", True)
pevent = StatusEvent("testing", originatorId, ps)
self.assert_(not self.joboffice.processJobDoneEvent(pevent))
self.testAllocateJobs()
with self.joboffice.bb.queues:
self.assertEquals(self.joboffice.bb.queues.jobsInProgress.length(),1)
self.assertEquals(self.joboffice.bb.queues.jobsDone.length(),0)
# pdb.set_trace()
self.assert_(self.joboffice.processJobDoneEvent(pevent))
with self.joboffice.bb.queues:
self.assertEquals(self.joboffice.bb.queues.jobsInProgress.length(),0)
self.assertEquals(self.joboffice.bb.queues.jobsDone.length(),1)
示例14: preprocess
def preprocess(self):
self.activeClipboard = self.inputQueue.getNextDataset()
eventName = self._policy.get("inputEvent")
event = self.activeClipboard.get(eventName)
visitId = event.get("visitId")
exposureId = event.get("exposureId")
fpaExposureId = (long(visitId) << 1) + exposureId
visit = PropertySet()
visit.setInt("visitId", visitId)
visit.setLongLong("exposureId", fpaExposureId)
self.activeClipboard.put("visit" + str(exposureId), visit)
rawFpaExposure = PropertySet()
rawFpaExposure.setLongLong("rawFPAExposureId", fpaExposureId)
rawFpaExposure.set("ra", event.get("ra"))
rawFpaExposure.set("decl", event.get("decl"))
rawFpaExposure.set("filterId",
self.lookupFilterId(event.get("filter")))
rawFpaExposure.set("equinox", event.get("equinox"))
rawFpaExposure.set("dateObs", DateTime(event.get("dateObs")))
rawFpaExposure.set("mjdObs", DateTime(event.get("dateObs")).mjd())
rawFpaExposure.set("expTime", event.get("expTime"))
rawFpaExposure.set("airmass", event.get("airmass"))
self.activeClipboard.put("fpaExposure" + str(exposureId), rawFpaExposure)
示例15: sendFilterableStatusEvent
def sendFilterableStatusEvent(self, broker, topic):
trans = events.EventTransmitter(broker, topic)
root = PropertySet()
root.set(events.Event.TOPIC, topic)
root.set("myname","myname")
root.set(events.Event.STATUS, "my special status")
filter = PropertySet()
filter.set("FOO", "bar")
filter.set("PLOUGH", 123)
eventSystem = events.EventSystem.getDefaultEventSystem();
locationID = eventSystem.createOriginatorId()
event = events.StatusEvent(locationID, root, filter)
# ok...now publish it
trans.publishEvent(event)