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

Bugfix Address negative values returned by calculate_bcmse() and calculate_bcrmse() in sl1l2_statistics module #329

Closed
23 tasks
bikegeek opened this issue Oct 3, 2023 · 5 comments
Assignees
Labels
METcalcpy: General Statistics priority: high High Priority reporting: DTC NCAR Base NCAR Base DTC Project reporting: DTC NOAA BASE NOAA Office of Atmospheric Research DTC Project requestor: NOAA/GSL NOAA Global Systems Laboratory required: FOR OFFICIAL RELEASE Required to be completed in the official release for the assigned milestone type: bug Fix something that is not working

Comments

@bikegeek
Copy link
Collaborator

bikegeek commented Oct 3, 2023

Describe the Problem

The calculate_bcmse() and the calculate_bcrmse() functions in the sl1l2_statistics.py module are returning negative values. This may be due to the round_half_up() applied to the calculate_mse() and calculate_rmse() values before returning them. See @mollybsmith-noaa comments in the comment section below for a detailed explanation.

Expected Behavior

Provide a clear and concise description of what you expected to happen here.

Environment

Describe your runtime environment:
1. Machine: (e.g. HPC name, Linux Workstation, Mac Laptop)
2. OS: (e.g. RedHat Linux, MacOS)
3. Software version number(s)

To Reproduce

Describe the steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
Post relevant sample data following these instructions:
https://dtcenter.org/community-code/model-evaluation-tools-met/met-help-desk#ftp

Relevant Deadlines

List relevant project deadlines here or state NONE.

Funding Source

Define the source of funding and account keys here or state NONE.

Define the Metadata

Assignee

  • Select engineer(s) or no engineer required
  • Select scientist(s) or no scientist required

Labels

  • Select component(s)
  • Select priority
  • Select requestor(s)

Projects and Milestone

  • Select Organization level Project for support of the current coordinated release
  • Select Repository level Project for development toward the next official release or add alert: NEED CYCLE ASSIGNMENT label
  • Select Milestone as the next bugfix version

Define Related Issue(s)

Consider the impact to the other METplus components.

Bugfix Checklist

See the METplus Workflow for details.

  • Complete the issue definition above, including the Time Estimate and Funding Source.
  • Fork this repository or create a branch of main_<Version>.
    Branch name: bugfix_<Issue Number>_main_<Version>_<Description>
  • Fix the bug and test your changes.
  • Add/update log messages for easier debugging.
  • Add/update unit tests.
  • Add/update documentation.
  • Add any new Python packages to the METplus Components Python Requirements table.
  • Push local changes to GitHub.
  • Submit a pull request to merge into main_<Version>.
    Pull request: bugfix <Issue Number> main_<Version> <Description>
  • Define the pull request metadata, as permissions allow.
    Select: Reviewer(s) and Development issues
    Select: Organization level software support Project for the current coordinated release
    Select: Milestone as the next bugfix version
  • Iterate until the reviewer(s) accept and merge your changes.
  • Delete your fork or branch.
  • Complete the steps above to fix the bug on the develop branch.
    Branch name: bugfix_<Issue Number>_develop_<Description>
    Pull request: bugfix <Issue Number> develop <Description>
    Select: Reviewer(s) and Development issues
    Select: Repository level development cycle Project for the next official release
    Select: Milestone as the next official version
  • Close this issue.
@bikegeek bikegeek added priority: high High Priority requestor: NOAA/GSL NOAA Global Systems Laboratory type: bug Fix something that is not working alert: NEED ACCOUNT KEY Need to assign an account key to this issue reporting: DTC NCAR Base NCAR Base DTC Project reporting: DTC NOAA BASE NOAA Office of Atmospheric Research DTC Project required: FOR OFFICIAL RELEASE Required to be completed in the official release for the assigned milestone METcalcpy: General Statistics labels Oct 3, 2023
@bikegeek bikegeek added this to the METcalcpy-3.0.0 milestone Oct 3, 2023
@bikegeek bikegeek self-assigned this Oct 3, 2023
@bikegeek bikegeek changed the title Bugfix Bugfix Address negative values returned by calculate_me() and calculate_mse() in sl1l2_statistics module Oct 3, 2023
@mollybsmith-noaa
Copy link
Collaborator

The description in this issue is not correct. The problem is that calculate_bcmse is returning negative numbers, which it should never do, because it calls both calculate_mse and caluclate_me, which are positive but are subject to rounding. This means that when one is subtracted from the other, a negative value can be produced. @bikegeek does this make sense?

@bikegeek bikegeek changed the title Bugfix Address negative values returned by calculate_me() and calculate_mse() in sl1l2_statistics module Bugfix Address negative values returned by calculate_bcmse() and calculate_bcrmse() in sl1l2_statistics module Oct 3, 2023
@bikegeek
Copy link
Collaborator Author

bikegeek commented Oct 4, 2023

