Image Base Class

This module defines the class for IMAGE entries in BDP’s

class admit.util.Image.Image(**keyval)

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, description/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 bdp_types for a list of available formats
auxiliary (string) The name of the auxiliary file.
auxtype (string) The format of the auxiliary file, see bdp_types 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
getaux() Method to get the auxiliary file name
getimage(type) Method which returns the requested image from the class as an imagedescriptor.
getthumbnail() Method to get the thumbnail image file name
isequal(img) Method to determine if two images are equivalent
removeimage(typ[, basedir, delete]) Method to remove a specific image from the class, including from disk if requested.
setkey([name, value]) set keys, two styles are possible:
write(root, name) Method to write an xml entry for the Image class
addfile(image)

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)

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)

Method to delete everything

Parameters:

delfile : Boolean

Whether or not do delete the underlying files (default is True)

Returns:

None

getaux()

Method to get the auxiliary file name

Returns:

string

The name of the auxiliry file, relative to the encasing BDP

getimage(type)

Method which returns the requested image from the class as an imagedescriptor.

Parameters:

type : string

Can be any of the following: bdp_types.AUX to retrieve the auxiliary file, bdp_types.THUMB to retrieve the thumbnail, or a file format (e.g. bdp_types.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.

getthumbnail()

Method to get the thumbnail image file name

Returns:

string

The file name of the thumbnail image, relative to the encasing BDP

isequal(img)

Method to determine if two images are equivalent

Parameters:

img : Image

The image to compare to this one

Returns:

Boolean

Whether or not the two image classes are equivalent

Notes

Useful for testing purposes, still experimental

removeimage(typ, basedir='', delete=True)

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: bdp_types.AUX to remove the auxiliary file, bdp_types.THUMB to remove the thumbnail, or a file format (e.g. bdp_types.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

setkey(name='', value='')

set keys, two styles are possible:

  1. name = {key:val} e.g. setkey({“a”:1})
  2. 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

write(root, name)

Method to write an xml entry for the Image class

Parameters:

root : elementtree node

The parent node to write to

name : string

The name of the containing node

Returns:

None

class admit.util.Image.imagedescriptor(file, format, type='DATA')

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. bdp_types.FITS), and type (one of bdp_types.THUMB, bdp_types.AUX, or bdp_types.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 bdp_types 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 is bt.DATA)

Attributes

Same as Parameters  
file
format
type

This Page