当前位置: 首页>>代码示例>>Python>>正文


Python AzimuthalIntegrator.sload方法代码示例

本文整理汇总了Python中pyFAI.azimuthalIntegrator.AzimuthalIntegrator.sload方法的典型用法代码示例。如果您正苦于以下问题:Python AzimuthalIntegrator.sload方法的具体用法?Python AzimuthalIntegrator.sload怎么用?Python AzimuthalIntegrator.sload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyFAI.azimuthalIntegrator.AzimuthalIntegrator的用法示例。


在下文中一共展示了AzimuthalIntegrator.sload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from pyFAI.azimuthalIntegrator import AzimuthalIntegrator [as 别名]
# 或者: from pyFAI.azimuthalIntegrator.AzimuthalIntegrator import sload [as 别名]
def main():
    usage = "pyFAI-saxs [options] -n 1000 -p ponifile file1.edf file2.edf ..."
    version = "PyFAI-saxs version %s from %s " % (pyFAI_version, date)
    description = """Azimuthal integration for SAXS users."""
    epilog = """pyFAI-saxs is the SAXS script of pyFAI that allows data
    reduction (azimuthal integration) for Small Angle Scattering with output
    axis in q space."""
    parser = ArgumentParser(usage=usage, description=description, epilog=epilog)
    parser.add_argument("-v", "--version", action='version', version=version)
    parser.add_argument("args", metavar="FILE", type=str, nargs='+',
                        help="Image files to integrate")
    parser.add_argument("-p", dest="ponifile",
                        type=str, default=None,
                        help="PyFAI parameter file (.poni)")
    parser.add_argument("-n", "--npt", dest="npt",
                        type=int, default=None,
                        help="Number of points in radial dimension")
    parser.add_argument("-w", "--wavelength", dest="wavelength", type=float,
                        help="wavelength of the X-Ray beam in Angstrom", default=None)
    parser.add_argument("-e", "--energy", dest="energy", type=float,
                        help="energy of the X-Ray beam in keV (hc=%skeV.A)" %
                        hc, default=None)
    parser.add_argument("-u", "--dummy", dest="dummy",
                        type=float, default=None,
                        help="dummy value for dead pixels")
    parser.add_argument("-U", "--delta_dummy", dest="delta_dummy",
                        type=float, default=None,
                        help="delta dummy value")
    parser.add_argument("-m", "--mask", dest="mask",
                        type=str, default=None,
                        help="name of the file containing the mask image")
    parser.add_argument("-d", "--dark", dest="dark",
                        type=str, default=None,
                        help="name of the file containing the dark current")
    parser.add_argument("-f", "--flat", dest="flat",
                        type=str, default=None,
                        help="name of the file containing the flat field")
