Exemple #1
0
    def test_Track_read(track):
        # test Track data format
        from etrack.io import trackio
        import os

        filebase = ''.join(
            chr(i) for i in np.random.randint(97, 122, size=(8,)))
        filename = '.'.join([filebase, 'h5'])
        with h5py.File(filename, 'a') as h5file:
            trackio.write_object_to_hdf5(
                track, h5file, 'track')
        with h5py.File(filename, 'r') as h5file:
            track2 = trackio.read_object_from_hdf5(
                h5file['track'])

        assert track2['is_modeled'] == track.is_modeled
        assert track2['pixel_size_um'] == track.pixel_size_um
        assert track2['noise_ev'] == track.noise_ev
        assert track2['label'] == track.label
        assert track2['energy_kev'] == track.energy_kev
        assert np.all(track2['image'] == track.image)

        assert track2['algorithms']['python HT v1.5']['alpha_deg'] == 120.5
        assert track2['algorithms']['python HT v1.5']['beta_deg'] == 43.5

        test_Track_from_pydict(track, track2)

        test_Track_from_hdf5()

        os.remove(filename)
Exemple #2
0
    def test_Track_read(track):
        # test Track data format
        from etrack.io import trackio
        import os

        filebase = ''.join(
            chr(i) for i in np.random.randint(97, 122, size=(8, )))
        filename = '.'.join([filebase, 'h5'])
        with h5py.File(filename, 'a') as h5file:
            trackio.write_object_to_hdf5(track, h5file, 'track')
        with h5py.File(filename, 'r') as h5file:
            track2 = trackio.read_object_from_hdf5(h5file['track'])

        assert track2['is_modeled'] == track.is_modeled
        assert track2['pixel_size_um'] == track.pixel_size_um
        assert track2['noise_ev'] == track.noise_ev
        assert track2['label'] == track.label
        assert track2['energy_kev'] == track.energy_kev
        assert np.all(track2['image'] == track.image)

        assert track2['algorithms']['python HT v1.5']['alpha_deg'] == 120.5
        assert track2['algorithms']['python HT v1.5']['beta_deg'] == 43.5

        test_Track_from_pydict(track, track2)

        test_Track_from_hdf5()

        os.remove(filename)
Exemple #3
0
    def from_hdf5(cls, h5group, h5_to_pydict=None, pydict_to_pyobj=None):
        """
        Initialize a Track instance from an HDF5 group.
        """

        if h5_to_pydict is None:
            h5_to_pydict = {}
        if pydict_to_pyobj is None:
            pydict_to_pyobj = {}

        read_dict = trackio.read_object_from_hdf5(
            h5group, h5_to_pydict=h5_to_pydict)

        constructed_object = cls.from_pydict(
            read_dict, pydict_to_pyobj=pydict_to_pyobj)

        return constructed_object
Exemple #4
0
    def from_hdf5(cls, h5group, h5_to_pydict=None, pydict_to_pyobj=None):
        """
        Initialize a MatlabAlgorithmInfo object from an HDF5 group.
        """

        if h5_to_pydict is None:
            h5_to_pydict = {}
        if pydict_to_pyobj is None:
            pydict_to_pyobj = {}

        read_dict = trackio.read_object_from_hdf5(h5group,
                                                  h5_to_pydict=h5_to_pydict)

        constructed_object = cls.from_pydict(read_dict,
                                             pydict_to_pyobj=pydict_to_pyobj)

        return constructed_object
Exemple #5
0
    def from_hdf5(cls, h5group, h5_to_pydict=None, pydict_to_pyobj=None,
                  reconstruct=False):
        """
        Initialize a Classifier object from an HDF5 group.
        """

        if h5_to_pydict is None:
            h5_to_pydict = {}
        if pydict_to_pyobj is None:
            pydict_to_pyobj = {}

        read_dict = trackio.read_object_from_hdf5(
            h5group, h5_to_pydict=h5_to_pydict)

        constructed_object = cls.from_pydict(
            read_dict, pydict_to_pyobj=pydict_to_pyobj,
            reconstruct=reconstruct)

        return constructed_object
Exemple #6
0
    def from_hdf5(cls, h5group, h5_to_pydict=None, pydict_to_pyobj=None,
                  reconstruct=False):
        """
        Initialize a Classifier object from an HDF5 group.
        """

        if h5_to_pydict is None:
            h5_to_pydict = {}
        if pydict_to_pyobj is None:
            pydict_to_pyobj = {}

        read_dict = trackio.read_object_from_hdf5(
            h5group, h5_to_pydict=h5_to_pydict)

        constructed_object = cls.from_pydict(
            read_dict, pydict_to_pyobj=pydict_to_pyobj,
            reconstruct=reconstruct)

        return constructed_object