camera.formats.raw (version 638) | index d:\00_ip\spmdev\tripod\applications\python\packages\camera\formats\raw.py |
Module raw provides access to frame and channel information of Camera raw files.
Camera is the control and analysis application for the Leiden Probe Microscopy
Scanning Tunneling Microscope (STM) and for the Atomic Force Microscope (AFM).
Camera is the acronym for Computer Aided Measurement Environment for Realtime
Atomic imaging.
During a measurement Camera collects the data in a 'swap file'. When the measurement
has been completed, Camera creates a 'raw file' from the data in the named swap file.
Raw File Format
The raw file contains information about the measurements and the image data itself.
This information is roughly organized as follows:
(class RawFileReader)
.-------------------------------------------------.
| Header (class RawFileHeader) |
|-------------------------------------------------|
| Frame 0 info (class RawFileFrameInfo) |
| Channel 0 info (class RawFileChannelInfo |
| Channel 0 image (class RawFileChannelImage) |
| ... |
| Channel K info |
| Channel K image |
|-------------------------------------------------|
| ... |
|-------------------------------------------------|
| Frame N info |
| Channel 0 info |
| Channel 0 image |
| ... |
| Channel K info |
| Channel K image |
'-------------------------------------------------'
Header
The file contains a single header with information such as hardware interface
id and version and channels used and their names. For example:
header: file version id: RAW1305
header: interface id: CameraSTM_d
header: interface version: 4.0
header: frame count: 434
header: channel mask: 0x7, 0b111
header: channel count: 3
header: channel0 name: Topographical height map
header: channel1 name: Topographical height map [dZ]
header: channel2 name:
header: channel3 name:
header: channel4 name:
header: channel5 name:
header: channel6 name:
header: channel7 name:
header: channel0 unit: nm
header: channel1 unit: nm
header: channel2 unit:
header: channel3 unit:
header: channel4 unit:
header: channel5 unit:
header: channel6 unit:
header: channel7 unit:
The header is represented by class RawFileHeader.
Frame Information
For each frame there is a section with information about the measurement, such
as the acquisition time, the scanned physical area (RawFileFrameScanArea) and
the measurement (device) settings (RawFileFrameDeviceInfo). For example:
frame 0: id: 0
frame 0: acquisition time: 1275418042, Tue Jun 01 18:47:22 2010
frame 0: x-offset [pm]: 35000
frame 0: y-offset [pm]: 95000
frame 0: x-step [pm]: 19.53125
frame 0: x-step [pm]: 19.53125
frame 0: x-size [pixels]: 512
frame 0: y-size [pixels]: 512
frame 0: scan angle [rad]: 0.0
frame 0: sizeof device info: 440
frame 0: pixel clock [kHz]: 80.0
frame 0: sample per point: 8
frame 0: oversampling factor: 8
frame 0: z-gain: 32
frame 0: dz-gain: 1
frame 0: bandwidth [kHz]: 600
frame 0: z-offset [??]: -1.85
frame 0: zoverdz: 1.0
frame 0: x-rounding [%]: 0.0
frame 0: backwardstroke: 1024
frame 0: u-sample [V]: 2.0
frame 0: triangle attenuation: 0, 0x0
frame 0: sawtooth attenuation: 0, 0x0
frame 0: x-sample slope: 0
frame 0: y-sample slope: 0
frame 0: integration time code: 112
frame 0: proportional gain code: 6
frame 0: setvalue code: 46
frame 0: 3D measurements per pixel: 0
frame 0: 3D display index: 0
frame 0: 3D frame number: 0
frame 0: extra mixer offset [V]: 0.0
frame 0: extra mixer x-gain: 0
frame 0: extra mixer y-gain: 0
frame 0: extra mixer attenuation: 4
frame 0: extra mixer slewrate: 65535
frame 0: adc channels: array('H', [0, 0, 0, 0, 42076, 271, 0, 0])
frame 0: iv name:
The frame information is represented by class RawFileFrameInfo.
Please note that the frames are selected by their sequence number in the file,
not by their frameId; these may differ if frames have been deleted.
Channel Information
For each channel in a frame there is information about the size of the image
and of the scaling of its data. For example frame 0, channel 0:
channel 0.0: flags: 3, 0b11
channel 0.0: x-size: 512
channel 0.0: y-size: 513
channel 0.0: pixels: 525312
channel 0.0: data scale factor: 0.00074065625
channel 0.0: data offset: -193986
channel 0.0: parameter mask: 7, 0b111
channel 0.0: x-slope [?]: 0.0
channel 0.0: y-slope [?]: 0.0
channel 0.0: average [?]: 162.075654087
channel 0.0: z-min: -32768
channel 0.0: z-max: 32766
The channel information is represented by class RawFileChannelInfo.
Channel Images
And finally for each channel in a frame there is the image information
(16-bit signed integers), represented by class RawFileChannelImage.
Classes, Exceptions and Functions
Classes
- RawFileReader - provide access to the various parts of a Camera raw file
- RawFileHeader - provide access to the elements of the file header
- RawFileFrameInfo - provide access to the elements of a frame header
- RawFileChannelInfo - provide access to the elements of a channel header
- RawFileChannelImage - provide access to the channel image data
Exceptions
- RawFileReaderError - module's exception class
Functions
- supportedRawFileFormats() - provide a list of the supported raw file formats
Examples
Below are several examples how the classes in this module can be used to retrieve
the various parts of the Camera raw files.
#
# Obtain raw file header, and last frame, last channel information:
#
from camera.formats.raw import *
f = open( path, "rb" )
reader = RawFileReader( f )
# can also use: reader = RawFileReader( path )
print( reader.header )
frame = reader.frameCount - 1
channel = reader.channelCount - 1
print( reader.frameInfo( frame ) )
print( reader.channelInfo( frame, channel ) )
print( reader.channelImage( frame, channel ) )
#
# Iterate over all frame information headers:
#
for info in reader.frameInfoIter():
print( 'frame {frm}:'.format( frm=info.frame ) )
print( info )
#
# Iterate over all channel information headers:
#
for info in reader.channelInfoIter():
print( 'channel {frm}.{chn}:'.format( frm=info.frame, chn=info.channel ) )
print( info )
#
# Iterate over all channel images:
#
for image in reader.imageIter():
print( 'image {frm}.{chn}:'.format( frm=image.frame, chn=image.channel ) )
print( image )
print()
References
The C++ code with reading of the raw file and relevant data structures are at:
method CScanDocument::BuildInternalDataStructureFromRAW()
- https://svn.eld.leidenuniv.nl/repos/ip-camera/application/trunk/Camera/ScanDocument.h
- https://svn.eld.leidenuniv.nl/repos/ip-camera/application/trunk/Camera/ScanDocument.cpp
- see Python class RawFileReader, method _createIndex()
struct __SpmScanPosition
- https://svn.eld.leidenuniv.nl/repos/ip-camera/application/trunk/Camera/InterfaceDll.h
- see Python class RawFileFrameScanArea
struct __SpmCameraDeviceSpecificFrameData
- https://svn.eld.leidenuniv.nl/repos/ip-camera/application/trunk/CameraDll/CameraDll.h
- see Python class RawFileFrameDeviceInfo
Weblinks
IP: Interface Physics, http://www.physics.leidenuniv.nl/sections/cm/ip/
LPM: Leiden Probe Microscopy, http://www.leidenprobemicroscopy.com/
See also http://www.physics.leidenuniv.nl/sections/cm/ip/Internal/Camera/Camera-MainPage.html
Modules | ||||||
|
Classes | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Functions | ||
|
Data | ||
__all__ = ['supportedRawFileFormats', 'RawFileReaderError', 'RawFileReader', 'RawFileHeader', 'RawFileFrameInfo', 'RawFileChannelInfo', 'RawFileChannelImage'] __author__ = 'Martin Moene <m.j.moene@eld.physics.LeidenUniv.nl>' __url__ = 'http://www.physics.leidenuniv.nl/sections/cm/ip/Internal/Camera/Camera-MainPage.html' __version__ = '$Revision: 638 $' __version_date__ = '$Date: 2012-01-09 18:04:51 +0100 (Mon, 09 Jan 2012) $' |
Author | ||
Martin Moene <m.j.moene@eld.physics.LeidenUniv.nl> |