plot_gmx_densmap
Read up to three matrices from text files and plot them as one RGB
matrix with matplotlib.axes.Axes.imshow()
.
Todo
Finish docstring.
Each matrix must be stored in a separate text file. The first column of the text files must contain the x values and the first row the y values (note that this is opposed to the standard matrix convention). The value in the upper left corner will be ignored. The remaining elements of the matrix must contain the z values for each (x,y) pair. The file may contain comment lines starting with ‘#’, which will be ignored.
Options
- -r
File containing the matrix that shall be represented as red levels in the final RGB matrix.
- -g
File containing the matrix that shall be represented as green levels in the final RGB matrix.
- -b
File containing the matrix that shall be represented as blue levels in the final RGB matrix. Note that at leas one of the -r, -g and -b flag must be provided. If multiple matrices are given, all matrices must have the same shape and the same x and y values. The input matrices must not contain negative values.
- -o
Output filename.
- -c
Eliminate values below a certain cutoff in the final RGB matrix to suppress noise. The values of each RGB channel are normalized to the interval [0, 1] (not [0,255] as usual). Default:
0
.- --Otsu
Use Otsu’s binarization1 to automatically calculate a cutoff. If --Otsu is set, -c will be ignored. This option requires the opencv-python package to be installed on your computer.
- --xylabel
x- and y-axis label. Default:
[r'$x$ / nm', r'$y$ / nm']
.- --xlim
Left and right limit of the x-axis in data coordinates. Pass ‘None’ to adjust the limit(s) automatically. Default:
[None, None]
.- --ylim
Lower and upper limit of the y-axis in data coordinates. Pass ‘None’ to adjust the limit(s) automatically. Default:
[None, None]
.- --xticks-at-yticks
Set x-ticks at the same positions as y-ticks.
Notes
This python script is inspired by the work of Hadrian Montes-Campos2,3. It was originally designed to read the output file that is produced by the GROMACS tool ‘gmx densmap’ with the ‘-od’ flag.
References
- 1
N. Otsu, “A threshold selection method from gray-level histograms”, IEEE transactions on systems, man, and cybernetics, 1979, 9, 62-66.
- 2
H. Montes-Campos, J. M. Otero-Mato, T. Mendez-Morales, O. Cabeza, L. J. Gallego, A. Ciach, L. M. Varela, “Two-dimensional pattern formation in ionic liquids confined between graphene walls”, Physical Chemistry Chemical Physics, 2017, 19, 24505-24512.
- 3
J. M. Otero-Mato, H. Montes-Campos, O. Cabeza, D. Diddens, A. Ciach, L. J. Gallego, L. M. Varela, “3D structure of the electric double layer of ionic liquid-alcohol mixtures at the electrochemical interface”, Physical Chemistry Chemical Physics, 2018, 20, 30412-30427.
Examples
TODO
Functions
Read a 2-dimensional matrix from a text file. |