408 def load_samples(prefs, context, ext=psfexLib.Prefs.ALL_EXTENSIONS, next=1, plot=dict()):
409 minsn = prefs.getMinsn()
410 maxelong = (prefs.getMaxellip() + 1.0)/(1.0 - prefs.getMaxellip())
if prefs.getMaxellip() < 1.0
else 100
411 min = prefs.getFwhmrange()[0]
412 max = prefs.getFwhmrange()[1]
414 filenames = prefs.getCatalogs()
416 ncat = len(filenames)
417 fwhmmin = np.empty(ncat)
418 fwhmmax = np.empty(ncat)
420 if not prefs.getAutoselectFlag():
421 fwhmmin = np.zeros(ncat) + prefs.getFwhmrange()[0]
422 fwhmmax = np.zeros(ncat) + prefs.getFwhmrange()[1]
423 fwhmmode = (fwhmmin + fwhmmax)/2.0
430 for i, fileName
in enumerate(filenames):
433 if prefs.getVerboseType() != prefs.QUIET:
434 print(
"Examining Catalog #%d" % (i+1))
438 with fits.open(fileName)
as cat:
441 if tab.name ==
"LDAC_IMHEAD":
444 if extCtr != ext
and ext != prefs.ALL_EXTENSIONS:
449 if tab.name ==
"PRIMARY":
451 elif tab.name ==
"LDAC_IMHEAD":
456 except AttributeError:
460 if v < 1/psfexLib.BIG:
465 elif tab.name ==
"LDAC_OBJECTS":
467 rmsSize = tab.data[
"FLUX_RADIUS"]
468 fmax = tab.data[
"FLUX_MAX"]
469 flags = tab.data[
"FLAGS"]
470 elong = tab.data[
"ELONGATION"]
471 backnoise = backnoises[-1]
473 good = np.logical_and(fmax/backnoise > minsn,
474 np.logical_not(flags & prefs.getFlagMask()))
475 good = np.logical_and(good, elong < maxelong)
477 good = np.logical_and(good, fwhm >= min)
478 good = np.logical_and(good, fwhm < max)
479 fwhms[i] = fwhm[good]
481 if prefs.getVarType() == prefs.VAR_NONE:
483 fwhms_all = np.empty(sum([len(l)
for l
in fwhms.values()]))
485 for l
in fwhms.values():
486 fwhms_all[i:len(l)] = l
489 prefs.getFwhmrange()[0], prefs.getFwhmrange()[1],
492 raise RuntimeError(
"No source with appropriate FWHM found!!")
493 mode = min = max = 2.35/(1.0 - 1.0/psfexLib.cvar.INTERPFAC)
495 fwhmmin = np.zeros(ncat) + min
496 fwhmmax = np.zeros(ncat) + max
497 fwhmmode = np.zeros(ncat) + mode
499 fwhmmode = np.empty(ncat)
500 fwhmmin = np.empty(ncat)
501 fwhmmax = np.empty(ncat)
503 for i
in range(ncat):
506 fwhmmode[i], fwhmmin[i], fwhmmax[i] = \
508 prefs.getFwhmrange()[0], prefs.getFwhmrange()[1], plot=plot)
510 raise RuntimeError(
"No source with appropriate FWHM found!!")
511 fwhmmode[i] = fwhmmin[i] = fwhmmax[i] = 2.35/(1.0 - 1.0/psfexLib.cvar.INTERPFAC)
517 for i, fileName
in enumerate(filenames):
519 if ext == prefs.ALL_EXTENSIONS:
520 extensions =
list(range(len(backnoises)))
525 set =
read_samples(prefs, set, fileName, fwhmmin[i]/2.0, fwhmmax[i]/2.0,
526 e, next, i, context, context.getPc(i)
if context.getNpc()
else None, plot=plot)
528 if fwhmmode[i] < mode:
533 if prefs.getVerboseType() != prefs.QUIET:
535 print(
"%d samples loaded." % set.getNsample())
537 raise RuntimeError(
"No appropriate source found!!")
setstruct * load_samples(char **filenames, int catindex, int ncat, int ext, int next, contextstruct *context)
def read_samples(prefs, set, filename, frmin, frmax, ext, next, catindex, context, pcval, plot=dict(showFlags=False, showRejection=False))
def compute_fwhmrange(fwhm, maxvar, minin, maxin, plot=dict(fwhmHistogram=False))
daf::base::PropertyList * list