wolfhece.report.common

Module Contents

wolfhece.report.common.wolfgpu_version = 'not installed'[source]
wolfhece.report.common.pts2cm(pts)[source]

Convert points to centimeters for PyMuPDF.

One point equals 1/72 inches.

wolfhece.report.common.pt2inches(pts)[source]

Convert points to inches for PyMuPDF.

One point equals 1/72 inches.

wolfhece.report.common.inches2cm(inches)[source]

Convert inches to centimeters.

One inch equals 2.54 centimeters.

wolfhece.report.common.cm2pts(cm)[source]

Convert centimeters to points for PyMuPDF.

One point equals 1/72 inches.

wolfhece.report.common.cm2inches(cm)[source]

Convert centimeters to inches.

One inch equals 2.54 centimeters.

wolfhece.report.common.A4_rect()[source]

Return the A4 rectangle in PyMuPDF units.

(0, 0) is the top-left corner in PyMuPDF coordinates.

wolfhece.report.common.rect_cm(x, y, width, height)[source]

Create a rectangle in PyMuPDF units from centimeters.

(0, 0) is the top-left corner in PyMuPDF coordinates.

wolfhece.report.common.get_rect_from_text(text, width, fontsize=10, padding=5)[source]

Get a rectangle that fits the text in PyMuPDF units.

Parameters:
  • text – The text to fit in the rectangle.

  • width – The width of the rectangle in centimeters.

  • fontsize – The font size in points.

  • padding – Padding around the text in points.

Returns:

A PyMuPDF rectangle that fits the text.

wolfhece.report.common.list_to_html(list_items, font_size='10pt', font_family='Helvetica')[source]
wolfhece.report.common.list_to_html_aligned(list_items, font_size='10pt', font_family='Helvetica')[source]
wolfhece.report.common.dict_to_html(data_dict: dict, font_size='10pt', font_family='Helvetica')[source]

Convert a dictionary to an HTML table with dataframe_image

wolfhece.report.common.dataframe_to_html(data: pandas.DataFrame, font_size='10pt', font_family='Helvetica')[source]

Convert a DataFrame to an HTML table with dataframe_image

wolfhece.report.common.convert_report_to_images(pdf_path: str | pathlib.Path, dpi=150) list[PIL.Image.Image][source]

Convert the PDF report to a list of images (one per page).

Parameters:

dpi – Dots per inch for the output images.

Returns:

List of Images, one per page.

wolfhece.report.common.PAGE_WIDTH = 21[source]
wolfhece.report.common.PAGE_HEIGHT = 29.7[source]
wolfhece.report.common.SLIDE_HEIGHT = 19.05[source]
wolfhece.report.common.SLIDE_WIDTH = 33.866582[source]
class wolfhece.report.common.DefaultLayoutA4(title: str, filename='', ox=0, oy=0, tx=0, ty=0, parent=None, is2D=True, idx='', plotted=True, mapviewer=None, need_for_wx=False, bbox=None, find_minmax=True, shared=False, colors=None)[source]

Bases: wolfhece.PyVertexvectors.Zones

Inheritance diagram of wolfhece.report.common.DefaultLayoutA4

Global layout for A4 report.

This class inherits from Zones and defines a standard layout for A4 reports. It includes predefined areas for the title, versions, logo, and footer.

title[source]
left_right_margin = 1[source]
top_bottom_margin = 0.5[source]
padding = 0.5[source]
_doc = None[source]
_pdf_path = None[source]
add_element(name: str, width: float, height: float, x: float = 0, y: float = 0) wolfhece.PyVertexvectors.vector[source]

Add a single element to the page.

Parameters:
  • name – Name of the element.

  • width – Width of the element in cm.

  • height – Height of the element in cm.

  • x – X coordinate of the bottom-left corner in cm.

  • y – Y coordinate of the bottom-left corner in cm.

Returns:

The created vector representing the element.

add_element_repeated(name: str, width: float, height: float, first_x: float = 0, first_y: float = 0, count_x: int = 1, count_y: int = 1, padding: float = None) wolfhece.PyVertexvectors.zone[source]

Add multiple elements to the page in a grid.

Parameters:
  • name – Base name for the elements.

  • width – Width of each element in cm.

  • height – Height of each element in cm.

  • first_x – X coordinate of the first element in cm.

  • first_y – Y coordinate of the first element in cm.

  • count_x – Number of elements in the X direction (positive for right, negative for left).

  • count_y – Number of elements in the Y direction (positive for up, negative for down).

  • padding – Padding between elements in cm. If None, use self.padding.

Returns:

A zone containing the added elements.

check_if_overlap(vec: wolfhece.PyVertexvectors.vector) bool[source]

Check if the vector overlaps with any existing vector in the page layout.

Parameters:

vec – The vector to check.

Returns:

True if there is an overlap, False otherwise.

property useful_part: wolfhece.PyVertexvectors.vector[source]

Get the useful part of the page, excluding margins.

property page_dimension: tuple[float, float][source]

Get the dimensions of the page in centimeters.

property keys: list[str][source]

Get the keys of the page layout.

property layout: dict[source]

Get the layout as a dictionary.

get_item_in_layout(name: str)[source]

Override the indexing to access layout elements by name.

_to_dict()[source]

Convert the layout Zones to a dictionary.

plot(scale=1.0)[source]

Plot the page layout using matplotlib.

Parameters:

scale – Scale factor for the plot.

_summary_versions()[source]

Find the versions of the simulation, wolfhece and the wolfgpu package

_insert_to_page(page: pymupdf.Page)[source]

Insert the layout into the PDF page.

create_report() pymupdf.Document[source]

Create the PDF report for the default LayoutA4.

save_report(output_path: pathlib.Path | str)[source]

Save the report to a PDF file

property pdf_path[source]

Return the PDF document