User Tools

Site Tools


xray_data:convertfileseries

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
xray_data:convertfileseries [2019/01/18 14:31] smerkelxray_data:convertfileseries [2026/08/10 10:37] (current) smerkel
Line 4: Line 4:
 ===== Introduction ===== ===== Introduction =====
  
-Typical diamond anvil cell beamlines generate series of diffraction files in various formats, which are not the EDF format used in further processing. The tools here can be used to convert the files into the proper format.+Typical diamond anvil cell beamlines generate series of diffraction files in various formats, which are not the [[fileformat:edf|EDF]] format used in further processing. The tools here can be used to convert the files into the proper format.
  
 Data collected at step scans have a starting ω position, an end ω position, and a step size δω. Diffraction are collected at each ω and save in files such as ''name-0000.tif'', ''name-0001.tif'', etc. For instance, if you collect data from -2° to +2° with a step size of 1.0°, starting from image 5, with a stem ''mydata'', you will save the following data files Data collected at step scans have a starting ω position, an end ω position, and a step size δω. Diffraction are collected at each ω and save in files such as ''name-0000.tif'', ''name-0001.tif'', etc. For instance, if you collect data from -2° to +2° with a step size of 1.0°, starting from image 5, with a stem ''mydata'', you will save the following data files
Line 14: Line 14:
 The scripts ''timelessTiff2edf'' and ''timelessMccd2edf'', which are both part of the [[software:timelesstools|TIMEleSS tools]], are meant to convert such file series into series of EDF files. The scripts ''timelessTiff2edf'' and ''timelessMccd2edf'', which are both part of the [[software:timelesstools|TIMEleSS tools]], are meant to convert such file series into series of EDF files.
  
 +Watch out! You can generate vast amount of data! You may want to include such scripts into larger scripts as you develop your data processing strategy.
  
 ===== timelessTiff2edf ===== ===== timelessTiff2edf =====
Line 70: Line 71:
   -d NDIGITS, --ndigits NDIGITS   -d NDIGITS, --ndigits NDIGITS
                         Number of digits for file number. Default is 4                         Number of digits for file number. Default is 4
 +</code>
 +
 +===== Other formats =====
 +
 +The ESRF fabio library, which you must have installed by now, can open and read many formats. Below is an example python program that will convert a series ''CBF'' files placed into a folder to ''EDF''.
 +
 +As you can see, the code is not specific to CBF, as long as Fabio can read it, it will work...
 +
 +<code>
 +import glob
 +import fabio, os
 +
 +cbf_dir = "/folder/with/CBFFiles"
 +edf_dir = "/folder/to/save/EDFFiles"
 +dest_format = "edf"
 +
 +# Starting value of omega
 +omegastart = -23.5
 +# Omega step
 +omegastep = 0.5
 +# The first file will be assigne a value of omega = omegastart+omegastep/2.
 +
 +
 +files = glob.glob("%s/*.cbf" % cbf_dir)
 +files.sort()
 +print("Number of files: %s" % len(files))
 +
 +if not os.path.exists(edf_dir):
 +    os.makedirs(edf_dir)
 +
 +omega = omegastart + omegastep / 2.
 +for onefile in files:
 +    dst_name = os.path.join(edf_dir, os.path.splitext(os.path.basename(onefile))[0] + "." + dest_format)
 +    print("Converting %s into %s" % (onefile, dst_name))
 +    im = fabio.open(onefile)
 +    im.header["Omega"] = omega
 +    im.convert(dest_format).save(dst_name)
 +    omega += omegastep
 +
 +print ("Read %d file in %s" % (len(files), cbf_dir))
 +print ("Saved %d file in %s"% (len(files), edf_dir))
 +print ("Done")
 </code> </code>
xray_data/convertfileseries.1547818301.txt.gz · Last modified: (external edit)