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

Refractors run_analysis to support generalization #26

Merged
merged 1 commit into from
Oct 7, 2016

Conversation

pwolfram
Copy link
Contributor

@pwolfram pwolfram commented Oct 6, 2016

Results from this merge should be identical to the previous version of the run script and the refractor is in preparation to help meet needs in issues, e.g., #20.

@pwolfram
Copy link
Contributor Author

pwolfram commented Oct 6, 2016

@milenaveneziani, do you mind taking a quick look at this and can I still test in the standard way on edison? @xylar obviously should review the code because he wrote run_analysis.py but the basic idea is to clean up the code and modularize as we have more file checking to do so that this is cleaner and we don't repeat code.

return False
errmsg = "Path %s not found. Exiting..." % inpath
if warn:
print 'WARNING!!! ' + errmsg
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question: when would the Warning be issued in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warn is a flag that the user can specify. It defaults to False. This would be useful if you just wanted to see if a file or directory exists but don't want to raise a SystemError. We can get rid of this if you don't think it is useful because it is vestigial code. I used it to get around the line if config.get('case', 'ref_casename_v0') is not 'None': below but ended up using that form instead of this function with warn=True because it was cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove it for now. We can always add it back if we need it.


if config.get('case', 'ref_casename_v0') is not 'None':
indir_v0data = path_existence(config, 'paths','ref_archive_v0_ocndir')
indir_v0data = path_existence(config, 'paths','ref_archive_v0_seaicedir')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really need indir_v0data at this point, right? We had it before only to check on its existence, but it seems that path_existence(...) should take care of this by itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. The argument doesn't need to be stored and I'll remove it.

usesi = config.getboolean('seaice_timeseries', 'generate')
sicompobs = config.getboolean('seaice_timeseries', 'compare_with_obs')
simodelvobs = config.getboolean('seaice_modelvsobs', 'generate')
if (usesi and sicompobs) or simodelvobs:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you possibly change the new variable names to make them more readable? Something like:
usesi --> use_seaice
sicompobs --> seaice_compare_obs
simodelvobs --> seaice_modelvsobs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8 standards are that names with underscores are for functions, but surprisingly it doesn't clearly specify variable names. Also, typically variable names should be 5-10 chars long, hence my choice of variable names. I was trying to avoid aliasing with known usage of functions but you are right, it is better in this case and I'll make this change.

if (usesi and sicompobs) or simodelvobs:
# we will need sea-ice observations. Make sure they're there
for obsFile in ['obs_iceareaNH', 'obs_iceareaSH', 'obs_icevolNH', 'obs_icevolSH']:
obs_filename = path_existence('seaIceData', obsFile, ignorestr='none')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above about the need for obs_filename.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it isn't needed.

@milenaveneziani
Copy link
Collaborator

@pwolfram: I added some comments in the review. Thanks for submitting this PR.

@pwolfram pwolfram force-pushed the run_analysis_refractor branch from 579830d to 397cd3b Compare October 6, 2016 18:04
@pwolfram
Copy link
Contributor Author

pwolfram commented Oct 6, 2016

@milenaveneziani, I've made the changes as you requested. The next step is to test this on edison.

@pwolfram pwolfram force-pushed the run_analysis_refractor branch from 397cd3b to a5783ef Compare October 6, 2016 18:14
@milenaveneziani
Copy link
Collaborator

@pwolfram: I will test it in standalone on IC. Running on edison/within the ACME script means dealing with submodule and a non-merged branch, which I am not sure how to deal with right now.

# Checks on directory/files existence:
indir = path_existence(config, 'paths', 'archive_dir_ocn')

if config.get('case', 'ref_casename_v0') is not 'None':
Copy link
Collaborator

@milenaveneziani milenaveneziani Oct 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @pwolfram, I neglected this before: the syntax should go back to:
if config.get('case', 'ref_casename_v0') != 'None':
because anything that is defined in the config file (with or without quotes) becomes a character and this module has no ways to recognize the special variable None. I went through this in PR #25.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milenaveneziani, doesn't the config return a string? 'None' is also a string so this shouldn't cause problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should mention this is confusing because None is a special python character and 'None' is the string "None".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To test this in PR #25, I had set ref_case_v0 to None (no quotes) in the config file, but the variable was returned as character in the python driver. It was not recognized as the variable None.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milenaveneziani, does this mean that the config file recognized it as the special character None? It sounds like this may be the case. This isn't a big deal either way and I reverted it. Thanks for catching this potential issue.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only know that whatever I was setting in the config file (quotes or no quotes), the python driver was seeing it as character "None", so the if statement was never satisfied with the syntax 'is not None'. So this was a real issue, and only treating the variable as character everywhere would solve the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense now, thanks for clarifying!

@pwolfram
Copy link
Contributor Author

pwolfram commented Oct 6, 2016

@milenaveneziani, I tested this on edison in the sub-module / non-merged branch and results are here /global/project/projectdirs/acme/pwolfram/coupled_diagnostics_20160805.A_WCYCL1850.ne30_oEC.edison.alpha7_00-20160520.A_WCYCL1850.ne30_oEC.edison.alpha6_01/index.html and all the ocean/ice plots appear to be working correctly.

@milenaveneziani
Copy link
Collaborator

@pwolfram: there is still the ref_case_v0 = None issue. I think if you set that, you will obtain similar plots (with ACME v0 stuff added to them) because the v0 data will be read anyway.

@pwolfram pwolfram force-pushed the run_analysis_refractor branch from a5783ef to c6a60a8 Compare October 6, 2016 20:22
@pwolfram
Copy link
Contributor Author

pwolfram commented Oct 6, 2016

@milenaveneziani, I fixed that issue above and you should be able to do a reset to get the commit to test under this case. Sorry about the confusion.

@pwolfram
Copy link
Contributor Author

pwolfram commented Oct 6, 2016

@milenaveneziani, as far as I'm concerned this should be ready to commit, assuming the issue with ref_casename_v0 is dealt with properly following my change.

@milenaveneziani milenaveneziani merged commit c6a60a8 into MPAS-Dev:master Oct 7, 2016
@milenaveneziani
Copy link
Collaborator

ok, great. We should keep this (and near-future commits) on the MPAS repo only, though, and commit the changes in the ACME repo after next week. Thanks @pwolfram.

@pwolfram
Copy link
Contributor Author

pwolfram commented Oct 7, 2016

Agreed @milenaveneziani, thanks for the help with this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants