natcap.invest.recreation.buffered_numpy_disk_map module¶
Buffered file manager module.
- class natcap.invest.recreation.buffered_numpy_disk_map.BufferedNumpyDiskMap(manager_filename, max_bytes_to_buffer)¶
Bases:
object
Persistent object to append and read numpy arrays to unique keys.
This object is abstractly a key/value pair map where the operations are to append, read, and delete numpy arrays associated with those keys. The object attempts to keep data in RAM as much as possible and saves data to files on disk to manage memory and persist between instantiations.
- append(array_id, array_data)¶
Append data to the file.
- Parameters:
array_id (int) – unique key to identify the array node
array_data (numpy.ndarray) – data to append to node.
- Returns:
None
- delete(array_id)¶
Delete node array_id from disk and cache.
- flush()¶
Method to flush data in memory to disk.
- read(array_id)¶
Read the entirety of the file.
Internally this might mean that part of the file is read from disk and the end from the buffer or any combination of those.
- Parameters:
array_id (string) – unique node id to read
- Returns:
contents of node as a numpy.ndarray.