GalSim  2.0
The modular galaxy image simulation toolkit
Public Member Functions | Public Attributes | List of all members
galsim.real.RealGalaxyCatalog Class Reference

Class containing a catalog with information about real galaxy training data. More...

Public Member Functions

def __init__ (self, file_name=None, sample=None, dir=None, preload=False, logger=None, _nobjects_only=False)
def __del__ (self)
def close (self)
def getNObjects (self)
def __len__ (self)
def getFileName (self)
def getIndexForID (self, id)
 Internal function to find which index number corresponds to the value ID in the ident field. More...
def preload (self)
 Preload the files into memory. More...
def getBandpass (self)
 Returns a Bandpass object for the catalog. More...
def getGalImage (self, i)
 Returns the galaxy at index i as an Image object. More...
def getPSFImage (self, i)
 Returns the PSF at index i as an Image object. More...
def getPSF (self, i, x_interpolant=None, k_interpolant=None, gsparams=None)
 Returns the PSF at index i as a GSObject. More...
def getNoiseProperties (self, i)
 Returns the components needed to make the noise correlation function at index i. More...
def getNoise (self, i, rng=None, gsparams=None)
 Returns the noise correlation function at index i as a CorrelatedNoise object. More...
def __repr__ (self)
def __eq__ (self, other)
def __ne__ (self, other)
def __hash__ (self)
def __getstate__ (self)
def __setstate__ (self, d)

Public Attributes


Detailed Description

Class containing a catalog with information about real galaxy training data.

The RealGalaxyCatalog class reads in and stores information about a specific training sample of realistic galaxies. We assume that all files containing the images (galaxies and PSFs) live in one directory; they could be individual files, or multiple HDUs of the same file. Currently there is no functionality that lets this be a FITS data cube, because we assume that the object postage stamps will in general need to be different sizes depending on the galaxy size.

Note that when simulating galaxies based on HST but using either realistic or parametric galaxy models, the COSMOSCatalog class may be more useful. It allows the imposition of selection criteria and other subtleties that are more difficult to impose with RealGalaxyCatalog.

