pysis package¶
Submodules¶
pysis.cubefile module¶
-
class
pysis.cubefile.
CubeFile
(stream_or_fname, filename=None)[source]¶ Bases:
object
A Isis Cube file reader.
-
BYTE_ORDERS
= {'Lsb': '<', 'Msb': '>', 'NoByteOrder': '='}¶
-
PIXEL_TYPES
= {'Real': dtype('float32'), 'SignedWord': dtype('int16'), 'UnsignedByte': dtype('uint8'), 'Double': dtype('float64'), 'UnsignedInteger': dtype('uint32'), 'SignedInteger': dtype('int32'), 'SignedByte': dtype('int8'), 'UnsignedWord': dtype('uint16')}¶
-
SPECIAL_PIXELS
= {'Real': {'His': -3.4028233e+38, 'Min': -3.4028225e+38, 'Max': 3.4028235e+38, 'Hrs': -3.4028235e+38, 'Lrs': -3.4028229e+38, 'Lis': -3.4028231e+38, 'Null': -3.4028227e+38}, 'UnsignedByte': {'His': 255, 'Min': 1, 'Max': 254, 'Hrs': 255, 'Lrs': 0, 'Lis': 0, 'Null': 0}, 'Double': {'His': -1.7976931348623155e+308, 'Min': -1.7976931348623147e+308, 'Max': 1.7976931348623157e+308, 'Hrs': -1.7976931348623157e+308, 'Lrs': -1.7976931348623151e+308, 'Lis': -1.7976931348623153e+308, 'Null': -1.7976931348623149e+308}, 'SignedWord': {'His': -32765, 'Min': -32752, 'Max': 32767, 'Hrs': -32764, 'Lrs': -32767, 'Lis': -32766, 'Null': -32768}, 'SignedInteger': {'His': -8388610, 'Min': -8388614, 'Max': 2147483647, 'Hrs': -8388609, 'Lrs': -8388612, 'Lis': -8388611, 'Null': -8388613}, 'UnsignedWord': {'His': 65534, 'Min': 3, 'Max': 65522, 'Hrs': 65535, 'Lrs': 1, 'Lis': 2, 'Null': 0}}¶
-
apply_numpy_specials
(copy=True)[source]¶ Convert isis special pixel values to numpy special pixel values.
Isis Numpy Null nan Lrs -inf Lis -inf His inf Hrs inf Parameters: copy – whether to apply the new special values to a copy of the pixel data and leave the orginial unaffected Returns: a numpy array with special values converted to numpy’s nan, inf and -inf
-
apply_scaling
(copy=True)[source]¶ Scale pixel values to there true DN.
Parameters: copy – whether to apply the scalling to a copy of the pixel data and leave the orginial unaffected Returns: a scalled version of the pixel data
-
bands
¶ Number of image bands.
-
base
¶ An additive factor by which to offset pixel DN.
-
data
= None¶ A numpy array representing the image data.
-
dtype
¶ Pixel data type.
-
filename
= None¶ The filename if given, otherwise none.
-
format
¶
-
get_image_array
()[source]¶ Create an array for use in making an image.
Creates a linear stretch of the image and scales it to between 0 and 255. Null, Lis and Lrs pixels are set to 0. His and Hrs pixels are set to 255.
Usage:
from pysis import CubeFile from PIL import Image # Read in the image and create the image data image = CubeFile.open('test.cub') data = image.get_image_array() # Save the first band to a new file Image.fromarray(data[0]).save('test.png')
Returns: A uint8 array of pixel values.
-
label
= None¶ The parsed label header in dictionary form.
-
lines
¶ Number of lines per band.
-
multiplier
¶ A multiplicative factor by which to scale pixel DN.
-
classmethod
open
(filename)[source]¶ Read an Isis Cube file from disk.
Parameters: filename – name of file to read as an isis file
-
samples
¶ Number of samples per line.
-
shape
¶ Tuple of images bands, lines and samples.
-
size
¶ Total number of pixels.
-
specials
¶
-
specials_mask
()[source]¶ Create a pixel map for special pixels.
Returns: an array where the value is False if the pixel is special and True otherwise
-
start_byte
¶ Index of the start of the image data (zero indexed).
-
tile_lines
¶ Number of lines per tile.
-
tile_samples
¶ Number of samples per tile.
-
pysis.env module¶
pysis.exceptions module¶
This module contains the set of Pysis exceptions.
-
exception
pysis.exceptions.
IsisException
[source]¶ Bases:
exceptions.Exception
Base exception for isis errors.
-
exception
pysis.exceptions.
ProcessError
(returncode, cmd, stdout, stderr)[source]¶ Bases:
pysis.exceptions.IsisException
This exception is raised when an isis process returns a non-zero exit status.
-
exception
pysis.exceptions.
VersionError
[source]¶ Bases:
pysis.exceptions.IsisException
The wrong version of isis is being used.
pysis.isis module¶
pysis.isiscommand module¶
pysis.isispool module¶
-
class
pysis.isispool.
IsisPool
(strict=False, *args, **kwargs)[source]¶ Bases:
pysis.isiscommand.Isis
Multiprocessing pool for ISIS commands.
Example for running the following isis script in parallel for a list of images.
On the command line:
mdis2isis from=filename.IMG to=filename.cub spiceinit from=filename.cub mdiscal from=filename.cub to=filename.cal.cub
With pysis:
from pysis import IsisPool from pysis.util import ImageName def calibrate_mdis(images): images = [ImageName(filename) for filename in images] with IsisPool() as isis_pool: for filename in images: isis_pool.mdis2isis(from_=filename.IMG, to=filename.cub) with IsisPool() as isis_pool: for filename in images: isis_pool.spiceinit(from_=filename.cub) with IsisPool() as isis_pool: for filename in images: isis_pool.mdiscal(from_=filename.cub, to=filename.cal.cub)
Parameters: - strict – when in strict mode, the isis pool will initialize its attributes with commands from the isis environment. Otherwise attributes are dynamically added as use
- **kwargs –
additional parameters used to initialize the multiprocessing pool
pysis.specialpixels module¶
Constants for Isis Special Pixels.
Min: The minimum valid value for a pixel. Null: Pixel has no data available. Lis: Pixel was lower bound saturated on the instrument. His: Pixel was higher bound saturated on the instrument. Lrs: Pixel was lower bound saturated during a computation. Hrs: Pixel was higher bound saturated during a computation. Max: The maximum valid value for a pixel.
Module contents¶
-
class
pysis.
IsisPool
(strict=False, *args, **kwargs)[source]¶ Bases:
pysis.isiscommand.Isis
Multiprocessing pool for ISIS commands.
Example for running the following isis script in parallel for a list of images.
On the command line:
mdis2isis from=filename.IMG to=filename.cub spiceinit from=filename.cub mdiscal from=filename.cub to=filename.cal.cub
With pysis:
from pysis import IsisPool from pysis.util import ImageName def calibrate_mdis(images): images = [ImageName(filename) for filename in images] with IsisPool() as isis_pool: for filename in images: isis_pool.mdis2isis(from_=filename.IMG, to=filename.cub) with IsisPool() as isis_pool: for filename in images: isis_pool.spiceinit(from_=filename.cub) with IsisPool() as isis_pool: for filename in images: isis_pool.mdiscal(from_=filename.cub, to=filename.cal.cub)
Parameters: - strict – when in strict mode, the isis pool will initialize its attributes with commands from the isis environment. Otherwise attributes are dynamically added as use
- **kwargs –
additional parameters used to initialize the multiprocessing pool
-
class
pysis.
CubeFile
(stream_or_fname, filename=None)[source]¶ Bases:
object
A Isis Cube file reader.
-
BYTE_ORDERS
= {'Lsb': '<', 'Msb': '>', 'NoByteOrder': '='}¶
-
PIXEL_TYPES
= {'Real': dtype('float32'), 'SignedWord': dtype('int16'), 'UnsignedByte': dtype('uint8'), 'Double': dtype('float64'), 'UnsignedInteger': dtype('uint32'), 'SignedInteger': dtype('int32'), 'SignedByte': dtype('int8'), 'UnsignedWord': dtype('uint16')}¶
-
SPECIAL_PIXELS
= {'Real': {'His': -3.4028233e+38, 'Min': -3.4028225e+38, 'Max': 3.4028235e+38, 'Hrs': -3.4028235e+38, 'Lrs': -3.4028229e+38, 'Lis': -3.4028231e+38, 'Null': -3.4028227e+38}, 'UnsignedByte': {'His': 255, 'Min': 1, 'Max': 254, 'Hrs': 255, 'Lrs': 0, 'Lis': 0, 'Null': 0}, 'Double': {'His': -1.7976931348623155e+308, 'Min': -1.7976931348623147e+308, 'Max': 1.7976931348623157e+308, 'Hrs': -1.7976931348623157e+308, 'Lrs': -1.7976931348623151e+308, 'Lis': -1.7976931348623153e+308, 'Null': -1.7976931348623149e+308}, 'SignedWord': {'His': -32765, 'Min': -32752, 'Max': 32767, 'Hrs': -32764, 'Lrs': -32767, 'Lis': -32766, 'Null': -32768}, 'SignedInteger': {'His': -8388610, 'Min': -8388614, 'Max': 2147483647, 'Hrs': -8388609, 'Lrs': -8388612, 'Lis': -8388611, 'Null': -8388613}, 'UnsignedWord': {'His': 65534, 'Min': 3, 'Max': 65522, 'Hrs': 65535, 'Lrs': 1, 'Lis': 2, 'Null': 0}}¶
-
apply_numpy_specials
(copy=True)[source]¶ Convert isis special pixel values to numpy special pixel values.
Isis Numpy Null nan Lrs -inf Lis -inf His inf Hrs inf Parameters: copy – whether to apply the new special values to a copy of the pixel data and leave the orginial unaffected Returns: a numpy array with special values converted to numpy’s nan, inf and -inf
-
apply_scaling
(copy=True)[source]¶ Scale pixel values to there true DN.
Parameters: copy – whether to apply the scalling to a copy of the pixel data and leave the orginial unaffected Returns: a scalled version of the pixel data
-
bands
¶ Number of image bands.
-
base
¶ An additive factor by which to offset pixel DN.
-
dtype
¶ Pixel data type.
-
format
¶
-
get_image_array
()[source]¶ Create an array for use in making an image.
Creates a linear stretch of the image and scales it to between 0 and 255. Null, Lis and Lrs pixels are set to 0. His and Hrs pixels are set to 255.
Usage:
from pysis import CubeFile from PIL import Image # Read in the image and create the image data image = CubeFile.open('test.cub') data = image.get_image_array() # Save the first band to a new file Image.fromarray(data[0]).save('test.png')
Returns: A uint8 array of pixel values.
-
lines
¶ Number of lines per band.
-
multiplier
¶ A multiplicative factor by which to scale pixel DN.
-
classmethod
open
(filename)[source]¶ Read an Isis Cube file from disk.
Parameters: filename – name of file to read as an isis file
-
samples
¶ Number of samples per line.
-
shape
¶ Tuple of images bands, lines and samples.
-
size
¶ Total number of pixels.
-
specials
¶
-
specials_mask
()[source]¶ Create a pixel map for special pixels.
Returns: an array where the value is False if the pixel is special and True otherwise
-
start_byte
¶ Index of the start of the image data (zero indexed).
-
tile_lines
¶ Number of lines per tile.
-
tile_samples
¶ Number of samples per tile.
-