LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Functions
lsst.datarel.utils Namespace Reference

Functions

def getDataset
 
def getPsf
 

Function Documentation

def lsst.datarel.utils.getDataset (   butler,
  dataset,
  dataId,
  strict,
  warn 
)
Get a dataset from a repository with an optional exception or warning if not found

@param[in] butler: data butler
@param[in] dataset: name of desired dataset
@param[in] dataId: data ID dict
@param[in] strict: if True then raise RuntimeError if dataset not found
@param[in] warn: if True and strict False then print a warning to stderr if dataset not found

@raise RuntimeError if dataset not found and strict true

Definition at line 27 of file utils.py.

27 
28 def getDataset(butler, dataset, dataId, strict, warn):
29  """Get a dataset from a repository with an optional exception or warning if not found
30 
31  @param[in] butler: data butler
32  @param[in] dataset: name of desired dataset
33  @param[in] dataId: data ID dict
34  @param[in] strict: if True then raise RuntimeError if dataset not found
35  @param[in] warn: if True and strict False then print a warning to stderr if dataset not found
36 
37  @raise RuntimeError if dataset not found and strict true
38  """
39  try:
40  ds = butler.get(dataset, dataId=dataId, immediate=True)
41  except:
42  ds = None
43  if ds == None:
44  msg = '{} : Failed to retrieve {} dataset'.format(dataId, dataset)
45  if strict:
46  raise RuntimeError(msg)
47  elif warn:
48  print >>sys.stderr, '*** Skipping ' + msg
49  return ds
def lsst.datarel.utils.getPsf (   butler,
  dataset,
  dataId,
  strict,
  warn 
)
Get the PSF from a repository without reading (very much of) the exposure

@param[in] butler: data butler
@param[in] dataset: name of desired dataset
@param[in] dataId: data ID dict of exposure containing desired PSF
@param[in] strict: if True then raise RuntimeError if psf not found
@param[in] warn: if True and strict False then print a warning to stderr if psf not found

@raise RuntimeError if exposure not found (regardless of strict)
@raise RuntimeError if exposure has no PSF and strict true

Definition at line 50 of file utils.py.

50 
51 def getPsf(butler, dataset, dataId, strict, warn):
52  """Get the PSF from a repository without reading (very much of) the exposure
53 
54  @param[in] butler: data butler
55  @param[in] dataset: name of desired dataset
56  @param[in] dataId: data ID dict of exposure containing desired PSF
57  @param[in] strict: if True then raise RuntimeError if psf not found
58  @param[in] warn: if True and strict False then print a warning to stderr if psf not found
59 
60  @raise RuntimeError if exposure not found (regardless of strict)
61  @raise RuntimeError if exposure has no PSF and strict true
62  """
63  # there is not yet a way to read just the PSF, so read a 1x1 subregion of the exposure
64  tinyBBox = afwGeom.Box2I(afwGeom.Point2I(0,0), afwGeom.Extent2I(1,1))
65  tinyExposure = butler.get(dataset + "_sub", dataId=dataId, bbox=tinyBBox, imageOrigin="LOCAL", immediate=True)
66  psf = tinyExposure.getPsf()
67  if psf is None:
68  msg = '%s : %s exposure had no PSF' % (dataId, dataset)
69  psf = None
70  if strict:
71  raise RuntimeError(msg)
72  elif warn:
73  print >>sys.stderr, '*** Skipping ' + msg
74  return psf
An integer coordinate rectangle.
Definition: Box.h:53