Metagen – Spyview metafile generation

Module for generation of spyview metafiles

Spyview typically requires an additional metafile to correctly label the axes and labels of a dataset. The meta file structure is detailed at Spyview.

Given a dataset, the metafile contains the x,y axis start, end and number of points as well as column titles. This means that spyview can only handle uniformly spaced axes. It can also contain z axis start, stop and number of points for data cubes but this is rarely used so it is generally left with 1 point (single 2d plot). This z axis is NOT the data axis.

The module provides a few different functions for generating the axes limits and metafile from your data. It is important to keep in mind that in general spyview does not treat any of the columns in the file as special in any way. It only reads the requested column and tries to reshape it into a matrix to display in the final color plot. The metafile tells spyview how this reshaping should be done, i.e, how many points are on x and y and how it should label the axis values and titles. When importing without a metafile, spyview searches for blank lines to figure out when each line of the matrix ends.

stlabutils.metagen.fromarrays(myfile, xarray, yarray, zarray=[], xtitle='', ytitle='', ztitle='', colnames=None)[source]

Generates a metafile for a given file using axes arrays as input

Generates a metafile for the given file taking the endponts of given arrays and their length. Column titles are added manually providing a list of titles or by autogenerating from the file title line.

Internally, this function calls fromlimits

Parameters
  • myfile (file or string) – Base file for metafile

  • xarray (array of floats) – Array for x axis limits and number of points

  • yarray (array of floats) – Array for y axis limits and number of points

  • zarray (array of floats or empty list, optional) – Array for z axis limits and number of points (for data cubes)

  • ytitle, ztitle (xtitle,) – Title for x, y, z axis axis

  • colnames (list of str, 'auto' or None, optional) – List of column titles for the given file. If None, no titles are written in metafile. If auto function reads the first line of the file and uses the obtained titles in the metafile

stlabutils.metagen.fromlimits(myfile, Nx, xmin, xmax, Ny, ymin, ymax, Nz=None, zmin=None, zmax=None, xtitle='', ytitle='', ztitle='', colnames=None)[source]

Generates a metafile for the given axis limits and point number

Generates a metafile for the given file taking the endponts of given arrays and their length. Column titles are added manually providing a list of titles or by autogenerating from the file title line.

Internally, this function is called by fromarrays.

Parameters
  • myfile (file or string) – Base file for metafile

  • Ny (Nx,) – Number of points in x, y axis

  • Nz (int or None, optional) – Number of points in z axis

  • ymin (xmin,) – Minimum value for x and y axis

  • ymax (xmax,) – Maximum value for x and y axis

  • zmax (zmin,) – Maximum and minimum value for the z axis (for data cubes)

  • ytitle, ztitle (xtitle,) – Title for x, y, z axis axis

  • colnames (list of str, 'auto' or None, optional) – List of column titles for the given file. If None, no titles are written in metafile. If auto function reads the first line of the file and uses the obtained titles in the metafile