Image Management¶
Working with a directory of images¶
msumastro.image_collection Module¶
Classes¶
ImageFileCollection([location, keywords, ...]) | Representation of a collection of image files. |
Turning an image collection into a tree¶
- class msumastro.table_tree.TableTree(*args)[source]¶
Base class for grouping images hierarchically into a tree based on metadata
This class can be used directly, though subclasses for a few common cases are provided in this package.
Parameters: table : astropy.table.Table instance
Table containing the metadata to be used for grouping images.
tree_keys : list of str
Keys to be used in grouping images. Each key must be the name of a column in table.
index_key : str
Key which is used to indicate which rows of the input table are in each group; it must be the name of one of the columns in table. Values of the index must uniquely identify rows of the table (in database parlance, index must be able to serve as a primary key for the table).
Raises: TypeError
Raised if the number of initialization arguments is incorrect or the types of any of the arguments is incorrect.
Attributes
table astropy.table.Table of metadata used to group rows. tree_keys list of str, Table columns to be used in grouping the rows. index_key str, Name of column whose values uniquely identify each row. - walk(*args, **kwd)[source]¶
Walk the grouped tree
The functionality provided is similar to that in os.walk: starting at the top of tree, yield a tuple of return values indicating parents, children and rows at each level of the tree.
Parameters: None
Returns: parents, children, index : lists
parents : list
Dictionary keys that led to this return
children : list
Child nodes at this level
index : list
Index values for the items in the table that correspond to the values in parents
Image class that includes WCS information¶
- class msumastro.image.ImageWithWCS(filepath, **kwd)[source]¶
FITS image with WCS
A FITS images with a few convenience methods defined, including easy access to WCS transforms.
Parameters: filepath : str
Path to the FITS file.
kwd : dict, optional
All keywords are passed through to astropy.io.fits.open
Attributes
data Image data; will be scaled by default using BZERO and BSCALE header FITS header for this file wcs WCS object for this file - save(fname, clobber=False)[source]¶
Save FITS file.
Parameters: fname : str
Name of the file to save to
clobber : bool, optional
Set to True to overwrite an existing file.
- shift(int_shift, in_place=False)[source]¶
Shift image by an integer number of pixels without interpolation.
Parameters: int_shift : list-like of two integers
Amount by which image should be shifted; floats will be rounded.
in_place : bool, optional
If True the image is shifted in place, and the wcs reference pixel is updated appropriately. Otherwise an array is returned that is shifted with no WCS information.
Raises: ValueError
If the shift is not by an integer amount.
- wcs_pix2world(pix, **kwargs)[source]¶
Wrapper around astropy.wcs function that handles a single tuple gracefully.
Parameters: pix : numpy array either of dimension 2 (e.g. [xpix, ypix]) or Nx2
Pixel positions at which sky coordinates should be calculated.
Returns: numpy.ndarray with same shape as pix.
Sky coordinates for each input pixel.
- wcs_world2pix(sky, **kwargs)[source]¶
Wrapper around astropy.wcs function that handles a single tuple gracefully.
Parameters: sky : numpy array either of dimension 2 (e.g. [xpix, ypix]) or Nx2
Pixel positions at which sky coordinates should be calculated.
Returns: numpy.ndarray with same shape as sky.
Pixel positions for each input sky coordinate.