While you could create your own catalog to use with this class, the typical use cases would be to use one of the catalogs that we have created and distributed. There are three such catalogs currently, which can be use with one of the following initializations:

  1. A small example catalog is distributed with the GalSim distribution. This catalog only has 100 galaxies, so it is not terribly useful as a representative galaxy population. But for simplistic use cases, it might be sufficient. We use it for our unit tests and in some of the demo scripts (demo6, demo10, and demo11). To use this catalog, you would initialize with
    >>> rgc = galsim.RealGalaxyCatalog('real_galaxy_catalog_23.5_example.fits',
  2. There are two larger catalogs based on HST observations of the COSMOS field with around 26,000 and 56,000 galaxies each with a limiting magnitude of F814W=23.5. (The former is a subset of the latter.) For information about how to download these catalogs, see the RealGalaxy Data Download Page on the GalSim Wiki:

    Be warned that the catalogs are quite large. The larger one is around 11 GB after unpacking the tarball. To use one of these catalogs, you would initialize with

    >>> rgc = galsim.RealGalaxyCatalog('real_galaxy_catalog_23.5.fits',
  3. There is a catalog containing a random subsample of the HST COSMOS images with a limiting magnitude of F814W=25.2. More information about downloading these catalogs can be found on the RealGalaxy Data Download page linked above.
  4. Finally, we provide a program that will download the large COSMOS sample for you and put it in the $PREFIX/share/galsim directory of your installation path. The program is


    which gets installed in the $PREFIX/bin directory when you install GalSim. If you use this program to download the COSMOS catalog, then you can use it with

    >>> rgc = galsim.RealGalaxyCatalog()

    GalSim knows the location of the installation share directory, so it will automatically look for it there.

file_nameThe file containing the catalog. [default: None, which will look for the F814W<25.2 COSMOS catalog in $PREFIX/share/galsim. It will raise an exception if the catalog is not there telling you to run galsim_download_cosmos.]
sampleA keyword argument that can be used to specify the sample to use, i.e., "23.5" or "25.2". At most one of file_name and sample should be specified. [default: None, which results in the same default as file_name=None.]
dirThe directory containing the catalog, image, and noise files, or symlinks to them. [default: None]
preloadWhether to preload the header information. If preload=True, the bulk of the I/O time is in the constructor. If preload=False, there is approximately the same total I/O time (assuming you eventually use most of the image files referenced in the catalog), but it is spread over the various calls to getGalImage() and getPSFImage(). [default: False]
loggerAn optional logger object to log progress. [default: None]

Constructor & Destructor Documentation

◆ __init__()

def galsim.real.RealGalaxyCatalog.__init__ (   self,
  file_name = None,
  sample = None,
  dir = None,
  preload = False,
  logger = None,
  _nobjects_only = False 

◆ __del__()

def galsim.real.RealGalaxyCatalog.__del__ (   self)

Member Function Documentation

◆ __eq__()

def galsim.real.RealGalaxyCatalog.__eq__ (   self,

◆ __getstate__()

def galsim.real.RealGalaxyCatalog.__getstate__ (   self)

◆ __hash__()

def galsim.real.RealGalaxyCatalog.__hash__ (   self)

◆ __len__()

def galsim.real.RealGalaxyCatalog.__len__ (   self)

◆ __ne__()

def galsim.real.RealGalaxyCatalog.__ne__ (   self,

◆ __repr__()

def galsim.real.RealGalaxyCatalog.__repr__ (   self)

◆ __setstate__()

def galsim.real.RealGalaxyCatalog.__setstate__ (   self,

◆ close()

def galsim.real.RealGalaxyCatalog.close (   self)

◆ getBandpass()

def galsim.real.RealGalaxyCatalog.getBandpass (   self)

Returns a Bandpass object for the catalog.

◆ getFileName()

def galsim.real.RealGalaxyCatalog.getFileName (   self)

◆ getGalImage()

def galsim.real.RealGalaxyCatalog.getGalImage (   self,

Returns the galaxy at index i as an Image object.

◆ getIndexForID()

def galsim.real.RealGalaxyCatalog.getIndexForID (   self,

Internal function to find which index number corresponds to the value ID in the ident field.

◆ getNObjects()

def galsim.real.RealGalaxyCatalog.getNObjects (   self)

◆ getNoise()

def galsim.real.RealGalaxyCatalog.getNoise (   self,
  rng = None,
  gsparams = None 

Returns the noise correlation function at index i as a CorrelatedNoise object.

Note: the return value from this function is not picklable, so this cannot be used across processes.

◆ getNoiseProperties()

def galsim.real.RealGalaxyCatalog.getNoiseProperties (   self,

Returns the components needed to make the noise correlation function at index i.

Specifically, the noise image (or None), the pixel_scale, and the noise variance, as a tuple (im, scale, var).

◆ getPSF()

def galsim.real.RealGalaxyCatalog.getPSF (   self,
  x_interpolant = None,
  k_interpolant = None,
  gsparams = None 

Returns the PSF at index i as a GSObject.

◆ getPSFImage()

def galsim.real.RealGalaxyCatalog.getPSFImage (   self,

Returns the PSF at index i as an Image object.

◆ preload()

def galsim.real.RealGalaxyCatalog.preload (   self)

Preload the files into memory.

There are memory implications to this, so we don't do this by default. However, it can be a big speedup if memory isn't an issue.

Member Data Documentation

◆ band

◆ cat

◆ file_name


◆ gal_file_name


◆ gal_hdu


◆ gal_lock


◆ ident


◆ image_dir


◆ loaded_files


◆ loaded_lock


◆ logger


◆ mag


◆ nobjects


◆ noise_file_name


◆ noise_lock


◆ pixel_scale


◆ psf_file_name


◆ psf_hdu


◆ psf_lock


◆ sample


◆ saved_noise_im


◆ stamp_flux


◆ variance


◆ weight


The documentation for this class was generated from the following file: