def test_SAXSWorkflow():
    # create processes
    thresholdmask = ThresholdMaskPlugin()
    qintegrate = QIntegratePlugin()

    # set values
    AI = AzimuthalIntegrator(.283,
                             5.24e-3,
                             4.085e-3,
                             0,
                             0,
                             0,
                             1.72e-4,
                             1.72e-4,
                             detector=Pilatus2M(),
                             wavelength=1.23984e-10)
    thresholdmask.data.value = fabio.open(
        '/Users/hari/Downloads/AGB_5S_USE_2_2m.edf').data

    def AI_func():
        from pyFAI.detectors import Pilatus2M
        from pyFAI import AzimuthalIntegrator, units
        return AzimuthalIntegrator(.283,
                                   5.24e-3,
                                   4.085e-3,
                                   0,
                                   0,
                                   0,
                                   1.72e-4,
                                   1.72e-4,
                                   detector=Pilatus2M(),
                                   wavelength=1.23984e-10)

    qintegrate.integrator.value = AI_func
    qintegrate.npt.value = 1000
    thresholdmask.minimum.value = 30
    thresholdmask.maximum.value = 1e12

    qintegrate.data.value = fabio.open(
        '/Users/hari/Downloads/AGB_5S_USE_2_2m.edf').data
    thresholdmask.neighborhood.value = 1
    qintegrate.normalization_factor.value = 0.5
    qintegrate.method.value = "numpy"

    # connect processes
    thresholdmask.mask.connect(qintegrate.mask)

    # add processes to workflow
    wf = Workflow('QIntegrate')
    wf.addProcess(thresholdmask)
    wf.addProcess(qintegrate)

    dsk = DaskExecutor()
    result = dsk.execute(wf)
    print(result)
Exemple #2
0
def test_tomoworkflow():
    read = read_APS2BM()
    read.path.value = '/Users/hari/test.hdf'
    read.sino.value = (1050, 1051)

    norm = Normalize()
    read.arr.connect(norm.arr)
    read.flat.connect(norm.flats)
    read.dark.connect(norm.darks)

    outliers = RemoveOutlier()
    norm.normalized.connect(outliers.arr)
    outliers.dif.value = 500
    outliers.size.value = 5

    # maximum = ArrayMax()
    # outliers.corrected.connect(maximum.arr)
    # maximum.floor.value = 1e-16

    # neglog = MinusLog()
    # maximum.out.connect(neglog.arr)

    # phase = RetrievePhase()
    # maximum.out.connect(phase.arr)
    # phase.pixel_size.value=6.5e-5
    # phase.dist.value=3
    # phase.energy.value=27

    stripe = RemoveStripeFw()
    outliers.corrected.connect(stripe.tomo)
    stripe.level.value = 8
    stripe.wname.value = 'db5'
    stripe.sigma.value = 4
    stripe.pad.value = True

    padding = Pad()
    stripe.corrected.connect(padding.arr)
    padding.axis.value = 2
    padding.npad.value = 448
    padding.mode.value = 'edge'

    # angles = Angles()
    # angles.nang.value=0
    # angles.ang1.value=90
    # angles.ang2.value=180


    gridrec = Recon()
    padding.padded.connect(gridrec.tomo)
    read.angles.connect(gridrec.theta)
    gridrec.filter_name.value = 'butterworth'
    gridrec.algorithm.value = 'gridrec'
    gridrec.center.value = np.array([1295 + 448])  # 1295
    gridrec.filter_par.value = np.array([0.2, 2])
    # gridrec.sinogram_order.value = True

    crop = Crop()
    gridrec.reconstructed.connect(crop.arr)
    crop.p11.value = 448
    crop.p22.value = 448
    crop.p12.value = 448
    crop.p21.value = 448
    crop.axis.value = 0

    divide = ArrayDivide()

    circularmask = CircMask()
    crop.croppedarr.connect(circularmask.arr)
    circularmask.val.value = 0
    circularmask.axis.value = 0
    circularmask.ratio.value = 1

    writetiff = WriteTiffStack()

    workflow = Workflow('Tomography')
    for process in [read,
                    norm,
                    outliers,
                    # maximum,
                    # neglog,
                    # phase,
                    stripe,
                    padding,
                    # angles,
                    gridrec,
                    crop,
                    # divide,
                    circularmask,
                    # writetiff
                    ]:
        workflow.addProcess(process)

    dsk = DaskExecutor()
    result = dsk.execute(workflow)
    print(result)

    import pyqtgraph as pg
    pg.image(result[0]['normalized'].value.squeeze())

    from qtpy.QtWidgets import QApplication
    app = QApplication([])
    app.exec_()