pds4_tools.reader.data module¶
Classes¶
PDS_array |
A factory and helper class to work with PDS_ndarray and PDS_marray. |
PDS_ndarray |
PDS ndarray, enabling some record array functionality and having a meta_data attribute. |
PDS_marray |
PDS masked array, enabling some record array functionality and having a meta_data attribute. |
Details¶
-
class
PDS_array
[source]¶ Bases:
object
A factory and helper class to work with PDS_ndarray and PDS_marray.
Intended such that
PDS_ndarray
andPDS_marray
never need to be separately imported or called, and rather that all initialization and type checking should go through this helper class.
-
class
PDS_ndarray
[source]¶ Bases:
numpy.ndarray
PDS ndarray, enabling some record array functionality and having a meta_data attribute.
Subclasses ndarrays such that we can provide meta data for an individual array or table field.
Inherits all Attributes from
np.ndarray
.Parameters: data : array_like
Data for the array.
meta_data : Meta_ArrayStructure or Meta_Field, optional
Meta-data for the array.
options : dict, optional
NumPy keywords to pass to the
np.ndarray
initializer.Attributes
meta_data (Meta_ArrayStructure, Meta_Field or None) Meta-data for the array. Defaults to None if no meta-data was given on initialization or has been set. -
copy
(order=u'C')[source]¶ Copy the array.
Parameters: order : {‘C’, ‘F’, ‘A’, ‘K’}, optional
Controls the memory layout of the copy. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible.
Returns: PDS_ndarray
An array with both the data and meta data copied.
-
field
(key, val=None)[source]¶ Get or set data for a single field.
Parameters: key : int or str
Key to select the field on. Either the name of the field, or its index.
val : any, optional
If given, sets the field specified by key to have value of val.
Returns: any or None
A view of the selected field, if val is None. Otherwise returns None.
-
set_field
(data, meta_data, name=None)[source]¶ Set data and meta data for a single field.
Parameters: data : any
Data to set for the field.
meta_data : Meta_Field
Meta data to set for the field. If name is None, then the field name to set data for will be pulled from this attribute.
name : str, optional
The name of the field to set data for.
Returns: None
-
-
class
PDS_marray
[source]¶ Bases:
numpy.ma.core.MaskedArray
,pds4_tools.reader.data.PDS_ndarray
PDS masked array, enabling some record array functionality and having a meta_data attribute.
Subclasses np.ma.MaskedArray such that we can provide meta data for an individual array or table field.
Inherits all Attributes from
np.ma.MaskedArray
.Parameters: data : array_like
Data for the array.
meta_data : Meta_ArrayStructure or Meta_Field, optional
Meta-data for the array.
options : dict, optional
NumPy keywords to pass to the
np.ndarray
initializer.Attributes
meta_data (Meta_ArrayStructure, Meta_Field or None) Meta-data for the array. Defaults to None if no meta-data was given on initialization or has been set. -
view
(dtype=None, type=None, fill_value=None)[source]¶ Return a view of the PDS_marray data.
Subclassed to fix a NumPy bug that breaks setting fill_value when subselecting a field from a structured array.
-
filled
(fill_value=None)[source]¶ Return a copy of self, with masked values filled with a given value.
Parameters: fill_value : scalar, optional
The value to use for invalid entries. If None, the
fill_value
attribute of the array is used instead. Defaults to None.Returns: PDS_ndarray
A copy of
self
with invalid entries replaced by fill_value.
-
compressed
()[source]¶ Return a copy of all the non-masked data as a 1-D array.
Returns: PDS_ndarray
A new array holding the non-masked data is returned.
-
copy
(order=u'C')[source]¶ Copy the array.
Parameters: order : {‘C’, ‘F’, ‘A’, ‘K’}, optional
Controls the memory layout of the copy. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible.
Returns: PDS_marray
An array with both the data and meta data copied.
-
fill_value
¶
-
set_fill_value
(value=None)[source]¶ Set the filling value.
Parameters: value : scalar, optional
A value used to fill the invalid entries of the masked array.
Returns: None
-
set_field
(data, meta_data, name=None)[source]¶ Set data and meta data for a single field.
Parameters: data : any
Data to set for the field.
meta_data : Meta_Field
Meta data to set for the field. If name is None, then the field name to set data for will be pulled from this attribute.
name : str, optional
The name of the field to set data for.
Returns: None
-