vestacrystparser.export

Open VESTA and export images.

export_image_from_file() is the core function, which directly opens a VESTA file then exports an image file using VESTA’s (rather sparse) command line interface.

This requires a working VESTA installation on your system.

exception vestacrystparser.export.NoVestaError

VESTA does not exist or cannot be found.

vestacrystparser.export.export_image_from_file(input: str, output: str, scale: int = 1, close: bool = True, block: bool = True, timeout: float = None)

Opens a file in VESTA and saves it as an image.

You can open VESTA before running this command to set the size of the window, which determines the size of the image.

Runs ASYNCHRONOUSLY. May be subject to race conditions. Modifying the files while running this command will cause unexpected behaviour. I do not know how to retrieve an exit call, besides checking if output has been written (which is what block does).

Note that, even with the close argument, VESTA will remain open after this call. (close just closes the tab within VESTA.) You are responsible for closing it yourself when you’re done.

block is strongly recommended if you are doing more than a couple at once, because I’ve found VESTA will max-out on processes if it tries to open too many files simultaneously.

VESTA has a command line interface: https://jp-minerals.org/vesta/en/doc/VESTAch17.html

Koichi Momma gives directions on how to use VESTA’s command line interface: https://groups.google.com/g/vesta-discuss/c/xePcwJ3Mdgw/m/GyC8_UZbAwAJ

Parameters:
  • input – Path to file readable by VESTA.

  • output – Path to write image to. Should include a recognisable image file extension.

  • scale – Amount to scale raster image by.

  • close – Whether to close the VESTA tab afterward.

  • block – Whether to block the main process until the file is written. If the export process fails on VESTA’s end, then this will hang! However, it is recommended to reduce race conditions or system overload.

  • timeout – Number of seconds to block for until we raise TimeoutError. If None, will count indefinitely. Note, though, that VESTA will still be running if we hit the Timeout. We just hand the focus back to Python.

Raises:
  • NoVestaError – If fails to run VESTA.

  • OSError – If run on an unsupport OS. (Supports Windows, Linux, MacOS/Darwin.)

  • FileNotFoundError – If input doesn’t exist or output’s directory doesn’t exist.

  • TimeoutError – block=True and we timeout.