Image — Image data base.¶
This module defines the Image class for IMAGE entries in BDPs as well as the imagedescriptor container class.
-
class
admit.util.Image.
Image
(**keyval)[source]¶ Defines the basic Image structure used in ADMIT.
The class can store multiple types of the same image (e.g. png, jpg, CASA), however no check is made that they are the same image, this must be ensured by the AT using the class. A thumbnail, caption, and auxiliary file (for e.g. a histogram) are also included.
Parameters: keyvals : dictionary of new values for the keywords, optional.
These keyword value pairs can be fed in form the command line instantiation of the class.
Attributes
images (dictionary) Dictionary containing the image data, one entry per format type. thumbnail (string) File name of the thumbnail image. thumbnailtype (string) The format of the thumbnail, see bt for a list of available formats. auxiliary (string) The name of the auxiliary file. auxtype (string) The format of the auxiliary file, see bt for a list of available formats. description (string) A description or caption for the image. Methods
addfile
(image)Method to add a file to the class, it should not be called directly, addimage
(image)Method to add an image to the class delete
([basedir, delfile])Method to delete everything deserialize
(serial)Create an Image from serialized data created by serialize(). getaux
()Method to get the auxiliary file name getimage
(type)Method which returns the requested image from the class as an imagedescriptor. getimagefile
(imtype)Method to get the name of a file for the given image type getkey
(key)Method to get a data member by name getthumbnail
()Method to get the thumbnail image file name removeimage
(typ[, basedir, delete])Method to remove a specific image from the class, including from disk if requested. serialize
()Create a string representation of the Image that can be converted to native Python structures with ast.literal_eval or back to a Table with deserialize(). setkey
([name, value])set keys, two styles are possible: -
addfile
(image)[source]¶ Method to add a file to the class, it should not be called directly, instead addimage should be called
Parameters: image : ImageDescriptor
An imagedescriptor of the image to be added. Removes any file that is being replaced
Returns: None
-
addimage
(image)[source]¶ Method to add an image to the class
Parameters: image : List/ImageDescriptor
Can be either a list of imagedescriptors or just an individual imagedescriptor. If the image type already exists in the class then it is replaced and the original removed. Any images labeled DATA will be added to the dictionary (overwriting any previous instances of the format)
Returns: None
-
delete
(basedir='', delfile=True)[source]¶ Method to delete everything
Parameters: delfile : Boolean
Whether or not do delete the underlying files (default is True)
Returns: None
-
deserialize
(serial)[source]¶ Create an Image from serialized data created by serialize().
Parameters: serial : The string representation of an Image in the format from
deserialize().
Returns: None
-
getaux
()[source]¶ Method to get the auxiliary file name
Returns: string
The name of the auxiliry file, relative to the encasing BDP
-
getimage
(type)[source]¶ Method which returns the requested image from the class as an imagedescriptor.
Parameters: type : string
Can be any of the following: bt.AUX to retrieve the auxiliary file, bt.THUMB to retrieve the thumbnail, or a file format (e.g. bt.FITS) to retrieve the requested format of the main image. If the requested image does not exist then None is returned.
Returns: ImageDescriptor
An imagedescriptor of the requested image or None if the image does not exist in the class.
-
getimagefile
(imtype)[source]¶ Method to get the name of a file for the given image type
Parameters: imtype : str
Can be any of the following: bt.AUX to retrieve the auxiliary file, bt.THUMB to retrieve the thumbnail, or a file format (e.g. bt.FITS) to retrieve the requested format of the main image. If the requested image does not exist then None is returned.
Returns: String containing the image name, or None if the image does not
exist
-
getthumbnail
()[source]¶ Method to get the thumbnail image file name
Parameters: None
Returns: string
The file name of the thumbnail image, relative to the encasing BDP
-
removeimage
(typ, basedir='', delete=True)[source]¶ Method to remove a specific image from the class, including from disk if requested.
Parameters: type : string
The type of the image to be removed. Can be any of the following: bt.AUX to remove the auxiliary file, bt.THUMB to remove the thumbnail, or a file format (e.g. bt.FITS) to remove the requested format from the main image dictionary.
delete : Boolean
Whether to delete the actual image from disk (default is True)
Returns: None
-
serialize
()[source]¶ Create a string representation of the Image that can be converted to native Python structures with ast.literal_eval or back to a Table with deserialize(). Intended for the summary but can be used wherever.
Parameters: None
Returns: A string representation of the Image that can be converted back
to a Image with deserialize().
-
setkey
(name='', value='')[source]¶ set keys, two styles are possible:
- name = {key:val} e.g. setkey({“a”:1})
- name = “key”, value = val e.g. setkey(“a”, 1)
This method checks the type of the keyword value, as it must remain the same. Also new keywords cannot be added.
Parameters: name : dictionary or string
Dictionary of keyword value pais to set or a string with the name of a single key
value : any
The value to change the keyword to
Returns: None
-
-
class
admit.util.Image.
imagedescriptor
(file, format, type='DATA')[source]¶ A lightweight class for transporting an image, its format and type. This class has three and only three data members, and no added methods. The members are file for the image file name on disk, format for the image format (e.g. bt.FITS), and type (one of bt.THUMB, bt.AUX, or bt.DATA) specifying what type of image this is.
Parameters: file : string
The name of the file containing the image No default
format : string
The format the image is in (see bt for a list of formats) No default
type : string
The data type this image is filling in the class auxiliary, thumbnail or data (where most images go). Use: bt.AUX, bt.THUMB, or bt.DATA Default : bt.DATA)
Attributes
Same as parameters. -
file
¶
-
format
¶
-
type
¶
-