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.

__init__(*args, **kwargs)

Methods

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.

pad()

Gets pad value of the copied variable.

rv()

Gets record variance of the variable this was copied from.

set(key, value)

Set CDF metadata

sparse()

Gets sparse records mode of the copied variable.

type()

Returns CDF type of the variable this was copied from.

Attributes

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

pad()[source]

Gets pad value of the copied variable.

This copy does not preserve which records were written, i.e. the entire copy is read, including pad values, and the pad values are treated as real data (if, e.g. writing to another CDF).

For details on padding, see spacepy.pycdf.Var.pad().

Returns:
various

Pad value, matching type of the variable.

Notes

Added in version 0.2.3.

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.

sparse()[source]

Gets sparse records mode of the copied variable.

This copy does not preserve which records were written, i.e. the entire copy is read, including pad values, and the pad values are treated as real data (if, e.g. writing to another CDF).

For details on sparse records, see spacepy.pycdf.Var.sparse().

Returns:
ctypes.c_long

Sparse record type

Notes

Added in version 0.2.3.

type()[source]

Returns CDF type of the variable this was copied from.

Returns:
int

CDF type

Allowed_Attributes = ['attrs', '_cdf_meta']
attrs: collections.abc.Mapping