cf.Partition.dataarray

Partition.dataarray(dimensions=None, directions=None, units=None, save=False, revert_to_file=False, hardmask=True, dtype=None, readonly=False, copy_regardless=False, func=None, update=True)[source]

Returns the partition’s data array.

After a partition has been conformed, the partition must be closed (with the close method) before another partition is conformed, otherwise a memory leak could occur. For example:

>>> dimensions     = partition_array._dimensions
>>> directions     = partition_array._directions
>>> units          = partition_array.units
>>> save           = partition_array.save_to_disk()
>>> revert_to_file = True
>>> for partition in partition_array.flat():
...
...    # Conform the partition
...    partition.dataarray(**conform_args)
...
...    # [ Some code to operate on the conformed partition ]
...
...    # Close the partition
...    partition.close()
...
...    # Now move on to conform the next partition 
...
>>>  
Parameters :

dimensions : list

directions : dict

units : Units

save : bool, optional

Modifies the behaviour of the close method, in conjunction with revert_to_file. By default is False.

save

revert_to_file

Behaviour of the close method

False

True or False

The subarray is replaced with the data array, which is kept in memory when the close method is called.

True

False

The subarray is replaced with the data array, which is saved to a temporary file on disk when the close method is called.

True

True

If the subarray was on disk then the file pointer will be reinstated when the close method is called.

revert_to_file : bool, optional

Modifies the behaviour of the close method, in conjunction with save. By default is False.

dtype : numpy.dtype, optional

Convert the partition’s data array to this data type. By default no conversion occurs.

hardmask : bool, optional

If False then force the partition’s data array’s mask to be soft. By default the mask is forced to be hard.

Returns :
out : numpy array

The partition’s data array as a numpy array.

Raises :
ValueError :

A ValueError is raised if the data type conversion specified with the dtype parameter is not possible (as would be the case when attempting to convert a string to a float, for example).

Previous topic

cf.Partition.copy

Next topic

cf.Partition.file_close

This Page