LSSTApplications  11.0-24-g0a022a1,14.0+77,15.0,15.0+1
LSSTDataManagementBasePackage
Functions
lsst.datarel.utils Namespace Reference

Functions

def getDataset (butler, dataset, dataId, strict, warn)
 
def getPsf (butler, dataset, dataId, strict, warn)
 

Function Documentation

◆ getDataset()

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 29 of file utils.py.

29 def getDataset(butler, dataset, dataId, strict, warn):
30  """Get a dataset from a repository with an optional exception or warning if not found
31 
32  @param[in] butler: data butler
33  @param[in] dataset: name of desired dataset
34  @param[in] dataId: data ID dict
35  @param[in] strict: if True then raise RuntimeError if dataset not found
36  @param[in] warn: if True and strict False then print a warning to stderr if dataset not found
37 
38  @raise RuntimeError if dataset not found and strict true
39  """
40  try:
41  ds = butler.get(dataset, dataId=dataId, immediate=True)
42  except:
43  ds = None
44  if ds is None:
45  msg = '{} : Failed to retrieve {} dataset'.format(dataId, dataset)
46  if strict:
47  raise RuntimeError(msg)
48  elif warn:
49  print('*** Skipping ' + msg, file=sys.stderr)
50  return ds
51 
52 
def getDataset(butler, dataset, dataId, strict, warn)
Definition: utils.py:29
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:134

◆ getPsf()

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 53 of file utils.py.

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