522def load_samplesLsst(prefs, context, ext=psfexLib.Prefs.ALL_EXTENSIONS, next=1, plot=dict()):
523 minsn = prefs.getMinsn()
524 maxelong = (prefs.getMaxellip() + 1.0)/(1.0 - prefs.getMaxellip())
if prefs.getMaxellip() < 1.0
else 100
525 min = prefs.getFwhmrange()[0]
526 max = prefs.getFwhmrange()[1]
528 filenames = prefs.getCatalogs()
530 ncat = len(filenames)
531 fwhmmin = np.empty(ncat)
532 fwhmmax = np.empty(ncat)
534 if not prefs.getAutoselectFlag():
535 fwhmmin = np.zeros(ncat) + prefs.getFwhmrange()[0]
536 fwhmmax = np.zeros(ncat) + prefs.getFwhmrange()[1]
537 fwhmmode = (fwhmmin + fwhmmax)/2.0
544 for i, fileName
in enumerate(filenames):
547 if prefs.getVerboseType() != prefs.QUIET:
548 print(
"Examining Catalog #%d" % (i+1))
551 tab = afwTable.SourceCatalog.readFits(fileName)
554 shape = tab.getShapeDefinition()
555 ixx = tab.get(
"%s.xx" % shape)
556 iyy = tab.get(
"%s.yy" % shape)
558 rmsSize = np.sqrt(0.5*(ixx + iyy))
559 elong = 0.5*(ixx - iyy)/(ixx + iyy)
561 flux = tab.get(prefs.getPhotfluxRkey())
562 fluxErr = tab.get(prefs.getPhotfluxerrRkey())
566 good = np.logical_and(flux/fluxErr > minsn,
567 np.logical_not(flags & prefs.getFlagMask()))
568 good = np.logical_and(good, elong < maxelong)
570 good = np.logical_and(good, fwhm >= min)
571 good = np.logical_and(good, fwhm < max)
572 fwhms[i] = fwhm[good]
574 if prefs.getVarType() == prefs.VAR_NONE:
576 fwhms_all = np.empty(sum([len(f)
for f
in fwhms.values()]))
578 for f
in fwhms.values():
579 fwhms_all[i:len(f)] = f
582 prefs.getFwhmrange()[0], prefs.getFwhmrange()[1],
585 raise RuntimeError(
"No source with appropriate FWHM found!!")
586 mode = min = max = 2.35/(1.0 - 1.0/psfexLib.cvar.INTERPFAC)
588 fwhmmin = np.zeros(ncat) + min
589 fwhmmax = np.zeros(ncat) + max
590 fwhmmode = np.zeros(ncat) + mode
592 fwhmmode = np.empty(ncat)
593 fwhmmin = np.empty(ncat)
594 fwhmmax = np.empty(ncat)
596 for i
in range(ncat):
599 fwhmmode[i], fwhmmin[i], fwhmmax[i] = \
601 prefs.getFwhmrange()[0], prefs.getFwhmrange()[1], plot=plot)
603 raise RuntimeError(
"No source with appropriate FWHM found!!")
604 fwhmmode[i] = fwhmmin[i] = fwhmmax[i] = 2.35/(1.0 - 1.0/psfexLib.cvar.INTERPFAC)
610 for i, fileName
in enumerate(filenames):
612 for ext
in range(next):
613 set =
read_samplesLsst(prefs, set, fileName, fwhmmin[i]/2.0, fwhmmax[i]/2.0,
614 ext, next, i, context,
615 context.getPc(i)
if context.getNpc()
else None, nobj, plot=plot)
617 if fwhmmode[i] < mode:
622 if prefs.getVerboseType() != prefs.QUIET:
624 print(
"%d samples loaded." % set.getNsample())
626 raise RuntimeError(
"No appropriate source found!!")
def load_samplesLsst(prefs, context, ext=psfexLib.Prefs.ALL_EXTENSIONS, next=1, plot=dict())
def read_samplesLsst(prefs, set, filename, frmin, frmax, ext, next, catindex, context, pcval, nobj, plot=dict(showFlags=False, showRejection=False))