Files
AFM_thumbs/AFM_thumbs/Variables.py

649 lines
24 KiB
Python
Executable File

# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
#
# This is part of the python program 'AFM_thumbs'. Please, read the
# full licence text and other comments in the file 'AFM_thumbs.py'
#
# Dr. Clemens Barth (barth@root-1.de), project manager.
#
# DO NOT REMOVE THIS PREAMBLE !!!
#
#
#
# __________ Change the name and path of the config file ___________ from here
#
#
#
globvar_configfile = "Config_AFM_thumbs.conf"
globvar_configfile_path = "./AFM_thumbs/"
# Example for Linux
# globvar_configfile_path = "/home/user/bin/AFM_thumbs/"
# globvar_configfile = "Config_AFM_thumbs.conf"
#
# Example for Windows
# globvar_configfile_path = "C:\Users\Username\Desktop\AFmThumbnails\" \
# "AFM_thumbs"
# globvar_configfile = "Config_AFM_thumbs.conf"
#
#
#
# _____________________________________________________________________ to here
#
#
#
# ____________________________________________________________ Global variables
# DO NOT CHANGE ANYTHING BELOW, OTHERWISE YOU KNOW WHAT TO DO !
import time
globvar_contributions = "Reinhard Olbrich (testing)\n" \
"Matthias Temmen (testing)\n" \
"Alexander v Schmidtsfeld (testing)\n" \
"..."
globvar_year = "2022-04-08"
globvar_version = "3.0011"
globvar_spaces = " "
globvar_name = "AFM thumbs v" + globvar_version
globvar_bar_title = (globvar_name + " - " +
globvar_year)
globvar_note = ("Version " + globvar_version + " (" +
globvar_year + ")\n"
"www.development.root-1.de\n\n" +
"Coordinated by:\n\n" +
"Clemens Barth\n" +
"(barth@root-1.de)\n\n" +
" and\n\n" +
"Niklas Rethmann " +
"(nrethmann@uni-osnabrueck.de)\n\n"+
"Contributions from:\n" +
globvar_contributions)
globvar_console = ("\n\n"+
globvar_spaces +
globvar_name + " - " +
globvar_year + "\n" +
globvar_spaces + "www.root-1.de\n\n" +
globvar_spaces + "Today: " +
time.strftime("%d-%m-%Y") +
", Time: " +
time.strftime("%H:%M:%S"))
globvar_python_directory = "AFM_thumbs"
globvar_default_config = "Config_default.conf"
globvar_thumb_size_x = 5.0
globvar_thumb_size_y = 6.0
globvar_thumb_text_width = 40
globvar_timepassed_1 = ("\n" +
globvar_spaces +
"Overall passed time: ")
globvar_timepassed_2 = "--- %d days --- %d hours --- %d minutes " + \
"--- %0.3f seconds ---\n\n"
# _______________________________________________________________ SPECS Nanonis
SPECS_Nanonis_images_must_exist = ".sxm"
SPECS_Nanonis_spectroscopy_must_exist = ".dat"
# _______________________________________________________________ Omicron SCALA
Omicron_SCALA_must_exist = ".par"
Omicron_SCALA_forward = ".tf"
Omicron_SCALA_backward = ".tb"
# ____________________________________________________________ Nanotec DULCINEA
Nanotec_DULCINEA_must_exist = ".f.top"
Nanotec_DULCINEA_forward = ".f."
Nanotec_DULCINEA_backward = ".b."
Nanotec_DULCINEA_suffix = ["f.top","f.ch4","f.ch5","f.ch6","f.ch7","f.ch8",
"b.top","b.ch4","b.ch5","b.ch6","b.ch7","b.ch8",
".f.1st.Auxfeed", ".f.2nd.Auxfeed",
".b.1st.Auxfeed", ".b.2nd.Auxfeed"]
# _________________________________________________________________________ RHK
RHK_must_exist = [".SM4", ".sm4"]
RHK_all_directions = ["all", "All", "ALL", "A", "a"]
RHK_forward_direction = ["forward", "Forward", "FORWARD", "for",
"For", "FOR", "f", "F"]
RHK_backward_direction = ["backward", "Backward", "BACKWARD",
"back", "Back", "BACK", "b", "B"]
RHK_message_direction = " --- Some RHK files could be detected! ---\n\n" \
"Choose scan direction: (f)orward" \
", (b)ackward, (a)ll: "
# ____________________________________________________________________ Tooltips
# Arrangement
TT_n_col = "Number of images in a column \n\n\
This option lets you specific how \n\
many images have to be in a column \n\n"
TT_n_row = "Number of images in arow \n\n\
This option lets you specific how \n\
many images have to be in a row \n\n"
TT_rms = "Contrast (times rms value) \n\n\
This option lets you specific the \n\
contrast of the images"
TT_res = "Image resolution factor (in percent) \n\n\
This option lets you specific the \n\
resolution of the images"
TT_qual = "Image quality \n\n\
This option lets you specific the \n\
quality of the images"
# Position
TT_size = "Font size \n\n\
This option lets you specific the \n\
font size of the image text"
TT_dx_pos = "dX position (in percent) \n\n\
This option lets you shift the \n\
image text left or right"
TT_dy_pos = "dY position (in percent) \n\n\
This option lets you shift the \n\
image text up or down"
TT_dw = "dWidth of text (in characters) \n\n\
This option lets you specific the \n\
width of the image text."
# Specification
TT_file_ex = "This option lets you specific which \n\
format should be considered"
TT_master_dir = "This option lets you specific which \n\
folders should be considered. \n\
Should only be used together with the \"All sub-directories\" option"
TT_filename = "This option lets you specific which \n\
files should be considered."
# Param
TT_date = "Include date and time \n\
in the image text"
TT_size_nm = "Include size in nanometer \n\
in the image text"
TT_size_px = "Include size in pixel \n\
in the image text"
TT_off = "Include offset in nanometer \n\
in the image text"
TT_vol = "Includes voltage (Volt) \n\
in the image text"
TT_feed = "Includes feedback\n\
in the image text"
TT_loop = "Includes loop gain\n\
in the image text"
TT_speed = "Include acquisition speed in s/line \n\
in the image text"
TT_amp = "Include amplitude\n\
in the image text"
TT_angle = "Include angle in degree \n\
in the image text"
# Other
TT_thumb_before = "Delete thumbs before all \n\n\
With this option enabled, the thumbnail directory \n\
will be deleted before a pdf thumbnail is created."
TT_thumb_after = "Delete thumbs after all \n\n\
With this option enabled, the thumbnail directory \n\
will be deleted after a pdf thumbnail has been created."
TT_extra_dir = "Extra directory \n\n\
Creates extra WSxM and Gwyddion directories. \n\
Two new directories are created in the directory one level above.\n\
The directory structure(s) of the AFM data is(are) conserved."
TT_pdfs = "Replace existing pdfs \n\n\
Existing pdf files are replaced by new ones."
TT_subdirs = "All sub-directories \n\n\
All subdirectories of the selected directory (Button 'Choose directory')\n\
are also considered. The respective pdf files are placed into the\n\
directory one level above."
TT_png = "Create images in png format \n\n\
Change the image format of the thumbnails from jpeg to png."
TT_spektral = " Include spectras \n\n\
With this option images of spectra are included\n\
into the pdf file."
TT_peek = " Set color scale to peek-peek \n\n\
This option permits setting the color scale of the \n\
images to peek-to-peek values."
TT_minimum_on_zero = " Set minimum value on zero \n\n\
This option permits setting the minimum value of \n\
the images onto zero."
TT_Reich = "Reichling Special Options \n\n\
This option triggers the following features: \n\
- Colour for Kelvin images is set to gray \n\
- One df image is inverted"
# _____________________________________________________________________ For all
ID_topography = r"[Tt]op(ograph(y|ie))?|TOP(OGRAPH(Y|IE))?|[Zz]"
ID_amplitude = r"[Aa]mplitude|AMPLITUDE|[Aa]mpl?\.?|AMPL?\.?"
ID_kelvin = r"[Kk]el(vin)?|KEL(VIN)?"
ID_kelvin_err = r"[Ee]rr(or)?|ERR(OR)?|[Ll]1[Xx]|KELVIN_ERR"
ID_df = r"[Dd][Ff]"
ID_df_fil = r"[Ff]iltered|FILTERED"
ID_dissipation = r"[Dd](issipation)?|DISSIPATION|[Dd]amp|DAMP|[Pp][Ll][Ll]"
ID_excitation = r"[Ee]xcitation|EXCITATION"
ID_ext1 = r"[Ee]xt(ernal)?( )?1|[Ee]XT(ERNALl)?( )?1"
ID_ext2 = r"[Ee]xt(ernal)?( )?2|[Ee]XT(ERNALl)?( )?2"
ID_phase = r"[Pp]ha(se)?|PHA(SE)?"
ID_list = [ID_topography, ID_amplitude, ID_kelvin, ID_kelvin_err, ID_df,
ID_df_fil, ID_dissipation, ID_excitation, ID_ext1, ID_ext2,
ID_phase]
ID_abbreviations = {"Topography" : "Z", "filtered df":"df_fil", "Amplitude":"A",
"Dissipation": "D", "Kelvin Error": "KPFM_err",
"Ext 1": "Ext1", "Ext 2": "Ext2", "Excitation": "A_ext",
"Phase": "Phase", "Kelvin": "KPFM", "DF_DIG": "df",
"EXT": "Ext", "EXT1": "Ext1", "EXT2": "Ext2"}
# ______________________________________________________________________ Colors
# Colors: see http://matplotlib.org/examples/color/colormaps_reference.html
# Note that many other colours still exist, pre-defined!
globvar_ttk_Combobox = 10
globvar_color_options = ["Grey", "Red", "Red2", "Blue", "Blue2", "Green",
"ReiGreen", "Yellow", "Gold",
"Orange", "Purples",
"BlueGreen", "GreenBlu",
"BluePurple", "PurpleBlue", "PupleRed", "RedPurple",
"OrangeRed",
"PurpleBlueGreen",
"Gnuplot", "Gnuplot2", "Ocean", "Rainbow",
"Gist_rainbow", "HSV", "Gist_stern", "Jet",
"Hot", "AFMhot", "Bone", "Gist_heat"]
# This red is very nice and also ...
Color_Red = {'red': ((0.0, 0.0, 0.0),
(0.333, 0.6, 0.6),
(0.666, 1.0, 1.0),
(1.0, 1.0, 1.0)),
'green': ((0.0, 0.0, 0.0),
(0.333, 0.0, 0.0),
(0.666, 0.0, 0.0),
(1.0, 1.0, 1.0)),
'blue': ((0.0, 0.0, 0.0),
(0.333, 0.0, 0.0),
(0.666, 0.0, 0.0),
(1.0, 1.0, 1.0))}
# ... this yellow, ...
Color_Yellow = {'red': ((0.0, 0.0, 0.0),
(0.333, 0.7, 0.7),
(0.666, 1.0, 1.0),
(1.0, 1.0, 1.0)),
'green': ((0.0, 0.0, 0.0),
(0.333, 0.8, 0.8),
(0.666, 1.0, 1.0),
(1.0, 1.0, 1.0)),
'blue': ((0.0, 0.0, 0.0),
(0.333, 0.0, 0.0),
(0.666, 0.0, 0.0),
(1.0, 1.0, 1.0))}
# ... this blue, ...
Color_Blue = {'red': ((0.0, 0.0, 0.0),
(0.3, 0.0, 0.0),
(0.7, 0.9, 0.9),
(1.0, 1.0, 1.0)),
'green': ((0.0, 0.0, 0.0),
(0.3, 0.0, 0.0),
(0.7, 0.9, 0.9),
(1.0, 1.0, 1.0)),
'blue': ((0.0, 0.0, 0.0),
(0.7, 0.9, 0.9),
(1.0, 1.0, 1.0))}
# ... gold and of course ...
Color_Gold = {'red': ((0.0, 0.0, 0.0),
(0.333, 0.545098039216, 0.545098039216),
(0.666, 0.803921568627, 0.803921568627),
(1.0, 1.0, 1.0)),
'green': ((0.0, 0.0, 0.0),
(0.333, 0.458823529412, 0.458823529412),
(0.666, 0.678431372549, 0.678431372549),
(1.0, 1.0, 1.0)),
'blue': ((0.0, 0.0, 0.0),
(0.333, 0.0, 0.0),
(0.666, 0.0, 0.0),
(1.0, 1.0, 1.0))}
# ... the famous green colour from the Michael Reichling group.
Color_ReiGreen = {'red': ((0.0, 0.0, 0.0),
(0.381166, 0.0, 0.0),
(0.672646, 0.471014, 0.471014),
(1.0, 1.0, 1.0)),
'green': ((0.0, 0.0, 0.0),
(0.381166, 0.381166, 0.381166),
(0.672646, 0.672646, 0.672646),
(1.0, 1.0, 1.0)),
'blue': ((0.0, 0.0, 0.0),
(0.381166, 0.0, 0.0),
(0.672646, 0.0, 0.0),
(1.0, 1.0, 1.0))}
Color_list = ["Greys_r", "Reds_r", Color_Red, "Blues_r", Color_Blue, "Greens_r",
Color_ReiGreen, Color_Yellow, Color_Gold,
"Oranges_r", "Purples_r",
"BuGn_r", "GnBu_r",
"BuPu_r", "PuBu_r", "PuRd_r", "RdPu_r",
"OrRd_r",
"PuBuGn_r",
"gnuplot", "gnuplot2", "ocean", "rainbow",
"gist_rainbow", "hsv", "gist_stern", "jet",
"hot", "afmhot", "bone", "gist_heat"]
globvar_color_dict = {name:color for name, color in \
zip(globvar_color_options, Color_list)}
# ___________________________________________________________________ Fonts
globvar_fonts = ['Courier', 'Courier New', 'Arial', 'FreeSans']
globvar_bad_fonts = ['NotoColorEmoji.ttf']
# ___________________________________________________________________ Classes
class CLASSparameters(object):
def __init__(self, row, col, rms, res, font,
thumbs_before, thumbs_after, peek, minimum_on_zero,
png, date, sizenm,
sizepx, offset, voltage, feedback, gain,
speed, ampl, text_block, text_block_height,
text_size, pdfs, text_x, text_y, angle,
extra_direct, extension, masterdir, filename, jpeg,
channel_names, thumbs, line_fit, plane_fit, invert,
colors, geometry_x, geometry_y, spektra):
self.row = row
self.col = col
self.rms = rms
self.res = res
self.font = font
self.thumbs_before = thumbs_before
self.thumbs_after = thumbs_after
self.peek = peek
self.minimum_on_zero = minimum_on_zero
self.png = png
self.date = date
self.sizenm = sizenm
self.sizepx = sizepx
self.offset = offset
self.voltage = voltage
self.feedback = feedback
self.gain = gain
self.speed = speed
self.ampl = ampl
self.text_block = text_block
self.text_block_height = text_block_height
self.text_size = text_size
self.pdfs = pdfs
self.text_x = text_x
self.text_y = text_y
self.angle = angle
self.extra_direct = extra_direct
self.extension = extension
self.masterdir = masterdir
self.filename = filename
self.jpeg = jpeg
self.channel_names = channel_names
self.thumbs = thumbs
self.line_fit = line_fit
self.plane_fit = plane_fit
self.invert = invert
self.colors = colors
self.geometry_x = geometry_x
self.geometry_y = geometry_y
self.spektra = spektra
class CLASSdir(object):
def __init__(self, working_directory, pdf_path,
thumbnail_directory, data_directory_name):
self.working_directory = working_directory
self.pdf_path = pdf_path
self.thumbnail_directory = thumbnail_directory
self.data_directory_name = data_directory_name
class CLASSdata(object):
__slots__ = ('date', 'x_size', 'y_size', 'x_pixel', 'y_pixel',
'x_off', 'y_off',
'voltage', 'measurement_type', 'feedback',
'gain', 'gain_prop', 'gain_int', 'gain_xy',
'gain_signal', 'gain_z',
'speed', 'amplitude', 'angle', 'scan_updown',
'sweep_f0', 'sweep_phase', 'sweep_A_exec', 'sweep_Q',
'NONE',
'datfile', 'channel', 'unit',
'z_average', 'z_calibration', 'z_factor', 'z_offset', 'z_min',
'z_max', 'res_freq', 'z_amplitude',
'scandir', 'spec_x_unit', 'spec_x_label',
'spec_y_unit', 'spec_y_label', 'spec_y_factor',
'spec_points', 'spec_feedback', 'spec_acquisition',
'spec_delay', 'spec_time', 'spec_position', 'spec_files',
'spec_other')
def __init__(self,
date,
x_size,
y_size,
x_pixel,
y_pixel,
x_off,
y_off,
voltage,
measurement_type,
feedback,
gain,
gain_prop,
gain_int,
gain_xy,
gain_signal,
gain_z,
speed,
res_freq,
amplitude,
angle,
scan_updown,
sweep_f0,
sweep_phase,
sweep_A_exec,
sweep_Q,
#
# From here to end: lists
#
NONE,
datfile,
channel,
unit,
z_average,
z_calibration,
z_factor,
z_offset,
z_min,
z_max,
z_amplitude,
scandir,
spec_x_unit,
spec_x_label,
spec_y_unit,
spec_y_label,
spec_y_factor,
spec_points,
spec_feedback,
spec_acquisition,
spec_delay,
spec_time,
spec_position,
spec_files,
spec_other):
self.date = date
self.x_size = x_size
self.y_size = y_size
self.x_pixel = x_pixel
self.y_pixel = y_pixel
self.x_off = x_off
self.y_off = y_off
self.voltage = voltage
self.measurement_type = measurement_type # SPECS Nanonis
self.feedback = feedback # I, df, etc.
self.gain = gain # SCALA
self.gain_prop = gain_prop # DULCINEA
self.gain_int = gain_int # DULCINEA
self.gain_xy = gain_xy # DULCINEA
self.gain_signal = gain_signal # DULCINEA
self.gain_z = gain_z # DULCINEA
self.speed = speed
self.res_freq = res_freq
self.amplitude = amplitude
self.angle = angle
self.scan_updown = scan_updown # SPECS Nanonis
self.sweep_f0 = sweep_f0 # SPECS Nanonis
self.sweep_phase = sweep_phase # SPECS Nanonis
self.sweep_A_exec = sweep_A_exec # SPECS Nanonis
self.sweep_Q = sweep_Q # SPECS Nanonis
self.NONE = NONE # This is a dummy ...
#
# From here to end: lists
#
self.datfile = datfile
self.channel = channel
self.unit = unit
self.z_average = z_average # float, is set during runtime
self.z_calibration = z_calibration
self.z_factor = z_factor # DULCINEA, not used
self.z_offset = z_offset # SPECS Nanonis
self.z_amplitude = z_amplitude
self.z_min = z_min # DULCINEA, not used
self.z_max = z_max # DULCINEA, not used
self.scandir = scandir
self.spec_x_unit = spec_x_unit
self.spec_x_label = spec_x_label
self.spec_y_unit = spec_y_unit
self.spec_y_label = spec_y_label
self.spec_y_factor = spec_y_factor
self.spec_points = spec_points
self.spec_feedback = spec_feedback
self.spec_acquisition = spec_acquisition
self.spec_delay = spec_delay
self.spec_time = spec_time
self.spec_position = spec_position
self.spec_files = spec_files
self.spec_other = spec_other # This can be used for any properties.
class CLASSLinalg(object):
__slots__ = ('plane_M512', 'plane_M1024',
'plane_x_vec512', 'plane_y_vec512',
'plane_x_vec1024', 'plane_y_vec1024',
'line_M512', 'line_M1024',
'line_x_vec512', 'line_x_vec1024')
def __init__(self, plane_M512, plane_M1024,
plane_x_vec512, plane_y_vec512,
plane_x_vec1024, plane_y_vec1024,
line_M512, line_M1024,
line_x_vec512,line_x_vec1024):
self.plane_M512 = plane_M512
self.plane_M1024 = plane_M1024
self.plane_x_vec512 = plane_x_vec512
self.plane_y_vec512 = plane_y_vec512
self.plane_x_vec1024 = plane_x_vec1024
self.plane_y_vec1024 = plane_y_vec1024
self.line_M512 = line_M512
self.line_M1024 = line_M1024
self.line_x_vec512 = line_x_vec512
self.line_x_vec1024 = line_x_vec1024
# The next 2 classes are used specifically for the RHK routine.
class CLASSRHK_position_counter(object):
def __init__(self, position):
self.position = position
def add(self):
self.position += 1
class CLASSRHK_direction_request(object):
def __init__(self, direction = all):
self.direction = direction
class CLASSRHK_true(object):
def __init__(self, true = False):
self.true = true
globvar_LINALG = CLASSLinalg(None,None,None,None,None,None,None,None,None,None)
# The global variables 'globvar_AFMdata' and 'globvar_ThumbPara' are created!
globvar_AFMdata = CLASSdata(None,None,None,None,None,None,None,None,None,None,
None,None,None,None,None,None,None,None,None,None,
None,None,None,None,None,None,
[],[],[], None, [],[],[],[],[],[],[],
[],[],[],[],[],[],[],[], [], [], [], [], None)
globvar_AFMdir = CLASSdir(None,None,None,None)
globvar_ThumbPara = CLASSparameters(None, None, None, None, None,
False, False, False, False, False, False,
False, False, False, False, False,
False, False, False,
0, 0, 0, False, 0, 0, False,
False, None, None, None, 0,
[], [], [], [], [], [],
[], [], None)
# For RHK
RHK_PositionCounter = CLASSRHK_position_counter(None)
RHK_special = CLASSRHK_true(False)