Exemplo n.º 1
0
        from xfel.cxi.cspad_ana.cspad_tbx import xpp_active_areas
        assert params.old_metrology in xpp_active_areas

    if params.new_metrology is None:
        params.new_metrology = libtbx.env.find_in_repositories(
            "xfel/metrology/CSPad/run4/CxiDs1.0_Cspad.0")
    assert os.path.isdir(params.new_metrology) or os.path.isfile(
        params.new_metrology)

    # Read the new metrology, either from a calibration directory or an optical metrology
    # flat file
    if os.path.isdir(params.new_metrology):
        metro_style = "calibdir"

        from xfel.cftbx.detector.metrology2phil import metrology2phil
        metro = metrology2phil(params.new_metrology, False)

        args = []

        import iotbx.phil
        for arg in args:
            metro = metro.fetch(sources=[iotbx.phil.parse(arg)])
    else:
        assert os.path.isfile(params.new_metrology)
        ext = os.path.splitext(params.new_metrology)[1].lower()
        if ext in ['.def', '.cbf']:
            metro_style = "cbf"

            from xfel.cftbx.detector.cspad_cbf_tbx import cbf_file_to_basis_dict
            metro = cbf_file_to_basis_dict(params.new_metrology)
Exemplo n.º 2
0
  else:
    from xfel.cxi.cspad_ana.cspad_tbx import xpp_active_areas
    assert params.old_metrology in xpp_active_areas

  if params.new_metrology is None:
    params.new_metrology=libtbx.env.find_in_repositories(
      "xfel/metrology/CSPad/run4/CxiDs1.0_Cspad.0")
  assert os.path.isdir(params.new_metrology) or os.path.isfile(params.new_metrology)

  # Read the new metrology, either from a calibration directory or an optical metrology
  # flat file
  if os.path.isdir(params.new_metrology):
    metro_style = "calibdir"

    from xfel.cftbx.detector.metrology2phil import metrology2phil
    metro = metrology2phil(params.new_metrology,False)

    args = []

    import iotbx.phil
    for arg in args:
      metro = metro.fetch(sources=[iotbx.phil.parse(arg)])
  else:
    assert os.path.isfile(params.new_metrology)
    ext = os.path.splitext(params.new_metrology)[1].lower()
    if ext in ['.def','.cbf']:
      metro_style = "cbf"

      from xfel.cftbx.detector.cspad_cbf_tbx import cbf_file_to_basis_dict
      metro = cbf_file_to_basis_dict(params.new_metrology)
Exemplo n.º 3
0
    if (os.path.isdir(arg)) :
      user_phil.append(libtbx.phil.parse("""metrology_dir=\"%s\" """ % arg))
    else :
      try :
        user_phil.append(libtbx.phil.parse(arg))
      except RuntimeError as e :
        raise Sorry("Unrecognized argument '%s' (error: %s)" % (arg, str(e)))

  params = master_phil.fetch(sources=user_phil).extract()
  if (params.metrology_dir is None) :
    master_phil.show()
    raise Usage("metrology_dir must be defined (either metrology_dir=XXX, or the directory path alone).")
  assert params.out is not None

  if params.corrections_phil is None:
    metro_phil = metrology2phil(params.metrology_dir, verbose=True)
    write_cspad_cbf(None, metro_phil, 'calibdir', None, params.out, None, 0, header_only=True)
  else:
    from xfel.cxi.cspad_ana.parse_calib import calib2sections
    sections = calib2sections(params.metrology_dir)

    from spotfinder.applications.xfel import cxi_phil
    horizons_phil = cxi_phil.cxi_versioned_extract()
    horizons_phil = horizons_phil.persist.phil_scope.fetch(source=libtbx.phil.parse(file_name=params.corrections_phil))
    corrections_params = horizons_phil.extract()

    bc = [0,0]
    for q in range(len(sections)):
      corner = sections[q][1].corners(True)[0]
      bc     = [bc[0] + corner[1] / len(sections), bc[1] + corner[0] / len(sections)]
    beam = col(bc)
  .help = Directory with optical metrology information posistioning quadrants and sensors, corrected for
  .help = rectangularity
  .optional = False
out = None
  .type = str
  .help = Output file name
  .optional = False
""")

if (__name__ == "__main__") :
  user_phil = []
  for arg in sys.argv[1:]:
    if (os.path.isdir(arg)) :
      user_phil.append(libtbx.phil.parse("""metrology_dir=\"%s\"""" % arg))
    else :
      try :
        user_phil.append(libtbx.phil.parse(arg))
      except RuntimeError, e :
        raise Sorry("Unrecognized argument '%s' (error: %s)" % (arg, str(e)))

  params = master_phil.fetch(sources=user_phil).extract()
  if (params.metrology_dir is None) :
    master_phil.show()
    raise Usage("metrology_dir must be defined (either metrology_dir=XXX, or the directory path alone).")
  assert params.out is not None

  metro_phil = metrology2phil(params.metrology_dir, verbose=True)

  write_cspad_cbf(None, metro_phil, 'calibdir', None, params.out, None, 0, header_only=True)