Module gpkimgclass :: Class gpk_img
[frames] | no frames]

Class gpk_img

source code

This class describes a data file. It contains header information and data. The header information follows the NASA FITS standard closely with a few extensions.

Header items: _NAME -- the filename from which the data came, _FILETYPE -- a string indicating the format of the data file

Each instance has two attributes that are intended for general use: hdr -- a dictionary containing all the header information, and d -- a 2-dimensional numpy array containing the data.

Instance Methods
 
__init__(self, hdr, data=None)
Creates an gpk_img object from hdr (a dictionary that describes a data array) and the data (a Numeric 2-dimensional array).
source code
 
copy(self) source code
 
add_history(self, h)
Adds an item to the file's history.
source code
 
get_history(self)
Returns the file's history as a list of strings.
source code
 
empty(self)
Returns True if there is no data.
source code
 
index(self, t, i)
What is the i^th index if the i^th coordinate = t? More plainly, this function gives you the index that corresponds to the coordinate, and 'i' selects which index.
source code
 
coord(self, index, i)
What is the i^th coordinate if the i^th index==index? More plainly, this function gives you the coordinate that corresponds to the index, and 'i' selects which index.
source code
 
x_index(self, x)
Returns the y-index for a particular x-coordinate.
source code
 
y_index(self, y)
Returns the y-index for a particular y-coordinate.
source code
 
x(self, index=None)
Returns the x-coordinate for a particular x-index.
source code
 
y(self, index=None)
Returns the y-coordinate for a particular y-index.
source code
 
write(self, f)
Write out a data file, with the information in this class.
source code
 
__len__(self)
This is here to make it possible to access the class as a (header,data) tuple.
source code
 
__getitem__(self, key)
This is here to make it possible to access the class as a (header,data) tuple.
source code
 
time(self, index=None)
What time corresponds to a certain index? (This is the same as self.y(index).)
source code
 
t_index(self, y)
Returns the y-index for a particular y-coordinate.
source code
 
start(self)
Starting time of the data.
source code
 
end(self)
Ending time of the data.
source code
 
dt(self)
Assuming time flows down a column (axis=2), what's the time interval?
source code
 
column(self, s=None)
Return the requested column of data.
source code
 
register(self, ttype, column, trange=None, tunit=None)
This sets up the TTYPE fields so that the specified datatype lives in the specified column.
source code
 
attach_col(self, data, ttype, trange=None, tunit=None, extra_hdr={})
Attach another column to an existing class.
source code
 
select_cols(self, columns, extra_hdr={})
Select a set of columns in an existing class, returning a new gpk_img class containing a subset of the data.
source code
Method Details

index(self, t, i)

source code 

What is the i^th index if the i^th coordinate = t? More plainly, this function gives you the index that corresponds to the coordinate, and 'i' selects which index. (i=1 or 2).

coord(self, index, i)

source code 

What is the i^th coordinate if the i^th index==index? More plainly, this function gives you the coordinate that corresponds to the index, and 'i' selects which index. If index=None, it returns an array of all the coordinates. (i=1 or 2).

y_index(self, y)

source code 

Returns the y-index for a particular y-coordinate. Also used for t-index, which returns the index for a particular time, if the data is a time-series.

t_index(self, y)

source code 

Returns the y-index for a particular y-coordinate. Also used for t-index, which returns the index for a particular time, if the data is a time-series.

column(self, s=None)

source code 

Return the requested column of data. (This is the actual data, not a copy.) If s is a string, it returns the column which has TTYPEx=s. Otherwise, if s is an integer, it returns that column (zero-based index). As a special case, if there is only one column, and the function is called with s=None (the default), it will return the data.

register(self, ttype, column, trange=None, tunit=None)

source code 

This sets up the TTYPE fields so that the specified datatype lives in the specified column. Column is zero-based. You can erase by specifying ttype=None.

attach_col(self, data, ttype, trange=None, tunit=None, extra_hdr={})

source code 

Attach another column to an existing class. This modifies the object it is called upon. The data may or may not be copied in the process.

select_cols(self, columns, extra_hdr={})

source code 

Select a set of columns in an existing class, returning a new gpk_img class containing a subset of the data. The data is copied; the new and old objects share nothing.