Пример #1
0
    def save(self, includeSettings: t_.List[str], binning: int, parallelProcessing: bool, numericalAperture: float, parentWidget: QWidget):
        self.loadIfNeeded(includeSettings, binning, parallelProcessing)
        cubes = self.dataprovider.getCubes()
        settings = set(cubes['setting'])
        for setting in settings:
            sCubes = cubes[cubes['setting'] == setting]
            materials = set(sCubes['material'])
            theoryR = er.getTheoreticalReflectances(materials,
                                                    sCubes['cube'].iloc[0].wavelengths, numericalAperture)  # Theoretical reflectances
            matCombos = er.generateMaterialCombos(materials)
            matCubes = sCubes.groupby('material')['cube'].apply(list).to_dict()
            combos = er.getAllCubeCombos(matCombos, matCubes)
            erCube, rExtraDict = er.generateRExtraCubes(combos, theoryR, numericalAperture)
            dock = DockablePlotWindow(title=setting)
            dock.addWidget(
                PlotNd(erCube.data,
                       title='Mean',
                       indices=[range(erCube.data.shape[0]), range(erCube.data.shape[1]),
                                erCube.wavelengths],
                       names=('y', 'x', 'lambda')),
                title='Mean'
            )
            for matCombo, rExtraArr in rExtraDict.items():
                dock.addWidget(
                    PlotNd(rExtraArr, title=matCombo,
                           indices=[range(erCube.data.shape[0]), range(erCube.data.shape[1]),
                                    erCube.wavelengths],
                           names=('y', 'x', 'lambda')),
                    title=str(matCombo)
                )
            logger = logging.getLogger(__name__)
            erCube.data[np.isnan(erCube.data)] = 0  # Somehow a nan can still get through. This will mess everything up.
            erCube.data[erCube.data < 0] = 0
            logger.info(f"Final data max is {erCube.data.max()}")
            logger.info(f"Final data min is {erCube.data.min()}")
            self.figs.append(dock)  # keep track of opened figures.
            saveName = f'{self.currDir}-{setting}'
            dialog = IndexInfoForm(f'{self.currDir}-{setting}', erCube.metadata.idTag, parent=parentWidget)

            def accepted(dialog, erCube, saveName):
                erCube.metadata.inheritedMetadata['description'] = dialog.description
                erCube.toHdfFile(self.homeDir, saveName)
                self.updateIndex(saveName, erCube.metadata.idTag, dialog.description, erCube.metadata.dirName2Directory('', saveName))

            dialog.accepted.connect(lambda dlg=dialog, ercube=erCube, savename=saveName: accepted(dlg, ercube, savename))
            dialog.show()
Пример #2
0
 def plotOpd3d(self):
     opd, opdIndex = self.analysis.pws.opd
     self.plotnd = PlotNd(
         opd,
         names=('y', 'x', 'um'),
         title=os.path.split(self.acq.filePath)[-1],
         indices=[range(opd.shape[0]),
                  range(opd.shape[1]), opdIndex],
         parent=self)
Пример #3
0
 def plotDynRaw3d(self):
     im = self.acq.dynamics.toDataClass()
     self.plotnd = PlotNd(im.data,
                          title=os.path.split(self.acq.filePath)[-1],
                          names=('y', 'x', 't'),
                          indices=[
                              range(im.data.shape[0]),
                              range(im.data.shape[1]), im.times
                          ],
                          parent=self)
Пример #4
0
 def plotDynAn3d(self):
     refl = self.analysis.dyn.reflectance
     self.plotnd = PlotNd(refl.data,
                          title=os.path.split(self.acq.filePath)[-1],
                          names=('y', 'x', 't'),
                          indices=[
                              range(refl.data.shape[0]),
                              range(refl.data.shape[1]), refl.times
                          ],
                          parent=self)
Пример #5
0
 def plotRaw3d(self):
     im = PwsCube.fromMetadata(self.acq.pws)
     self.plotnd = PlotNd(im.data,
                          title=os.path.split(self.acq.filePath)[-1],
                          names=('y', 'x', 'lambda'),
                          indices=[
                              range(im.data.shape[0]),
                              range(im.data.shape[1]), im.wavelengths
                          ],
                          parent=self)
Пример #6
0
 def plotAn3d(self):
     refl = self.analysis.pws.reflectance
     refl += self.analysis.pws.meanReflectance[:, :,
                                               None]  # The `reflectance has had the mean subtracted. add it back in.
     self.plotnd = PlotNd(refl.data,
                          title=os.path.split(self.acq.filePath)[-1],
                          names=('y', 'x', 'k (rad/um)'),
                          indices=[
                              range(refl.data.shape[0]),
                              range(refl.data.shape[1]), refl.wavenumbers
                          ],
                          parent=self)
Пример #7
0
    def plotRMSOpd3d(self):
        """
        Square root of cumulative sum of OPD^2. Important note: The units are in terms of OPD not depth. Since the light makes a round trip -> depth = OPD / (2 * RI of cell)
        """
        opd: np.ndarray
        opd, opdIndx = self.analysis.pws.opd

        opdSquaredSum = np.cumsum(
            opd**2, axis=2
        )  # Parseval's theorem tells us that this is equivalent to the sum of the squares of our original signal. Cumulative sum from 0 up to a given OPD
        opdSquaredSum *= len(
            self.analysis.pws.reflectance.wavenumbers
        ) / opd.shape[
            2]  # If the original data and opd were of the same length then the above line would be correct. Since the fft may have been upsampled. we need to normalize.
        rmsByOPD = np.sqrt(opdSquaredSum)

        self.plotnd = PlotNd(
            rmsByOPD,
            names=('y', 'x', 'um'),
            title=os.path.split(self.acq.filePath)[-1],
            indices=[range(opd.shape[0]),
                     range(opd.shape[1]), opdIndx],
            parent=self)
Пример #8
0
 def plotData(self, index: QModelIndex):
     idTag = self.fileStatus.iloc[index.row()]['idTag']
     md = self._dataComparator.local.getMetadataFromId(idTag)
     erCube = ExtraReflectanceCube.fromMetadata(md)
     self.plotHandle = PlotNd(erCube.data)