示例#1
0
# y: out of the ring
# z: upwards
# The outer most sample rotation (so the one mounted on the floor) is one
# which turns left-handed (-) around the z-direction -> z- (mu)
# The second sample rotation ('eta') is lefthanded (-) around y -> y-
qconv = xu.experiment.QConversion(['z-', 'y-', 'z-'],
                                  ['z-', 'y-', 'ty', 'tz'],
                                  [1, 0, 0])
hxrd = xu.HXRD([1, 1, 0], [0, 0, 1], qconv=qconv, sampleor='z+')
hxrd._A2QConversion.init_area('z-', 'y+', cch1=333.94, cch2=235.62, Nch1=516,
                              Nch2=516, pwidth1=5.5000e-02, pwidth2=5.5000e-02,
                              distance=0.53588*1000, detrot=-1.495,
                              tiltazimuth=155.0, tilt=0.745, Nav=(2, 2))
# all in mm since mm are used for mpxy,z in the spec-file

qx, qy, qz, gint, gridder = id01.gridmap(s, SCANNR, hxrd, nx, ny, nz)

# ################################################
# for a 3D plot using python function I sugggest
# to use mayavi's mlab package. the basic usage
# is shown below. otherwise have a look at the
# file xrayutilities_export_data2vtk.py in order learn
# how you can get your data to a vtk file for further
# processing.
# #####
# one of the following import statements is needed
# depending on the system/distribution you use
# from mayavi import mlab
# # from enthough.mayavi import mlab
# # plot 3D map using mayavi mlab
# QX,QY,QZ = numpy.mgrid[qx.min():qx.max():1j * nx,
h5file = os.path.join(specdir, sample + ".h5")
# read spec file and save to HDF5 (needs to be done only once)
# try: s
# except NameError: s = xu.io.SPECFile(sample+".spec",path=specdir)
# else:
#    s.Update()
# s.Save2HDF5(h5file)
# in ipython run with: "run -i script" to just update the spec file and parse
# for new scans only

# number of points to be used during the gridding
nx, ny, nz = 100, 101, 102

# read and grid data with helper function
qx, qy, qz, gint, gridder = id01.gridmap(h5file, SCANNR, ccdfiletmp, nx, ny,
                                         nz)

# prepare data for export to VTK image file
INT = xu.maplog(gint, 3.0, 0)

# export variables qx, qy, qz, INT
qx0 = qx.min()
dqx = (qx.max() - qx.min()) / nx

qy0 = qy.min()
dqy = (qy.max() - qy.min()) / ny

qz0 = qz.min()
dqz = (qz.max() - qz.min()) / nz

INT = numpy.transpose(INT).reshape((INT.size))
h5file = os.path.join(specdir, sample + ".h5")
# read spec file and save to HDF5 (needs to be done only once)
# try: s
# except NameError: s = xu.io.SPECFile(sample+".spec",path=specdir)
# else:
#    s.Update()
# s.Save2HDF5(h5file)
# in ipython run with: "run -i script" to just update the spec file and parse
# for new scans only

# number of points to be used during the gridding
nx, ny, nz = 100, 101, 102

# read and grid data with helper function
qx, qy, qz, gint, gridder = id01.gridmap(h5file, SCANNR, ccdfiletmp,
                                         nx, ny, nz)

# prepare data for export to VTK image file
INT = xu.maplog(gint, 3.0, 0)

# export variables qx, qy, qz, INT
qx0 = qx.min()
dqx = (qx.max() - qx.min()) / nx

qy0 = qy.min()
dqy = (qy.max() - qy.min()) / ny

qz0 = qz.min()
dqz = (qz.max() - qz.min()) / nz

INT = numpy.transpose(INT).reshape((INT.size))