spacepy.pycdf.zAttrList¶
- class spacepy.pycdf.zAttrList(zvar)[source]¶
Object representing all the zAttributes in a zVariable.
Normally accessed as an attribute of a
Var
in an open CDF:>>> epoch_attribs = cdffile['Epoch'].attrs
Appears as a dictionary: keys are attribute names, values are the value of the zEntry associated with the appropriate zVariable. Each vAttribute in a CDF may only have a single entry associated with each variable. The entry may be a string, a single numerical value, or a series of numerical values. Entries with multiple values are returned as an entire list; direct access to the individual elements is not possible.
Example: finding the first dependency of (ISTP-compliant) variable
Flux
:>>> print cdffile['Flux'].attrs['DEPEND_0']
zAttributes are shared among zVariables, one zEntry allowed per zVariable. (pyCDF hides this detail.) Deleting the last zEntry for a zAttribute will delete the underlying zAttribute.
zEntries are created and destroyed by the usual dict methods on the zAttrlist:
>>> epoch_attribs['new_entry'] = [1, 2, 4] #assign a list to new zEntry >>> del epoch_attribs['new_entry'] #delete the zEntry
The type of the zEntry is guessed from data provided. The type is chosen to match the data; subject to that constraint, it will try to match (in order):
existing zEntry corresponding to this zVar
other zEntries in this zAttribute
the type of this zVar
data-matching constraints described in
CDF.new()
See also
- __init__(zvar)[source]¶
Initialize the attribute collection
- Parameters:
- zvar
Var
zVariable these attributes are in
- zvar
Methods
type
(name[, new_type])Find or change the CDF type of a zEntry in this zVar
Attributes
- type(name, new_type=None)[source]¶
Find or change the CDF type of a zEntry in this zVar
- Parameters:
- namestring
name of the zAttr to check or change
- new_typectypes.c_long
type to change it to, see
pycdf.const
- Returns:
- CDF variable typeint
Notes
If changing types, old and new must be equivalent, see CDF User’s guide section 2.5.5 pg. 57
- attr_name = 'zAttribute'¶
- global_scope = False¶