How to use the pynpoint.core.dataio.OutputPort function in pynpoint

To help you get started, we’ve selected a few pynpoint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PynPoint / PynPoint / tests / test_core / test_outputport.py View on Github external
def test_create_instance(self) -> None:

        with pytest.raises(ValueError) as error:
            OutputPort('config', self.storage)

        assert str(error.value) == 'The tag name \'config\' is reserved for the central ' \
                                   'configuration of PynPoint.'

        with pytest.raises(ValueError) as error:
            OutputPort('fits_header', self.storage)

        assert str(error.value) == 'The tag name \'fits_header\' is reserved for storage of the ' \
                                   'FITS headers.'

        active_port = OutputPort('test', self.storage, activate_init=True)
        deactive_port = OutputPort('test', self.storage, activate_init=False)
        control_port = InputPort('test', self.storage)

        deactive_port.open_port()
        deactive_port.set_all(np.asarray([0, 1, 2, 3]))
        deactive_port.flush()

        with pytest.warns(UserWarning) as warning:
            control_port.get_all()

        assert len(warning) == 1

        assert warning[0].message.args[0] == 'No data under the tag which is linked by the ' \
                                             'InputPort.'

        active_port.set_all(np.asarray([0, 1, 2, 3]))
        active_port.flush()
github PynPoint / PynPoint / tests / test_core / test_outputport.py View on Github external
def create_output_port(self, tag_name: str) -> OutputPort:

        outport = OutputPort(tag_name, self.storage)

        return outport
github PynPoint / PynPoint / tests / test_core / test_outputport.py View on Github external
def test_create_instance(self) -> None:

        with pytest.raises(ValueError) as error:
            OutputPort('config', self.storage)

        assert str(error.value) == 'The tag name \'config\' is reserved for the central ' \
                                   'configuration of PynPoint.'

        with pytest.raises(ValueError) as error:
            OutputPort('fits_header', self.storage)

        assert str(error.value) == 'The tag name \'fits_header\' is reserved for storage of the ' \
                                   'FITS headers.'

        active_port = OutputPort('test', self.storage, activate_init=True)
        deactive_port = OutputPort('test', self.storage, activate_init=False)
        control_port = InputPort('test', self.storage)

        deactive_port.open_port()
        deactive_port.set_all(np.asarray([0, 1, 2, 3]))
        deactive_port.flush()

        with pytest.warns(UserWarning) as warning:
            control_port.get_all()

        assert len(warning) == 1
github PynPoint / PynPoint / tests / test_core / test_outputport.py View on Github external
def test_set_all_error(self) -> None:

        # ---- Test database not set -----

        data = [1, 2, 3, 4, 0]

        with pytest.warns(UserWarning) as record:
            out_port = OutputPort('some_data')
            out_port.set_all(data)

        assert len(record) == 1

        assert record[0].message.args[0] == 'OutputPort can not store data unless a database is ' \
                                            'connected.'

        # ---- Test data dim of actual data for new data entry is < 1 or > 5

        out_port = self.create_output_port('new_data')

        data = [[[[[[2, 2], ], ], ], ]]

        with pytest.raises(ValueError) as error:
            out_port.set_all(data, data_dim=2)
github PynPoint / PynPoint / tests / test_core / test_outputport.py View on Github external
def test_create_instance(self) -> None:

        with pytest.raises(ValueError) as error:
            OutputPort('config', self.storage)

        assert str(error.value) == 'The tag name \'config\' is reserved for the central ' \
                                   'configuration of PynPoint.'

        with pytest.raises(ValueError) as error:
            OutputPort('fits_header', self.storage)

        assert str(error.value) == 'The tag name \'fits_header\' is reserved for storage of the ' \
                                   'FITS headers.'

        active_port = OutputPort('test', self.storage, activate_init=True)
        deactive_port = OutputPort('test', self.storage, activate_init=False)
        control_port = InputPort('test', self.storage)

        deactive_port.open_port()
        deactive_port.set_all(np.asarray([0, 1, 2, 3]))
        deactive_port.flush()

        with pytest.warns(UserWarning) as warning:
            control_port.get_all()

        assert len(warning) == 1

        assert warning[0].message.args[0] == 'No data under the tag which is linked by the ' \
                                             'InputPort.'

        active_port.set_all(np.asarray([0, 1, 2, 3]))
github PynPoint / PynPoint / tests / test_core / test_inputport.py View on Github external
def test_get_all_attributes(self) -> None:

        port = InputPort('images', self.storage)

        assert port.get_all_static_attributes() == {'PIXSCALE': 0.01}
        assert port.get_all_non_static_attributes() == ['PARANG', ]

        port = OutputPort('images', self.storage)
        assert port.del_all_attributes() is None

        port = InputPort('images', self.storage)
        assert port.get_all_non_static_attributes() is None
github PynPoint / PynPoint / tests / test_core / test_outputport.py View on Github external
def test_create_instance(self) -> None:

        with pytest.raises(ValueError) as error:
            OutputPort('config', self.storage)

        assert str(error.value) == 'The tag name \'config\' is reserved for the central ' \
                                   'configuration of PynPoint.'

        with pytest.raises(ValueError) as error:
            OutputPort('fits_header', self.storage)

        assert str(error.value) == 'The tag name \'fits_header\' is reserved for storage of the ' \
                                   'FITS headers.'

        active_port = OutputPort('test', self.storage, activate_init=True)
        deactive_port = OutputPort('test', self.storage, activate_init=False)
        control_port = InputPort('test', self.storage)

        deactive_port.open_port()
        deactive_port.set_all(np.asarray([0, 1, 2, 3]))
github PynPoint / PynPoint / pynpoint / core / dataio.py View on Github external
----------
        tag : str
            The tag of the port. The port can be used in order to write data to the dataset with
            the key = `tag`.
        data_storage_in : pynpoint.core.dataio.DataStorage
            It is possible to give the constructor of an OutputPort a DataStorage instance which
            will link the port to that DataStorage. Usually the DataStorage is set later by calling
            :func:`~pynpoint.core.dataio.Port.set_database_connection`.

        Returns
        -------
        NoneType
            None
        """

        super(OutputPort, self).__init__(tag, data_storage_in)

        self.m_activate = activate_init

        if tag == 'config':
            raise ValueError('The tag name \'config\' is reserved for the central configuration '
                             'of PynPoint.')

        if tag == 'fits_header':
            raise ValueError('The tag name \'fits_header\' is reserved for storage of the FITS '
                             'headers.')
github PynPoint / PynPoint / pynpoint / core / processing.py View on Github external
Parameters
        ----------
        tag : str
            Tag of the new output port.
        activation : bool
            Activation status of the Port after creation. Deactivated ports will not save their
            results until they are activated.

        Returns
        -------
        pynpoint.core.dataio.OutputPort
            The new OutputPort for the ReadingModule.
        """

        port = OutputPort(tag, activate_init=activation)

        if tag in self._m_output_ports:
            warnings.warn(f'Tag \'{tag}\' of ReadingModule \'{self._m_name}\' is already used.')

        if self._m_data_base is not None:
            port.set_database_connection(self._m_data_base)

        self._m_output_ports[tag] = port

        return port
github PynPoint / PynPoint / pynpoint / core / processing.py View on Github external
Parameters
        ----------
        tag : str
            Tag of the new output port.
        activation : bool
            Activation status of the Port after creation. Deactivated ports will not save their
            results until they are activated.

        Returns
        -------
        pynpoint.core.dataio.OutputPort
            The new OutputPort for the ReadingModule.
        """

        port = OutputPort(tag, activate_init=activation)

        if tag in self._m_output_ports:
            warnings.warn(f'Tag \'{tag}\' of ReadingModule \'{self._m_name}\' is already used.')

        if self._m_data_base is not None:
            port.set_database_connection(self._m_data_base)

        self._m_output_ports[tag] = port

        return port