-
Notifications
You must be signed in to change notification settings - Fork 34
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
AdfData class for streamlined I/O in plotting scripts #269
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic cleanup! However, I did have some change requests, specifically about moving the new AdfData
object to inside the AdfDiag
class, and simply updating the current plotting scripts instead of adding new *_B.py
scripts.
Otherwise the rest of my change requests should be pretty minor, although feel free to push back if something ends up being more difficult than expected. Thanks!
…data for derived time series.
@nusbaume -- Okay. I think I've got an updated version that is working. I didn't rename the scripts because I'd like @justin-richling to confirm that the plots are actually working correctly. In my limited testing using recent development runs, I had to also update I also ran into the issue where doing the derived time series was hanging, so I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks good to me now! I have a few, hopefully trivial, change requests, but I trust that hey can be resolved without a re-review from me. I also left the one comment un-resolved about replacing the lat-lon and zonal mean plots, as I figured we won't want to do this until @justin-richling has successfully tested the new routines.
Finally, my hope is that if we can get PR #310 merged in soon, and then merge this PR to the head of the ADF, that it will fix the current test failures. Of course if that turns out not to be the case then I am happy to take on getting those tests fixed before this PR is officially brought in.
Thanks!
lib/adf_dataset.py
Outdated
@@ -131,7 +129,7 @@ def load_climo_file(self, case, variablename): | |||
"""Return Dataset for climo of variablename""" | |||
fils = self.get_climo_file(case, variablename) | |||
if not fils: | |||
print(f"ERROR: Did not find climo file for variable: {variablename}. Will try to skip.") | |||
warnings.warning(f"ERROR: Did not find climo file for variable: {variablename}. Will try to skip.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think (?) this should be warn
not warning
:
warnings.warning(f"ERROR: Did not find climo file for variable: {variablename}. Will try to skip.") | |
warnings.warn(f"ERROR: Did not find climo file for variable: {variablename}. Will try to skip.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. Fixed it.
lib/adf_info.py
Outdated
except: | ||
print(" ----------- ERROR ------------") | ||
print(ts_files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is OK for now, but do you remember what the specific error was that prompted this try/except? In general we want to try and check for a specific type of exception, otherwise it could catch potential errors that we actually want to be exposed (for example if the computer itself has a system/hardware error).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this is a remnant of me trying to do testing. I'm taking it out. I was hitting a problem where multiple time series files had been generated for case (and put in the same directory). It resulted in having multiple files identified in the search that couldn't be concatenated because they had overlapping times. Maybe that needs to be revisited sometime, but I don't think this check needs to be included here.
@@ -83,7 +82,7 @@ def global_latlon_map_B(adfobj): | |||
# | |||
# Use ADF api to get all necessary information | |||
# | |||
data = AdfData(adfobj) | |||
# data = AdfData(adfobj) NO LONGER NEEDED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this script works as expected I would just delete this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
scripts/plotting/zonal_mean_B.py
Outdated
@@ -47,7 +46,7 @@ def zonal_mean_B(adfobj): | |||
|
|||
# Start by instantiating the AdfData object | |||
# and Extract needed quantities from ADF object: | |||
data = AdfData(adfobj) | |||
# data = AdfData(adfobj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this script works as expected I would just delete this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@brianpm Looks like the plots for Lat/Lon and Zonal are the same between the old way and this way. Thanks for the clean up of the code! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks for the work on this!
Okay, I think I've got everything in. It says there's conflicts with |
This PR introduces a new class called
ADFData
inlib/adf_dataset.py
. This class is instantiated with an ADFDiag instance. It is intended to hold most of the boilerplate code that is in the plotting scripts to set paths and load data. It also abstracts the treatment of "obs" and "baseline" into something that looks more unified (at least to the plotting scripts). The upshot is that using this class can reduce the amount of code in plotting scripts. As examples, I've addedzonal_mean_B.py
andglobal_latlon_map_B.py
. These are refactors of the current versions that now use ADFData, and both are quite a bit shorter in the B versions. In limited testing, I think they are producing the same output.NOTE I see that
create_climo_files.py
also appears to be changed here. I don't know why. That should not be part of this PR... I did a sync with ADF so I thought I was completely up to date. I think the changes in that file were developed to help @justin-richling with an issue with the climatology years. The code looks right, but I wasn't intending it to be part of this PR. (It can be if we double check it.)