| | |
- __builtin__.list(__builtin__.object)
-
- pyfits.NP_pyfits.CardList
- pyfits.NP_pyfits.HDUList(__builtin__.list, pyfits.NP_pyfits._Verify)
- __builtin__.object
-
- pyfits.NP_pyfits.ColDefs
- pyfits.NP_pyfits.FITS_record
- exceptions.Exception(exceptions.BaseException)
-
- pyfits.NP_pyfits.VerifyError
- pyfits.NP_pyfits.Column
- pyfits.NP_pyfits.Delayed
- pyfits.NP_pyfits.Header
- pyfits.NP_pyfits.Section
- pyfits.NP_pyfits.StreamingHDU
- pyfits.NP_pyfits.Undefined
- pyfits.NP_pyfits._ExtensionHDU(pyfits.NP_pyfits._ValidHDU)
-
- pyfits.NP_pyfits.ImageHDU(pyfits.NP_pyfits._ExtensionHDU, pyfits.NP_pyfits._py_ImageBaseHDU)
- pyfits.NP_pyfits._TableBaseHDU(pyfits.NP_pyfits._ExtensionHDU)
-
- pyfits.NP_pyfits.BinTableHDU
- pyfits.NP_pyfits.TableHDU
- pyfits.NP_pyfits._Verify
-
- pyfits.NP_pyfits.Card
- pyfits.NP_pyfits.HDUList(__builtin__.list, pyfits.NP_pyfits._Verify)
- pyfits.NP_pyfits._py_ImageBaseHDU(pyfits.NP_pyfits._ValidHDU)
-
- pyfits.NP_pyfits.ImageHDU(pyfits.NP_pyfits._ExtensionHDU, pyfits.NP_pyfits._py_ImageBaseHDU)
- pyfits.NP_pyfits.PrimaryHDU
-
- pyfits.NP_pyfits.GroupsHDU
- pyfits.rec.recarray(numpy.ndarray)
-
- pyfits.NP_pyfits.FITS_rec
-
- pyfits.NP_pyfits.GroupData
- urllib.FancyURLopener(urllib.URLopener)
-
- pyfits.NP_pyfits.ErrorURLopener
class BinTableHDU(_TableBaseHDU) |
| |
Binary table HDU class. |
| |
- Method resolution order:
- BinTableHDU
- _TableBaseHDU
- _ExtensionHDU
- _ValidHDU
- _AllHDU
- _Verify
Methods defined here:
- __init__(self, data=None, header=None, name=None)
- data: data of the table
header: header to be used for the HDU
name: the EXTNAME value
Methods inherited from _TableBaseHDU:
- __getattr__(self, attr)
- Get the 'data' or 'columns' attribute.
- copy(self)
- Make a copy of the table HDU, both header and data are copied.
- get_coldefs(self)
- Returns the table's column definitions.
- update(self)
- Update header keywords to reflect recent changes of columns.
Methods inherited from _ExtensionHDU:
- __setattr__(self, attr, value)
- Set an HDU attribute.
Methods inherited from _ValidHDU:
- req_cards(self, keywd, pos, test, fix_value, option, errlist)
- Check the existence, location, and value of a required Card.
- size(self)
- Size (in bytes) of the data portion of the HDU.
- writeto(self, name, output_verify='exception', clobber=False)
- Write the HDU to a new file. This is a convenience method
to provide a user easier output interface if only one HDU
needs to be written to a file.
name: output FITS file name to be written to.
output_verify: output verification option, default='exception'.
clobber: Overwrite the output file if exists, default = False.
Methods inherited from _Verify:
- run_option(self, option='warn', err_text='', fix_text='Fixed.', fix='pass', fixable=1)
- Execute the verification with selected option.
- verify(self, option='warn')
- Wrapper for _verify.
|
class Card(_Verify) |
| | |
Methods defined here:
- __getattr__(self, name)
- instanciate specified attribute object.
- __init__(self, key='', value='', comment='')
- Construct a card from key, value, and (optionally) comment.
Any specifed arguments, except defaults, must be compliant to
FITS standard.
key: keyword name, default=''.
value: keyword value, default=''.
comment: comment, default=''.
- __repr__(self)
- __setattr__(self, name, val)
- ascardimage(self, option='silentfix')
- Generate a (new) card image from the attributes: key, value,
and comment, or from raw string.
option: verification option, default=silentfix.
- fromstring(self, input)
- Construct a Card object from a (raw) string. It will pad the
string if it is not the length of a card image (80 columns).
If the card image is longer than 80, assume it contains CONTINUE
card(s).
Data and other attributes defined here:
- length = 80
Methods inherited from _Verify:
- run_option(self, option='warn', err_text='', fix_text='Fixed.', fix='pass', fixable=1)
- Execute the verification with selected option.
- verify(self, option='warn')
- Wrapper for _verify.
|
class CardList(__builtin__.list) |
| |
FITS header card list class. |
| |
- Method resolution order:
- CardList
- __builtin__.list
- __builtin__.object
Methods defined here:
- __delitem__(self, key)
- Delete a Card from the CardList.
- __getitem__(self, key)
- Get a Card by indexing or by the keyword name.
- __getslice__(self, start, end)
- __init__(self, cards=[], keylist=None)
- Construct the CardList object from a list of Cards.
cards: A list of Cards, default=[].
- __repr__(self)
- Format a list of cards into a string.
- __setitem__(self, key, value)
- Set a Card by indexing or by the keyword name.
- __str__(self)
- Format a list of cards into a printable string.
- append(self, card, useblanks=1, bottom=0)
- Append a Card to the CardList.
card: The Card to be appended.
useblanks: Use any *extra* blank cards? default=1.
If useblanks != 0, and if there are blank cards directly
before END, it will use this space first, instead of
appending after these blank cards, so the total space
will not increase (default). When useblanks == 0, the
card will be appended at the end, even if there are
blank cards in front of END.
bottom: If =0 (default) the card will be appended after the last
non-commentary card. If =1, the card will be appended
after the last non-blank card.
- copy(self)
- Make a (deep)copy of the CardList.
- count_blanks(self)
- Find out how many blank cards are *directly* before the END card.
- index_of(self, key, backward=0)
- Get the index of a keyword in the CardList.
key: the keyword name (a string) or the index (an integer).
backward: search the index from the END, i.e. backward? default=0.
If backward = 1, search from the end.
- insert(self, pos, card, useblanks=1)
- Insert a Card to the CardList.
pos: The position (index, keyword name will not be allowed) to
insert. The new card will be inserted before it.
card: The Card to be inserted.
useblanks: Use any *extra* blank cards? default=1.
If useblanks != 0, and if there are blank cards directly
before END, it will use this space first, instead of
appending after these blank cards, so the total space
will not increase (default). When useblanks == 0, the
card will be appended at the end, even if there are
blank cards in front of END.
- keys(self)
- Return a list of all keywords from the CardList.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Methods inherited from __builtin__.list:
- __add__(...)
- x.__add__(y) <==> x+y
- __contains__(...)
- x.__contains__(y) <==> y in x
- __delslice__(...)
- x.__delslice__(i, j) <==> del x[i:j]
Use of negative indices is not supported.
- __eq__(...)
- x.__eq__(y) <==> x==y
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __gt__(...)
- x.__gt__(y) <==> x>y
- __hash__(...)
- x.__hash__() <==> hash(x)
- __iadd__(...)
- x.__iadd__(y) <==> x+=y
- __imul__(...)
- x.__imul__(y) <==> x*=y
- __iter__(...)
- x.__iter__() <==> iter(x)
- __le__(...)
- x.__le__(y) <==> x<=y
- __len__(...)
- x.__len__() <==> len(x)
- __lt__(...)
- x.__lt__(y) <==> x<y
- __mul__(...)
- x.__mul__(n) <==> x*n
- __ne__(...)
- x.__ne__(y) <==> x!=y
- __reversed__(...)
- L.__reversed__() -- return a reverse iterator over the list
- __rmul__(...)
- x.__rmul__(n) <==> n*x
- __setslice__(...)
- x.__setslice__(i, j, y) <==> x[i:j]=y
Use of negative indices is not supported.
- count(...)
- L.count(value) -> integer -- return number of occurrences of value
- extend(...)
- L.extend(iterable) -- extend list by appending elements from the iterable
- index(...)
- L.index(value, [start, [stop]]) -> integer -- return first index of value
- pop(...)
- L.pop([index]) -> item -- remove and return item at index (default last)
- remove(...)
- L.remove(value) -- remove first occurrence of value
- reverse(...)
- L.reverse() -- reverse *IN PLACE*
- sort(...)
- L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
cmp(x, y) -> -1, 0, 1
Data and other attributes inherited from __builtin__.list:
- __new__ = <built-in method __new__ of type object at 0x720020>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class ColDefs(__builtin__.object) |
| |
Column definitions class. It has attributes corresponding to the
Column attributes (e.g. ColDefs has the attribute .names while Column
has .name), Each attribute in ColDefs is a list of corresponding
attribute values from all Columns. |
| |
Methods defined here:
- __add__(self, other, option='left')
- __coerce__(self, other)
- __getattr__(self, name)
- Populate the attributes.
- __getitem__(self, key)
- __init__(self, input, tbtype='BinTableHDU')
- input: a list of Columns, an (table) HDU
tbtype: which table HDU, 'BinTableHDU' (default) or
'TableHDU' (text table).
- __len__(self)
- __radd__(self, other)
- __repr__(self)
- __sub__(self, other)
- add_col(self, column)
- Append one Column to the column definition.
- change_attrib(self, col_name, attrib, new_value)
- Change an attribute (in the commonName list) of a Column.
- change_name(self, col_name, new_name)
- Change a Column's name.
- change_unit(self, col_name, new_unit)
- Change a Column's unit.
- del_col(self, col_name)
- Delete (the definition of) one Column.
- info(self, attrib='all')
- Get attribute(s) information of the column definition.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Column |
| |
Column class which contains the definition of one column, e.g.
ttype, tform, etc. and the array. Does not support theap yet. |
| |
Methods defined here:
- __init__(self, name=None, format=None, unit=None, null=None, bscale=None, bzero=None, disp=None, start=None, dim=None, array=None)
- Construct a Column by specifying attributes. All attributes
except format can be optional.
name: column name, corresponding to TTYPE keyword
format: column format, corresponding to TFORM keyword
unit: column unit, corresponding to TUNIT keyword
null: null value, corresponding to TNULL keyword
bscale: bscale value, corresponding to TSCAL keyword
bzero: bzero value, corresponding to TZERO keyword
disp: display format, corresponding to TDISP keyword
start: column starting position (ASCII table only),
corresponding to TBCOL keyword
dim: column dimension corresponding to TDIM keyword
- __repr__(self)
- copy(self)
|
class ErrorURLopener(urllib.FancyURLopener) |
| |
A class to use with urlretrieve to allow IOError exceptions to be
raised when a file specified by a URL cannot be accessed |
| |
- Method resolution order:
- ErrorURLopener
- urllib.FancyURLopener
- urllib.URLopener
Methods defined here:
- http_error_default(self, url, fp, errcode, errmsg, headers)
Methods inherited from urllib.FancyURLopener:
- __init__(self, *args, **kwargs)
- get_user_passwd(self, host, realm, clear_cache=0)
- http_error_301(self, url, fp, errcode, errmsg, headers, data=None)
- Error 301 -- also relocated (permanently).
- http_error_302(self, url, fp, errcode, errmsg, headers, data=None)
- Error 302 -- relocated (temporarily).
- http_error_303(self, url, fp, errcode, errmsg, headers, data=None)
- Error 303 -- also relocated (essentially identical to 302).
- http_error_307(self, url, fp, errcode, errmsg, headers, data=None)
- Error 307 -- relocated, but turn POST into error.
- http_error_401(self, url, fp, errcode, errmsg, headers, data=None)
- Error 401 -- authentication required.
This function supports Basic authentication only.
- http_error_407(self, url, fp, errcode, errmsg, headers, data=None)
- Error 407 -- proxy authentication required.
This function supports Basic authentication only.
- prompt_user_passwd(self, host, realm)
- Override this in a GUI environment!
- redirect_internal(self, url, fp, errcode, errmsg, headers, data)
- retry_http_basic_auth(self, url, realm, data=None)
- retry_https_basic_auth(self, url, realm, data=None)
- retry_proxy_http_basic_auth(self, url, realm, data=None)
- retry_proxy_https_basic_auth(self, url, realm, data=None)
Methods inherited from urllib.URLopener:
- __del__(self)
- addheader(self, *args)
- Add a header to be used by the HTTP interface only
e.g. u.addheader('Accept', 'sound/basic')
- cleanup(self)
- close(self)
- http_error(self, url, fp, errcode, errmsg, headers, data=None)
- Handle http errors.
Derived class can override this, or provide specific handlers
named http_error_DDD where DDD is the 3-digit error code.
- open(self, fullurl, data=None)
- Use URLopener().open(file) instead of open(file, 'r').
- open_data(self, url, data=None)
- Use "data" URL.
- open_file(self, url)
- Use local file or FTP depending on form of URL.
- open_ftp(self, url)
- Use FTP protocol.
- open_gopher(self, url)
- Use Gopher protocol.
- open_http(self, url, data=None)
- Use HTTP protocol.
- open_https(self, url, data=None)
- Use HTTPS protocol.
- open_local_file(self, url)
- Use local file.
- open_unknown(self, fullurl, data=None)
- Overridable interface to open unknown URL type.
- open_unknown_proxy(self, proxy, fullurl, data=None)
- Overridable interface to open unknown URL type.
- retrieve(self, url, filename=None, reporthook=None, data=None)
- retrieve(url) returns (filename, headers) for a local object
or (tempfilename, headers) for a remote object.
Data and other attributes inherited from urllib.URLopener:
- version = 'Python-urllib/1.17'
|
class FITS_rec(pyfits.rec.recarray) |
| |
FITS record array class. FITS record array is the data part of a
table HDU's data part. This is a layer over the recarray, so we
can deal with scaled columns. |
| |
- Method resolution order:
- FITS_rec
- pyfits.rec.recarray
- numpy.ndarray
- __builtin__.object
Methods defined here:
- __array_finalize__(self, obj)
- __getitem__(self, key)
- __repr__(self)
- __setitem__(self, row, value)
- field(self, key)
- A view of a Column's data as an array.
Static methods defined here:
- __new__(subtype, input)
- Construct a FITS record array from a recarray.
Methods inherited from pyfits.rec.recarray:
- __getattribute__(self, attr)
- __setattr__(self, attr, val)
- view(self, obj)
Data descriptors inherited from pyfits.rec.recarray:
- __dict__
- dictionary for instance variables (if defined)
Methods inherited from numpy.ndarray:
- __abs__(...)
- x.__abs__() <==> abs(x)
- __add__(...)
- x.__add__(y) <==> x+y
- __and__(...)
- x.__and__(y) <==> x&y
- __array__(...)
- a.__array__(|dtype) -> reference if type unchanged, copy otherwise.
Returns either a new reference to self if dtype is not given or a new array
of provided data type if dtype is different from the current dtype of the
array.
- __array_wrap__(...)
- a.__array_wrap__(obj) -> Object of same type as a from ndarray obj.
- __contains__(...)
- x.__contains__(y) <==> y in x
- __copy__(...)
- a.__copy__(|order) -> copy, possibly with different order.
Return a copy of the array.
Argument:
order -- Order of returned copy (default 'C')
If order is 'C' (False) then the result is contiguous (default).
If order is 'Fortran' (True) then the result has fortran order.
If order is 'Any' (None) then the result has fortran order
only if m is already in fortran order.;
- __deepcopy__(...)
- a.__deepcopy__() -> Deep copy of array.
Used if copy.deepcopy is called on an array.
- __delitem__(...)
- x.__delitem__(y) <==> del x[y]
- __delslice__(...)
- x.__delslice__(i, j) <==> del x[i:j]
Use of negative indices is not supported.
- __div__(...)
- x.__div__(y) <==> x/y
- __divmod__(...)
- x.__divmod__(y) <==> divmod(x, y)
- __eq__(...)
- x.__eq__(y) <==> x==y
- __float__(...)
- x.__float__() <==> float(x)
- __floordiv__(...)
- x.__floordiv__(y) <==> x//y
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __getslice__(...)
- x.__getslice__(i, j) <==> x[i:j]
Use of negative indices is not supported.
- __gt__(...)
- x.__gt__(y) <==> x>y
- __hex__(...)
- x.__hex__() <==> hex(x)
- __iadd__(...)
- x.__iadd__(y) <==> x+y
- __iand__(...)
- x.__iand__(y) <==> x&y
- __idiv__(...)
- x.__idiv__(y) <==> x/y
- __ifloordiv__(...)
- x.__ifloordiv__(y) <==> x//y
- __ilshift__(...)
- x.__ilshift__(y) <==> x<<y
- __imod__(...)
- x.__imod__(y) <==> x%y
- __imul__(...)
- x.__imul__(y) <==> x*y
- __index__(...)
- x[y:z] <==> x[y.__index__():z.__index__()]
- __int__(...)
- x.__int__() <==> int(x)
- __invert__(...)
- x.__invert__() <==> ~x
- __ior__(...)
- x.__ior__(y) <==> x|y
- __ipow__(...)
- x.__ipow__(y) <==> x**y
- __irshift__(...)
- x.__irshift__(y) <==> x>>y
- __isub__(...)
- x.__isub__(y) <==> x-y
- __iter__(...)
- x.__iter__() <==> iter(x)
- __itruediv__(...)
- x.__itruediv__(y) <==> x/y
- __ixor__(...)
- x.__ixor__(y) <==> x^y
- __le__(...)
- x.__le__(y) <==> x<=y
- __len__(...)
- x.__len__() <==> len(x)
- __long__(...)
- x.__long__() <==> long(x)
- __lshift__(...)
- x.__lshift__(y) <==> x<<y
- __lt__(...)
- x.__lt__(y) <==> x<y
- __mod__(...)
- x.__mod__(y) <==> x%y
- __mul__(...)
- x.__mul__(y) <==> x*y
- __ne__(...)
- x.__ne__(y) <==> x!=y
- __neg__(...)
- x.__neg__() <==> -x
- __nonzero__(...)
- x.__nonzero__() <==> x != 0
- __oct__(...)
- x.__oct__() <==> oct(x)
- __or__(...)
- x.__or__(y) <==> x|y
- __pos__(...)
- x.__pos__() <==> +x
- __pow__(...)
- x.__pow__(y[, z]) <==> pow(x, y[, z])
- __radd__(...)
- x.__radd__(y) <==> y+x
- __rand__(...)
- x.__rand__(y) <==> y&x
- __rdiv__(...)
- x.__rdiv__(y) <==> y/x
- __rdivmod__(...)
- x.__rdivmod__(y) <==> divmod(y, x)
- __reduce__(...)
- a.__reduce__()
For pickling.
- __rfloordiv__(...)
- x.__rfloordiv__(y) <==> y//x
- __rlshift__(...)
- x.__rlshift__(y) <==> y<<x
- __rmod__(...)
- x.__rmod__(y) <==> y%x
- __rmul__(...)
- x.__rmul__(y) <==> y*x
- __ror__(...)
- x.__ror__(y) <==> y|x
- __rpow__(...)
- y.__rpow__(x[, z]) <==> pow(x, y[, z])
- __rrshift__(...)
- x.__rrshift__(y) <==> y>>x
- __rshift__(...)
- x.__rshift__(y) <==> x>>y
- __rsub__(...)
- x.__rsub__(y) <==> y-x
- __rtruediv__(...)
- x.__rtruediv__(y) <==> y/x
- __rxor__(...)
- x.__rxor__(y) <==> y^x
- __setslice__(...)
- x.__setslice__(i, j, y) <==> x[i:j]=y
Use of negative indices is not supported.
- __setstate__(...)
- a.__setstate__(version, shape, typecode, isfortran, rawdata)
For unpickling.
Arguments:
version -- optional pickle version. If omitted defaults to 0.
shape -- a tuple giving the shape
typecode -- a typecode
isFortran -- a bool stating if Fortran or no
rawdata -- a binary string with the data (or a list if Object array)
- __str__(...)
- x.__str__() <==> str(x)
- __sub__(...)
- x.__sub__(y) <==> x-y
- __truediv__(...)
- x.__truediv__(y) <==> x/y
- __xor__(...)
- x.__xor__(y) <==> x^y
- all(...)
- a.all(axis=None)
- any(...)
- a.any(axis=None, out=None)
- argmax(...)
- a.argmax(axis=None, out=None)
- argmin(...)
- a.argmin(axis=None, out=None)
- argsort(...)
- a.argsort(axis=-1, kind='quicksort', order=None) -> indices
Perform an indirect sort along the given axis using the algorithm specified
by the kind keyword. It returns an array of indices of the same shape as
'a' that index data along the given axis in sorted order.
:Parameters:
axis : integer
Axis to be indirectly sorted. None indicates that the flattened
array should be used. Default is -1.
kind : string
Sorting algorithm to use. Possible values are 'quicksort',
'mergesort', or 'heapsort'. Default is 'quicksort'.
order : list type or None
When a is an array with fields defined, this argument specifies
which fields to compare first, second, etc. Not all fields need be
specified.
:Returns:
indices : integer array
Array of indices that sort 'a' along the specified axis.
:SeeAlso:
- lexsort : indirect stable sort with multiple keys
- sort : inplace sort
:Notes:
------
The various sorts are characterized by average speed, worst case
performance, need for work space, and whether they are stable. A stable
sort keeps items with the same key in the same relative order. The three
available algorithms have the following properties:
|------------------------------------------------------|
| kind | speed | worst case | work space | stable|
|------------------------------------------------------|
|'quicksort'| 1 | O(n^2) | 0 | no |
|'mergesort'| 2 | O(n*log(n)) | ~n/2 | yes |
|'heapsort' | 3 | O(n*log(n)) | 0 | no |
|------------------------------------------------------|
All the sort algorithms make temporary copies of the data when the sort is not
along the last axis. Consequently, sorts along the last axis are faster and use
less space than sorts along other axis.
- astype(...)
- a.astype(t) -> Copy of array cast to type t.
Cast array m to type t. t can be either a string representing a typecode,
or a python type object of type int, float, or complex.
- byteswap(...)
- a.byteswap(False) -> View or copy. Swap the bytes in the array.
Swap the bytes in the array. Return the byteswapped array. If the first
argument is True, byteswap in-place and return a reference to self.
- choose(...)
- a.choose(b0, b1, ..., bn, out=None, mode='raise')
Return an array that merges the b_i arrays together using 'a' as
the index The b_i arrays and 'a' must all be broadcastable to the
same shape. The output at a particular position is the input
array b_i at that position depending on the value of 'a' at that
position. Therefore, 'a' must be an integer array with entries
from 0 to n+1.;
- clip(...)
- a.clip(min=, max=, out=None)
- compress(...)
- a.compress(condition=, axis=None, out=None)
- conj(...)
- a.conj()
- conjugate(...)
- a.conjugate()
- copy(...)
- a.copy(|order) -> copy, possibly with different order.
Return a copy of the array.
Argument:
order -- Order of returned copy (default 'C')
If order is 'C' (False) then the result is contiguous (default).
If order is 'Fortran' (True) then the result has fortran order.
If order is 'Any' (None) then the result has fortran order
only if m is already in fortran order.;
- cumprod(...)
- a.cumprod(axis=None, dtype=None)
- cumsum(...)
- a.cumsum(axis=None, dtype=None, out=None)
- diagonal(...)
- a.diagonal(offset=0, axis1=0, axis2=1) -> diagonals
If a is 2-d, return the diagonal of self with the given offset, i.e., the
collection of elements of the form a[i,i+offset]. If a is n-d with n > 2,
then the axes specified by axis1 and axis2 are used to determine the 2-d
subarray whose diagonal is returned. The shape of the resulting array can
be determined by removing axis1 and axis2 and appending an index to the
right equal to the size of the resulting diagonals.
:Parameters:
offset : integer
Offset of the diagonal from the main diagonal. Can be both positive
and negative. Defaults to main diagonal.
axis1 : integer
Axis to be used as the first axis of the 2-d subarrays from which
the diagonals should be taken. Defaults to first index.
axis2 : integer
Axis to be used as the second axis of the 2-d subarrays from which
the diagonals should be taken. Defaults to second index.
:Returns:
array_of_diagonals : same type as original array
If a is 2-d, then a 1-d array containing the diagonal is returned.
If a is n-d, n > 2, then an array of diagonals is returned.
:SeeAlso:
- diag : matlab workalike for 1-d and 2-d arrays.
- diagflat : creates diagonal arrays
- trace : sum along diagonals
Examples
--------
>>> a = arange(4).reshape(2,2)
>>> a
array([[0, 1],
[2, 3]])
>>> a.diagonal()
array([0, 3])
>>> a.diagonal(1)
array([1])
>>> a = arange(8).reshape(2,2,2)
>>> a
array([[[0, 1],
[2, 3]],
[[4, 5],
[6, 7]]])
>>> a.diagonal(0,-2,-1)
array([[0, 3],
[4, 7]])
- dump(...)
- a.dump(file) Dump a pickle of the array to the specified file.
The array can be read back with pickle.load or numpy.load
Arguments:
file -- string naming the dump file.
- dumps(...)
- a.dumps() returns the pickle of the array as a string.
pickle.loads or numpy.loads will convert the string back to an array.
- fill(...)
- a.fill(value) -> None. Fill the array with the scalar value.
- flatten(...)
- a.flatten([fortran]) return a 1-d array (always copy)
- getfield(...)
- a.getfield(dtype, offset) -> field of array as given type.
Returns a field of the given array as a certain type. A field is a view of
the array data with each itemsize determined by the given type and the
offset into the current array.
- item(...)
- a.item() -> copy of first array item as Python scalar.
Copy the first element of array to a standard Python scalar and return
it. The array must be of size one.
- itemset(...)
- max(...)
- a.max(axis=None)
- mean(...)
- a.mean(axis=None, dtype=None, out=None) -> mean
Returns the average of the array elements. The average is taken over the
flattened array by default, otherwise over the specified axis.
:Parameters:
axis : integer
Axis along which the means are computed. The default is
to compute the standard deviation of the flattened array.
dtype : type
Type to use in computing the means. For arrays of
integer type the default is float32, for arrays of float types it
is the same as the array type.
out : ndarray
Alternative output array in which to place the result. It must have
the same shape as the expected output but the type will be cast if
necessary.
:Returns:
mean : The return type varies, see above.
A new array holding the result is returned unless out is specified,
in which case a reference to out is returned.
:SeeAlso:
- var : variance
- std : standard deviation
Notes
-----
The mean is the sum of the elements along the axis divided by the
number of elements.
- min(...)
- a.min(axis=None)
- newbyteorder(...)
- a.newbyteorder(<byteorder>) is equivalent to
a.view(a.dtype.newbytorder(<byteorder>))
- nonzero(...)
- a.nonzero() returns a tuple of arrays
Returns a tuple of arrays, one for each dimension of a,
containing the indices of the non-zero elements in that
dimension. The corresponding non-zero values can be obtained
with
a[a.nonzero()].
To group the indices by element, rather than dimension, use
transpose(a.nonzero())
instead. The result of this is always a 2d array, with a row for
each non-zero element.;
- prod(...)
- a.prod(axis=None, dtype=None)
- ptp(...)
- a.ptp(axis=None) a.max(axis)-a.min(axis)
- put(...)
- a.put(indices, values, mode) sets a.flat[n] = values[n] for
each n in indices. If values is shorter than indices then it
will repeat.
- ravel(...)
- a.ravel([fortran]) return a 1-d array (copy only if needed)
- repeat(...)
- a.repeat(repeats=, axis=none)
copy elements of a, repeats times. the repeats argument must be a sequence
of length a.shape[axis] or a scalar.
- reshape(...)
- a.reshape(d1, d2, ..., dn, order='c')
Return a new array from this one. The new array must have the same number
of elements as self. Also always returns a view or raises a ValueError if
that is impossible.
- resize(...)
- a.resize(new_shape, refcheck=True, order=False) -> None. Change array shape.
Change size and shape of self inplace. Array must own its own memory and
not be referenced by other arrays. Returns None.
- round(...)
- a.round(decimals=0, out=None) -> out (a). Rounds to 'decimals' places.
Keyword arguments:
decimals -- number of decimals to round to (default 0). May be negative.
out -- existing array to use for output (default a).
Return:
Reference to out, where None specifies the original array a.
Round to the specified number of decimals. When 'decimals' is negative it
specifies the number of positions to the left of the decimal point. The
real and imaginary parts of complex numbers are rounded separately. Nothing
is done if the array is not of float type and 'decimals' is >= 0.
The keyword 'out' may be used to specify a different array to hold the
result rather than the default 'a'. If the type of the array specified by
'out' differs from that of 'a', the result is cast to the new type,
otherwise the original type is kept. Floats round to floats by default.
Numpy rounds to even. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round to
0.0, etc. Results may also be surprising due to the inexact representation
of decimal fractions in IEEE floating point and the errors introduced in
scaling the numbers when 'decimals' is something other than 0.
- searchsorted(...)
- a.searchsorted(v, side='left') -> index array.
Find the indices into a sorted array such that if the corresponding keys in
v were inserted before the indices the order of a would be preserved. If
side='left', then the first such index is returned. If side='right', then
the last such index is returned. If there is no such index because the key
is out of bounds, then the length of a is returned, i.e., the key would
need to be appended. The returned index array has the same shape as v.
:Parameters:
v : array or list type
Array of keys to be searched for in a.
side : string
Possible values are : 'left', 'right'. Default is 'left'. Return
the first or last index where the key could be inserted.
:Returns:
indices : integer array
The returned array has the same shape as v.
:SeeAlso:
- sort
- histogram
:Notes:
-------
The array a must be 1-d and is assumed to be sorted in ascending order.
Searchsorted uses binary search to find the required insertion points.
- setfield(...)
- m.setfield(value, dtype, offset) -> None.
places val into field of the given array defined by the data type and offset.
- setflags(...)
- a.setflags(write=None, align=None, uic=None)
- sort(...)
- a.sort(axis=-1, kind='quicksort', order=None) -> None.
Perform an inplace sort along the given axis using the algorithm specified
by the kind keyword.
:Parameters:
axis : integer
Axis to be sorted along. None indicates that the flattened array
should be used. Default is -1.
kind : string
Sorting algorithm to use. Possible values are 'quicksort',
'mergesort', or 'heapsort'. Default is 'quicksort'.
order : list type or None
When a is an array with fields defined, this argument specifies
which fields to compare first, second, etc. Not all fields need be
specified.
:Returns:
None
:SeeAlso:
- argsort : indirect sort
- lexsort : indirect stable sort on multiple keys
- searchsorted : find keys in sorted array
:Notes:
------
The various sorts are characterized by average speed, worst case
performance, need for work space, and whether they are stable. A stable
sort keeps items with the same key in the same relative order. The three
available algorithms have the following properties:
|------------------------------------------------------|
| kind | speed | worst case | work space | stable|
|------------------------------------------------------|
|'quicksort'| 1 | O(n^2) | 0 | no |
|'mergesort'| 2 | O(n*log(n)) | ~n/2 | yes |
|'heapsort' | 3 | O(n*log(n)) | 0 | no |
|------------------------------------------------------|
All the sort algorithms make temporary copies of the data when the sort is not
along the last axis. Consequently, sorts along the last axis are faster and use
less space than sorts along other axis.
- squeeze(...)
- m.squeeze() eliminate all length-1 dimensions
- std(...)
- a.std(axis=None, dtype=None, out=None) -> standard deviation.
Returns the standard deviation of the array elements, a measure of the
spread of a distribution. The standard deviation is computed for the
flattened array by default, otherwise over the specified axis.
:Parameters:
axis : integer
Axis along which the standard deviation is computed. The default is
to compute the standard deviation of the flattened array.
dtype : type
Type to use in computing the standard deviation. For arrays of
integer type the default is float32, for arrays of float types it
is the same as the array type.
out : ndarray
Alternative output array in which to place the result. It must have
the same shape as the expected output but the type will be cast if
necessary.
:Returns:
standard deviation : The return type varies, see above.
A new array holding the result is returned unless out is specified,
in which case a reference to out is returned.
:SeeAlso:
- var : variance
- mean : average
Notes
-----
The standard deviation is the square root of the average of the squared
deviations from the mean, i.e. var = sqrt(mean((x - x.mean())**2)). The
computed standard deviation is biased, i.e., the mean is computed by
dividing by the number of elements, N, rather than by N-1.
- sum(...)
- a.sum(axis=None, dtype=None) -> Sum of array over given axis.
Sum the array over the given axis. If the axis is None, sum over
all dimensions of the array.
The optional dtype argument is the data type for the returned
value and intermediate calculations. The default is to upcast
(promote) smaller integer types to the platform-dependent int.
For example, on 32-bit platforms:
a.dtype default sum dtype
---------------------------------------------------
bool, int8, int16, int32 int32
Warning: The arithmetic is modular and no error is raised on overflow.
Examples:
>>> array([0.5, 1.5]).sum()
2.0
>>> array([0.5, 1.5]).sum(dtype=int32)
1
>>> array([[0, 1], [0, 5]]).sum(axis=0)
array([0, 6])
>>> array([[0, 1], [0, 5]]).sum(axis=1)
array([1, 5])
>>> ones(128, dtype=int8).sum(dtype=int8) # overflow!
-128
- swapaxes(...)
- a.swapaxes(axis1, axis2) -> new view with axes swapped.
- take(...)
- a.take(indices, axis=None, out=None, mode='raise') -> new array.
The new array is formed from the elements of a indexed by indices along the
given axis.
- tofile(...)
- a.tofile(fid, sep="", format="%s") -> None. Write the data to a file.
Required arguments:
file -- an open file object or a string containing a filename
Keyword arguments:
sep -- separator for text output. Write binary if empty (default "")
format -- format string for text file output (default "%s")
A convenience function for quick storage of array data. Information on
endianess and precision is lost, so this method is not a good choice for
files intended to archive data or transport data between machines with
different endianess. Some of these problems can be overcome by outputting
the data as text files at the expense of speed and file size.
If 'sep' is empty this method is equivalent to file.write(a.tostring()). If
'sep' is not empty each data item is converted to the nearest Python type
and formatted using "format"%item. The resulting strings are written to the
file separated by the contents of 'sep'. The data is always written in "C"
(row major) order independent of the order of 'a'.
The data produced by this method can be recovered by using the function
fromfile().
- tolist(...)
- a.tolist() -> Array as hierarchical list.
Copy the data portion of the array to a hierarchical python list and return
that list. Data items are converted to the nearest compatible Python type.
- tostring(...)
- a.tostring(order='C') -> raw copy of array data as a Python string.
Keyword arguments:
order -- order of the data item in the copy {"C","F","A"} (default "C")
Construct a Python string containing the raw bytes in the array. The order
of the data in arrays with ndim > 1 is specified by the 'order' keyword and
this keyword overrides the order of the array. The
choices are:
"C" -- C order (row major)
"Fortran" -- Fortran order (column major)
"Any" -- Current order of array.
None -- Same as "Any"
- trace(...)
- a.trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)
return the sum along the offset diagonal of the array's indicated
axis1 and axis2.
- transpose(...)
- a.transpose(*axes)
Returns a view of 'a' with axes transposed. If no axes are given,
or None is passed, switches the order of the axes. For a 2-d
array, this is the usual matrix transpose. If axes are given,
they describe how the axes are permuted.
Example:
>>> a = array([[1,2],[3,4]])
>>> a
array([[1, 2],
[3, 4]])
>>> a.transpose()
array([[1, 3],
[2, 4]])
>>> a.transpose((1,0))
array([[1, 3],
[2, 4]])
>>> a.transpose(1,0)
array([[1, 3],
[2, 4]])
- var(...)
- a.var(axis=None, dtype=None, out=None) -> variance
Returns the variance of the array elements, a measure of the spread of a
distribution. The variance is computed for the flattened array by default,
otherwise over the specified axis.
:Parameters:
axis : integer
Axis along which the variance is computed. The default is to
compute the variance of the flattened array.
dtype : type
Type to use in computing the variance. For arrays of integer type
the default is float32, for arrays of float types it is the same as
the array type.
out : ndarray
Alternative output array in which to place the result. It must have
the same shape as the expected output but the type will be cast if
necessary.
:Returns:
variance : The return type varies, see above.
A new array holding the result is returned unless out is specified,
in which case a reference to out is returned.
:SeeAlso:
- std : standard deviation
- mean: average
Notes
-----
The variance is the average of the squared deviations from the mean, i.e.
var = mean((x - x.mean())**2). The computed variance is biased, i.e.,
the mean is computed by dividing by the number of elements, N, rather
than by N-1.
Data descriptors inherited from numpy.ndarray:
- T
- Same as transpose() except self is returned for self.ndim < 2.
- __array_interface__
- Array protocol: Python side.
- __array_priority__
- Array priority.
- __array_struct__
- Array protocol: C-struct side.
- base
- Base object if memory is from some other object.
- ctypes
- A ctypes interface object.
- data
- Buffer object pointing to the start of the data.
- dtype
- Data-type for the array.
- flags
- Special object providing array flags.
- flat
- A 1-d flat iterator.
- imag
- Imaginary part of the array.
- itemsize
- Length of one element in bytes.
- nbytes
- Number of bytes in the array.
- ndim
- Number of array dimensions.
- real
- Real part of the array.
- shape
- Tuple of array dimensions.
- size
- Number of elements in the array.
- strides
- Tuple of bytes to step in each dimension.
|
class GroupData(FITS_rec) |
| |
Random groups data object.
Allows structured access to FITS Group data in a manner analogous to tables |
| |
- Method resolution order:
- GroupData
- FITS_rec
- pyfits.rec.recarray
- numpy.ndarray
- __builtin__.object
Methods defined here:
- __getattr__(self, attr)
- __str__(self)
- par(self, parName)
- Get the group parameter values.
- setpar(self, parName, value)
- Set the group parameter values.
Static methods defined here:
- __new__(subtype, input=None, bitpix=None, pardata=None, parnames=[], bscale=None, bzero=None, parbscales=None, parbzeros=None)
- input: input data, either the group data itself (a numarray) or
a record array (FITS_rec) which will contain both group
parameter info and the data. The rest of the arguments are
used only for the first case.
bitpix: data type as expressed in FITS BITPIX value
(8, 16, 32, 64, -32, or -64)
pardata: parameter data, as a list of (numeric) arrays.
parnames: list of parameter names.
bscale: BSCALE of the data
bzero: BZERO of the data
parbscales: list of bscales for the parameters
parbzeros: list of bzeros for the parameters
Methods inherited from FITS_rec:
- __array_finalize__(self, obj)
- __getitem__(self, key)
- __repr__(self)
- __setitem__(self, row, value)
- field(self, key)
- A view of a Column's data as an array.
Methods inherited from pyfits.rec.recarray:
- __getattribute__(self, attr)
- __setattr__(self, attr, val)
- view(self, obj)
Data descriptors inherited from pyfits.rec.recarray:
- __dict__
- dictionary for instance variables (if defined)
Methods inherited from numpy.ndarray:
- __abs__(...)
- x.__abs__() <==> abs(x)
- __add__(...)
- x.__add__(y) <==> x+y
- __and__(...)
- x.__and__(y) <==> x&y
- __array__(...)
- a.__array__(|dtype) -> reference if type unchanged, copy otherwise.
Returns either a new reference to self if dtype is not given or a new array
of provided data type if dtype is different from the current dtype of the
array.
- __array_wrap__(...)
- a.__array_wrap__(obj) -> Object of same type as a from ndarray obj.
- __contains__(...)
- x.__contains__(y) <==> y in x
- __copy__(...)
- a.__copy__(|order) -> copy, possibly with different order.
Return a copy of the array.
Argument:
order -- Order of returned copy (default 'C')
If order is 'C' (False) then the result is contiguous (default).
If order is 'Fortran' (True) then the result has fortran order.
If order is 'Any' (None) then the result has fortran order
only if m is already in fortran order.;
- __deepcopy__(...)
- a.__deepcopy__() -> Deep copy of array.
Used if copy.deepcopy is called on an array.
- __delitem__(...)
- x.__delitem__(y) <==> del x[y]
- __delslice__(...)
- x.__delslice__(i, j) <==> del x[i:j]
Use of negative indices is not supported.
- __div__(...)
- x.__div__(y) <==> x/y
- __divmod__(...)
- x.__divmod__(y) <==> divmod(x, y)
- __eq__(...)
- x.__eq__(y) <==> x==y
- __float__(...)
- x.__float__() <==> float(x)
- __floordiv__(...)
- x.__floordiv__(y) <==> x//y
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __getslice__(...)
- x.__getslice__(i, j) <==> x[i:j]
Use of negative indices is not supported.
- __gt__(...)
- x.__gt__(y) <==> x>y
- __hex__(...)
- x.__hex__() <==> hex(x)
- __iadd__(...)
- x.__iadd__(y) <==> x+y
- __iand__(...)
- x.__iand__(y) <==> x&y
- __idiv__(...)
- x.__idiv__(y) <==> x/y
- __ifloordiv__(...)
- x.__ifloordiv__(y) <==> x//y
- __ilshift__(...)
- x.__ilshift__(y) <==> x<<y
- __imod__(...)
- x.__imod__(y) <==> x%y
- __imul__(...)
- x.__imul__(y) <==> x*y
- __index__(...)
- x[y:z] <==> x[y.__index__():z.__index__()]
- __int__(...)
- x.__int__() <==> int(x)
- __invert__(...)
- x.__invert__() <==> ~x
- __ior__(...)
- x.__ior__(y) <==> x|y
- __ipow__(...)
- x.__ipow__(y) <==> x**y
- __irshift__(...)
- x.__irshift__(y) <==> x>>y
- __isub__(...)
- x.__isub__(y) <==> x-y
- __iter__(...)
- x.__iter__() <==> iter(x)
- __itruediv__(...)
- x.__itruediv__(y) <==> x/y
- __ixor__(...)
- x.__ixor__(y) <==> x^y
- __le__(...)
- x.__le__(y) <==> x<=y
- __len__(...)
- x.__len__() <==> len(x)
- __long__(...)
- x.__long__() <==> long(x)
- __lshift__(...)
- x.__lshift__(y) <==> x<<y
- __lt__(...)
- x.__lt__(y) <==> x<y
- __mod__(...)
- x.__mod__(y) <==> x%y
- __mul__(...)
- x.__mul__(y) <==> x*y
- __ne__(...)
- x.__ne__(y) <==> x!=y
- __neg__(...)
- x.__neg__() <==> -x
- __nonzero__(...)
- x.__nonzero__() <==> x != 0
- __oct__(...)
- x.__oct__() <==> oct(x)
- __or__(...)
- x.__or__(y) <==> x|y
- __pos__(...)
- x.__pos__() <==> +x
- __pow__(...)
- x.__pow__(y[, z]) <==> pow(x, y[, z])
- __radd__(...)
- x.__radd__(y) <==> y+x
- __rand__(...)
- x.__rand__(y) <==> y&x
- __rdiv__(...)
- x.__rdiv__(y) <==> y/x
- __rdivmod__(...)
- x.__rdivmod__(y) <==> divmod(y, x)
- __reduce__(...)
- a.__reduce__()
For pickling.
- __rfloordiv__(...)
- x.__rfloordiv__(y) <==> y//x
- __rlshift__(...)
- x.__rlshift__(y) <==> y<<x
- __rmod__(...)
- x.__rmod__(y) <==> y%x
- __rmul__(...)
- x.__rmul__(y) <==> y*x
- __ror__(...)
- x.__ror__(y) <==> y|x
- __rpow__(...)
- y.__rpow__(x[, z]) <==> pow(x, y[, z])
- __rrshift__(...)
- x.__rrshift__(y) <==> y>>x
- __rshift__(...)
- x.__rshift__(y) <==> x>>y
- __rsub__(...)
- x.__rsub__(y) <==> y-x
- __rtruediv__(...)
- x.__rtruediv__(y) <==> y/x
- __rxor__(...)
- x.__rxor__(y) <==> y^x
- __setslice__(...)
- x.__setslice__(i, j, y) <==> x[i:j]=y
Use of negative indices is not supported.
- __setstate__(...)
- a.__setstate__(version, shape, typecode, isfortran, rawdata)
For unpickling.
Arguments:
version -- optional pickle version. If omitted defaults to 0.
shape -- a tuple giving the shape
typecode -- a typecode
isFortran -- a bool stating if Fortran or no
rawdata -- a binary string with the data (or a list if Object array)
- __sub__(...)
- x.__sub__(y) <==> x-y
- __truediv__(...)
- x.__truediv__(y) <==> x/y
- __xor__(...)
- x.__xor__(y) <==> x^y
- all(...)
- a.all(axis=None)
- any(...)
- a.any(axis=None, out=None)
- argmax(...)
- a.argmax(axis=None, out=None)
- argmin(...)
- a.argmin(axis=None, out=None)
- argsort(...)
- a.argsort(axis=-1, kind='quicksort', order=None) -> indices
Perform an indirect sort along the given axis using the algorithm specified
by the kind keyword. It returns an array of indices of the same shape as
'a' that index data along the given axis in sorted order.
:Parameters:
axis : integer
Axis to be indirectly sorted. None indicates that the flattened
array should be used. Default is -1.
kind : string
Sorting algorithm to use. Possible values are 'quicksort',
'mergesort', or 'heapsort'. Default is 'quicksort'.
order : list type or None
When a is an array with fields defined, this argument specifies
which fields to compare first, second, etc. Not all fields need be
specified.
:Returns:
indices : integer array
Array of indices that sort 'a' along the specified axis.
:SeeAlso:
- lexsort : indirect stable sort with multiple keys
- sort : inplace sort
:Notes:
------
The various sorts are characterized by average speed, worst case
performance, need for work space, and whether they are stable. A stable
sort keeps items with the same key in the same relative order. The three
available algorithms have the following properties:
|------------------------------------------------------|
| kind | speed | worst case | work space | stable|
|------------------------------------------------------|
|'quicksort'| 1 | O(n^2) | 0 | no |
|'mergesort'| 2 | O(n*log(n)) | ~n/2 | yes |
|'heapsort' | 3 | O(n*log(n)) | 0 | no |
|------------------------------------------------------|
All the sort algorithms make temporary copies of the data when the sort is not
along the last axis. Consequently, sorts along the last axis are faster and use
less space than sorts along other axis.
- astype(...)
- a.astype(t) -> Copy of array cast to type t.
Cast array m to type t. t can be either a string representing a typecode,
or a python type object of type int, float, or complex.
- byteswap(...)
- a.byteswap(False) -> View or copy. Swap the bytes in the array.
Swap the bytes in the array. Return the byteswapped array. If the first
argument is True, byteswap in-place and return a reference to self.
- choose(...)
- a.choose(b0, b1, ..., bn, out=None, mode='raise')
Return an array that merges the b_i arrays together using 'a' as
the index The b_i arrays and 'a' must all be broadcastable to the
same shape. The output at a particular position is the input
array b_i at that position depending on the value of 'a' at that
position. Therefore, 'a' must be an integer array with entries
from 0 to n+1.;
- clip(...)
- a.clip(min=, max=, out=None)
- compress(...)
- a.compress(condition=, axis=None, out=None)
- conj(...)
- a.conj()
- conjugate(...)
- a.conjugate()
- copy(...)
- a.copy(|order) -> copy, possibly with different order.
Return a copy of the array.
Argument:
order -- Order of returned copy (default 'C')
If order is 'C' (False) then the result is contiguous (default).
If order is 'Fortran' (True) then the result has fortran order.
If order is 'Any' (None) then the result has fortran order
only if m is already in fortran order.;
- cumprod(...)
- a.cumprod(axis=None, dtype=None)
- cumsum(...)
- a.cumsum(axis=None, dtype=None, out=None)
- diagonal(...)
- a.diagonal(offset=0, axis1=0, axis2=1) -> diagonals
If a is 2-d, return the diagonal of self with the given offset, i.e., the
collection of elements of the form a[i,i+offset]. If a is n-d with n > 2,
then the axes specified by axis1 and axis2 are used to determine the 2-d
subarray whose diagonal is returned. The shape of the resulting array can
be determined by removing axis1 and axis2 and appending an index to the
right equal to the size of the resulting diagonals.
:Parameters:
offset : integer
Offset of the diagonal from the main diagonal. Can be both positive
and negative. Defaults to main diagonal.
axis1 : integer
Axis to be used as the first axis of the 2-d subarrays from which
the diagonals should be taken. Defaults to first index.
axis2 : integer
Axis to be used as the second axis of the 2-d subarrays from which
the diagonals should be taken. Defaults to second index.
:Returns:
array_of_diagonals : same type as original array
If a is 2-d, then a 1-d array containing the diagonal is returned.
If a is n-d, n > 2, then an array of diagonals is returned.
:SeeAlso:
- diag : matlab workalike for 1-d and 2-d arrays.
- diagflat : creates diagonal arrays
- trace : sum along diagonals
Examples
--------
>>> a = arange(4).reshape(2,2)
>>> a
array([[0, 1],
[2, 3]])
>>> a.diagonal()
array([0, 3])
>>> a.diagonal(1)
array([1])
>>> a = arange(8).reshape(2,2,2)
>>> a
array([[[0, 1],
[2, 3]],
[[4, 5],
[6, 7]]])
>>> a.diagonal(0,-2,-1)
array([[0, 3],
[4, 7]])
- dump(...)
- a.dump(file) Dump a pickle of the array to the specified file.
The array can be read back with pickle.load or numpy.load
Arguments:
file -- string naming the dump file.
- dumps(...)
- a.dumps() returns the pickle of the array as a string.
pickle.loads or numpy.loads will convert the string back to an array.
- fill(...)
- a.fill(value) -> None. Fill the array with the scalar value.
- flatten(...)
- a.flatten([fortran]) return a 1-d array (always copy)
- getfield(...)
- a.getfield(dtype, offset) -> field of array as given type.
Returns a field of the given array as a certain type. A field is a view of
the array data with each itemsize determined by the given type and the
offset into the current array.
- item(...)
- a.item() -> copy of first array item as Python scalar.
Copy the first element of array to a standard Python scalar and return
it. The array must be of size one.
- itemset(...)
- max(...)
- a.max(axis=None)
- mean(...)
- a.mean(axis=None, dtype=None, out=None) -> mean
Returns the average of the array elements. The average is taken over the
flattened array by default, otherwise over the specified axis.
:Parameters:
axis : integer
Axis along which the means are computed. The default is
to compute the standard deviation of the flattened array.
dtype : type
Type to use in computing the means. For arrays of
integer type the default is float32, for arrays of float types it
is the same as the array type.
out : ndarray
Alternative output array in which to place the result. It must have
the same shape as the expected output but the type will be cast if
necessary.
:Returns:
mean : The return type varies, see above.
A new array holding the result is returned unless out is specified,
in which case a reference to out is returned.
:SeeAlso:
- var : variance
- std : standard deviation
Notes
-----
The mean is the sum of the elements along the axis divided by the
number of elements.
- min(...)
- a.min(axis=None)
- newbyteorder(...)
- a.newbyteorder(<byteorder>) is equivalent to
a.view(a.dtype.newbytorder(<byteorder>))
- nonzero(...)
- a.nonzero() returns a tuple of arrays
Returns a tuple of arrays, one for each dimension of a,
containing the indices of the non-zero elements in that
dimension. The corresponding non-zero values can be obtained
with
a[a.nonzero()].
To group the indices by element, rather than dimension, use
transpose(a.nonzero())
instead. The result of this is always a 2d array, with a row for
each non-zero element.;
- prod(...)
- a.prod(axis=None, dtype=None)
- ptp(...)
- a.ptp(axis=None) a.max(axis)-a.min(axis)
- put(...)
- a.put(indices, values, mode) sets a.flat[n] = values[n] for
each n in indices. If values is shorter than indices then it
will repeat.
- ravel(...)
- a.ravel([fortran]) return a 1-d array (copy only if needed)
- repeat(...)
- a.repeat(repeats=, axis=none)
copy elements of a, repeats times. the repeats argument must be a sequence
of length a.shape[axis] or a scalar.
- reshape(...)
- a.reshape(d1, d2, ..., dn, order='c')
Return a new array from this one. The new array must have the same number
of elements as self. Also always returns a view or raises a ValueError if
that is impossible.
- resize(...)
- a.resize(new_shape, refcheck=True, order=False) -> None. Change array shape.
Change size and shape of self inplace. Array must own its own memory and
not be referenced by other arrays. Returns None.
- round(...)
- a.round(decimals=0, out=None) -> out (a). Rounds to 'decimals' places.
Keyword arguments:
decimals -- number of decimals to round to (default 0). May be negative.
out -- existing array to use for output (default a).
Return:
Reference to out, where None specifies the original array a.
Round to the specified number of decimals. When 'decimals' is negative it
specifies the number of positions to the left of the decimal point. The
real and imaginary parts of complex numbers are rounded separately. Nothing
is done if the array is not of float type and 'decimals' is >= 0.
The keyword 'out' may be used to specify a different array to hold the
result rather than the default 'a'. If the type of the array specified by
'out' differs from that of 'a', the result is cast to the new type,
otherwise the original type is kept. Floats round to floats by default.
Numpy rounds to even. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round to
0.0, etc. Results may also be surprising due to the inexact representation
of decimal fractions in IEEE floating point and the errors introduced in
scaling the numbers when 'decimals' is something other than 0.
- searchsorted(...)
- a.searchsorted(v, side='left') -> index array.
Find the indices into a sorted array such that if the corresponding keys in
v were inserted before the indices the order of a would be preserved. If
side='left', then the first such index is returned. If side='right', then
the last such index is returned. If there is no such index because the key
is out of bounds, then the length of a is returned, i.e., the key would
need to be appended. The returned index array has the same shape as v.
:Parameters:
v : array or list type
Array of keys to be searched for in a.
side : string
Possible values are : 'left', 'right'. Default is 'left'. Return
the first or last index where the key could be inserted.
:Returns:
indices : integer array
The returned array has the same shape as v.
:SeeAlso:
- sort
- histogram
:Notes:
-------
The array a must be 1-d and is assumed to be sorted in ascending order.
Searchsorted uses binary search to find the required insertion points.
- setfield(...)
- m.setfield(value, dtype, offset) -> None.
places val into field of the given array defined by the data type and offset.
- setflags(...)
- a.setflags(write=None, align=None, uic=None)
- sort(...)
- a.sort(axis=-1, kind='quicksort', order=None) -> None.
Perform an inplace sort along the given axis using the algorithm specified
by the kind keyword.
:Parameters:
axis : integer
Axis to be sorted along. None indicates that the flattened array
should be used. Default is -1.
kind : string
Sorting algorithm to use. Possible values are 'quicksort',
'mergesort', or 'heapsort'. Default is 'quicksort'.
order : list type or None
When a is an array with fields defined, this argument specifies
which fields to compare first, second, etc. Not all fields need be
specified.
:Returns:
None
:SeeAlso:
- argsort : indirect sort
- lexsort : indirect stable sort on multiple keys
- searchsorted : find keys in sorted array
:Notes:
------
The various sorts are characterized by average speed, worst case
performance, need for work space, and whether they are stable. A stable
sort keeps items with the same key in the same relative order. The three
available algorithms have the following properties:
|------------------------------------------------------|
| kind | speed | worst case | work space | stable|
|------------------------------------------------------|
|'quicksort'| 1 | O(n^2) | 0 | no |
|'mergesort'| 2 | O(n*log(n)) | ~n/2 | yes |
|'heapsort' | 3 | O(n*log(n)) | 0 | no |
|------------------------------------------------------|
All the sort algorithms make temporary copies of the data when the sort is not
along the last axis. Consequently, sorts along the last axis are faster and use
less space than sorts along other axis.
- squeeze(...)
- m.squeeze() eliminate all length-1 dimensions
- std(...)
- a.std(axis=None, dtype=None, out=None) -> standard deviation.
Returns the standard deviation of the array elements, a measure of the
spread of a distribution. The standard deviation is computed for the
flattened array by default, otherwise over the specified axis.
:Parameters:
axis : integer
Axis along which the standard deviation is computed. The default is
to compute the standard deviation of the flattened array.
dtype : type
Type to use in computing the standard deviation. For arrays of
integer type the default is float32, for arrays of float types it
is the same as the array type.
out : ndarray
Alternative output array in which to place the result. It must have
the same shape as the expected output but the type will be cast if
necessary.
:Returns:
standard deviation : The return type varies, see above.
A new array holding the result is returned unless out is specified,
in which case a reference to out is returned.
:SeeAlso:
- var : variance
- mean : average
Notes
-----
The standard deviation is the square root of the average of the squared
deviations from the mean, i.e. var = sqrt(mean((x - x.mean())**2)). The
computed standard deviation is biased, i.e., the mean is computed by
dividing by the number of elements, N, rather than by N-1.
- sum(...)
- a.sum(axis=None, dtype=None) -> Sum of array over given axis.
Sum the array over the given axis. If the axis is None, sum over
all dimensions of the array.
The optional dtype argument is the data type for the returned
value and intermediate calculations. The default is to upcast
(promote) smaller integer types to the platform-dependent int.
For example, on 32-bit platforms:
a.dtype default sum dtype
---------------------------------------------------
bool, int8, int16, int32 int32
Warning: The arithmetic is modular and no error is raised on overflow.
Examples:
>>> array([0.5, 1.5]).sum()
2.0
>>> array([0.5, 1.5]).sum(dtype=int32)
1
>>> array([[0, 1], [0, 5]]).sum(axis=0)
array([0, 6])
>>> array([[0, 1], [0, 5]]).sum(axis=1)
array([1, 5])
>>> ones(128, dtype=int8).sum(dtype=int8) # overflow!
-128
- swapaxes(...)
- a.swapaxes(axis1, axis2) -> new view with axes swapped.
- take(...)
- a.take(indices, axis=None, out=None, mode='raise') -> new array.
The new array is formed from the elements of a indexed by indices along the
given axis.
- tofile(...)
- a.tofile(fid, sep="", format="%s") -> None. Write the data to a file.
Required arguments:
file -- an open file object or a string containing a filename
Keyword arguments:
sep -- separator for text output. Write binary if empty (default "")
format -- format string for text file output (default "%s")
A convenience function for quick storage of array data. Information on
endianess and precision is lost, so this method is not a good choice for
files intended to archive data or transport data between machines with
different endianess. Some of these problems can be overcome by outputting
the data as text files at the expense of speed and file size.
If 'sep' is empty this method is equivalent to file.write(a.tostring()). If
'sep' is not empty each data item is converted to the nearest Python type
and formatted using "format"%item. The resulting strings are written to the
file separated by the contents of 'sep'. The data is always written in "C"
(row major) order independent of the order of 'a'.
The data produced by this method can be recovered by using the function
fromfile().
- tolist(...)
- a.tolist() -> Array as hierarchical list.
Copy the data portion of the array to a hierarchical python list and return
that list. Data items are converted to the nearest compatible Python type.
- tostring(...)
- a.tostring(order='C') -> raw copy of array data as a Python string.
Keyword arguments:
order -- order of the data item in the copy {"C","F","A"} (default "C")
Construct a Python string containing the raw bytes in the array. The order
of the data in arrays with ndim > 1 is specified by the 'order' keyword and
this keyword overrides the order of the array. The
choices are:
"C" -- C order (row major)
"Fortran" -- Fortran order (column major)
"Any" -- Current order of array.
None -- Same as "Any"
- trace(...)
- a.trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)
return the sum along the offset diagonal of the array's indicated
axis1 and axis2.
- transpose(...)
- a.transpose(*axes)
Returns a view of 'a' with axes transposed. If no axes are given,
or None is passed, switches the order of the axes. For a 2-d
array, this is the usual matrix transpose. If axes are given,
they describe how the axes are permuted.
Example:
>>> a = array([[1,2],[3,4]])
>>> a
array([[1, 2],
[3, 4]])
>>> a.transpose()
array([[1, 3],
[2, 4]])
>>> a.transpose((1,0))
array([[1, 3],
[2, 4]])
>>> a.transpose(1,0)
array([[1, 3],
[2, 4]])
- var(...)
- a.var(axis=None, dtype=None, out=None) -> variance
Returns the variance of the array elements, a measure of the spread of a
distribution. The variance is computed for the flattened array by default,
otherwise over the specified axis.
:Parameters:
axis : integer
Axis along which the variance is computed. The default is to
compute the variance of the flattened array.
dtype : type
Type to use in computing the variance. For arrays of integer type
the default is float32, for arrays of float types it is the same as
the array type.
out : ndarray
Alternative output array in which to place the result. It must have
the same shape as the expected output but the type will be cast if
necessary.
:Returns:
variance : The return type varies, see above.
A new array holding the result is returned unless out is specified,
in which case a reference to out is returned.
:SeeAlso:
- std : standard deviation
- mean: average
Notes
-----
The variance is the average of the squared deviations from the mean, i.e.
var = mean((x - x.mean())**2). The computed variance is biased, i.e.,
the mean is computed by dividing by the number of elements, N, rather
than by N-1.
Data descriptors inherited from numpy.ndarray:
- T
- Same as transpose() except self is returned for self.ndim < 2.
- __array_interface__
- Array protocol: Python side.
- __array_priority__
- Array priority.
- __array_struct__
- Array protocol: C-struct side.
- base
- Base object if memory is from some other object.
- ctypes
- A ctypes interface object.
- data
- Buffer object pointing to the start of the data.
- dtype
- Data-type for the array.
- flags
- Special object providing array flags.
- flat
- A 1-d flat iterator.
- imag
- Imaginary part of the array.
- itemsize
- Length of one element in bytes.
- nbytes
- Number of bytes in the array.
- ndim
- Number of array dimensions.
- real
- Real part of the array.
- shape
- Tuple of array dimensions.
- size
- Number of elements in the array.
- strides
- Tuple of bytes to step in each dimension.
|
class GroupsHDU(PrimaryHDU) |
| |
FITS Random Groups HDU class. |
| |
- Method resolution order:
- GroupsHDU
- PrimaryHDU
- _py_ImageBaseHDU
- _ValidHDU
- _AllHDU
- _Verify
Methods defined here:
- __getattr__(self, attr)
- Get the 'data' or 'columns' attribute. The data of random group
FITS file will be like a binary table's data.
- __init__(self, data=None, header=None, name=None)
- size(self)
- Returns the size (in bytes) of the HDU's data part.
Methods inherited from _py_ImageBaseHDU:
- scale(self, type=None, option='old', bscale=1, bzero=0)
- Scale image data by using BSCALE/BZERO.
Call to this method will scale self.data and update the keywords
of BSCALE and BZERO in self.header. This method should only be
used right before writing to the output file, as the data will be
scaled and is therefore not very usable after the call.
type (string): destination data type, use numarray attribute format,
(e.g. 'UInt8', 'Int16', 'Float32' etc.). If is None, use the
current data type.
option: how to scale the data: if "old", use the original BSCALE
and BZERO values when the data was read/created. If
"minmax", use the minimum and maximum of the data to scale.
The option will be overwritten by any user specified
bscale/bzero values.
bscale/bzero: user specified BSCALE and BZERO values.
- update_header(self)
- Update the header keywords to agree with the data.
Data and other attributes inherited from _py_ImageBaseHDU:
- ImgCode = {'float32': -32, 'float64': -64, 'int16': 16, 'int32': 32, 'int64': 64, 'uint8': 8}
- NumCode = {-64: 'float64', -32: 'float32', 8: 'uint8', 16: 'int16', 32: 'int32', 64: 'int64'}
Methods inherited from _ValidHDU:
- copy(self)
- Make a copy of the HDU, both header and data are copied.
- req_cards(self, keywd, pos, test, fix_value, option, errlist)
- Check the existence, location, and value of a required Card.
- writeto(self, name, output_verify='exception', clobber=False)
- Write the HDU to a new file. This is a convenience method
to provide a user easier output interface if only one HDU
needs to be written to a file.
name: output FITS file name to be written to.
output_verify: output verification option, default='exception'.
clobber: Overwrite the output file if exists, default = False.
Methods inherited from _Verify:
- run_option(self, option='warn', err_text='', fix_text='Fixed.', fix='pass', fixable=1)
- Execute the verification with selected option.
- verify(self, option='warn')
- Wrapper for _verify.
|
class HDUList(__builtin__.list, _Verify) |
| |
HDU list class. This is the top-level FITS object. When a FITS
file is opened, a HDUList object is returned. |
| |
- Method resolution order:
- HDUList
- __builtin__.list
- __builtin__.object
- _Verify
Methods defined here:
- __delitem__(self, key)
- Delete an HDU from the HDUList, indexed by number or name.
- __delslice__(self, i, j)
- Delete a slice of HDUs from the HDUList, indexed by number only.
- __getitem__(self, key)
- Get an HDU from the HDUList, indexed by number or name.
- __getslice__(self, start, end)
- __init__(self, hdus=[], file=None)
- Construct a HDUList object.
hdus: Input, can be a list of HDU's or a single HDU. Default = None,
i.e. an empty HDUList.
file: The opened physical file associated with the HDUList.
Default = None.
- __iter__(self)
- __setitem__(self, key, hdu)
- Set an HDU to the HDUList, indexed by number or name.
- append(self, hdu)
- Append a new HDU to the HDUList.
- close(self, output_verify='exception', verbose=0)
- Close the associated FITS file and memmap object, if any.
output_verify: output verification option, default = 'exception'.
verbose: print out verbose messages? default = 0.
This simply calls the close method of the _File class. It has this
two-tier calls because _File has ts own private attribute __file.
- flush(self, output_verify='exception', verbose=0)
- Force a write of the HDUList back to the file (for append and
update modes only).
output_verify: output verification option, default = 'exception'.
verbose: print out verbose messages? default = 0.
- index_of(self, key)
- Get the index of an HDU from the HDUList. The key can be an
integer, a string, or a tuple of (string, integer).
- info(self)
- Summarize the info of the HDU's in this HDUList.
- readall(self)
- Read data of all HDU's into memory.
- update_extend(self)
- Make sure if the primary header needs the keyword EXTEND or if
it has the proper value.
- update_tbhdu(self)
- Update all table HDU's for scaled fields.
- writeto(self, name, output_verify='exception', clobber=False)
- Write the HDUList to a new file.
name: output FITS file name to be written to.
output_verify: output verification option, default = 'exception'.
clobber: Overwrite the output file if exists, default = False.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Methods inherited from __builtin__.list:
- __add__(...)
- x.__add__(y) <==> x+y
- __contains__(...)
- x.__contains__(y) <==> y in x
- __eq__(...)
- x.__eq__(y) <==> x==y
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __gt__(...)
- x.__gt__(y) <==> x>y
- __hash__(...)
- x.__hash__() <==> hash(x)
- __iadd__(...)
- x.__iadd__(y) <==> x+=y
- __imul__(...)
- x.__imul__(y) <==> x*=y
- __le__(...)
- x.__le__(y) <==> x<=y
- __len__(...)
- x.__len__() <==> len(x)
- __lt__(...)
- x.__lt__(y) <==> x<y
- __mul__(...)
- x.__mul__(n) <==> x*n
- __ne__(...)
- x.__ne__(y) <==> x!=y
- __repr__(...)
- x.__repr__() <==> repr(x)
- __reversed__(...)
- L.__reversed__() -- return a reverse iterator over the list
- __rmul__(...)
- x.__rmul__(n) <==> n*x
- __setslice__(...)
- x.__setslice__(i, j, y) <==> x[i:j]=y
Use of negative indices is not supported.
- count(...)
- L.count(value) -> integer -- return number of occurrences of value
- extend(...)
- L.extend(iterable) -- extend list by appending elements from the iterable
- index(...)
- L.index(value, [start, [stop]]) -> integer -- return first index of value
- insert(...)
- L.insert(index, object) -- insert object before index
- pop(...)
- L.pop([index]) -> item -- remove and return item at index (default last)
- remove(...)
- L.remove(value) -- remove first occurrence of value
- reverse(...)
- L.reverse() -- reverse *IN PLACE*
- sort(...)
- L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
cmp(x, y) -> -1, 0, 1
Data and other attributes inherited from __builtin__.list:
- __new__ = <built-in method __new__ of type object at 0x720020>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
Methods inherited from _Verify:
- run_option(self, option='warn', err_text='', fix_text='Fixed.', fix='pass', fixable=1)
- Execute the verification with selected option.
- verify(self, option='warn')
- Wrapper for _verify.
|
class Header |
| |
FITS header class. |
| |
Methods defined here:
- __delitem__(self, key)
- Delete card(s) with the name 'key'.
- __getitem__(self, key)
- Get a header keyword value.
- __init__(self, cards=[])
- Construct a Header from a CardList.
cards: A list of Cards, default=[].
- __setitem__(self, key, value)
- Set a header keyword value.
- __str__(self)
- add_blank(self, value='', before=None, after=None)
- Add a blank card.
value: Text to be added.
before: [same as in update()]
after: [same as in update()]
- add_comment(self, value, before=None, after=None)
- Add a COMMENT card.
value: Comment text to be added.
before: [same as in update()]
after: [same as in update()]
- add_history(self, value, before=None, after=None)
- Add a HISTORY card.
value: History text to be added.
before: [same as in update()]
after: [same as in update()]
- ascardlist(self)
- Returns a CardList.
- copy(self)
- Make a copy of the Header.
- get(self, key, default=None)
- Get a keyword value from the CardList.
If no keyword is found, return the default value.
key: keyword name or index
default: if no keyword is found, the value to be returned.
- get_comment(self)
- Get all comments as a list of string texts.
- get_history(self)
- Get all histories as a list of string texts.
- has_key(self, key)
- Check for existence of a keyword. Returns 1 if found, otherwise, 0.
key: keyword name. If given an index, always returns 0.
- items(self)
- Return a list of all keyword-value pairs from the CardList.
- rename_key(self, oldkey, newkey, force=0)
- Rename a card's keyword in the header.
oldkey: old keyword, can be a name or index.
newkey: new keyword, must be a string.
force: if new key name already exist, force to have duplicate name.
- update(self, key, value, comment=None, before=None, after=None)
- Update one header card.
|
class ImageHDU(_ExtensionHDU, _py_ImageBaseHDU) |
| |
FITS image extension HDU class. |
| |
- Method resolution order:
- ImageHDU
- _ExtensionHDU
- _ValidHDU
- _AllHDU
- _Verify
- _py_ImageBaseHDU
Methods defined here:
- __init__(self, data=None, header=None, name=None)
- Construct an image HDU.
data: the data in the HDU, default=None.
header: the header to be used (as a template), default=None.
If header=None, a minimal Header will be provided.
name: The name of the HDU, will be the value of the keywod EXTNAME,
default=None.
Methods inherited from _ExtensionHDU:
- __setattr__(self, attr, value)
- Set an HDU attribute.
Methods inherited from _ValidHDU:
- copy(self)
- Make a copy of the HDU, both header and data are copied.
- req_cards(self, keywd, pos, test, fix_value, option, errlist)
- Check the existence, location, and value of a required Card.
- size(self)
- Size (in bytes) of the data portion of the HDU.
- writeto(self, name, output_verify='exception', clobber=False)
- Write the HDU to a new file. This is a convenience method
to provide a user easier output interface if only one HDU
needs to be written to a file.
name: output FITS file name to be written to.
output_verify: output verification option, default='exception'.
clobber: Overwrite the output file if exists, default = False.
Methods inherited from _Verify:
- run_option(self, option='warn', err_text='', fix_text='Fixed.', fix='pass', fixable=1)
- Execute the verification with selected option.
- verify(self, option='warn')
- Wrapper for _verify.
Methods inherited from _py_ImageBaseHDU:
- __getattr__(self, attr)
- Get the data attribute.
- scale(self, type=None, option='old', bscale=1, bzero=0)
- Scale image data by using BSCALE/BZERO.
Call to this method will scale self.data and update the keywords
of BSCALE and BZERO in self.header. This method should only be
used right before writing to the output file, as the data will be
scaled and is therefore not very usable after the call.
type (string): destination data type, use numarray attribute format,
(e.g. 'UInt8', 'Int16', 'Float32' etc.). If is None, use the
current data type.
option: how to scale the data: if "old", use the original BSCALE
and BZERO values when the data was read/created. If
"minmax", use the minimum and maximum of the data to scale.
The option will be overwritten by any user specified
bscale/bzero values.
bscale/bzero: user specified BSCALE and BZERO values.
- update_header(self)
- Update the header keywords to agree with the data.
Data and other attributes inherited from _py_ImageBaseHDU:
- ImgCode = {'float32': -32, 'float64': -64, 'int16': 16, 'int32': 32, 'int64': 64, 'uint8': 8}
- NumCode = {-64: 'float64', -32: 'float32', 8: 'uint8', 16: 'int16', 32: 'int32', 64: 'int64'}
|
class PrimaryHDU(_py_ImageBaseHDU) |
| |
FITS primary HDU class. |
| |
- Method resolution order:
- PrimaryHDU
- _py_ImageBaseHDU
- _ValidHDU
- _AllHDU
- _Verify
Methods defined here:
- __init__(self, data=None, header=None)
- Construct a primary HDU.
data: the data in the HDU, default=None.
header: the header to be used (as a template), default=None.
If header=None, a minimal Header will be provided.
Methods inherited from _py_ImageBaseHDU:
- __getattr__(self, attr)
- Get the data attribute.
- scale(self, type=None, option='old', bscale=1, bzero=0)
- Scale image data by using BSCALE/BZERO.
Call to this method will scale self.data and update the keywords
of BSCALE and BZERO in self.header. This method should only be
used right before writing to the output file, as the data will be
scaled and is therefore not very usable after the call.
type (string): destination data type, use numarray attribute format,
(e.g. 'UInt8', 'Int16', 'Float32' etc.). If is None, use the
current data type.
option: how to scale the data: if "old", use the original BSCALE
and BZERO values when the data was read/created. If
"minmax", use the minimum and maximum of the data to scale.
The option will be overwritten by any user specified
bscale/bzero values.
bscale/bzero: user specified BSCALE and BZERO values.
- update_header(self)
- Update the header keywords to agree with the data.
Data and other attributes inherited from _py_ImageBaseHDU:
- ImgCode = {'float32': -32, 'float64': -64, 'int16': 16, 'int32': 32, 'int64': 64, 'uint8': 8}
- NumCode = {-64: 'float64', -32: 'float32', 8: 'uint8', 16: 'int16', 32: 'int32', 64: 'int64'}
Methods inherited from _ValidHDU:
- copy(self)
- Make a copy of the HDU, both header and data are copied.
- req_cards(self, keywd, pos, test, fix_value, option, errlist)
- Check the existence, location, and value of a required Card.
- size(self)
- Size (in bytes) of the data portion of the HDU.
- writeto(self, name, output_verify='exception', clobber=False)
- Write the HDU to a new file. This is a convenience method
to provide a user easier output interface if only one HDU
needs to be written to a file.
name: output FITS file name to be written to.
output_verify: output verification option, default='exception'.
clobber: Overwrite the output file if exists, default = False.
Methods inherited from _Verify:
- run_option(self, option='warn', err_text='', fix_text='Fixed.', fix='pass', fixable=1)
- Execute the verification with selected option.
- verify(self, option='warn')
- Wrapper for _verify.
|
class StreamingHDU |
| |
A class that provides the capability to stream data to a FITS file
instead of requiring data to all be written at once.
The following psudo code illustrates its use:
header = pyfits.Header()
for all the cards you need in the header:
header.update(key,value,comment)
shdu = pyfits.StreamingHDU('filename.fits',header)
for each piece of data:
shdu.write(data)
shdu.close() |
| |
Methods defined here:
- __init__(self, name, header)
- Construct a StreamingHDU object given a file name and a header.
:Parameters:
name : string
The name of the file to which the header and data will be
streamed.
header : Header
The header object associated with the data to be written
to the file.
:Returns:
None
Notes
-----
The file will be opened and the header appended to the end of
the file. If the file does not already exist, it will be created
and if the header represents a Primary header, it will be written
to the beginning of the file. If the file does not exist and the
provided header is not a Primary header, a default Primary HDU will
be inserted at the beginning of the file and the provided header
will be added as the first extension. If the file does already
exist, but the provided header represents a Primary header, the
header will be modified to an image extension header and appended
to the end of the file.
- close(self)
- Close the 'physical' FITS file.
:Parameters:
None
:Returns:
None
- size(self)
- Return the size (in bytes) of the data portion of the HDU.
:Parameters:
None
:Returns:
size : integer
The number of bytes of data required to fill the stream
per the header provided in the constructor.
- write(self, data)
- Write the given data to the stream.
:Parameters:
data : ndarray
Data to stream to the file.
:Returns:
writeComplete : integer
Flag that when true indicates that all of the required data
has been written to the stream.
Notes
-----
Only the amount of data specified in the header provided to the
class constructor may be written to the stream. If the provided
data would cause the stream to overflow, an IOError exception is
raised and the data is not written. Once sufficient data has been
written to the stream to satisfy the amount specified in the header,
the stream is padded to fill a complete FITS block and no more data
will be accepted. An attempt to write more data after the stream
has been filled will raise an IOError exception. If the dtype of
the input data does not match what is expected by the header, a
TypeError exception is raised.
|
class TableHDU(_TableBaseHDU) |
| |
FITS ASCII table extension HDU class. |
| |
- Method resolution order:
- TableHDU
- _TableBaseHDU
- _ExtensionHDU
- _ValidHDU
- _AllHDU
- _Verify
Methods defined here:
- __init__(self, data=None, header=None, name=None)
- data: data of the table
header: header to be used for the HDU
name: the EXTNAME value
Methods inherited from _TableBaseHDU:
- __getattr__(self, attr)
- Get the 'data' or 'columns' attribute.
- copy(self)
- Make a copy of the table HDU, both header and data are copied.
- get_coldefs(self)
- Returns the table's column definitions.
- update(self)
- Update header keywords to reflect recent changes of columns.
Methods inherited from _ExtensionHDU:
- __setattr__(self, attr, value)
- Set an HDU attribute.
Methods inherited from _ValidHDU:
- req_cards(self, keywd, pos, test, fix_value, option, errlist)
- Check the existence, location, and value of a required Card.
- size(self)
- Size (in bytes) of the data portion of the HDU.
- writeto(self, name, output_verify='exception', clobber=False)
- Write the HDU to a new file. This is a convenience method
to provide a user easier output interface if only one HDU
needs to be written to a file.
name: output FITS file name to be written to.
output_verify: output verification option, default='exception'.
clobber: Overwrite the output file if exists, default = False.
Methods inherited from _Verify:
- run_option(self, option='warn', err_text='', fix_text='Fixed.', fix='pass', fixable=1)
- Execute the verification with selected option.
- verify(self, option='warn')
- Wrapper for _verify.
|
|