pycroscopy / sidpy

Python utilities for storing, processing, and visualizing spectroscopic and imaging data
https://pycroscopy.github.io/sidpy/
MIT License
11 stars 14 forks source link

sidpy dimension name not asserting uniqueness #82

Closed ramav87 closed 3 years ago

ramav87 commented 3 years ago

set_dimension does not assert uniqueness of the name of the dimension. This will then throw errors during writing.

data = np.random.normal(size=(5,5,5))
data = np.squeeze(np.array(data, dtype=np.float64))

data_set = sid.Dataset.from_array(data[:], name='Image')
dim_types = ['spatial', 'spatial', 'spectral']

for ind in range(dims):
    print(ind, dims)
    data_set.set_dimension(ind, sid.Dimension(np.linspace(-2, 2, num=data_set.shape[ind], endpoint=True),
                                            name='x', units='um', quantity='Length',
                                            dimension_type=dim_types[ind]))