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

[Bug]: UnboundLocalError: local variable 'cwv_max' referenced before assignment for arm_diags plot with region sgpc1 #858

Closed
tomvothecoder opened this issue Sep 30, 2024 · 3 comments
Assignees
Labels
bug Bug fix (will increment patch version)

Comments

@tomvothecoder
Copy link
Collaborator

What happened?

There is a FIXME: comment to address this for awhile:

# FIXME: UnboundLocalError: local variable 'cwv_max' referenced before assignment
number_of_bins = int(np.ceil((cwv_max - cwv_min) / bin_width))

What did you expect to happen? Are there are possible answers you came across?

This occurs when the region is sgpc1. The conditional that sets cwv_max and other plotting variables don't consider this region:

# Define cwc bounds and bin_width for each site
if region == "twpc1": # twpc1
cwv_max = 69
cwv_min = 28
bin_width = 1.5
sitename = "Manus Island"
if region == "twpc2": # twpc2
cwv_max = 70
cwv_min = 28
bin_width = 2.0
sitename = "Nauru"
if region == "twpc3": # twpc3
cwv_max = 85
cwv_min = 28
bin_width = 2.0
sitename = "Darwin"
if region == "sgp": # sgp
cwv_max = 75
cwv_min = 20
bin_width = 2.0
sitename = "SGP"

Minimal Complete Verifiable Example (MVCE)

No response

Relevant log output

No response

Anything else we need to know?

No response

Environment

Latest main and cdat-migration-fy24 branch

@tomvothecoder tomvothecoder added the bug Bug fix (will increment patch version) label Sep 30, 2024
@tomvothecoder tomvothecoder self-assigned this Sep 30, 2024
@tomvothecoder
Copy link
Collaborator Author

Hey @chengzhuzhang, this bug has been around for a long time. I can now fix it in #842.

Do you have an idea what the values should be for cwv_max, cwv_min, bin_width, and sitename?

@chengzhuzhang
Copy link
Contributor

I think there is a typo:

if region == "sgp": # sgp

It should be
if region == "sgpc1":

@tomvothecoder tomvothecoder changed the title [Bug]: UnboundLocalError: local variable 'cwv_max' referenced before assignment for arm_diags plot with region `sgpc1 [Bug]: UnboundLocalError: local variable 'cwv_max' referenced before assignment for arm_diags plot with region sgpc1 Sep 30, 2024
@tomvothecoder
Copy link
Collaborator Author

Closed by #842

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug fix (will increment patch version)
Projects
None yet
Development

No branches or pull requests

2 participants