示例#1
0
        np.savez_compressed(savedir + 'S' + str(scans[scan_nb]) + '_pynx_previous' + comment, data=data)
        np.savez_compressed(savedir + 'S' + str(scans[scan_nb]) + '_maskpynx_previous', mask=mask)

    else:  # new masking process

        flatfield = pru.load_flatfield(flatfield_file)
        hotpix_array = pru.load_hotpixels(hotpixels_file)

        logfile = pru.create_logfile(setup=setup, detector=detector, scan_number=scans[scan_nb],
                                     root_folder=root_folder, filename=specfile)

        if use_rawdata:
            q_values, data, _, mask, _, frames_logical, monitor = \
                pru.gridmap(logfile=logfile, scan_number=scans[scan_nb], detector=detector, setup=setup,
                            flatfield=flatfield, hotpixels=hotpix_array, hxrd=None, follow_bragg=follow_bragg,
                            normalize=normalize_flux, debugging=debug, orthogonalize=False)
        else:
            q_values, rawdata, data, _, mask, frames_logical, monitor = \
                pru.gridmap(logfile=logfile, scan_number=scans[scan_nb], detector=detector, setup=setup,
                            flatfield=flatfield, hotpixels=hotpix_array, hxrd=hxrd, follow_bragg=follow_bragg,
                            normalize=normalize_flux, debugging=debug, orthogonalize=True)

            np.savez_compressed(savedir+'S'+str(scans[scan_nb])+'_data_before_masking_stack', data=rawdata)
            if save_to_mat:
                # save to .mat, the new order is x y z (outboard, vertical up, downstream)
                savemat(savedir+'S'+str(scans[scan_nb])+'_data_before_masking_stack.mat',
                        {'data': np.moveaxis(rawdata, [0, 1, 2], [-1, -2, -3])})
            del rawdata
            gc.collect()
示例#2
0
##############
# load files #
##############
flatfield = pru.load_flatfield(flatfield_file)
hotpix_array = pru.load_hotpixels(hotpixels_file)

logfile = pru.create_logfile(beamline=setup_pre.beamline,
                             detector=detector,
                             scan_number=scan,
                             root_folder=root_folder,
                             filename=specfile_name)

if filtered_data == 0:
    _, data, _, mask, _, frames_logical, monitor = \
        pru.gridmap(logfile=logfile, scan_number=scan, detector=detector, setup=setup_pre,
                    flatfield=flatfield, hotpixels=hotpix_array, hxrd=None, follow_bragg=False,
                    debugging=False, orthogonalize=False)
else:
    root = tk.Tk()
    root.withdraw()
    file_path = filedialog.askopenfilename(initialdir=homedir + "pynxraw/",
                                           title="Select 3D data",
                                           filetypes=[("NPZ", "*.npz")])
    data = np.load(file_path)['data']
    data = data[detector.roi[0]:detector.roi[1],
                detector.roi[2]:detector.roi[3]]
    frames_logical = np.ones(
        data.shape[0])  # use all frames from the filtered data
numz, numy, numx = data.shape
print("Shape of dataset: ", numz, numy, numx)