From ecc169feeea9b6dee23f9ef96002c4679b98a402 Mon Sep 17 00:00:00 2001 From: niermann Date: Fri, 24 Mar 2017 07:26:09 +0100 Subject: [PATCH] * BeamTilt/BeamShift * Documentation update * renamed source directory from _temscript to _temscript_module --- CHANGELOG.txt | 4 + LICENSE.txt | 2 +- README.txt | 6 +- .../acqimage.cpp | 0 .../acquisition.cpp | 0 .../blankershutter.cpp | 0 .../ccdacqparams.cpp | 0 .../ccdcamera.cpp | 0 .../ccdcamerainfo.cpp | 0 .../configuration.cpp | 0 {_temscript => _temscript_module}/defines.h | 0 {_temscript => _temscript_module}/gauge.cpp | 0 {_temscript => _temscript_module}/gun.cpp | 0 .../illumination.cpp | 0 .../instrument.cpp | 0 .../instrumentmodecontrol.cpp | 0 {_temscript => _temscript_module}/module.cpp | 0 .../projection.cpp | 0 {_temscript => _temscript_module}/stage.cpp | 0 .../stemacqparams.cpp | 0 .../stemdetector.cpp | 0 .../stemdetectorinfo.cpp | 0 {_temscript => _temscript_module}/temscript.h | 0 {_temscript => _temscript_module}/types.h | 0 {_temscript => _temscript_module}/vacuum.cpp | 0 doc/conf.py | 6 +- doc/index.rst | 18 +- doc/{module.rst => instrument.rst} | 397 +++++++++--------- doc/microscope.rst | 7 + setup.py | 4 +- temscript/client.py | 18 + temscript/instrument.py | 2 +- temscript/microscope.py | 57 +++ temscript/server.py | 8 + 34 files changed, 315 insertions(+), 214 deletions(-) rename {_temscript => _temscript_module}/acqimage.cpp (100%) rename {_temscript => _temscript_module}/acquisition.cpp (100%) rename {_temscript => _temscript_module}/blankershutter.cpp (100%) rename {_temscript => _temscript_module}/ccdacqparams.cpp (100%) rename {_temscript => _temscript_module}/ccdcamera.cpp (100%) rename {_temscript => _temscript_module}/ccdcamerainfo.cpp (100%) rename {_temscript => _temscript_module}/configuration.cpp (100%) rename {_temscript => _temscript_module}/defines.h (100%) rename {_temscript => _temscript_module}/gauge.cpp (100%) rename {_temscript => _temscript_module}/gun.cpp (100%) rename {_temscript => _temscript_module}/illumination.cpp (100%) rename {_temscript => _temscript_module}/instrument.cpp (100%) rename {_temscript => _temscript_module}/instrumentmodecontrol.cpp (100%) rename {_temscript => _temscript_module}/module.cpp (100%) rename {_temscript => _temscript_module}/projection.cpp (100%) rename {_temscript => _temscript_module}/stage.cpp (100%) rename {_temscript => _temscript_module}/stemacqparams.cpp (100%) rename {_temscript => _temscript_module}/stemdetector.cpp (100%) rename {_temscript => _temscript_module}/stemdetectorinfo.cpp (100%) rename {_temscript => _temscript_module}/temscript.h (100%) rename {_temscript => _temscript_module}/types.h (100%) rename {_temscript => _temscript_module}/vacuum.cpp (100%) rename doc/{module.rst => instrument.rst} (88%) create mode 100644 doc/microscope.rst diff --git a/CHANGELOG.txt b/CHANGELOG.txt index bc6b8b8..7a56bdf 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,7 @@ +-- Version 1.0.7 -------------------------------------------- + +Started new interface (with client/server support). + -- Version 1.0.5 -------------------------------------------- Small fixes diff --git a/LICENSE.txt b/LICENSE.txt index a0b0d96..adc5a16 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2012-2016, Tore Niermann +Copyright (c) 2012-2017, Tore Niermann All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.txt b/README.txt index 22769b9..dcc06fa 100644 --- a/README.txt +++ b/README.txt @@ -21,6 +21,8 @@ Requirements: Numpy (tested with 1.6) Sphinx (only for building documentation, tested with 1.1.3) A compiler (tested with MS Visual Studio 8/10) + FEI Microscope's scripting adapter DLL. On a Titan V1.1 PC typically located in + C:\Titan\Scripting\stdscript.dll Alternatively, use the Anaconda python distribution (you still need the compiler though) @@ -29,7 +31,7 @@ the compiler though) Install your own microscope's scripting adapters type library: 1) Copy your version of the scripting adapter's stdscript.dll into - to the _temscript subdirectory + to the _temscript_module subdirectory Simply execute from the command line (assuming you have your python interpreter in the path): @@ -67,7 +69,7 @@ Relative to Titan V1.1 scripting adapter: -- Copyright & Disclaimer ----------------------------------------- -Copyright (c) 2012-2016 by Tore Niermann +Copyright (c) 2012-2017 by Tore Niermann Contact: niermann (at) physik.tu-berlin.de All product and company names are trademarks or registered trademarks diff --git a/_temscript/acqimage.cpp b/_temscript_module/acqimage.cpp similarity index 100% rename from _temscript/acqimage.cpp rename to _temscript_module/acqimage.cpp diff --git a/_temscript/acquisition.cpp b/_temscript_module/acquisition.cpp similarity index 100% rename from _temscript/acquisition.cpp rename to _temscript_module/acquisition.cpp diff --git a/_temscript/blankershutter.cpp b/_temscript_module/blankershutter.cpp similarity index 100% rename from _temscript/blankershutter.cpp rename to _temscript_module/blankershutter.cpp diff --git a/_temscript/ccdacqparams.cpp b/_temscript_module/ccdacqparams.cpp similarity index 100% rename from _temscript/ccdacqparams.cpp rename to _temscript_module/ccdacqparams.cpp diff --git a/_temscript/ccdcamera.cpp b/_temscript_module/ccdcamera.cpp similarity index 100% rename from _temscript/ccdcamera.cpp rename to _temscript_module/ccdcamera.cpp diff --git a/_temscript/ccdcamerainfo.cpp b/_temscript_module/ccdcamerainfo.cpp similarity index 100% rename from _temscript/ccdcamerainfo.cpp rename to _temscript_module/ccdcamerainfo.cpp diff --git a/_temscript/configuration.cpp b/_temscript_module/configuration.cpp similarity index 100% rename from _temscript/configuration.cpp rename to _temscript_module/configuration.cpp diff --git a/_temscript/defines.h b/_temscript_module/defines.h similarity index 100% rename from _temscript/defines.h rename to _temscript_module/defines.h diff --git a/_temscript/gauge.cpp b/_temscript_module/gauge.cpp similarity index 100% rename from _temscript/gauge.cpp rename to _temscript_module/gauge.cpp diff --git a/_temscript/gun.cpp b/_temscript_module/gun.cpp similarity index 100% rename from _temscript/gun.cpp rename to _temscript_module/gun.cpp diff --git a/_temscript/illumination.cpp b/_temscript_module/illumination.cpp similarity index 100% rename from _temscript/illumination.cpp rename to _temscript_module/illumination.cpp diff --git a/_temscript/instrument.cpp b/_temscript_module/instrument.cpp similarity index 100% rename from _temscript/instrument.cpp rename to _temscript_module/instrument.cpp diff --git a/_temscript/instrumentmodecontrol.cpp b/_temscript_module/instrumentmodecontrol.cpp similarity index 100% rename from _temscript/instrumentmodecontrol.cpp rename to _temscript_module/instrumentmodecontrol.cpp diff --git a/_temscript/module.cpp b/_temscript_module/module.cpp similarity index 100% rename from _temscript/module.cpp rename to _temscript_module/module.cpp diff --git a/_temscript/projection.cpp b/_temscript_module/projection.cpp similarity index 100% rename from _temscript/projection.cpp rename to _temscript_module/projection.cpp diff --git a/_temscript/stage.cpp b/_temscript_module/stage.cpp similarity index 100% rename from _temscript/stage.cpp rename to _temscript_module/stage.cpp diff --git a/_temscript/stemacqparams.cpp b/_temscript_module/stemacqparams.cpp similarity index 100% rename from _temscript/stemacqparams.cpp rename to _temscript_module/stemacqparams.cpp diff --git a/_temscript/stemdetector.cpp b/_temscript_module/stemdetector.cpp similarity index 100% rename from _temscript/stemdetector.cpp rename to _temscript_module/stemdetector.cpp diff --git a/_temscript/stemdetectorinfo.cpp b/_temscript_module/stemdetectorinfo.cpp similarity index 100% rename from _temscript/stemdetectorinfo.cpp rename to _temscript_module/stemdetectorinfo.cpp diff --git a/_temscript/temscript.h b/_temscript_module/temscript.h similarity index 100% rename from _temscript/temscript.h rename to _temscript_module/temscript.h diff --git a/_temscript/types.h b/_temscript_module/types.h similarity index 100% rename from _temscript/types.h rename to _temscript_module/types.h diff --git a/_temscript/vacuum.cpp b/_temscript_module/vacuum.cpp similarity index 100% rename from _temscript/vacuum.cpp rename to _temscript_module/vacuum.cpp diff --git a/doc/conf.py b/doc/conf.py index 4fa1110..f5323dd 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -25,7 +25,7 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [] +extensions = ['sphinx.ext.autodoc'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -41,7 +41,7 @@ # General information about the project. project = u'temscript' -copyright = u'2012-2016, Tore Niermann' +copyright = u'2012-2017, Tore Niermann' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -50,7 +50,7 @@ # The short X.Y version. version = '1.0' # The full version, including alpha/beta/rc tags. -release = '1.0.6' +release = '1.0.7' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/index.rst b/doc/index.rst index 82b7903..3eb08f3 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -4,9 +4,10 @@ Welcome to temscript's documentation! Contents: .. toctree:: - :maxdepth: 2 + :maxdepth: 2 - module + microscope + instrument Introduction: ============= @@ -25,7 +26,9 @@ Enumerations Many of the object's attributes actually return values from enumeration. The Python wrappers of these attributes will return an integer value. There are constants in the :mod:`temscript` module representing the enumeration values (e.g. ``pmImaging`` and ``pmDiffraction`` -for the ``Mode`` attribute of the :class:`Projection` object) +for the ``Mode`` attribute of the :class:`Projection` object). Since version 1.0.5 there are also +python enums for these, which can be found in the :mod:`temscript.enums` module and are imported +into the :mod:`temscript` namespace. Vectors ^^^^^^^ @@ -40,6 +43,15 @@ Collections Collections will be returned as list or tuple of objects. In future versions this might change, and dictionaries will be returned. +Globals +^^^^^^^ + +.. data:: version + + A string describing the version of temscript in the format 'X.Y.Z'. + Current value is '|release|'. This is not the version of the TEMScripting interface + (which can't be queried such easily). + Indices and tables ================== diff --git a/doc/module.rst b/doc/instrument.rst similarity index 88% rename from doc/module.rst rename to doc/instrument.rst index e73840c..df98959 100644 --- a/doc/module.rst +++ b/doc/instrument.rst @@ -1,51 +1,44 @@ -The :mod:`temscript` module -====================================================================== +The classical interface +======================= .. module:: temscript - :synopsis: Contains the classes that wrap various functions of your microscope - -.. data:: version - - A string describing the version of temscript in the format 'X.Y.Z'. - Current value is '|release|'. This is not the version of the TEMScripting interface - (which can't be queried such easily). - + .. function:: GetInstrument() - + Creates a new instance of the :class:`Instrument` class. If your computer is not the microscope's PC or you don't have the *Scripting* option installed on your microscope, this method will raise an exception (most likely of the :exc:`COMError` type). - + .. exception:: COMError - + Exceptions of this type are raised, when something with COM libary or the communication - with the microscope server failed. The value of the exception consists of a + with the microscope server failed. The value of the exception consists of a tuple containing the error code and a textual representation of the error (most likely just something like "HRESULT=0xXXXXXXXX"). -:class:`Instrument` - Your entry point to the microscope --------------------------------------------------------- +:class:`Instrument` - The entry point... +---------------------------------------- .. class:: Instrument Top level object representing the microscope. Use the :func:`GetInstrument` function to create an instance of this class. - + .. attribute:: Gun (read) Instance of :class:`Gun` for access to gun related functionalities .. attribute:: Illumination - (read) Instance of :class:`Illumination` for access to illumination + (read) Instance of :class:`Illumination` for access to illumination system and condenser related functionalities .. attribute:: Projection - (read) Instance of :class:`Projection` for access to projection + (read) Instance of :class:`Projection` for access to projection system related functionalities - + .. attribute:: Stage (read) Instance of :class:`Stage` for stage control @@ -53,7 +46,7 @@ The :mod:`temscript` module .. attribute:: Acquisition (read) Instance of :class:`Acquisition` for image acquisition - + .. attribute:: Vacuum (read) Instance of :class:`Vacuum` for access to vacuum system related @@ -62,7 +55,7 @@ The :mod:`temscript` module .. attribute:: InstrumentModeControl (read) Instance of :class:`InstrumentModeControl` for TEM/STEM switching. - + .. attribute:: BlankerShutter (read) Instance of :class:`BlankerShutter` for blanker control. @@ -70,7 +63,7 @@ The :mod:`temscript` module .. attribute:: Configuration (read) Instance of :class:`Configuration` for microscope identification. - + .. attribute:: AutoNormalizeEnabled (read/write) *bool* Enable/Disable autonormalization procedures @@ -83,30 +76,30 @@ The :mod:`temscript` module .. attribute:: Tilt (read/write) (X,Y) tuple in the range of -1.0 to +1.0 (logical units). - This attribute is inaccessable when the beamblanker (see + This attribute is inaccessable when the beamblanker (see :class:`Illumination`) is active. .. attribute:: Shift - + (read/write) (X,Y) tuple in the range of -1.0 to +1.0 (logical units). .. attribute:: HTState - + (read/write) One of these * ``htDisabled`` * ``htOff`` - * ``htOn`` - + * ``htOn`` + .. attribute:: HTValue - + (read/write) *float* Current acceleration voltage (Volts) - - .. warning:: - + + .. warning:: + Be careful when writing this attribute, it allows you to change the high tension. .. attribute:: HTMaxValue - + (read) *float* Max. HT Value of the microscope (Volts) :class:`Illumination` - Condenser sytem @@ -114,110 +107,110 @@ The :mod:`temscript` module .. class:: Illumination - The functionality of some methods/attributes depend on the + The functionality of some methods/attributes depend on the mode the illumination is in (see the manual for details). .. attribute:: Mode - + (read/write) Setting of minicondensor lens * ``imNanoProbe`` * ``imMicroProbe`` .. attribute:: DFMode - + (read/write) Dark field mode: * ``dfOff`` * ``dfCartesian`` * ``dfConical`` .. attribute:: DarkFieldMode - + (read/write) Alias of :attr:``DFMode`` - + .. attribute:: BeamBlanked - - (read/write) *bool* Setting of beam blanker. The beam blanker puts a large current to + + (read/write) *bool* Setting of beam blanker. The beam blanker puts a large current to the gun tilt coils to blank the beam before it is entering the condenser system. - .. attribute:: CondenserStigmator - + .. attribute:: CondenserStigmator + (read/write) (X,Y) tuple in the range of -1.0 to +1.0 (logical units). - .. attribute: SpotsizeIndex - - (read/write) *long* The spot size (1-11). - - .. attribute: Intensity - + .. attribute: SpotsizeIndex + + (read/write) *long* The spot size (1-11). + + .. attribute: Intensity + (read/write) *float* Value corresponding to the C2-Knob setting, range between 0.0 to 1.0 (logical units) - .. attribute: IntensityZoomEnabled - + .. attribute: IntensityZoomEnabled + (read/write) *bool* Enable intensity zoom - .. attribute: - + .. attribute: + (read/write) *bool* Enable Intensity limit - .. attribute:: Shift - + .. attribute:: Shift + (read/write) (X,Y) tuple of shift value (Meters). This corresponds to the *User (Beam) Shift* setting (which is displayed in logical units) in the *System Status* page. The scaling between the *Meters* and *logical units* depend on the calibration value stored in the aligment. - + .. attribute:: Tilt - + (read/write) - * in ``dfCartesian`` mode: (X,Y) tuple of shift value (Radians). - * in ``dfConical`` mode: (theta,phi) tuple of angles (Radians). - + * in ``dfCartesian`` mode: (X,Y) tuple of shift value (Radians). + * in ``dfConical`` mode: (theta,phi) tuple of angles (Radians). + This corresponds to the *DF Tilt* setting (which is displayed in logical units) in the *System Status* page. The scaling between the *Radians* and the *logical units* depend on the calibration value stored in the aligment. .. attribute:: RotationCenter - (read/write) (X,Y) tuple of tilt value (Radians). This corresponds to the + (read/write) (X,Y) tuple of tilt value (Radians). This corresponds to the *Rot. Center* setting (which is displayed in logical units) in the *System Status* page. The scaling between the *Radians* and the *logical units* depend on the calibration value stored in the aligment. .. attribute:: StemMagnification - + (read/write) *float* Magnification in STEM. As the magnification must be one of the discret values (as displayed on the micrsocope), the value is rounded to the next available value on write. - + .. attribute:: StemRotation - + (read/write) *float* Rotation in STEM (radians). .. attribute:: CondenserMode - + (read/write) One of * ``cmParallelIllumination`` * ``cmProbeIllumination`` - + (Available only on Titan). .. attribute:: IlluminatedArea - + (read/write) *float* Illuminated area (meters? Is diameter meant? still to check). Requires parallel condensor mode. (Available only on Titan). .. attribute:: ProbeDefocus - + (read/write) *float* Probe defocus (meters) Requires probe condensor mode. (Available only on Titan). .. attribute:: ConvergenceAngle - + (read/write) *float* Convergence angle (radians) Requires probe condensor mode. (Available only on Titan). .. method:: Normalize(mode) - + Normalizes condenser lenses. *mode* is one of * ``nmSpotsize`` * ``nmIntensity`` @@ -231,17 +224,17 @@ The :mod:`temscript` module .. class:: Projection - Depending on the mode the microscope is in not all properties are + Depending on the mode the microscope is in not all properties are accessable at all times (see manual for details). - + .. attribute:: Mode - - (read/write) One of + + (read/write) One of * ``pmImaging`` * ``pmDiffraction`` .. attribute:: SubMode - + (read) One of * ``psmLM`` * ``psmMi`` @@ -251,80 +244,80 @@ The :mod:`temscript` module * ``psmD`` .. attribute:: SubModeString - + (read) *unicode* Textual description of :attr:`Submode`. .. attribute:: LensProgram - + (read/write) One of * ``lpRegular`` * ``lpEFTEM`` .. attribute:: Magnification - - (read) *float* Magnification as seen be plate camera. + + (read) *float* Magnification as seen be plate camera. Use :attr:`MagnificationIndex` to change. .. attribute:: MagnificationIndex - + (read/write) *long* Magnification setting - .. attribute:: ImageRotation - + .. attribute:: ImageRotation + (read) *float* Rotation of image/diffraction pattern with respect to specimen (radians) .. attribute:: DetectorShift - + (read/write) Move image/diffraction pattern to detector. One of * ``pdsOnAxis`` * ``pdsNearAxis`` * ``pdsOffAxis`` .. attribute:: DetectorShiftMode - + (read/write) One of * ``pdsmAutoIgnore`` * ``pdsmManual`` * ``pdsmAlignment`` .. attribute:: Focus - - (read/write) *float* Focus setting relative to focus preset (logical units). - Range -1.0 (underfocus) to +1.0 (overfocus). - + + (read/write) *float* Focus setting relative to focus preset (logical units). + Range -1.0 (underfocus) to +1.0 (overfocus). + .. attribute:: Defocus - + (read/write) *float* Defocus (meters), relative to defocus set with :func:`ResetDefocus`. .. attribute:: ObjectiveExcitation - + (read) *float* Objective lens excitation in percent. .. attribute:: CameraLength - - (read) *float* Camera length as seen by plate camera (meters). Use + + (read) *float* Camera length as seen by plate camera (meters). Use :attr:`CameraLengthIndex` to change. - + .. attribute:: CameraLengthIndex - + (read/write) *long* Camera length setting - .. attribute:: ObjectiveStigmator - + .. attribute:: ObjectiveStigmator + (read/write) (X,Y) tuple in the range of -1.0 to +1.0 (logical units). - .. attribute:: DiffractionStigmator - + .. attribute:: DiffractionStigmator + (read/write) (X,Y) tuple in the range of -1.0 to +1.0 (logical units). - .. attribute:: DiffractionShift - + .. attribute:: DiffractionShift + (read/write) (X,Y) tuple of shift value (radians). This corresponds to the *User Diffraction Shift* setting (which is displayed in logical units) in the *System Status* page. The scaling between the *radians* and *logical units* depend on the calibration value stored in the aligment. - + .. attribute:: ImageShift (read/write) (X,Y) tuple of shift value (meters). This corresponds to @@ -340,21 +333,21 @@ The :mod:`temscript` module one of them ot zero before using the other. .. attribute:: ImageBeamTilt - + (read/write) (X,Y) tuple of tilt value. Tilts beam and compensates tilt by diffraction shift. .. attribute:: ProjectionIndex - - (read/write) *long* Corresponts to :attr:`MagnificationIndex` or + + (read/write) *long* Corresponts to :attr:`MagnificationIndex` or :attr:`CameraLengthIndex` depending on mode. .. attribute:: SubModeMinIndex - + (read) *long* Smallest projection index of current submode. .. attribute:: SubModeMaxIndex - + (read) *long* Largest projection index of current submode. .. method:: ResetDefocus() @@ -363,7 +356,7 @@ The :mod:`temscript` module actually change the focus). .. method:: ChangeProjectionIndex(steps) - + Changes the current :attr:`ProjectionIndex` by *steps*. .. method:: Normalize(norm) @@ -379,7 +372,7 @@ The :mod:`temscript` module .. class:: Stage .. attribute:: Status - + (read) One of * ``stReady`` * ``stDisabled`` @@ -389,12 +382,12 @@ The :mod:`temscript` module * ``stWobbling`` .. attribute:: Position - - (read) Current position of stage. The function returns a ``dict`` - object with the values of the indiviual axes. + + (read) Current position of stage. The function returns a ``dict`` + object with the values of the indiviual axes. .. attribute:: Holder - + (read) Type of holder. One of * ``hoNone`` * ``hoSingleTilt`` @@ -403,35 +396,35 @@ The :mod:`temscript` module * ``hoPolara`` * ``hoDualAxis`` - .. method:: AxisData(axis) - + .. method:: AxisData(axis) + Returns tuple with information about that axis. Returned tuple is of the form (*min*, *max*, *unit*), where *min* is the minimum value, *max* the maximim value of the particular axis, and *unit* is a string containing the unit the axis is measured in (either 'meters' or - 'radians'). The *axis* must be of string type and contain + 'radians'). The *axis* must be of string type and contain either 'x', 'y', 'z', 'a', or 'b'. .. method:: GoTo(x=None, y=None, z=None, a=None, b=None) - + Moves stage to indicated position. Stage is only moved along the axes that are not ``None``. - + .. method:: MoveTo(x=None, y=None, z=None, a=None, b=None) - + Moves stage to indicated position. Stage is only moved along the axes that are not ``None``. In order to avoid pole-piece touch, the movement is carried out in the following order: - + b->0; a->0; z->Z; (x,y)->(X,Y); a->A; b->B Vacuum related classes ---------------------- -.. class:: Vacuum +.. class:: Vacuum .. attribute:: Status - + (read) One of: * ``vsUnknown`` * ``vsOff`` @@ -441,51 +434,51 @@ Vacuum related classes * ``vsElse`` .. attribute:: ColumnValvesOpen - + (read/write) *bool* Status of column valves .. attribute:: PVPRunning - + (read) *bool* Whether the prevacuum pump is running .. attribute:: Gauges - + (read) List of :class:`Gauge` objects .. method:: RunBufferCycle() - + Runs a buffer cycle. - + .. class:: Gauge .. attribute:: Name - + (read) *unicode* Name of the gauge - + .. attribute:: Status - + (read) One of * ``gsUndefined`` * ``gsUnderflow`` * ``gsOverflow`` * ``gsInvalid`` * ``gsValid`` - + .. attribute:: Pressure - + (read) *float* Last measured pressure (Pascal) - + .. attribute:: PressureLevel - + (read) One of * ``plGaugePressurelevelUndefined`` * ``plGaugePressurelevelLow`` * ``plGaugePressurelevelLowMedium`` * ``plGaugePressurelevelMediumHigh`` * ``plGaugePressurelevelHigh`` - + .. method:: Read() - + Read the pressure level. Call this before reading the value from :attr:`Pressure`. @@ -494,55 +487,55 @@ Acquisition related classes .. class:: Acquisition - .. note:: - + .. note:: + From the manual: * TIA must be running - * After changing the detector selection in the UI you must + * After changing the detector selection in the UI you must reacquire a new :class:`Instrument` using the :func:`GetInstrument` function. * In order for detectors/cameras to be available, they must be selected in the UI. - + .. attribute:: Cameras - + (read) List of :class:`CCDCamera` objects. - + .. attribute:: Detectors - + (read) List of :class:`STEMDetector` objects. - + .. method:: AddAcqDevice(device) - + Adds *device* to the list active devices. *device* must be of type :class:`CCDCamera` or :class:`STEMDetector`. - + .. method:: AddAcqDeviceByName(deviceName) - + Adds device with name *deviceName* to the list active devices. .. method:: RemoveAcqDevice(device) - + Removes *device* to the list active devices. *device* must be of type :class:`CCDCamera` or :class:`STEMDetector`. - + .. method:: RemoveAcqDeviceByName(deviceName) - + Removes device with name *deviceName* to the list active devices. .. method:: RemoveAllAcqDevices() - + Clears the list of active devices. - + .. method:: AcquireImages() - + Acquires image from each active device, and returns them as list of :class:`AcqImage`. .. class:: CCDCamera .. attribute:: Info - + Information about the camera as instance of :class:`CCDCameraInfo` .. attribute:: AcqParams @@ -552,32 +545,32 @@ Acquisition related classes .. class:: CCDCameraInfo .. attribute:: Name - + (read) *unicode* Name of CCD camera .. attribute:: Height - + (read) *long* Height of camera (pixels) .. attribute:: Width - + (read) *long* Width of camera (pixels) .. attribute:: PixelSize - + (read) (X, Y)-Tuple with physical pixel size (Manual says nothing about units, seems to be meters) .. attribute:: Binnings - + (read) *numpy.ndarray* with supported binning values. .. attribute:: ShutterModes - + (read) *numpy.ndarray* with supported shutter modes. See :attr:`ShutterMode` for possible values. - + .. attribute:: ShutterMode - + (read/write) One of * ``AcqShutterMode_PreSpecimen`` * ``AcqShutterMode_PostSpecimen`` @@ -586,28 +579,28 @@ Acquisition related classes .. class:: CCDAcqParams .. attribute:: ImageSize - + (read/write) One of * ``AcqImageSize_Full`` * ``AcqImageSize_Half`` * ``AcqImageSize_Quarter`` - + .. attribute:: ExposureTime - + (read/write) *float* Exposure time (seconds) .. attribute:: Binning - + (read/write) *long* Binning value .. attribute:: ImageCorrection - + (read/write) One of * ``AcqImageCorrection_Unprocessed`` * ``AcqImageCorrection_Default`` .. attribute:: ExposureMode - + (read/write) One of * ``AcqExposureMode_None`` * ``AcqExposureMode_Simultaneous`` @@ -615,33 +608,33 @@ Acquisition related classes * ``AcqExposureMode_PreExposurePause`` .. attribute:: MinPreExposureTime - + (read) *float* Smallest pre exposure time (seconds) .. attribute:: MaxPreExposureTime - + (read) *float* Largest pre exposure time (seconds) .. attribute:: MinPreExposurePauseTime - + (read) *float* Smallest pre exposure pause time (seconds) .. attribute:: MaxPreExposurePauseTime - + (read) *float* Largest pre exposure pause time (seconds) - + .. attribute:: PreExposureTime - + (read/write) *float* pre exposure time (seconds) .. attribute:: PreExposurePauseTime - + (read/write) *float* pre exposure pause time (seconds) .. class:: STEMDetector .. attribute:: Info - + Information about the detector as instance of :class:`STEMDetectorInfo` .. attribute:: AcqParams @@ -649,7 +642,7 @@ Acquisition related classes Acquisition parameters of the detector as instance of :class:`STEMAcqParams`. The acquisition parameters of all STEM detectors are identical, so this attribute will return the same instance for all detectors. - + In the original Scripting interface the instance of the STEM acquisition parameters is obtained via the list of detectors returned by the Acquisition instance. In the temscript python interface, the parameter instance is obtained via the STEMDetector instances. @@ -658,59 +651,59 @@ Acquisition related classes .. class:: STEMDetectorInfo .. attribute:: Name - + (read) *unicode* Name of detector camera .. attribute:: Brightness - + (read/write) *float* Brightness setting of the detector. .. attribute:: Contrast - + (read/write) *float* Contrast setting of the detector. .. attribute:: Binnings - + (read) *numpy.ndarray* with supported binning values. .. class:: STEMAcqParams .. attribute:: ImageSize - + (read/write) One of * ``AcqImageSize_Full`` * ``AcqImageSize_Half`` * ``AcqImageSize_Quarter`` - + .. attribute:: DwellTime - + (read/write) *float* Dwell time (seconds) .. attribute:: Binning - + (read/write) *long* Binning value .. class:: AcqImage .. attribute:: Name - + (read) *unicode* Name of camera/detector - + .. attribute:: Height - + (read) *long* Height of acquired data array (pixels) .. attribute:: Width - + (read) *long* Width of acquired data array (pixels) .. attribute:: Depth - + (read) *long* Unsure: something like dynamic in bits, but not correct on our microscope. - + .. attribute:: Array - + (read) *numpy.ndarray* Acquired data as array object. Miscellaneous classes @@ -719,32 +712,32 @@ Miscellaneous classes .. class:: InstrumentModeControl .. attribute:: StemAvailabe - + (read) *bool* Quite self decribing attribute - + .. attribute:: InstrumentMode (read/write) Possible values * ``InstrumentMode_TEM`` * ``InstrumentMode_STEM`` - + .. class:: BlankerShutter .. attribute:: ShutterOverrideOn - - (read/write) *bool* Overrides shutter control. - - .. warning:: - + + (read/write) *bool* Overrides shutter control. + + .. warning:: + From the manual: If this override is on, there is no way to - determine externally, that the override shutter is the active. + determine externally, that the override shutter is the active. So **always** reset this value from script, when finished. .. class:: Configuration .. attribute:: ProductFamily - - (read) Possible values + + (read) Possible values * ``ProductFamily_Tecnai`` * ``ProductFamily_Titan`` - + diff --git a/doc/microscope.rst b/doc/microscope.rst new file mode 100644 index 0000000..deff287 --- /dev/null +++ b/doc/microscope.rst @@ -0,0 +1,7 @@ +A more python-like interface +============================ + +.. module:: temscript + +.. autoclass:: Microscope + :members: diff --git a/setup.py b/setup.py index c49901e..58e6a65 100644 --- a/setup.py +++ b/setup.py @@ -12,11 +12,11 @@ py_includes = [] _temscript_module = Extension('_temscript', - glob.glob(os.path.join('_temscript', '*.cpp')), + glob.glob(os.path.join('_temscript_module', '*.cpp')), include_dirs=py_includes) setup(name = 'temscript', - version = '1.0.6', + version = '1.0.7', description = 'TEM Scripting adapter for FEI microscopes', author = 'Tore Niermann', author_email = 'niermann (at) physik.tu-berlin.de', diff --git a/temscript/client.py b/temscript/client.py index 280ed04..cec9e74 100644 --- a/temscript/client.py +++ b/temscript/client.py @@ -132,6 +132,24 @@ def set_image_shift(self, pos): self._request("PUT", "/v1/image_shift", body=content, accepted_response=[200, 204], headers={"Content-Type": "application/json"}) + def get_beam_shift(self): + response, body = self._request("GET", "/v1/beam_shift") + return body + + def set_beam_shift(self, pos): + content = json.dumps(tuple(pos)).encode("utf-8") + self._request("PUT", "/v1/beam_shift", body=content, accepted_response=[200, 204], + headers={"Content-Type": "application/json"}) + + def get_beam_tilt(self): + response, body = self._request("GET", "/v1/beam_tilt") + return body + + def set_beam_tilt(self, pos): + content = json.dumps(tuple(pos)).encode("utf-8") + self._request("PUT", "/v1/beam_tilt", body=content, accepted_response=[200, 204], + headers={"Content-Type": "application/json"}) + allowed_types = {"INT8", "INT16", "INT32", "INT64", "UINT8", "UINT16", "UINT32", "UINT64", "FLOAT32", "FLOAT64"} allowed_endianness = {"LITTLE", "BIG"} diff --git a/temscript/instrument.py b/temscript/instrument.py index 1820ec2..6f66bd2 100644 --- a/temscript/instrument.py +++ b/temscript/instrument.py @@ -1,7 +1,7 @@ __all__ = ("version", "GetInstrument") # Set temscript version string -version = "1.0.5" +version = "1.0.7" try: # Where the _temscript module is available and the COM interface works (i.e. the microscope's computer) diff --git a/temscript/microscope.py b/temscript/microscope.py index c56159a..c0b9fe5 100644 --- a/temscript/microscope.py +++ b/temscript/microscope.py @@ -1,5 +1,6 @@ from __future__ import division, print_function from temscript.enums import * +import math # Get imports from library try: @@ -335,6 +336,8 @@ def get_image_shift(self): The units this is returned in are meters. The accuracy of ths value depends on the accuracy of the calibration within the microscope and thus is better not to be trusted blindly. + + On FEI microscopes this corresponds to the state of "User Image Shift" (in different units though). """ return self._tem_projection.ImageShift @@ -343,3 +346,57 @@ def set_image_shift(self, pos): Set image shift to position `pos`, which should be an (x, y) tuple, as returned for instance by :meth:`get_image_shift`. """ self._tem_projection.ImageShift = pos + + def get_beam_shift(self): + """ + Return beam shift as (x,y) tuple. + + The units this is returned in are meters. The accuracy of ths value depends on the accuracy of the + calibration within the microscope and thus is better not to be trusted blindly. + + On FEI microscopes this corresponds to the state of "User Beam Shift" (in different units though). + """ + return self._tem_illumination.Shift + + def set_beam_shift(self, pos): + """ + Set beam shift to position `pos`, which should be an (x, y) tuple, as returned for instance by :meth:`get_image_shift`. + """ + self._tem_illumination.Shift = pos + + def get_beam_tilt(self): + """ + Return beam tilt as (x,y) tuple. + + The units this is returned in are radians. The accuracy of ths value depends on the accuracy of the + calibration within the microscope and thus is better not to be trusted blindly. + + On FEI microscopes this corresponds to the state of "DF Tilt" (in different units though). + """ + tilt = self._tem_illumination.Tilt + mode = self._tem_illumination.DFMode + if mode == DarkFieldMode.CONICAL: + return tilt[0] * math.cos(tilt[1]), tilt[0] * math.sin(tilt[1]) + elif mode == DarkFieldMode.CARTESIAN: + return tilt + else: + return 0.0, 0.0 # Microscope might return nonsense if DFMode is OFF + + def set_beam_tilt(self, tilt): + """ + Set beam tilt to position `tilt`, which should be an (x, y) tuple, as returned for instance by :meth:`get_image_shift`. + + On FEI microscopes: + * this will turn on dark field mode, unless (0, 0) is set, which will also turn off the dark field mode. + """ + mode = self._tem_illumination.DFMode + if tilt[0] == 0.0 and tilt[1] == 0.0: + self._tem_illumination.Tilt = 0.0, 0.0 + self._tem_illumination.DFMode = DarkFieldMode.OFF + elif mode == DarkFieldMode.CONICAL: + self._tem_illumination.Tilt = math.sqrt(tilt[0]**2 + tilt[1]**2), math.atan2(tilt[1], tilt[0]) + elif mode == DarkFieldMode.OFF: + self._tem_illumination.DFMode = DarkFieldMode.CARTESIAN + self._tem_illumination.Tilt = tilt + else: + self._tem_illumination.Tilt = tilt diff --git a/temscript/server.py b/temscript/server.py index dfc10da..72bf142 100644 --- a/temscript/server.py +++ b/temscript/server.py @@ -117,6 +117,10 @@ def do_GET_V1(self, endpoint, query): response = self.server.microscope.get_detectors() elif endpoint == "image_shift": response = self.server.microscope.get_image_shift() + elif endpoint == "beam_shift": + response = self.server.microscope.get_beam_shift() + elif endpoint == "beam_tilt": + response = self.server.microscope.get_beam_tilt() elif endpoint.startswith("detector_param/"): try: name = endpoint[15:] @@ -155,6 +159,10 @@ def do_PUT_V1(self, endpoint, query): self.server.microscope.set_stage_position(pos, method=method) elif endpoint == "image_shift": self.server.microscope.set_image_shift(decoded_content) + elif endpoint == "beam_shift": + self.server.microscope.set_beam_shift(decoded_content) + elif endpoint == "beam_tilt": + self.server.microscope.set_beam_tilt(decoded_content) elif endpoint.startswith("detector_param/"): try: name = endpoint[15:]