Newer
Older
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cfelpyutils package — cfelpyutils 0.5 documentation</title>
<link rel="stylesheet" href="_static/bizstyle.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.5',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/bizstyle.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!--[if lt IE 9]>
<script type="text/javascript" src="_static/css3-mediaqueries.js"></script>
<![endif]-->
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">cfelpyutils 0.5 documentation</a> »</li>
</ul>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">cfelpyutils package</a><ul>
<li><a class="reference internal" href="#submodules">Submodules</a></li>
<li><a class="reference internal" href="#module-cfelpyutils.cfel_crystfel">cfelpyutils.cfel_crystfel module</a></li>
<li><a class="reference internal" href="#module-cfelpyutils.cfel_cxi">cfelpyutils.cfel_cxi module</a></li>
<li><a class="reference internal" href="#module-cfelpyutils.cfel_fabio">cfelpyutils.cfel_fabio module</a></li>
<li><a class="reference internal" href="#module-cfelpyutils.cfel_geom">cfelpyutils.cfel_geom module</a></li>
<li><a class="reference internal" href="#module-cfelpyutils.cfel_hdf5">cfelpyutils.cfel_hdf5 module</a></li>
<li><a class="reference internal" href="#module-cfelpyutils.cfel_optarg">cfelpyutils.cfel_optarg module</a></li>
<li><a class="reference internal" href="#module-cfelpyutils.cfel_psana">cfelpyutils.cfel_psana module</a></li>
<li><a class="reference internal" href="#module-cfelpyutils">Module contents</a></li>
</ul>
</li>
</ul>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/cfelpyutils.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="cfelpyutils-package">
<h1>cfelpyutils package<a class="headerlink" href="#cfelpyutils-package" title="Permalink to this headline">¶</a></h1>
<div class="section" id="submodules">
<h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline">¶</a></h2>
</div>
<div class="section" id="module-cfelpyutils.cfel_crystfel">
<span id="cfelpyutils-cfel-crystfel-module"></span><h2>cfelpyutils.cfel_crystfel module<a class="headerlink" href="#module-cfelpyutils.cfel_crystfel" title="Permalink to this headline">¶</a></h2>
<p>Utilities for interoperability with the CrystFEL software package.</p>
<p>This module contains reimplementation of Crystfel functions and utilities.</p>
<dt id="cfelpyutils.cfel_crystfel.load_crystfel_geometry">
<code class="descclassname">cfelpyutils.cfel_crystfel.</code><code class="descname">load_crystfel_geometry</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_crystfel.load_crystfel_geometry" title="Permalink to this definition">¶</a></dt>
<dd><p>Loads a CrystFEL geometry file into a dictionary.</p>
<p>Reimplements the get_detector_geometry_2 function from CrystFEL amost verbatim. Returns a dictionary with the
geometry information. Entries in the geometry file appears as keys in the returned dictionary. For a full
documentation on the CrystFEL geometry format, see:</p>
<p>tfel/manual-crystfel_geometry.html</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>filename</strong> (<em>str</em>) – filename of the geometry file</td>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">dictionary with the geometry loaded from the file</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">detector (dict)</td>
</tr>
</tbody>
</table>
</dd></dl>
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
</div>
<div class="section" id="module-cfelpyutils.cfel_cxi">
<span id="cfelpyutils-cfel-cxi-module"></span><h2>cfelpyutils.cfel_cxi module<a class="headerlink" href="#module-cfelpyutils.cfel_cxi" title="Permalink to this headline">¶</a></h2>
<p>Utilities for writing multi-event files in the CXIDB format.</p>
<p>This module contains utilities to write files that adhere to the CXIDB file format:</p>
<p><a class="reference external" href="http://www.cxidb.org/cxi.html">http://www.cxidb.org/cxi.html</a> .</p>
<dl class="class">
<dt id="cfelpyutils.cfel_cxi.CXIWriter">
<em class="property">class </em><code class="descclassname">cfelpyutils.cfel_cxi.</code><code class="descname">CXIWriter</code><span class="sig-paren">(</span><em>filename</em>, <em>max_num_slices=5000</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_cxi.CXIWriter" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
<p>Writing of multi-event CXIDB files.</p>
<p>Implements a simple low-level CXIDB file format writer for multi event files. it allows the user to write data
“stacks” in the CXIDB files, making sure that the entries in all stacks are synchronized.</p>
<p>A CXI Writer instance manages one file. A user can add a stack to a CXI Writer instance with the
add_stack_to_writer function, which also writes the first entry in the stack. The user can then add to the writer
all the stacks that he wants in the file. Once all stacks are added, the user initializes them with the
initialize_stacks function. After initialization, no more stacks can be added. Instead, entries can be appended to
the existing stacks, using the append_data_to_stack function.</p>
<p>A “slice” (a set of synced entries in all the stacks in the file) can be written to the a file only after an entry
has been appended to all stacks in the file. Conversely, after an entry has been appended to a stack, the user
cannot append another entry before a slice is written. This ensures synchronization of the data in all the stacks.</p>
<p>A file can be closed at any time. In any case, the writer will not allow a file to contain more than the
number_of_entries specified during instantiation.</p>
<p>Simple non-stack entries can be written to the file at any time, before or after stack initialization (provided of
course that the file is open). Entries and stacks will general never be overwritten unless the overwrite parameter
is set to True.</p>
<p>Example of usage of the stack API:</p>
<p>f1 = CXIWriter(‘test1.h5’, )
f2 = CXIWriter(‘test2.h5’, )</p>
<dl class="docutils">
<dt>f1.add_stack_to_writer(‘detector1’, ‘/entry_1/detector_1/data’, numpy.random.rand(2, 2),</dt>
<dd>‘frame:y:x’)</dd>
<dt>f2.add_stack_to_writer(‘detector2’, ‘/entry_1/detector_1/data’, numpy.random.rand(3, 2),</dt>
<dd>‘frame:y:x’, compression=False, chunk_size=(1,3,2))</dd>
</dl>
<p>f1.add_stack_to_writer(‘counter1’, ‘/entry_1/detector_1/count’, c1)
f2.add_stack_to_writer(‘counter2’, ‘/entry_1/detector_1/count’, c2)</p>
<p>f1.write_simple_entry(‘/entry_1/detector_1/name’, ‘FrontCSPAD’)
f2.write_simple_entry(‘/entry_1/detector_1/name’, ‘BackCSPAD’)</p>
<p>f1.initialize_stacks()
f2.initialize_stacks()</p>
<p>a = numpy.random.rand(2, 2)
b = numpy.random.rand(3, 2)</p>
<p>c1 += 1
c2 += 2</p>
<p>f1.append_data_to_stack(‘detector1’, a)
f2.append_data_to_stack(‘detector2’, b)</p>
<p>f1.append_data_to_stack(‘counter1’, c1)
f2.append_data_to_stack(‘counter2’, c2)</p>
<p>f1.write_stack_slice_and_increment()
f2.write_stack_slice_and_increment()</p>
<p>f1.close_file()
f2.close_file()</p>
<dl class="method">
<dt id="cfelpyutils.cfel_cxi.CXIWriter.add_stack_to_writer">
<code class="descname">add_stack_to_writer</code><span class="sig-paren">(</span><em>name</em>, <em>path</em>, <em>initial_data</em>, <em>axes=None</em>, <em>compression=True</em>, <em>chunk_size=None</em>, <em>overwrite=True</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_cxi.CXIWriter.add_stack_to_writer" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a new stack to the file.</p>
<p>Adds a new stack to the CXI Writer instance. The user must provide a name for the stack, that will identify
the stack in all subsequents operations. The user must also provide the data that will be written as the
initial entry in the stack (initial_data). This initial entry is used to set the size and type of data that the
stack will hold and these parameters are in turn be used to validate all data that is subsequently appended to
the stack.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>name</strong> (<em>str</em>) – stack name.</li>
<li><strong>path</strong> (<em>str</em>) – path in the hdf5 file where the stack will be written.</li>
<li><strong></strong><strong>(</strong><strong>Union</strong><strong>[</strong><strong>numpy.ndarray</strong><strong>, </strong><strong>str</strong><strong>, </strong><strong>int</strong><strong>, </strong><strong>float</strong><strong>]</strong><strong></strong> (<em>initial_data</em>) – initial entry in the stack. It gets written to the</li>
<li><strong>as slice 0. Its characteristics are used to validate all data subsequently appended to the stack.</strong> (<em>stack</em>) – </li>
<li><strong>axes</strong> (<em>str</em>) – the ‘axes’ attribute for the stack, as defined by the CXIDB file format.</li>
<li><strong>compression</strong> (<em>Union</em><em>[</em><em>None</em><em>, </em><em>bool</em><em>,</em><em>str</em><em>]</em><em></em>) – compression parameter for the stack. This parameters works in the same</li>
<li><strong>as the normal compression parameter from h5py. The default value of this parameter is True.</strong> (<em>way</em>) – </li>
<li><strong>chunk_size</strong> (<em>Union</em><em>[</em><em>None</em><em>, </em><em>tuple</em><em>]</em><em></em>) – HDF5 chuck size for the stack. If this parameter is set to None, the</li>
<li><strong>writer will compute a chuck size automatically</strong> (<em>CXI</em>) – </li>
<li><strong>use the provided tuple to set the chunk size.</strong> (<em>will</em>) – </li>
<li><strong>overwrite</strong> (<em>bool</em>) – if set to True, a stack already existing at the same location will be overwritten. If set</li>
<li><strong>False</strong><strong>, </strong><strong>an attempt to overwrite a stack will raise an error.</strong> (<em>to</em>) – </li>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="cfelpyutils.cfel_cxi.CXIWriter.append_data_to_stack">
<code class="descname">append_data_to_stack</code><span class="sig-paren">(</span><em>name</em>, <em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_cxi.CXIWriter.append_data_to_stack" title="Permalink to this definition">¶</a></dt>
<dd><p>Appends data to a stack.</p>
<p>Appends data to a stack, validating the data to make sure that the data type and size match the previous entries
in the stack. Only one entry can be appended to each stack before writing a slice across all stacks with
the write_slice_and_increment.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>name</strong> (<em>str</em>) – stack name, defining the stack to which the data will be appended.</li>
<li><strong></strong><strong>(</strong><strong>Union</strong> (<em>data</em>) – numpy.ndarray, str, int, float): data to write. The data will be validated against the type</li>
<li><strong>size of previous entries in the stack.</strong> (<em>and</em>) – </li>
</ul>
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="cfelpyutils.cfel_cxi.CXIWriter.close_file">
<code class="descname">close_file</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_cxi.CXIWriter.close_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Closes the file.</p>
<p>Closes the file for writing, ending all writing operations.</p>
</dd></dl>
<dl class="method">
<dt id="cfelpyutils.cfel_cxi.CXIWriter.get_file_handle">
<code class="descname">get_file_handle</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_cxi.CXIWriter.get_file_handle" title="Permalink to this definition">¶</a></dt>
<dd><p>Access to the naked h5py file handle.</p>
<p>This function allows access to the a naked h5py handle for the file managed by the CXI Writer. This allowa
operations on the file that are not covered by CXI Writer API. Use it at your own risk.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">an h5py file handle to the file managed by the writer.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">fh (h5py.File)</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="cfelpyutils.cfel_cxi.CXIWriter.initialize_stacks">
<code class="descname">initialize_stacks</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_cxi.CXIWriter.initialize_stacks" title="Permalink to this definition">¶</a></dt>
<dd><p>Initializes the stacks.</p>
<p>Initializes the stacks in the CXI Writer instance. This fixes the number and type of stacks in the file. No
stacks can be added to the CXI Writer after initialization.</p>
</dd></dl>
<dl class="method">
<dt id="cfelpyutils.cfel_cxi.CXIWriter.write_simple_entry">
<code class="descname">write_simple_entry</code><span class="sig-paren">(</span><em>path</em>, <em>data</em>, <em>overwrite=False</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_cxi.CXIWriter.write_simple_entry" title="Permalink to this definition">¶</a></dt>
<dd><p>Writes a simple, non-stack entry in the file.</p>
<p>Writes a simple, non-stack entry in the file, at the specified path. A simple entry can be written at all times,
before or after the stack initialization.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>path</strong> (<em>str</em>) – path in the hdf5 file where the entry will be written.</li>
<li><strong></strong><strong>(</strong><strong>Union</strong> (<em>data</em>) – numpy.ndarray, str, int, float): data to write</li>
<li><strong>overwrite</strong> (<em>bool</em>) – if set to True, an entry already existing at the same location will be overwritten. If set</li>
<li><strong>False</strong><strong>, </strong><strong>an attempt to overwrite an entry will raise an error.</strong> (<em>to</em>) – </li>
</ul>
<dl class="method">
<dt id="cfelpyutils.cfel_cxi.CXIWriter.write_stack_slice_and_increment">
<code class="descname">write_stack_slice_and_increment</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_cxi.CXIWriter.write_stack_slice_and_increment" title="Permalink to this definition">¶</a></dt>
<dd><p>Writes a slice across all stacks and resets the writer for the next slice.</p>
<p>Writes a slice across all stacks in the file. It checks that an entry has been appended to each stack, and
writes all the entries on top of the relevant stacks in one go. If an entry is missing in a stack, the function
will raise an error. After writing the slice, the function resets the writer to allow again appending data to
the stacks.</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="module-cfelpyutils.cfel_fabio">
<span id="cfelpyutils-cfel-fabio-module"></span><h2>cfelpyutils.cfel_fabio module<a class="headerlink" href="#module-cfelpyutils.cfel_fabio" title="Permalink to this headline">¶</a></h2>
<p>Utilities based on the fabio python module.</p>
<p>This module contains utilities based on the fabio python module.
files.</p>
<dt id="cfelpyutils.cfel_fabio.read_cbf_from_stream">
<code class="descclassname">cfelpyutils.cfel_fabio.</code><code class="descname">read_cbf_from_stream</code><span class="sig-paren">(</span><em>stream</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_fabio.read_cbf_from_stream" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads a cbfimage object out of a data string buffer.</p>
<p>Read a data string buffer received as a payload from the PETRAIII P11 sender, and creates a cbfimage object from
it (See the documentation of the fabio python module).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>stream</strong> (<em>str</em>) – a data string buffer received from the PETRAIII P11 sender.</td>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><dl class="docutils">
<dt>a cbfimage object containing the data extracted</dt>
<dd>from the string buffer.</dd>
</dl>
</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">cbf_obj (fabio.cbfimage)</td>
</div>
<div class="section" id="module-cfelpyutils.cfel_geom">
<span id="cfelpyutils-cfel-geom-module"></span><h2>cfelpyutils.cfel_geom module<a class="headerlink" href="#module-cfelpyutils.cfel_geom" title="Permalink to this headline">¶</a></h2>
<p>Utilities for CrystFEL-style geometry files.</p>
<p>This module contains utilities for the processing of CrystFEL-style geometry
files.</p>
<dt id="cfelpyutils.cfel_geom.apply_geometry_from_file">
<code class="descclassname">cfelpyutils.cfel_geom.</code><code class="descname">apply_geometry_from_file</code><span class="sig-paren">(</span><em>data_as_slab</em>, <em>geometry_filename</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_geom.apply_geometry_from_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Parses a geometry file and applies the geometry to data.</p>
<p>Parses a geometry file and applies the geometry to detector data in ‘slab’ format. Turns a 2d array of pixel
values into an array containing a representation of the physical layout of the detector, keeping the origin of
the reference system at the beam interaction point.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>data_as_slab</strong> (<em>numpy.ndarray</em>) – the pixel values to which geometry is to be applied.</li>
<li><strong>geometry_filename</strong> (<em>str</em>) – geometry filename.</li>
</ul>
</td>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Array containing a representation of the physical layout of the
detector, with the origin of the reference system at the beam interaction point.</p>
</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">im_out (numpy.ndarray data_as_slab.dtype)</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="cfelpyutils.cfel_geom.apply_geometry_from_pixel_maps">
<code class="descclassname">cfelpyutils.cfel_geom.</code><code class="descname">apply_geometry_from_pixel_maps</code><span class="sig-paren">(</span><em>data_as_slab</em>, <em>yx</em>, <em>im_out=None</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_geom.apply_geometry_from_pixel_maps" title="Permalink to this definition">¶</a></dt>
<dd><p>Applies geometry in pixel map format to data.</p>
<p>Applies geometry, in the form of pixel maps, to detector data in ‘slab’ format. Turns a 2d array of pixel values
into an array containing a representation of the physical layout of the detector, keeping the origin of the
reference system at the beam interaction point.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>data_as_slab</strong> (<em>numpy.ndarray</em>) – the pixel values to which geometry is to be applied.</li>
<li><strong>yx</strong> (<em>tuple</em>) – the yx pixel maps describing the geometry of the detector; each map is a numpy.ndarray.</li>
<li><strong>im_out</strong> (<em>Optional</em><em>[</em><em>numpy.ndarray</em><em>]</em><em></em>) – array to hold the output; if not provided, one will be generated</li>
<li><strong>automatically.</strong> – </li>
</ul>
</td>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Array containing a representation of the physical layout of the
detector, with the origin of the reference system at the beam interaction point.</p>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">im_out (numpy.ndarray data_as_slab.dtype)</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dt id="cfelpyutils.cfel_geom.pixel_maps_for_image_view">
<code class="descclassname">cfelpyutils.cfel_geom.</code><code class="descname">pixel_maps_for_image_view</code><span class="sig-paren">(</span><em>geometry_filename</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_geom.pixel_maps_for_image_view" title="Permalink to this definition">¶</a></dt>
<dd><p>Parses a geometry file and creates pixel maps for pyqtgraph visualization.</p>
<p>Parse the geometry file and creates pixel maps for an array in ‘slab’ format containing pixel values. The pixel
maps can be used to create a representation of the physical layout of the detector in a pyqtgraph ImageView
widget (i.e. they apply the detector geometry setting the origin of the reference system is in the top left corner
of the output array).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>geometry_filename</strong> (<em>str</em>) – geometry filename.</td>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">pixel maps<p>slab_shape tuple (int, int): shape of the original geometry uncorrected array (the pixel values in “slab”
format).</p>
<p>img_shape tuple (int, int): shape of the array needed to contain the representation of the physical layout
of the detector.</p>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">(y, x) (numpy.ndarray int, numpy.ndarray int)</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="cfelpyutils.cfel_geom.pixel_maps_from_geometry_file">
<code class="descclassname">cfelpyutils.cfel_geom.</code><code class="descname">pixel_maps_from_geometry_file</code><span class="sig-paren">(</span><em>fnam</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_geom.pixel_maps_from_geometry_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Parses a geometry file and creates pixel maps.</p>
<p>Extracts pixel maps from a CrystFEL-style geometry file. The pixel maps can be used to create a representation of
the physical layout of the detector, keeping the origin of the reference system at the beam interaction
point.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>fnam</strong> (<em>str</em>) – geometry filename.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">slab-like pixel maps with
respectively x, y coordinates of the pixel and distance of the pixel from the center of the reference system.</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">x,y,r (numpy.ndarray float, numpy.ndarray float, numpy.ndarray float)</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="module-cfelpyutils.cfel_hdf5">
<span id="cfelpyutils-cfel-hdf5-module"></span><h2>cfelpyutils.cfel_hdf5 module<a class="headerlink" href="#module-cfelpyutils.cfel_hdf5" title="Permalink to this headline">¶</a></h2>
<p>Utilities for HDF5 files.</p>
<p>This module contains utilities for the processing of HDF5. This module builds
on what the h5py module already provides.</p>
<dl class="function">
<dt id="cfelpyutils.cfel_hdf5.load_nparray_from_hdf5_file">
<code class="descclassname">cfelpyutils.cfel_hdf5.</code><code class="descname">load_nparray_from_hdf5_file</code><span class="sig-paren">(</span><em>data_filename</em>, <em>data_group</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_hdf5.load_nparray_from_hdf5_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Loads a numpy.ndarray from an HDF5 file.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>data_filename</strong> (<em>str</em>) – filename of the file to read.</li>
<li><strong>data_group</strong> (<em>str</em>) – internal HDF5 path of the data block to read.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">numpy array with the data read from the file.</p>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">nparray (numpy.ndarray)</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="module-cfelpyutils.cfel_optarg">
<span id="cfelpyutils-cfel-optarg-module"></span><h2>cfelpyutils.cfel_optarg module<a class="headerlink" href="#module-cfelpyutils.cfel_optarg" title="Permalink to this headline">¶</a></h2>
<p>Utilities for parsing command line options and configuration files.</p>
<p>This module contains utilities for parsing of command line options and
configuration files.</p>
<dl class="function">
<dt id="cfelpyutils.cfel_optarg.parse_parameters">
<code class="descclassname">cfelpyutils.cfel_optarg.</code><code class="descname">parse_parameters</code><span class="sig-paren">(</span><em>config</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_optarg.parse_parameters" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets correct types for parameter dictionaries.</p>
<p>Reads a parameter dictionary returned by the ConfigParser python module, and assigns correct types to parameters,
without changing the structure of the dictionary.</p>
<p>The parser tries to interpret each entry in the dictionary according to the following rules:</p>
<li><p class="first">If the entry starts and ends with a single quote or double quote, it is
interpreted as a string.</p>
</li>
<li><p class="first">If the entry starts and ends with a square bracket, it is interpreted as a list.</p>
</li>
<li><p class="first">If the entry starts and ends with a brace, it is interpreted as a dictionary.</p>
</li>
<li><p class="first">If the entry is the word None, without quotes, then the entry is
interpreted as NoneType.</p>
</li>
<li><p class="first">If the entry is the word False, without quotes, then the entry is
interpreted as a boolean False.</p>
</li>
<li><p class="first">If the entry is the word True, without quotes, then the entry is
interpreted as a boolean True.</p>
</li>
<li><p class="first">If none of the previous options match the content of the entry,
the parser tries to interpret the entry in order as:</p>
<blockquote>
<div><ul class="simple">
<li>An integer number.</li>
<li>A float number.</li>
<li>A string.</li>
</ul>
</div></blockquote>
<p>The first choice that succeeds determines the entry type.</p>
</li>
</ul>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>config</strong> (<em>class RawConfigParser</em>) – ConfigParser instance.</td>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">dictionary with the same structure as the input dictionary, but with correct types
assigned to each entry.</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">monitor_params (dict)</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="module-cfelpyutils.cfel_psana">
<span id="cfelpyutils-cfel-psana-module"></span><h2>cfelpyutils.cfel_psana module<a class="headerlink" href="#module-cfelpyutils.cfel_psana" title="Permalink to this headline">¶</a></h2>
<p>This module provides utilities that build on the functionality provided by the psana python module.</p>
<dt id="cfelpyutils.cfel_psana.dirname_from_source_runs">
<code class="descclassname">cfelpyutils.cfel_psana.</code><code class="descname">dirname_from_source_runs</code><span class="sig-paren">(</span><em>source</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_psana.dirname_from_source_runs" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a directory name based on a psana source string.</p>
<p>Takes a psana source string (e.g exp=CXI/cxix....) and returns a string that can be used as a subdirectory name or
a prefix for files and directories.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>source</strong> (<em>str</em>) – a psana source string (e.g. exp=CXI/cxi....).</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a string that can be used as a filename or a prefix .</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">dirname (str)</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="cfelpyutils.cfel_psana.psana_event_inspection">
<code class="descclassname">cfelpyutils.cfel_psana.</code><code class="descname">psana_event_inspection</code><span class="sig-paren">(</span><em>source</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_psana.psana_event_inspection" title="Permalink to this definition">¶</a></dt>
<p>Takes a psana source string (e.g. exp=CXI/cxix....) and inspects the structure of the first event in the data,
printing information about the the content of the event.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>source</strong> (<em>str</em>) – a psana source string (e.g. exp=CXI/cxix....).</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="cfelpyutils.cfel_psana.psana_obj_from_string">
<code class="descclassname">cfelpyutils.cfel_psana.</code><code class="descname">psana_obj_from_string</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_psana.psana_obj_from_string" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts a string into a psana object type.</p>
<p>Takes a string and returns the python object type described by the string.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>str</em>) – a string describing a python type.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">the python type described by the string.</td>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">mod (type)</td>
</div>
<div class="section" id="module-cfelpyutils">
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-cfelpyutils" title="Permalink to this headline">¶</a></h2>
<p>Utilities for CFEL software projects.</p>
<p>This module provides utilities (functions, classes, etc.) used by many CFEL projects.</p>
<p>It contains the following submodules (non of which are automatically imported):</p>
<p>cfelfabio: utilities based on the fabio python module (a module that allows
python to work with several file format used in x-ray imaging).</p>
<p>cfelgeom: utilities for processing CrystFEL-style geometry files.</p>
<p>cfelhdf5: utilities for processing HDF5 files (based on the h5py python module).</p>
<p>cfeloptarg: utilities to parse command line arguments and parameter files.</p>
<p>cfelpsana: utilities that expand the functionality of the psana python module.</p>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">cfelpyutils 0.5 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2016, CFEL Team.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.1.