#    parser.add_argument("-b", "--background", dest="background",
#                      type="string", default=None,
#                      help="name of the file containing the background")
    parser.add_argument("-P", "--polarization", dest="polarization_factor",
                        type=float, default=None,
                        help="Polarization factor, from -1 (vertical) to +1 (horizontal), \
                      default is None for no correction, synchrotrons are around 0.95")
    parser.add_argument("--error-model", dest="error_model",
                        type=str, default=None,
                        help="Error model to use. Currently on 'poisson' is implemented ")
    parser.add_argument("--unit", dest="unit",
                        type=str, default="q_nm^-1",
                        help="unit for the radial dimension: can be q_nm^-1, q_A^-1, 2th_deg, \
                          2th_rad or r_mm")
    parser.add_argument("--ext", dest="ext",
                        type=str, default=".dat",
                        help="extension of the regrouped filename (.dat)")
    parser.add_argument("--method", dest="method",
                        type=str, default=None,
                        help="Integration method ")

    options = parser.parse_args()
    if len(options.args) < 1:
        logger.error("incorrect number of arguments")
    to_process = utils.expand_args(options.args)

    if options.ponifile and to_process:
        integrator = AzimuthalIntegrator.sload(options.ponifile)

        if to_process:
            first = to_process[0]
            fabimg = fabio.open(first)
            integrator.detector.guess_binning(fabimg.data)
        if options.wavelength:
            integrator.wavelength = options.wavelength * 1e-10
        elif options.energy:
            integrator.wavelength = hc / options.energy * 1e-10
        if options.mask and os.path.exists(options.mask):  # override with the command line mask
            integrator.maskfile = options.mask
        if options.dark and os.path.exists(options.dark):  # set dark current
            integrator.darkcurrent = fabio.open(options.dark).data
        if options.flat and os.path.exists(options.flat):  # set Flat field
            integrator.flatfield = fabio.open(options.flat).data
        if options.method:
            method = options.method
        else:
            if len(to_process) > 5:
                method = IntegrationMethod.select_method(1, "full", "csr")[0]
            else:
                method = IntegrationMethod.select_method(1, "full", "histogram")[0]
        print(integrator)
        print("Mask: %s\tMethod: %s" % (integrator.maskfile, method))

        for afile in to_process:
            sys.stdout.write("Integrating %s --> " % afile)
            outfile = os.path.splitext(afile)[0] + options.ext
            t0 = time.time()
            fimg = fabio.open(afile)
            t1 = time.time()
            if fimg.nframes > 1:
                integrator.integrate1d(data=fimg.data,
                                       npt=options.npt or min(fimg.data.shape),
                                       dummy=options.dummy,
#.........这里部分代码省略.........
开发者ID:kif,项目名称:pyFAI,代码行数:103,代码来源:saxs.py

示例2: main

# 需要导入模块: from pyFAI.azimuthalIntegrator import AzimuthalIntegrator [as 别名]
# 或者: from pyFAI.azimuthalIntegrator.AzimuthalIntegrator import sload [as 别名]
def main():
    usage = "pyFAI-waxs [options] -p ponifile file1.edf file2.edf ..."
    version = "pyFAI-waxs version %s from %s" % (pyFAI_version, date)
    description = "Azimuthal integration for powder diffraction."
    epilog = """pyFAI-waxs is the script of pyFAI that allows data reduction
    (azimuthal integration) for Wide Angle Scattering to produce X-Ray Powder
    Diffraction Pattern with output axis in 2-theta space.
    """
    parser = ArgumentParser(usage=usage, description=description, epilog=epilog)
    parser.add_argument("-v", "--version", action='version', version=version)
    parser.add_argument("args", metavar="FILE", type=str, nargs='+',
                        help="Image files to integrate")
    parser.add_argument("-p", dest="ponifile",
                        type=str, default=None,
                        help="PyFAI parameter file (.poni)")
    parser.add_argument("-n", "--npt", dest="npt",
                        type=int, default=None,
                        help="Number of points in radial dimension")
    parser.add_argument("-w", "--wavelength", dest="wavelength", type=float,
                        help="wavelength of the X-Ray beam in Angstrom", default=None)
    parser.add_argument("-e", "--energy", dest="energy", type=float,
                        help="energy of the X-Ray beam in keV (hc=%skeV.A)" %
                        hc, default=None)
    parser.add_argument("-u", "--dummy", dest="dummy",
                        type=float, default=None,
                        help="dummy value for dead pixels")
    parser.add_argument("-U", "--delta_dummy", dest="delta_dummy",
                        type=float, default=None,
                        help="delta dummy value")
    parser.add_argument("-m", "--mask", dest="mask",
                        type=str, default=None,
                        help="name of the file containing the mask image")
    parser.add_argument("-d", "--dark", dest="dark",
                        type=str, default=None,
                        help="name of the file containing the dark current")
    parser.add_argument("-f", "--flat", dest="flat",
                        type=str, default=None,
                        help="name of the file containing the flat field")
    parser.add_argument("-P", "--polarization", dest="polarization_factor",
                        type=float, default=None,
                        help="Polarization factor, from -1 (vertical) to +1 (horizontal), \
                          default is None for no correction, synchrotrons are around 0.95")

#    parser.add_argument("-b", "--background", dest="background",
#                      type=str, default=None,
#                      help="name of the file containing the background")
    parser.add_argument("--error-model", dest="error_model",
                        type=str, default=None,
                        help="Error model to use. Currently on 'poisson' is implemented ")
    parser.add_argument("--unit", dest="unit",
                        type=str, default="2th_deg",
                        help="unit for the radial dimension: can be q_nm^-1, q_A^-1, 2th_deg, \
                          2th_rad or r_mm")
    parser.add_argument("--ext", dest="ext",
                        type=str, default=".xy",
                        help="extension of the regrouped filename (.xy) ")
    parser.add_argument("--method", dest="method",
                        type=str, default=None,
                        help="Integration method ")
    parser.add_argument("--multi", dest="multiframe",  # type=bool,
                        default=False, action="store_true",
                        help="Average out all frame in a file before integrating extracting variance, otherwise treat every single frame")
    parser.add_argument("--average", dest="average", type=str,
                        default="mean",
                        help="Method for averaging out: can be 'mean' (default), 'min', 'max' or 'median")
    parser.add_argument("--do-2D", dest="do_2d",
                        default=False, action="store_true",
                        help="Perform 2D integration in addition to 1D")

    options = parser.parse_args()
    if len(options.args) < 1:
        logger.error("incorrect number of arguments")

    to_process = utils.expand_args(options.args)

    if options.ponifile and to_process:
        integrator = AzimuthalIntegrator.sload(options.ponifile)

        if options.method:
            method1d = method2d = options.method
        else:
            if len(to_process) > 5:
                method1d = IntegrationMethod.select_method(1, "full", "csr")[0]
                method2d = IntegrationMethod.select_method(2, "full", "csr")[0]
            else:
                method1d = IntegrationMethod.select_method(1, "full", "histogram")[0]
                method2d = IntegrationMethod.select_method(2, "full", "histogram")[0]
        if to_process:
            first = to_process[0]
            fabimg = fabio.open(first)
            integrator.detector.guess_binning(fabimg.data)

        if options.wavelength:
            integrator.wavelength = options.wavelength * 1e-10
        elif options.energy:
            integrator.wavelength = hc / options.energy * 1e-10
        if options.mask and os.path.exists(options.mask):  # override with the command line mask
            integrator.maskfile = options.mask
        if options.dark and os.path.exists(options.dark):  # set dark current
            integrator.darkcurrent = fabio.open(options.dark).data
#.........这里部分代码省略.........
开发者ID:kif,项目名称:pyFAI,代码行数:103,代码来源:waxs.py


注:本文中的pyFAI.azimuthalIntegrator.AzimuthalIntegrator.sload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。