SourceXtractorPlusPlus  0.10
Please provide a description of the project.
measurement_images.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 
3 # Copyright © 2019 Université de Genève, LMU Munich - Faculty of Physics, IAP-CNRS/Sorbonne Université
4 #
5 # This library is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; either version 3.0 of the License, or (at your option)
8 # any later version.
9 #
10 # This library is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 # details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this library; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 from __future__ import division, print_function
19 
20 import os
21 import re
22 import sys
23 
24 from astropy.io import fits
25 
26 import _SourceXtractorPy as cpp
27 
28 if sys.version_info.major < 3:
29  from StringIO import StringIO
30 else:
31  from io import StringIO
32 
33 
34 measurement_images = {}
35 
36 
37 class MeasurementImage(cpp.MeasurementImage):
38  """
39  A MeasurementImage is the processing unit for SourceXtractor++. Measurements and model fitting can be done
40  over one, or many, of them. It models the image, plus its associated weight file, PSF, etc.
41 
42  Parameters
43  ----------
44  fits_file : str
45  The path to a FITS image. Only primary HDU images are supported.
46  psf_file : str
47  The path to a PSF. It can be either a FITS image, or a PSFEx model.
48  weight_file : str
49  The path to a FITS image with the pixel weights.
50  gain : float
51  Image gain. If None, `gain_keyword` will be used instead.
52  gain_keyword : str
53  Keyword for the header containing the gain.
54  saturation : float
55  Saturation value. If None, `saturation_keyword` will be used instead.
56  saturation_keyword : str
57  Keyword for the header containing the saturation value.
58  flux_scale : float
59  Flux scaling. Each pixel value will be multiplied by this. If None, `flux_scale_keyword` will be used
60  instead.
61  flux_scale_keyword : str
62  Keyword for the header containing the flux scaling.
63  weight_type : str
64  The type of the weight image. It must be one of:
65 
66  - none
67  The image itself is used to compute internally a constant variance (default)
68  - background
69  The image itself is used to compute internally a variance map
70  - rms
71  The weight image must contain a weight-map in units of absolute standard deviations
72  (in ADUs per pixel).
73  - variance
74  The weight image must contain a weight-map in units of relative variance.
75  - weight
76  The weight image must contain a weight-map in units of relative weights. The data are converted
77  to variance units.
78  weight_absolute : bool
79  If False, the weight map will be scaled according to an absolute variance map built from the image itself.
80  weight_scaling : float
81  Apply an scaling to the weight map.
82  weight_threshold : float
83  Pixels with weights beyond this value are treated just like pixels discarded by the masking process.
84  constant_background : float
85  If set a constant background of that value is assumed for the image instead of using automatic detection
86  image_hdu : int
87  For multi-extension FITS file specifies the HDU number for the image. Default 1 (primary HDU)
88  psf_hdu : int
89  For multi-extension FITS file specifies the HDU number for the psf. Defaults to the same value as image_hdu
90  weight_hdu : int
91  For multi-extension FITS file specifies the HDU number for the weight. Defaults to the same value as image_hdu
92  """
93 
94  def __init__(self, fits_file, psf_file=None, weight_file=None, gain=None,
95  gain_keyword='GAIN', saturation=None, saturation_keyword='SATURATE',
96  flux_scale=None, flux_scale_keyword='FLXSCALE',
97  weight_type='none', weight_absolute=False, weight_scaling=1.,
98  weight_threshold=None, constant_background=None,
99  image_hdu=1, psf_hdu=None, weight_hdu=None
100  ):
101  """
102  Constructor.
103  """
104  super(MeasurementImage, self).__init__(os.path.abspath(fits_file),
105  os.path.abspath(psf_file) if psf_file else '',
106  os.path.abspath(weight_file) if weight_file else '')
107 
108  if image_hdu <= 0 or (weight_hdu is not None and weight_hdu <= 0) or (psf_hdu is not None and psf_hdu <= 0):
109  raise ValueError('HDU indexes start at 1')
110 
111  self.meta = {
112  'IMAGE_FILENAME': self.file,
113  'PSF_FILENAME': self.psf_file,
114  'WEIGHT_FILENAME': self.weight_file
115  }
116  hdu_list = fits.open(fits_file)
117  hdu_meta = hdu_list[image_hdu-1].header
118  for key in hdu_meta:
119  self.meta[key] = hdu_meta[key]
120 
121  self._load_header_file(fits_file, image_hdu)
122 
123  if gain is not None:
124  self.gain = gain
125  elif gain_keyword in self.meta:
126  self.gain = float(self.meta[gain_keyword])
127  else:
128  self.gain = 0.
129 
130  if saturation is not None:
131  self.saturation = saturation
132  elif saturation_keyword in self.meta:
133  self.saturation = float(self.meta[saturation_keyword])
134  else:
135  self.saturation = 0.
136 
137  if flux_scale is not None:
138  self.flux_scale = flux_scale
139  elif flux_scale_keyword in self.meta:
140  self.flux_scale = float(self.meta[flux_scale_keyword])
141  else:
142  self.flux_scale = 1.
143 
144  self.weight_type = weight_type
145  self.weight_absolute = weight_absolute
146  self.weight_scaling = weight_scaling
147  if weight_threshold is None:
148  self.has_weight_threshold = False
149  else:
150  self.has_weight_threshold = True
151  self.weight_threshold = weight_threshold
152 
153  if constant_background is not None:
154  self.is_background_constant = True
155  self.constant_background_value = constant_background
156  else:
157  self.is_background_constant = False
159 
160 
161  self.image_hdu = image_hdu
162 
163  if psf_hdu is None:
164  self.psf_hdu = image_hdu
165  else:
166  self.psf_hdu = psf_hdu
167 
168  if weight_hdu is None:
169  self.weight_hdu = image_hdu
170  else:
171  self.weight_hdu = weight_hdu
172 
173  global measurement_images
174  measurement_images[self.id] = self
175 
176  # overrides the FITS headers using an ascii .head file if it can be found
177  def _load_header_file(self, filename, hdu):
178  pre, ext = os.path.splitext(filename)
179  header_file = pre + ".head"
180  current_hdu = 1
181 
182  if os.path.exists(header_file):
183  print("processing ascii header file: " + header_file)
184 
185  with open(header_file) as f:
186  for line in f:
187  line = re.sub("\\s*#.*", "", line)
188  line = re.sub("\\s*$", "", line)
189 
190  if line == "":
191  continue
192 
193  if line.upper() == "END":
194  current_hdu += 1
195  elif current_hdu == hdu:
196  m = re.match("(.+)=(.+)", line)
197  if m:
198  self.meta[m.group(1)] = m.group(2)
199 
200  def __str__(self):
201  """
202  Returns
203  -------
204  str
205  Human readable representation for the object
206  """
207  return 'Image {}: {} / {}, PSF: {} / {}, Weight: {} / {}'.format(
208  self.id, self.meta['IMAGE_FILENAME'], self.image_hdu, self.meta['PSF_FILENAME'], self.psf_hdu,
209  self.meta['WEIGHT_FILENAME'], self.weight_hdu)
210 
211 
212 def print_measurement_images(file=sys.stderr):
213  """
214  Print a human-readable representation of the configured measurement images.
215 
216  Parameters
217  ----------
218  file : file object
219  Where to print the representation. Defaults to sys.stderr
220  """
221  print('Measurement images:', file=file)
222  for i in measurement_images:
223  im = measurement_images[i]
224  print('Image {}'.format(i), file=file)
225  print(' File: {}'.format(im.file), file=file)
226  print(' PSF: {}'.format(im.psf_file), file=file)
227  print(' Weight: {}'.format(im.weight_file), file=file)
228 
229 
230 class ImageGroup(object):
231  """
232  Models the grouping of images. Measurement can *not* be made directly on instances of this type.
233  The configuration must be "frozen" before creating a MeasurementGroup
234 
235  See Also
236  --------
237  MeasurementGroup
238  """
239 
240  def __init__(self, **kwargs):
241  """
242  Constructor. It is not recommended to be used directly. Use instead load_fits_image or load_fits_images.
243  """
244  self.__images = []
245  self.__subgroups = None
246  self.__subgroup_names = set()
247  if len(kwargs) != 1 or ('images' not in kwargs and 'subgroups' not in kwargs):
248  raise ValueError('ImageGroup only takes as parameter one of "images" or "subgroups"')
249  key = list(kwargs.keys())[0]
250  if key == 'images':
251  if isinstance(kwargs[key], list):
252  self.__images = kwargs[key]
253  else:
254  self.__images = [kwargs[key]]
255  if key == 'subgroups':
256  self.__subgroups = kwargs[key]
257  for name, _ in self.__subgroups:
258  self.__subgroup_names.add(name)
259 
260  def __len__(self):
261  """
262  See Also
263  --------
264  is_leaf
265 
266  Returns
267  -------
268  int
269  How may subgroups or images are there in this group
270  """
271  if self.__subgroups:
272  return len(self.__subgroups)
273  else:
274  return len(self.__images)
275 
276  def __iter__(self):
277  """
278  Allows to iterate on the contained subgroups or images
279 
280  See Also
281  --------
282  is_leaf
283 
284  Returns
285  -------
286  iterator
287  """
288  if self.__subgroups:
289  return self.__subgroups.__iter__()
290  else:
291  return self.__images.__iter__()
292 
293  def split(self, grouping_method):
294  """
295  Splits the group in various subgroups, applying a filter on the contained images. If the group has
296  already been split, applies the split to each subgroup.
297 
298  Parameters
299  ----------
300  grouping_method : callable
301  A callable that receives as a parameter the list of contained images, and returns
302  a list of tuples, with the grouping key value, and the list of grouped images belonging to the given key.
303 
304  See Also
305  --------
306  ByKeyword
307  ByPattern
308 
309  Raises
310  -------
311  ValueError
312  If some images have not been grouped by the callable.
313  """
314  if self.__subgroups:
315  #if we are already subgrouped, apply the split to the subgroups
316  for _, sub_group in self.__subgroups:
317  sub_group.split(grouping_method)
318  else:
319  subgrouped_images = grouping_method(self.__images)
320  if sum(len(p[1]) for p in subgrouped_images) != len(self.__images):
321  self.__subgroups = None
322  raise ValueError('Some images were not grouped')
323  self.__subgroups = []
324  for k, im_list in subgrouped_images:
325  assert k not in self.__subgroup_names
326  self.__subgroup_names.add(k)
327  self.__subgroups.append((k, ImageGroup(images=im_list)))
328  self.__images = []
329 
330  def add_images(self, images):
331  """
332  Add new images to the group.
333 
334  Parameters
335  ----------
336  images : list of, or a single, MeasurementImage
337 
338  Raises
339  ------
340  ValueError
341  If the group has been split, no new images can be added.
342  """
343  if self.__subgroups is not None:
344  raise ValueError('ImageGroup is already subgrouped')
345  if isinstance(images, MeasurementImage):
346  self.__images.append(images)
347  else:
348  self.__images.extend(images)
349 
350  def add_subgroup(self, name, group):
351  """
352  Add a subgroup to a group.
353 
354  Parameters
355  ----------
356  name : str
357  The new of the new group
358 
359  group : ImageGroup
360  """
361  if self.__subgroups is None:
362  raise Exception('ImageGroup is not subgrouped yet')
363  if name in self.__subgroup_names:
364  raise Exception('Subgroup {} alread exists'.format(name))
365  self.__subgroup_names.add(name)
366  self.__subgroups.append((name, group))
367 
368  def is_leaf(self):
369  """
370  Returns
371  -------
372  bool
373  True if the group is a leaf group
374  """
375  return self.__subgroups is None
376 
377  def __getitem__(self, name):
378  """
379  Get a subgroup.
380 
381  Parameters
382  ----------
383  name : str
384  The name of the subgroup.
385 
386  Returns
387  -------
388  ImageGroup
389  The matching group.
390 
391  Raises
392  ------
393  ValueError
394  If the group has not been split.
395  KeyError
396  If the group has not been found.
397  """
398  if self.__subgroups is None:
399  raise ValueError('ImageGroup is not subgrouped yet')
400  try:
401  return next(x for x in self.__subgroups if x[0] == name)[1]
402  except StopIteration:
403  raise KeyError('Group {} not found'.format(name))
404 
405  def print(self, prefix='', show_images=False, file=sys.stderr):
406  """
407  Print a human-readable representation of the group.
408 
409  Parameters
410  ----------
411  prefix : str
412  Print each line with this prefix. Used internally for indentation.
413  show_images : bool
414  Show the images belonging to a leaf group.
415  file : file object
416  Where to print the representation. Defaults to sys.stderr
417  """
418  if self.__subgroups is None:
419  print('{}Image List ({})'.format(prefix, len(self.__images)), file=file)
420  if show_images:
421  for im in self.__images:
422  print('{} {}'.format(prefix, im), file=file)
423  else:
424  print('{}Image sub-groups: {}'.format(prefix, ','.join(str(x) for x, _ in self.__subgroups)), file=file)
425  for name, group in self.__subgroups:
426  print('{} {}:'.format(prefix, name), file=file)
427  group.print(prefix + ' ', show_images, file)
428 
429  def __str__(self):
430  """
431  Returns
432  -------
433  str
434  A human-readable representation of the group
435  """
436  string = StringIO()
437  self.print(show_images=True, file=string)
438  return string.getvalue()
439 
440 
441 class ImageCacheEntry(object):
442  def __init__(self, image, kwargs):
443  self.image = image
444  self.kwargs = kwargs
445 
446  def match_kwargs(self, kwargs):
447  mismatch = []
448  for key, value in kwargs.items():
449  if key not in self.kwargs:
450  mismatch.append('{} {} != undefined'.format(key, value))
451  elif self.kwargs[key] != value:
452  mismatch.append('{} {} != {}'.format(key, value, self.kwargs[key]))
453  return mismatch
454 
455 _image_cache = {}
456 
457 def load_fits_image(image, psf=None, weight=None, **kwargs):
458  """Creates an image group with the images of a (possibly multi-HDU) single FITS file.
459 
460  If image is multi-hdu, psf and weight can either be multi hdu or lists of individual files.
461 
462  In any case, they are matched in order and HDUs not containing images (two dimensional arrays) are ignored.
463 
464  :param image: The FITS file containing the image(s)
465  :param psf: psf file or list of psf files
466  :param weight: FITS file for the weight image or a list of such files
467 
468  :return: A ImageGroup representing the images
469  """
470 
471  hdu_list = [i for i, hdu in enumerate(fits.open(image)) if hdu.is_image and hdu.header['NAXIS'] == 2]
472 
473  # handles the PSFs
474  if isinstance(psf, list):
475  if len(psf) != len(hdu_list):
476  raise ValueError("The number of psf files must match the number of images!")
477  psf_list = psf
478  psf_hdu_list = [0] * len(psf_list)
479  else:
480  psf_list = [psf] * len(hdu_list)
481  psf_hdu_list = range(len(hdu_list))
482 
483  # handles the weight maps
484  if isinstance(weight, list):
485  if len(weight) != len(hdu_list):
486  raise ValueError("The number of weight files must match the number of images!")
487  weight_list = weight
488  weight_hdu_list = [0] * len(weight_list)
489  else:
490  if weight is None:
491  weight_list = [None] * len(hdu_list)
492  weight_hdu_list = [0] * len(weight_list)
493  else:
494  weight_hdu_list = [i for i, hdu in enumerate(fits.open(weight)) if hdu.is_image and hdu.header['NAXIS'] == 2]
495  weight_list = [weight] * len(hdu_list)
496 
497  image_list = []
498  for hdu, psf_file, psf_hdu, weight_file, weight_hdu in zip(
499  hdu_list, psf_list, psf_hdu_list, weight_list, weight_hdu_list):
500  image_list.append(MeasurementImage(image, psf_file, weight_file,
501  image_hdu=hdu+1, psf_hdu=psf_hdu+1, weight_hdu=weight_hdu+1, **kwargs))
502 
503  return ImageGroup(images=image_list)
504 
505 def load_fits_images(images, psfs=None, weights=None, **kwargs):
506  """Creates an image group for the given images.
507 
508  Parameters
509  ----------
510  images : list of str
511  A list of relative paths to the images FITS files. Can also be single string in which case,
512  this function acts like load_fits_image
513  psfs : list of str
514  A list of relative paths to the PSF FITS files (optional). It must match the length of image_list or be None.
515  weights : list of str
516  A list of relative paths to the weight files (optional). It must match the length of image_list or be None.
517 
518  Returns
519  -------
520  ImageGroup
521  A ImageGroup representing the images
522 
523  Raises
524  ------
525  ValueError
526  In case of mismatched list of files
527  """
528 
529  if isinstance(images, list):
530  if len(images) == 0:
531  raise ValueError("An empty list passed to load_fits_images")
532 
533  psfs = psfs or [None] * len(images)
534  weights = weights or [None] * len(images)
535 
536  if not isinstance(psfs, list) or len(psfs) != len(images):
537  raise ValueError("The number of image files and psf files must match!")
538 
539  if not isinstance(weights, list) or len(weights) != len(images):
540  raise ValueError("The number of image files and weight files must match!")
541 
542  groups = []
543  for f, p, w in zip(images, psfs, weights):
544  groups.append(load_fits_image(f, p, w, **kwargs))
545 
546  image_list = []
547  for g in groups:
548  image_list += g
549 
550  return ImageGroup(images=image_list)
551  else:
552  load_fits_image(images, psfs, weights, **kwargs)
553 
554 class ByKeyword(object):
555  """
556  Callable that can be used to split an ImageGroup by a keyword value (i.e. FILTER).
557 
558  Parameters
559  ----------
560  key : str
561  FITS header keyword (i.e. FILTER)
562 
563  See Also
564  --------
565  ImageGroup.split
566  """
567 
568  def __init__(self, key):
569  """
570  Constructor.
571  """
572  self.__key = key
573 
574  def __call__(self, images):
575  """
576  Parameters
577  ----------
578  images : list of MeasurementImage
579  List of images to group
580 
581  Returns
582  -------
583  list of tuples of str and list of MeasurementImage
584  i.e. [
585  (R, [frame_r_01.fits, frame_r_02.fits]),
586  (G, [frame_g_01.fits, frame_g_02.fits])
587  ]
588  """
589  result = {}
590  for im in images:
591  if self.__key not in im.meta:
592  raise KeyError('The image {}[{}] does not contain the key {}'.format(
593  im.meta['IMAGE_FILENAME'], im.image_hdu, self.__key
594  ))
595  if im.meta[self.__key] not in result:
596  result[im.meta[self.__key]] = []
597  result[im.meta[self.__key]].append(im)
598  return [(k, result[k]) for k in result]
599 
600 
601 class ByPattern(object):
602  """
603  Callable that can be used to split an ImageGroup by a keyword value (i.e. FILTER), applying a regular
604  expression and using the first matching group as key.
605 
606  Parameters
607  ----------
608  key : str
609  FITS header keyword
610  pattern : str
611  Regular expression. The first matching group will be used as grouping key.
612 
613  See Also
614  --------
615  ImageGroup.split
616  """
617 
618  def __init__(self, key, pattern):
619  """
620  Constructor.
621  """
622  self.__key = key
623  self.__pattern = pattern
624 
625  def __call__(self, images):
626  """
627  Parameters
628  ----------
629  images : list of MeasurementImage
630  List of images to group
631 
632  Returns
633  -------
634  list of tuples of str and list of MeasurementImage
635  """
636  result = {}
637  for im in images:
638  if self.__key not in im.meta:
639  raise KeyError('The image {}[{}] does not contain the key {}'.format(
640  im.meta['IMAGE_FILENAME'], im.image_hdu, self.__key
641  ))
642  group = re.match(self.__pattern, im.meta[self.__key]).group(1)
643  if group not in result:
644  result[group] = []
645  result[group].append(im)
646  return [(k, result[k]) for k in result]
647 
648 
649 class MeasurementGroup(object):
650  """
651  Once an instance of this class is created from an ImageGroup, its configuration is "frozen". i.e.
652  no new images can be added, or no new grouping applied.
653 
654  Parameters
655  ----------
656  image_group : ImageGroup
657  """
658 
659  _all_groups = list()
660 
661  def __init__(self, image_group, is_subgroup=False):
662  """
663  Constructor.
664  """
665  self.__images = None
666  self.__subgroups = None
667  if image_group.is_leaf():
668  self.__images = [im for im in image_group]
669  else:
670  self.__subgroups = [(n, MeasurementGroup(g, is_subgroup=True)) for n,g in image_group]
671  if not is_subgroup:
672  MeasurementGroup._all_groups.append(self)
673 
674  def __iter__(self):
675  """
676  Returns
677  -------
678  iterator
679  """
680  if self.__subgroups:
681  return self.__subgroups.__iter__()
682  else:
683  return self.__images.__iter__()
684 
685  def __getitem__(self, index):
686  """
687  The subgroup with the given name or image with the given index depending on whether this is a leaf group.
688 
689  Parameters
690  ----------
691  index : str or int
692  Subgroup name or image index
693 
694  Returns
695  -------
696  MeasurementGroup or MeasurementImage
697 
698  Raises
699  ------
700  KeyError
701  If we can't find what we want
702  """
703 
704  if self.__subgroups:
705  try:
706  return next(x for x in self.__subgroups if x[0] == index)[1]
707  except StopIteration:
708  raise KeyError('Group {} not found'.format(index))
709  else:
710  try:
711  return self.__images[index]
712  except:
713  raise KeyError('Image #{} not found'.format(index))
714 
715  def __len__(self):
716  """
717  Returns
718  -------
719  int
720  Number of subgroups, or images contained within the group
721  """
722  if self.__subgroups:
723  return len(self.__subgroups)
724  else:
725  return len(self.__images)
726 
727  def is_leaf(self):
728  """
729  Returns
730  -------
731  bool
732  True if the group is a leaf group
733  """
734  return self.__subgroups is None
735 
736  def print(self, prefix='', show_images=False, file=sys.stderr):
737  """
738  Print a human-readable representation of the group.
739 
740  Parameters
741  ----------
742  prefix : str
743  Print each line with this prefix. Used internally for indentation.
744  show_images : bool
745  Show the images belonging to a leaf group.
746  file : file object
747  Where to print the representation. Defaults to sys.stderr
748  """
749  if self.__images:
750  print('{}Image List ({})'.format(prefix, len(self.__images)), file=file)
751  if show_images:
752  for im in self.__images:
753  print('{} {}'.format(prefix, im), file=file)
754  if self.__subgroups:
755  print('{}Measurement sub-groups: {}'.format(prefix, ','.join(
756  x for x, _ in self.__subgroups)), file=file)
757  for name, group in self.__subgroups:
758  print('{} {}:'.format(prefix, name), file=file)
759  group.print(prefix + ' ', show_images, file=file)
760 
761  def __str__(self):
762  """
763  Returns
764  -------
765  str
766  A human-readable representation of the group
767  """
768  string = StringIO()
769  self.print(show_images=True, file=string)
770  return string.getvalue()
sourcextractor.config.measurement_images.ImageGroup.add_subgroup
def add_subgroup(self, name, group)
Definition: measurement_images.py:350
sourcextractor.config.measurement_images.ImageGroup.__getitem__
def __getitem__(self, name)
Definition: measurement_images.py:377
sourcextractor.config.measurement_images.ByPattern.__key
__key
Definition: measurement_images.py:622
sourcextractor.config.measurement_images.ImageGroup.__subgroup_names
__subgroup_names
Definition: measurement_images.py:246
sourcextractor.config.measurement_images.ByPattern.__call__
def __call__(self, images)
Definition: measurement_images.py:625
sourcextractor.config.measurement_images.ImageGroup.add_images
def add_images(self, images)
Definition: measurement_images.py:330
sourcextractor.config.measurement_images.ImageCacheEntry.image
image
Definition: measurement_images.py:443
sourcextractor.config.measurement_images.ImageGroup.__subgroups
__subgroups
Definition: measurement_images.py:245
sourcextractor.config.measurement_images.MeasurementImage.psf_hdu
psf_hdu
Definition: measurement_images.py:158
sourcextractor.config.measurement_images.MeasurementGroup.__subgroups
__subgroups
Definition: measurement_images.py:666
sourcextractor.config.measurement_images.print_measurement_images
def print_measurement_images(file=sys.stderr)
Definition: measurement_images.py:212
sourcextractor.config.measurement_images.ImageGroup.is_leaf
def is_leaf(self)
Definition: measurement_images.py:368
sourcextractor.config.measurement_images.ImageCacheEntry
Definition: measurement_images.py:441
sourcextractor.config.measurement_images.MeasurementImage.weight_hdu
weight_hdu
Definition: measurement_images.py:163
sourcextractor.config.measurement_images.MeasurementImage.weight_threshold
weight_threshold
Definition: measurement_images.py:145
sourcextractor.config.measurement_images.ImageGroup.print
def print(self, prefix='', show_images=False, file=sys.stderr)
Definition: measurement_images.py:405
sourcextractor.config.measurement_images.MeasurementGroup
Definition: measurement_images.py:649
sourcextractor.config.measurement_images.ByKeyword.__init__
def __init__(self, key)
Definition: measurement_images.py:568
sourcextractor.config.measurement_images.MeasurementImage.is_background_constant
is_background_constant
Definition: measurement_images.py:148
sourcextractor.config.measurement_images.MeasurementImage.__str__
def __str__(self)
Definition: measurement_images.py:200
sourcextractor.config.measurement_images.MeasurementGroup.__init__
def __init__(self, image_group, is_subgroup=False)
Definition: measurement_images.py:661
sourcextractor.config.measurement_images.MeasurementImage.has_weight_threshold
has_weight_threshold
Definition: measurement_images.py:142
sourcextractor.config.measurement_images.MeasurementImage.meta
meta
Definition: measurement_images.py:105
sourcextractor.config.measurement_images.MeasurementGroup.__len__
def __len__(self)
Definition: measurement_images.py:715
sourcextractor.config.measurement_images.MeasurementImage.__init__
def __init__(self, fits_file, psf_file=None, weight_file=None, gain=None, gain_keyword='GAIN', saturation=None, saturation_keyword='SATURATE', flux_scale=None, flux_scale_keyword='FLXSCALE', weight_type='none', weight_absolute=False, weight_scaling=1., weight_threshold=None, constant_background=None, image_hdu=1, psf_hdu=None, weight_hdu=None)
Definition: measurement_images.py:94
sourcextractor.config.measurement_images.MeasurementGroup.print
def print(self, prefix='', show_images=False, file=sys.stderr)
Definition: measurement_images.py:736
sourcextractor.config.measurement_images.MeasurementImage.constant_background_value
constant_background_value
Definition: measurement_images.py:149
sourcextractor.config.measurement_images.MeasurementImage.image_hdu
image_hdu
Definition: measurement_images.py:155
sourcextractor.config.measurement_images.MeasurementGroup.__getitem__
def __getitem__(self, index)
Definition: measurement_images.py:685
sourcextractor.config.measurement_images.ByKeyword
Definition: measurement_images.py:554
sourcextractor.config.measurement_images.ByKeyword.__key
__key
Definition: measurement_images.py:572
sourcextractor.config.measurement_images.ImageGroup.__init__
def __init__(self, **kwargs)
Definition: measurement_images.py:240
sourcextractor.config.measurement_images.MeasurementImage.saturation
saturation
Definition: measurement_images.py:125
sourcextractor.config.measurement_images.ImageGroup.__images
__images
Definition: measurement_images.py:244
sourcextractor.config.measurement_images.ImageGroup.__str__
def __str__(self)
Definition: measurement_images.py:429
sourcextractor.config.measurement_images.MeasurementImage._load_header_file
def _load_header_file(self, filename, hdu)
Definition: measurement_images.py:177
sourcextractor.config.measurement_images.MeasurementImage
Definition: measurement_images.py:37
sourcextractor.config.measurement_images.MeasurementGroup.__str__
def __str__(self)
Definition: measurement_images.py:761
sourcextractor.config.measurement_images.ImageGroup
Definition: measurement_images.py:230
sourcextractor.config.measurement_images.MeasurementImage.flux_scale
flux_scale
Definition: measurement_images.py:132
sourcextractor.config.measurement_images.load_fits_image
def load_fits_image(image, psf=None, weight=None, **kwargs)
Definition: measurement_images.py:457
sourcextractor.config.measurement_images.ByPattern.__pattern
__pattern
Definition: measurement_images.py:623
sourcextractor.config.measurement_images.MeasurementImage.weight_scaling
weight_scaling
Definition: measurement_images.py:140
sourcextractor.config.measurement_images.ByKeyword.__call__
def __call__(self, images)
Definition: measurement_images.py:574
sourcextractor.config.measurement_images.ImageCacheEntry.kwargs
kwargs
Definition: measurement_images.py:444
sourcextractor.config.measurement_images.MeasurementImage.weight_type
weight_type
Definition: measurement_images.py:138
sourcextractor.config.measurement_images.ImageGroup.__iter__
def __iter__(self)
Definition: measurement_images.py:276
sourcextractor.config.measurement_images.ImageGroup.__len__
def __len__(self)
Definition: measurement_images.py:260
sourcextractor.config.measurement_images.ImageGroup.split
def split(self, grouping_method)
Definition: measurement_images.py:293
sourcextractor.config.measurement_images.ByPattern
Definition: measurement_images.py:601
sourcextractor.config.measurement_images.ImageCacheEntry.__init__
def __init__(self, image, kwargs)
Definition: measurement_images.py:442
sourcextractor.config.measurement_images.MeasurementImage.weight_absolute
weight_absolute
Definition: measurement_images.py:139
sourcextractor.config.measurement_images.ImageCacheEntry.match_kwargs
def match_kwargs(self, kwargs)
Definition: measurement_images.py:446
sourcextractor.config.measurement_images.MeasurementGroup.__images
__images
Definition: measurement_images.py:665
sourcextractor.config.measurement_images.MeasurementGroup.__iter__
def __iter__(self)
Definition: measurement_images.py:674
sourcextractor.config.measurement_images.ByPattern.__init__
def __init__(self, key, pattern)
Definition: measurement_images.py:618
sourcextractor.config.measurement_images.load_fits_images
def load_fits_images(images, psfs=None, weights=None, **kwargs)
Definition: measurement_images.py:505
sourcextractor.config.measurement_images.MeasurementImage.gain
gain
Definition: measurement_images.py:118
sourcextractor.config.measurement_images.MeasurementGroup.is_leaf
def is_leaf(self)
Definition: measurement_images.py:727