herostools.actor.archiver.array
===============================

.. py:module:: herostools.actor.archiver.array


Classes
-------

.. autoapisummary::

   herostools.actor.archiver.array.ArrayArchiver


Module Contents
---------------

.. py:class:: ArrayArchiver(save_template: str, split_data_array: bool = False, *args, **kwargs)

   Bases: :py:obj:`herostools.actor.archiver.base.HERODataArchiver`


   HERODataArchiver that saves numpy arrays as ``.npy`` files.

   :param object_selector: Zenoh object selector for the devices to subscribe to.
   :param event_name: Name of the event.
   :param save_template: Jinja2 template used to generate the output file path from
                         the payload metadata.
   :param split_data_array: When ``True``, each row of a 2-D array is saved as a
                            separate file.  Use ``{{ _split_index }}`` in ``save_template`` to
                            embed the row index in the filename.
   :param default_metadata: Default metadata available to the filename template.
   :param max_retries: Number of times to retry a failed store before dropping the item.

   .. rubric:: Example

   BOSS json configuration::

       {
         "_id": "my-camera-capturer",
         "classname": "herostools.archiver.ArrayArchiver",
         "arguments": {
           "object_selector": "my-camera",
           "event_name": "acquisition_data",
           "default_metadata": {
             "file_path": "/mnt/mystorage/images"
           },
           "save_template": "{{ file_path }}/testimg-{{ '%04d' % ( frame / 2 ) |round(0, 'floor') }}-{{ frame % 2 }}.npy"
         }
       }

   Generates paths such as::

       /mnt/mystorage/images/testimg-0000-0.npy
       /mnt/mystorage/images/testimg-0000-1.npy


   .. py:attribute:: name_template


   .. py:attribute:: split_data_array
      :value: False



   .. py:method:: _store(source_name: str, payload: numpy.typing.NDArray[Any], metadata: dict) -> None

      Save the payload as a numpy ``.npy`` file.

      :param source_name: Name of the event source (the HERO).
      :param payload: Data to save as a numpy array.
      :param metadata: Incoming metadata merged with ``default_metadata``.



