spacepy.pycdf.Attr¶
-
class
spacepy.pycdf.Attr(cdf_file, attr_name, create=False)[source]¶ An attribute, g or z, for a CDF
Warning
This class should not be used directly, but only in its subclasses,
gAttrandzAttr. The methods listed here are safe to use in the subclasses.Represents a CDF attribute, providing access to the Entries in a format that looks like a Python list. General list information is available in the python docs: 1, 2, 3.
An introduction to CDF attributes can be found in section 2.4 of the CDF user’s guide.
Each element of the list is a single Entry of the appropriate type. The index to the elements is the Entry number.
Multi-dimensional slicing is not supported; an Entry with multiple elements will have all elements returned (and can thus be sliced itself). Example:
>>> first_three = attribute[5, 0:3] #will fail >>> first_three = attribute[5][0:3] #first three elements of 5th Entry
append(data)Add an entry to end of attribute
has_entry(number)Check if this attribute has a particular Entry number
insert(index, data)Insert an entry at a particular number
max_idx()Maximum index of Entries for this Attr
new(data[, type, number])Create a new Entry in this Attribute
number()Find the attribute number for this attribute
rename(new_name)Rename this attribute
type(number[, new_type])Find or change the CDF type of a particular Entry number
-
append(data)[source]¶ Add an entry to end of attribute
Puts entry after last defined entry (does not fill gaps)
- Parameters
- data :
data for the new entry
-
has_entry(number)[source]¶ Check if this attribute has a particular Entry number
- Parameters
- numberint
number of Entry to check or change
- Returns
- outbool
True if
numberis a valid entry number; False if not
-
insert(index, data)[source]¶ Insert an entry at a particular number
Inserts entry at particular number while moving all subsequent entries to one entry number later. Does not close gaps.
- Parameters
- indexint
index where to put the new entry
- data :
data for the new entry
-
new(data, type=None, number=None)[source]¶ Create a new Entry in this Attribute
Note
If
numberis provided and an Entry with that number already exists, it will be overwritten.- Parameters
- data
data to put in the Entry
- Other Parameters
- typeint
type of the new Entry, from
const(otherwise guessed fromdata)- numberint
Entry number to write, default is lowest available number.
-
rename(new_name)[source]¶ Rename this attribute
Renaming a zAttribute renames it for all zVariables in this CDF!
- Parameters
- new_namestr
the new name of the attribute
-
type(number, new_type=None)[source]¶ Find or change the CDF type of a particular Entry number
- Parameters
- numberint
number of Entry to check or change
- Returns
- outint
CDF variable type, see
const
- Other Parameters
- new_type
type to change this Entry to, from
const. Omit to only check type.
Notes
If changing types, old and new must be equivalent, see CDF User’s Guide section 2.5.5 pg. 57
-
