MJOLNIRPackage / MJOLNIR

Neutron scattering software to be used at Multiplexing Joint Organization
Mozilla Public License 2.0
4 stars 5 forks source link

Small refactoring of code #22

Closed Jakob-Lass closed 6 years ago

Jakob-Lass commented 6 years ago

Following refactoring could be beneficial for the code Move the actual conversion of h5 to nxs data to a data file methods such that a method in the data set object is:

 DataSet.convertDataFiles(self, binning=8):
 self.convertedFiles = [file.convert(binning) for file in self.dataFiles]

This allows for the code to not require a saving of the converted file. For this to work, a copying method might be needed. That is, when generating the converted datafile needs to assure that all properties of the old h5 file is copied to the new. This could be done by something like:

 def __init__(self,fileLocation):
    if isinstance(fileLocation,DataFile):
        dict = fileLocation.__dict__
        for key in dict.keys():
            self.__setattr__(key,dict[key])
   else:
       ....

with the check for name and location.

Jakob-Lass commented 6 years ago

Creation of copy initializer has been done in a79a6529289282d2a2fe3d6ae31ad9bbf9117533, together with a test of equality in copying.

Jakob-Lass commented 6 years ago

Movement of conversion algorithm from DataSet to DataFile has been done in d40bd90cd60d93017060d0dc5da9f76dff104f88.