Files¶
-
class
@files.
files
(varargin)¶ FILES Class to process file requests for nanodiffraction data. FILES accepts name value pairs and requires in general the path to certain scan parameters such as the directory of data storage, file naming conventions (prefixes and suffixes) and the type of detector used. Once initialized properly, it should be attached to a nanodiffraction class so that file reading will be done automatically based on the scan frame number.
DATA = FILES()
creates a files module, with a list of key-value pairs. See further below for a list of keys and possible values.The following options are supported:
- prepath: [homegroups/Labdata-Archive/AG_Salditt/Messzeiten_Rohdaten/2016/extern/ESRF_ID13_SC4304/id13/inhouse/DATA/AUTO-TRANSFER/eiger1]
- Path to folder where the data is stored. The prepath depends on the beamline you choose. Check help path_by_beamline for more information on the default settings.
- beamline: [id13]
The beamline argument is necessary, because it is referred to when a certain standard file naming convention should be used. See the help on path_by_beamline for more information.
Options: ‘id13’|’p10’|’id02’|’bessy’|’none’- newfile: [detdistcalib]
- File name prefix.
- detector: [eiger]
Type of detector used in the experiment. Each detector is currently contained in a separate module.
Options: ‘eiger’|’pilatus’|’rayonix’|’xia’- fn: [1]
- File number. Note, that some detectors start the numbering scheme with 1, while others start with 0.
- fpf: [101]
- Frames per file. If a container format is used that collects a given number (the fpf) of scattering patterns, this number of frames per container is termed ‘’. E.g. the Eiger detector uses the hdf5 container format. fpf can be an arbitrary number, but usually it is the number of scan points along the fast axis.
- scan: [210]
- Number of the scan. Be aware, that SPEC or other logging software might use a different numbering scheme than the detector. The scan number always refers to the number that is appended to the filename.
Example
- See the following example for help::
- f = files( ‘beamline’,’id13’,…
- ‘prepath’,[prepath ‘Labdata-Archive/AG_Salditt/Messzeiten_Rohdaten/2016/extern/ESRF_ID13_SC4304/id13/inhouse/DATA/AUTO-TRANSFER/eiger1’],… ‘newfile’,’herz2_roi2’,… ‘detector’,’eiger’,… ‘scan’,201);
-
See seperate help for each method.
Copyright 2017 Institute for X-ray Physics (University of Göttingen)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
files
(varargin)¶ prepare absolute path
-
path_by_beamline
(beamline, detector, prepath, newfile, scannr)¶ PATH_BY_BEAMLINE contains the appropriate folder structure for each beamline. This function should be adapted to ones specific needs.
configuration = path_by_beamline(beamline,detector,prepath,newfile,scannr)
- The following arguments are supported:
- beamline: [] (required)
- Beamline short name. As described in help files.Options: ‘p10’|’id13’|’id02’|’bessy’
- detector: [] (required)
- Detector. As described in help files.Options: ‘eiger’|’pirra’|’rayonix’|’xia’|’spec’
- prepath: [] (required)
- Path to data directory.
- newfile: [] (required)
- Name of scan.
- scannr: [] (required)
- Scan number.
Example
This function is only used internally.
- Output arguments:
- configuration:
- Configuration that is passed to the respective detector module.
-
read
(varargin)¶ READ reads data frame from the requested detector module.
data = read(fn)
- The following arguments are supported:
- fn: []
- File number. This number indicates the n’th frame that was collected within the session identified by the newfile name. It is NOT the frame number. The frame number represents the m’th frame collected during one scan (however, multiple scans could have been performed during one session).
Example
See the following example for help:
f = files(<some settings>); raw_data = f.read(19);
- Output arguments:
- data:
- Raw detector frame.
-
remove_leading_trailing_slashes
(string)¶ REMOVE_LEADING_TRAILING_SLASHES removes any leading or trailing slashes from a given string. This function ensures, that the user does need to worry about whether a string should start or end with a slash or backslash character.
remove_leading_trailing_slashes(string)
- The following arguments are supported:
- string: []
- Input string.
Example
See the following example for help:
f = files(<some configuration>); out_string = ... f.remove_leading_trailing_slashes('/home/testdir/raddamage1/');
- Output arguments:
- This function does not return any arguments.
-
set_eiger_scan
(newfile, scan)¶ SET_EIGER_SCAN updates the eiger module.
set_eiger_scan(newfile, scan)
- The following arguments are supported:
- newfile: [] (required)
- Scan name.
- scan: [] (required)
- Scan number.
Example
See the following example for help:
f = files(<some configuration>); f.set_eiger_scan('raddamage1',44);
- Output arguments:
- This function does not return any arguments.
-
set_pilatus_scan
(newfile)¶ SET_PILATUS_SCAN updates the pilatus module.
set_pilatus_scan(newfile)The following arguments are supported:
- newfile:: [] (required)
- Scan name.
Example
f = files(<some configuration>); f.set_pilatus_scan(‘raddamage1’);
- Output arguments:
- This function does not return any arguments.
-
set_spec_scan
(newfile)¶ SET_SPEC_SCAN updates the spec module.
SET_SPEC_SCAN(newfile)
- The following arguments are supported:
- newfile: [] (required)
- Scan name.
Example
See the following example for help:
f = files(<some configuration>); f.set_spec_scan('raddamage1'); specdata = f.read(1); % reads scan #1 from spec-file
- Output arguments:
- This function does not return any arguments.
-
set_xia_scan
(newfile, scan, fpf)¶ SET_XIA_SCAN updates the xia module.
set_xia_scan(newfile, scan, fpf)
The following arguments are supported:
- newfile: [] (required)
- Scan name.
- scan: [] (required)
- Scan number.
- fpf: [] (required)
- Frames per xia-file. This is typically the number of scan points per fast axis.
Example
See the following example for help:
f = files(<some configuration>); f.set_xia_scan('raddamage1',44,201);
- Output arguments:
- This function does not return any arguments.
-
show_configuration
(varargin)¶ SHOW_CONFIGURATION shows which detectors at which beamline are currently implemented.
show_configuration(opts)
- The following options are supported:
- opts: [see default values below] (optional)
Structure that can contain the following fields. Note, that all fields are optional. Default values that are otherwise used are as usual given in angle brackets:
- allDefaults: [0]
- Show all detectors at all beamlines that are currently implemented.
- useDefaults: [1]
- Use standard settings for the path, newfile, etc…
Example
- See the following example for help::
- f = files(); f.show_configuration(struct(‘allDefaults’,1,’useDefaults’,1));
- Output arguments:
- This function does not return any arguments.
-
which_slash
(string)¶ WHICH_SLASH checks for slashes in a string. If the string contains slashes they have to conform to naming convenctions based on the system (unix, windows) in use
[string,slash] = which_slash(string)
- The following arguments are supported:
- string: (required)
- This can be any string.
Example
See the following example for help:
f = files(); [out_string,sl] = f.which_slash('A test \ string /');
- Output arguments:
- string:
- A string where all slashes or backslashes have been replaced by the correct slash or backslash, based on the computer system used (mac, pc, unix).
- slash:
- The slash that should be used for paths to directories of files, based on the computer system used (mac, pc, unix).