Eomys / SciDataTool

SciDataTool is an open-source Python package for scientific data handling. The objective is to provide a user-friendly, unified, flexible module to postprocess any kind of signal. It is meant to be used by researchers, R&D engineers and teachers in any scientific area. This package allows to efficiently store data fields in the time/space or in the frequency domain, to easily perform Fourier Transforms, to extract slices, to convert units, to compare several fields, etc. It therefore leads to simplified plot commands.
Apache License 2.0
26 stars 21 forks source link

[CO] Improve error message when calling impossible plot #110

Open BonneelP opened 2 years ago

BonneelP commented 2 years ago

Hello all,

While working on a validation case for pyleecan I had the following issue: This PR https://github.com/Eomys/pyleecan/pull/529 introduces a new test "test_Bore_sym" in Tests/Validation/Magnetics/test_FEMM_periodicity.py where I compute the flux with/without angular sym. In both cases I set Nt_tot=1 and then I call (out of a copy/paste from another test with Nt_tot>1):

    out.mag.B.plot_2D_Data(
        "time",
        "angle[0]{°}",
        data_list=[out2.mag.B],
        legend_list=["Periodic", "Full"],
        save_path=join(save_path, simu.name + "_B_time.png"),
        is_show_fig=False,
        **dict_2D
    )

and I get the following error: image

I guess the error is that I'm calling a plot on an axis with a size one. If I increase Nt_tot=4, there is no error. So I think it is just a matter of adding a check and a clearer error message (the requested plot doesn't make sense).

From the same copy paste, I also had: image I'm requesting time[1] which doesn't exist, so we could also provide a dedicated error message for this case.

Best regards, Pierre