spacepy.pycdf.VarCopy

class spacepy.pycdf.VarCopy(zVar)[source]

A list-like copy of the data and attributes in a Var

Data are in the list elements. CDF attributes are in a dict, accessed through attrs. (I.e., data and attributes are accessed like in a Var.)

Do not instantiate this class directly; use copy() on an existing Var.

Several methods provide access to details about how the original variable was constructed. This is mostly for making it easier to reproduce the variable by passing it to new(). Operations that e.g. change the dimensionality of the copy may make this (or any) metadata out of date; see set() to update.

compress(*args, **kwargs)

Gets compression of the variable this was copied from.

dv()

Gets dimension variance of the variable this was copied from.

nelems()

Gets number of elements of the variable this was copied from.

rv()

Gets record variance of the variable this was copied from.

set(key, value)

Set CDF metadata

type()

Returns CDF type of the variable this was copied from.

attrs

Python dictionary containing attributes copied from the zVar

compress(*args, **kwargs)[source]

Gets compression of the variable this was copied from.

For details on CDF compression, see spacepy.pycdf.Var.compress().

If any arguments are specified, calls numpy.ndarray.compress() instead (as the names conflict)

Returns
tuple

compression type, parameter currently in effect.

dv()[source]

Gets dimension variance of the variable this was copied from.

Each dimension other than the record dimension may either vary or not.

Returns
list of boolean

True if that dimension has variance, else False

nelems()[source]

Gets number of elements of the variable this was copied from.

This is usually 1 except for strings, where it is the length of the string.

Returns
int

Number of elements in parent variable

rv()[source]

Gets record variance of the variable this was copied from.

Returns
boolean

True if parent variable was record varying, False if NRV

set(key, value)[source]

Set CDF metadata

Set the metadata describing the original variable this was copied from. Can be used to update the metadata if transformation of the copy has made it out of date (e.g. by removing dimensions.) There is very little checking done and this function should only be used with care.

Parameters
keystr

Which metadata to set; this matches the name of the method used to retrieve it (e.g. use type to set the CDF type, which is returned by type()).

value

Value to assign to key.

type()[source]

Returns CDF type of the variable this was copied from.

Returns
int

CDF type