Commit 11804961 authored by Duggan, John's avatar Duggan, John
Browse files

Handle plotting errors

parent 6195e39c
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
[project]
name = "ips-fastran-gui"
version = "0.2.3"
version = "0.2.4"
description = "IPS Fastran GUI Project"
authors = []
readme = "README.md"
+11 −3
Original line number Diff line number Diff line
"""Fastran Plotter."""

import os
import sys
from pathlib import Path
from typing import Any, Dict

@@ -24,6 +25,7 @@ class PlotFastran:
    def load_fastran(self, fn_ncfile: Path) -> None:
        self.figure.clear()

        self.filename = fn_ncfile
        self.fastran = netCDF4.Dataset(fn_ncfile, "r", format="NETCDF4")
        self.basename = os.path.basename(fn_ncfile)

@@ -44,9 +46,15 @@ class PlotFastran:
                p = self.ax[i_plot, j_plot]
                for key in define:
                    print(pannel, key)
                    try:
                        x = self.fastran.variables["rho"][:]
                        y = self.fastran.variables[key[0]][key[1], :]
                        p.plot(x, y, key[2])
                    except Exception as err:
                        print(
                            f"Error encountered while plotting file {self.filename} {pannel} {key}: {str(err)}",
                            file=sys.stderr,
                        )

                p.set_title(pannel)
                p.set_xlim(0, 1)