Generate image file names
Generator class creating image file names. An instance of this class can be used in two ways
In the first case one can use
g = filename_generator("image_%07i.tif",10,100)
print(g())
#output: image_0000010.tif
print(g())
#output: image_0000011.tif
while the latter case is done with
g = filename_generator("image_%04i.cbf",10,15)
for filename in g:
print(filename)
#output:
#image_0010.cbf
#image_0011.cbf
#image_0012.cbf
#image_0013.cbf
#...
If no stop_index is provided the generator will run infinitely.
Constructor for filename_generator.
Parameters: |
|
---|
Static factory method to create a filename_generator instance from a sliced user input
Users typically provide a string description of the filename format along with a range. This textual representation has the form
filename_format:start_index:stop_index
Where filename_format is a C-style format string describing the structure of the filename and start_index and stop_index are integers denoting the numerical index of the first and the last file generated respectively.
For instance
image_%06i.cbf:100:1000
Parameters: | file_template (str) – sliced file template |
---|---|
Returns: | instance of filename_generator |
Return type: | filename_generator |
Iterator type for filenames
This class is typically not instantiated by itself but rather by filename_generator.
If no stop_index is given the iterator will never stop.
Constructor for filename_iterator
Parameters: |
|
---|
Enumeration for image file types
indicating a CBF file
indicating a TIFF file
Return the extension for a particular file format.
The extension returned already includes the period.
Parameters: | fformat (file_format) – the file format enumeration |
---|---|
Returns: | string with file extension |
Return type: | str |
Get file format from file extension.
The extension passed can include the leading period but must not. So either form cbf or .cbf would be allowed.
Parameters: | file_extension (str) – file extension |
---|---|
Returns: | file format enumeration |
Return type: | file_format |
Raises ValueError: | |
if no format is know for this extension |
Iterator for a single field.
This iterator runs over the first index of a field and returns the content of the other dimensions as a numpy array.
Parameters: | field (nxfield) – NeXus field over which to iterate |
---|
Iterator over a list of NeXus fields
This iterator runs over a list of NeXus fields. The fields are iterated subsequently starting with the first one. ‘
Parameters: | field_list (list) – list with instances of nxfield |
---|
Predicate function identifying a detector group
Function returns True if object passed as its argument is an instance of nxgroup and is of type NXdetector.
Parameters: | group (nxobject) – NeXus object |
---|---|
Returns: | True object is a detector group, False otherwise |
Return type: | Boolean |
Predicate function identifying an NXdata group
Function returns True if the object passed as its argument is an instance of nxgroup and is of type NXdata.
Parameters: | group (nxobject) – NeXus object |
---|---|
Returns: | True if group is an NXdata group, False otherwise |
Return type: | Boolean |
Predicate checking for data child
This predicate function returns True if the object group passed
Parameters: | group (nxobject) – NeXus object |
---|---|
Returns: | True if group matches the above conditions, False otherwise |
Return type: | Boolean |
Get the entry for a articular object
This function returns the NXentry group nexus_object belongs to.
Parameters: | nexus_object (nxobject) – the object for which to find the entry |
---|---|
Returns: | group of type NXentry |
Return type: | nxgroup |