ImageCollection

class snappl.imagecollection.ImageCollection[source]

Bases: object

A class that keeps track of groups of images.

Never instantiate an object of this class of its subclasses directly. Call the get_collection() class method go get your image collection.

Available properties include:

base_path : pathlib.Path ; image paths are relative to this absolute path.

Methods Summary

find_images(**kwargs)

Find images.

get_collection([collection, subset, ...])

Get an ImageCollection object.

get_image([image_id, path, observation_id, ...])

Return an object of a subclass of Image based on input parameters.

get_image_path(observation_id, band, sca[, ...])

Return the absolute path to the desired image, if that makes sense.

Methods Documentation

find_images(**kwargs)[source]

Find images.

Note: if you’re using the ‘snpitdb’ image collection, this is the same as using the class method Image.find_images. See the docstring there.

Parameters:
  • path (pathlib.Path or str, default None) – Relative path of the image to search for. Usually if you feed it this, you don’t want to feed it nay other parameters.

  • mjd_min (float, default None) – Only return images at this mjd or later

  • mjd_max (float, default None) – Only return images at this mjd or earlier.

  • ra (float, default None) – Only return images that contain this ra

  • dec (float, default None) – Only return images that containe this dec

  • band (str, default None) – Only include images from this band

  • exptime_min (float, default None) – Only include images with at least this exptime in seconds.

  • exptime_max (float, default None) – Only include images with at most this exptime in seconds.

  • sca (int) – Only include images from this sca.

  • order_by (str or list, default None) – By default, the returned images are not sorted in any particular way. Put a keyword here to sort by that value (or by those values). Options include ‘id’, ‘provenance_id’, ‘observation_id’, ‘sca’, ‘ra’, ‘dec’, ‘filepath’, ‘width’, ‘height’, ‘mjd’, ‘exptime’. Not all of these are necessarily useful, and some of them may be null for many objects in the database.

  • limit (int, default None) – Only return this many objects at most.

  • offset (int, default None) – Useful with limit and order_by ; offset the returned value by this many entries. You can make repeated calls to find_objects to get subsets of objects by passing the same order_by and limit, but different offsets each time, to slowly build up a list.

Returns:

imagelist – Really it will be list of objects of a subclass of snappl.image.Image, but you shouldn’t need to know that.

Return type:

list of snappl.image.Image

classmethod get_collection(collection='snpitdb', subset=None, provenance_tag=None, process=None, provenance=None, dbclient=None, **kwargs)[source]

Get an ImageCollection object.

Parameters:
  • collection (str) – Name of the collection. Currently defined collections: * ou2024 - Open Universe 2024 FITS images * manual_fits - FITS images that aren’t really part of a collection * manual_rdm - Roman Datamodel images that aren’t really part of a collection or in the database * snpitdb - Images from Roman SNPIT internal DB.

  • subset (str or None) –

    Name of the subset, if relevant for that collection.
    • manual_fits
      • (None) - a single FITS file on disk

      • ”threefile” - follows the convention of snappl.image.FITSImageStdHeaders

        and std_imagenames=True passed to the constructor

  • provenance_tag (str, defanot None) – The Roman SNPIT internal database provenance tag for the provenance of the images. Either provenance_tag or provenance is required when collection is ‘snpitdb’. Invalid if collection is not ‘snpitdb’.

  • process (str, default None) – The process to go with provenance_tag; required when provenance_tag is not None.

  • provenance (Provenance or UUID or str, default None) – The Roman SNPIT internal database Provenance or provenance id for the images. Either provenance_tag or provenance is required when collection is ‘snpitdb’. Invalid if collection is not ‘snpitdb’.

  • dbclient (SNPITDBClient, default None) – Only needed if collection is ‘snpit’. If None, a new one will be made when needed.

  • **kwargs (Some collections types require additional arguments.)

get_image(image_id=None, path=None, observation_id=None, band=None, sca=None, dbclient=None)[source]

Return an object of a subclass of Image based on input parameters.

You can specify an image by:
  • image_id (for collections that point to the internal Roman SNPIT database)

  • path

  • observation_id, band, and sca

Parameters:
  • image_id (UUID or str, default None) – The id of the image you want to get. This is only relevant for image collections that refer to images in the internal Roman SNPIT database, otherwise it is invalid. If image_id is given, then path, observation_id, band, and sca are all ignored.

  • path (Path or str, default None) – The path to the relative to base_path. For some subclasses, this must be consistent wiht observation_id, band, and sca if passed.

  • observation_id (str, default None) – Observation_Id. If not given, just use the Path to find the image.

  • band (str, default None) – Band.

  • sca (int, default None) – SCA.

  • base_path (str or pathlib.Path, default None) – The base path for the image collection. If not given, use the default for the collection from when the collection object was instantiated.

  • dbclient (SNPITDBClient, default None) – Only relevant for image collections that refer to the internal SNPIT database. If None, a new connection will be made if needed.

Returns:

image

Return type:

Image

get_image_path(observation_id, band, sca, base_path=None)[source]

Return the absolute path to the desired image, if that makes sense.

This will only make sense for image collections where an image is uniquely defined by a observation_id, band, and sca. Other image collections will just not implement this method.

Parameters:
  • observation_id (str) – The identifier of the observation.

  • band (str) – The band

  • sca (int) – The SCA

  • base_path (str or Path, default None) – If None, use the default value for this collection

Return type:

pathlib.Path