tcutility.report package#

Subpackages#

Submodules#

tcutility.report.character module#

get_pixel_width(character, font='calibri', font_size=11)[source]#

Get the pixel width of a character for a given font and font-size. For this we need to interpolate the pixel width between two reference values. In the _char_widths.txt file you will find for each font a set of character pixel widths for font-size 1. We then simply multiply the 1-width value by the desired value to get the correct pixel width. See

Parameters:
  • character (str) – the character to get the pixel width for.

  • font (str) – the font family that is used.

  • font_size (float) – the font-size to get the pixel width at.

Return type:

float

text_width(text, font='calibri', font_size=11, mode='pixels')[source]#

Get the width of a string for a given font and font size.

Parameters:
  • text (str) – the object to determine the length for. Will be cast to a string before calculating width.

  • font (str) – the font family that is used.

  • font_size (float) – the font-size to get the pixel width at.

  • mode (str) – the width-mode. Can be ‘excel’ or ‘pixels’.

Return type:

float

Returns:

The width of the text for a certain font and font size. If mode is ‘excel’ we pad it with 8 pixels and then divide by 7.6 (i.e. standard excel char width).

tcutility.report.figure_resizer module#

This module is used for resizing pictures containing molecules.

resize(img_paths, circle_numbers=None, padding=0)[source]#

The main function for this module. Takes a directory d and selected circles and resizes and moves images in order to produce new aligned images.

Parameters:
  • d – the directory to take images from.

  • circle_numbers (Optional[Dict]) – a dictionary containing the image names as keys and circle indices as the values. The new images will be aligned based on these selected circles.

  • padding (Union[str, int, float]) – the amount of padding to add to the new images. If given an integer, it adds padding number of pixels. Alternatively a string consisting of a number and a % sign can be given to add relative padding. E.g. padding=’10%’ will add a 10% padding to the images.

tcutility.report.report module#

class DocxFigure(doc, width=None, height=None)[source]#

Bases: object

add_image(path, row, col=None, label='')[source]#
write()[source]#
class DocxTable(file='test.docx')[source]#

Bases: object

add_column(name, **kwargs)[source]#
add_column_group(group_name, column_names, **kwargs)[source]#
add_row(data)[source]#
add_header_row(name)[source]#
add_empty_row()[source]#
merge_cells(x, y)[source]#
property shape#
write()[source]#
write_cell(row, col, text, alignment='center', vert_alignment='center', bold=None, italic=None, bkgr_color=None, font_size=None, **kwargs)[source]#
add_footnote(text, bold=None, italic=None, font_size=None)[source]#
class SI(path, overwrite=False, font='Arial')[source]#

Bases: object

add_figure(*args, **kwargs)[source]#
Return type:

DocxFigure

add_table()[source]#
Return type:

DocxTable

add_xyz(obj, title=None, formatter=<tcutility.report.formatters.xyz.StandardXYZFormatter object>)[source]#

Adds XYZ formatted content to the document.

This method is responsible for adding the coordinates and information about a calculation to the supporting information document. It includes details such as the electronic bond energy, Gibb’s free energy, enthalpy, imaginary mode, and the coordinates of the molecule.

Parameters:
  • obj (Union[str, Result, Path]) – A string specifying a calculation directory or a TCutility.results.Result object from a calculation.

  • title (Optional[str]) – The title to be written before the coordinates and information. If None, no title is added.

  • formatter (WordFormatter) – The formatter to be used for formatting the content. Defaults to StandardXYZFormatter.

Return type:

None

Returns:

None

add_heading(text, level=1)[source]#

Adds a heading to the document.

This method allows for the addition of a heading to the Word document, with customizable text and level.

Parameters:
  • text (str) – The text of the heading.

  • level (int, optional) – The level of the heading (determines the size and style). Defaults to 1.

Return type:

None

add_page_break()[source]#
Return type:

None

add_toc()[source]#
Return type:

None

get_subdirs(root_folder)[source]#

Iteratively searches through a folder and returns all the most nested subdirs.

Return type:

List[Path]

replace_files_rkf_to_ams_rkf(root_folder)[source]#

Iteratively searches through a folder and replaces all files with the extension ‘.rkf’ to ‘.ams.rkf’, except if the file has ‘adf.rkf’ in the name.

Return type:

None

main()[source]#

Module contents#