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

set_dimension() allows higher dimensions than exist #130

Closed ramav87 closed 3 years ago

ramav87 commented 3 years ago

Need to raise an error when user attempts to set a dimension that is higher than what is actually present. Should write a unit test as well for this.

data_mat = np.random.uniform(size=(10,10,32))

Specify dimensions

x_dim = np.linspace(0, 1E-6, data_mat.shape[0]) y_dim = np.linspace(0, 1E-6, data_mat.shape[1]) z_dim = xvec

Make a sidpy dataset

data_set = sid.Dataset.from_array(data_mat, name='Current_spectral_map')

Set the data type

data_set.data_type = sid.DataType.SPECTRAL_IMAGE

Add dimension info

data_set.set_dimension(0, sid.Dimension(x_dim, name='x', units='m', quantity='x', dimension_type='spatial')) data_set.set_dimension(1, sid.Dimension(y_dim, name='y', units='m', quantity='y', dimension_type='spatial')) data_set.set_dimension(2, sid.Dimension(z_dim, name='Voltage', units='V', quantity='Voltage', dimension_type='spectral'))

data_set.set_dimension(3, sid.Dimension(z_dim, name='Voltage2', units='V', quantity='Voltage', dimension_type='spectral'))

saimani5 commented 3 years ago

Pull request #132 takes care of this