@mollybsmith-noaa can you please provide some data so we can re-create and test?

@mollybsmith-noaa
Copy link
Collaborator

I'm getting some data behind the case in dtcenter/METexpress#127, which is where I first found out about this bug.

@mollybsmith-noaa
Copy link
Collaborator

Function definition is: def calculate_bcrmse(input_data, columns_names, aggregation=False):

These produce the bug:

input_data = array([[8.69988460e+02, 3.63246150e+02, 7.56879923e+05, 1.31947769e+05, 3.16019963e+05, 1.00000000e+00]])
columns_names = array(['fbar', 'obar', 'ffbar', 'oobar', 'fobar', 'total'], dtype='<U5')

input_data = array([[4.37978400e+01, 4.70115800e+01, 1.91825108e+03, 2.21008843e+03, 2.05900571e+03, 1.00000000e+00]])
columns_names = array(['fbar', 'obar', 'ffbar', 'oobar', 'fobar', 'total'], dtype='<U5')

input_data = array([[8.66233900e+01, 4.83037900e+01, 7.50361146e+03, 2.33325660e+03, 4.18423840e+03, 1.00000000e+00]])
columns_names = array(['fbar', 'obar', 'ffbar', 'oobar', 'fobar', 'total'], dtype='<U5')

input_data = array([[3.68089000e+01, 1.64253370e+02, 1.35489535e+03, 2.69791703e+04, 6.04598647e+03, 1.00000000e+00]])
columns_names = array(['fbar', 'obar', 'ffbar', 'oobar', 'fobar', 'total'], dtype='<U5')

It's not every point on the graph but it can be several.

@bikegeek
Copy link
Collaborator Author

Successfully reproducing the negative BCMSE values with the provided data. However, attempts to remove rounding up in the ME calculation still results in negative BCMSE values. Eric suggests setting the result to 0 when MSE < ME^2.

bikegeek added a commit that referenced this issue Jan 4, 2024
* Issue #329 return 0 if negative BCMSE value is calculated

* Issue #329 add test for calculate_bcmse() in the sl1l2_statistics module

* Issue #392 added test_sl1l2.py to the list of pytests to run
@bikegeek bikegeek moved this from 🔖 Ready to ✅ Done in METplus-Analysis-6.0.0 Development Jan 4, 2024
@bikegeek bikegeek closed this as completed Jan 4, 2024
jprestop added a commit that referenced this issue Feb 2, 2024
* Prepare for next release

* add missing end quote to fix package install

* reset_index is performed on the float value #322 (#323)

* Update release notes (#328)

* Update release-notes.rst formatting

* Update and rename 2.1.0_wcoss2 to 3.0.0_wcoss2

* loop over statistics only once to avoid data multiplication #330 (#331)

* Added sphinx_rtd_theme to extensions

* Updated requirements.txt

* Added pillow

* feature 497 headers (#336)

* changing header for continuity

* Modified the other headers in the file to be consistent with other repos

---------

Co-authored-by: Julie Prestopnik <jpresto@ucar.edu>

* Beta2 release (#338)

* Next version

* Feature 332 di doc (#333)

* Add difficulty index documentation

* Add more documentation

* Add more definition

* Fix indent

* Add figure

* fix indentation

* fix equations

* Add table

* Added remaining tables

* fix table issue

* Add links

* formatting

* change link to latest

---------

Co-authored-by: Tracy <tracy.hertneky@noaa.gov>

* Additions to beta2 release (#340)

* Next beta

* Bugfix 329 negative bcmse (#344)

* Issue #329 return 0 if negative BCMSE value is calculated

* Issue #329 add test for calculate_bcmse() in the sl1l2_statistics module

* Issue #392 added test_sl1l2.py to the list of pytests to run

* command line updates

* updating yaml file

---------

Co-authored-by: Hank Fisher <fisherh@ucar.edu>
Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com>
Co-authored-by: John Halley Gotway <johnhg@ucar.edu>
Co-authored-by: Tatiana Burek <tatiana@ucar.edu>
Co-authored-by: jprestop <jpresto@ucar.edu>
Co-authored-by: Tracy Hertneky <39317287+hertneky@users.noreply.github.com>
Co-authored-by: Tracy <tracy.hertneky@noaa.gov>
Co-authored-by: bikegeek <3753118+bikegeek@users.noreply.github.com>
@jprestop jprestop removed the alert: NEED ACCOUNT KEY Need to assign an account key to this issue label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
METcalcpy: General Statistics priority: high High Priority reporting: DTC NCAR Base NCAR Base DTC Project reporting: DTC NOAA BASE NOAA Office of Atmospheric Research DTC Project requestor: NOAA/GSL NOAA Global Systems Laboratory required: FOR OFFICIAL RELEASE Required to be completed in the official release for the assigned milestone type: bug Fix something that is not working
Projects
No open projects
Status: 🏁 Done
Development

No branches or pull requests

3 participants