예제 #1
0
    def __load_data(self, file_path):
        """Loads a reflectivity dataset from a given file path and applies scaling.

        Args:
            file_path (string): a path to the file with the data to construct the model for.

        """
        data = ReflectDataset(file_path) #Load the data for which the model is designed for.
        self.filename = os.path.basename(data.filename)
        data.scale(np.max(data.data[1])) #Normalise Y and Error by dividing by max R point.

        x, y, y_err = data.x.tolist(), data.y.tolist(), data.y_err.tolist()
        removed = [] #Remove any points containing 0 values as these cause NaNs when fitting.
        for i in range(len(x)):
            if x[i] == 0 or y[i] == 0 or y_err[i] == 0:
                removed.append(i)

        #Remove the identified points and return the processed dataset.
        x     = np.delete(np.array(x),     removed)
        y     = np.delete(np.array(y),     removed)
        y_err = np.delete(np.array(y_err), removed)
        data_new = np.array([x, y, y_err])
        return ReflectDataset(data_new)