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

Wrong detection of CF version when running on multiple files with different CF version #104

Open
jkretz opened this issue May 17, 2022 · 0 comments
Assignees
Labels

Comments

@jkretz
Copy link
Contributor

jkretz commented May 17, 2022

When running the CF-Checker on multiple files with different CF versions using the auto-detection of the CF version (i.e. cfchecks -v auto file_cf_1_6.nc file_cf_1_7.nc), the CF-Checker will check for compatibility with the CF version of the first file (in this example CF-1.6 ) for all files given.

The issue is related to the following code snippet:

#if 'auto' version, check the CF version in the file
#if none found, use the default
if not self.version:
self.version = self.getFileCFVersion()
if not self.version:
self._add_warn("Cannot determine CF version from the Conventions attribute; checking against latest CF version: %s" % newest_version)
self.version = newest_version

The reason for this is that when the CF-Checker is being run on the first file, self.version is being set to a vaild CF version. For the second file, self.version is already set properly, so the code in the if-statement is not executed, causing the CF version to remain unchanged.

A simple fix would be to put the initialization of the CFChecker class into the file loop inside the main function. In this case, self.version gets reset every time a new file is processed and the CF version will be read from each file, but this could mess up the inst.get_total_counts(), but I haven't looked into it.

@RosalynHatcher RosalynHatcher self-assigned this Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants