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

calc_cam_climo logic needs help #214

Closed
bitterbark opened this issue Oct 27, 2022 · 2 comments · Fixed by #202
Closed

calc_cam_climo logic needs help #214

bitterbark opened this issue Oct 27, 2022 · 2 comments · Fixed by #202
Labels
bug Something isn't working

Comments

@bitterbark
Copy link
Collaborator

ADF run type

Model vs. Obs

What happened?

Note that this is a very unusual case: I'm trying to use ADF to calculate time series but not climatologies. Furthermore, the error occurs after the timeseries are generated, so it just means the script quits on an error, not that it doesn't do what I need. So this is not a high priority bug, but I figure I should file it because it isn't that likely to get exercised again!

When compare_obs = true, diag_cam_baseline_climo:calc_cam_climo = None.
In lib/adf_diag.py, the logic to determine if climos should be calculated is not properly triggered:

if self.get_cam_info('calc_cam_climo') or
self.get_baseline_info('calc_cam_climo'):

tests positive and goes into trying to calculate the climos.

I tried to solve this but have just become more confused. I read about truthy and falsey to come up with this test:

print(f"got calc_cam_climo cam {self.get_cam_info('calc_cam_climo')} baseline {self.get_baseline_info('calc_cam_climo')}")
bool_cam = bool(self.get_cam_info('calc_cam_climo'))
bool_baseline = bool(self.get_baseline_info('calc_cam_climo'))
print(f"bool(cam) {bool_cam} (baseline) {bool_baseline}")

The results are

got calc_cam_climo cam [False] baseline None
bool(cam) True (baseline) False

So the None evalues to False, which is good, we could just use bool.
But the [False] evaluates to True???

ADF Hash you are using

52cbe23

What machine were you running the ADF on?

CISL machine

What python environment were you using?

NPL (CISL machines only)

Extra info

No response

@bitterbark bitterbark added the bug Something isn't working label Oct 27, 2022
@bitterbark
Copy link
Collaborator Author

For the record, @brianpm suggests that the get_info functions return boolean values.

@brianpm
Copy link
Collaborator

brianpm commented Dec 1, 2022

I didn't fix the problem, but I have a hypothesis for what is happening.

In adf_diag.py in create_climo is where that logic lives:

if self.get_cam_info('calc_cam_climo') or \
           self.get_baseline_info('calc_cam_climo'):

The get_cam_info method is in adf_info.py, but it doesn't do anything except:

return self.read_config_var(...)

The read_config_var method is in adf_config.py.

I'm pretty sure that what is happening is that read_config_var is working as intended like this

var = var_dict[varname]
return copy.deepcopy(var)

BUT that is a list: [False], and a list that is not empty evaluates as true:

if [False]:
    print("That's a problem")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants