LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
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