Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error_summary output can be empty in some cases #10

Open
sdanfort opened this issue Mar 28, 2023 · 2 comments
Open

error_summary output can be empty in some cases #10

sdanfort opened this issue Mar 28, 2023 · 2 comments

Comments

@sdanfort
Copy link

I am using sdynpy.core.sdynpy_data.PowerSpectralDensityArray.error_summary to compare test data (from a Rattlesnake virtual test) to a CPSD spec. Documentation says it should return a tuple of dictionaries of error metrics.

I am running the following line:
error_metrics = cpsd_spec.error_summary(figure_kwargs={}, linewidth=1, plot_kwargs={}, cpsd_matrices = cpsd_data)
where cpsd_spec and cpsd_data are both PowerSpectralDensityArray objects with shape 10 x 10 and 1000 elements per function. The function does produce the error summary plot (including the dB error vs. frequency), but my error_metrics output is NoneType.

I see in line 1911 of sdynpy_data.py that return_data is initialized as None. If len(cpsd_matrices) > 1 (line 1928), return_data is populated with the error metrics. However, if this boolean returns False, as it does in my case, return_data stays as NoneType. Can a line be added to the len(cpsd_matrices) > 0 case to populate return_data, or is this a problem with my inputs to error_summary()? Thank you!

@dprohe
Copy link
Collaborator

dprohe commented Apr 3, 2023

You're right, this looks like a bug. I think the issue is that the error metrics that are returned are not computed when only one CPSD matrix is passed to the function, as they end up in the bar plot at the bottom of the figure which doesn't get plotted when only one CPSD is passed.

I'll work on a fix for that, but it might be a bit before it gets pushed to the github page due to the approval process we have for releasing code. In the meantime, you can trick the function to give you the data simply by doing something like this where you just repeat the data twice to get it to trigger the len(cpsd_matrices) > 1 if statement:
error_metrics = cpsd_spec.error_summary(figure_kwargs={}, linewidth=1, plot_kwargs={}, cpsd_matrices = cpsd_data, cpsd_matrices_2 = cpsd_data). You can then just pull the data out of the dictionary for the first cpsd_data key.

@sdanfort
Copy link
Author

sdanfort commented Apr 3, 2023

Thanks Dan; will do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants