-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add analysis task for waves #869
Conversation
Hello @sbrus89! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
@xylar, we should talk about how to clean this up before merging, but I wanted to get a PR started so I don't forget about it. |
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.
@sbrus89, this is really great! I'm excited to get this analysis in.
I hope my comments aren't too overwhelming or confusing but we can discuss them in a bit when we have our usual call.
if field['mpas'] == 'timeMonthly_avg_peakWaveFrequency': | ||
maskedVar = (cellMasks*(1.0/ds[field['prefix']])).compute() | ||
varRange=(0.0,15.0) | ||
else: | ||
maskedVar = (cellMasks*ds[field['prefix']]).compute() | ||
varRange=(0.0,10.0) |
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.
varRange
shouldn't be hard coded here. It should come from a config option.
field['prefix']
is not the variable you want with the changes I suggested above:
if field['mpas'] == 'timeMonthly_avg_peakWaveFrequency': | |
maskedVar = (cellMasks*(1.0/ds[field['prefix']])).compute() | |
varRange=(0.0,15.0) | |
else: | |
maskedVar = (cellMasks*ds[field['prefix']]).compute() | |
varRange=(0.0,10.0) | |
var = ds[mpas] | |
if mpas == 'peakWaveFrequency': | |
var = 1.0/var | |
varRange=(0.0,15.0) | |
else: | |
varRange=(0.0,10.0) | |
maskedVar = (cellMasks*var).compute() |
varRange=(0.0,10.0) | ||
|
||
for index, regionName in enumerate(regionNames): | ||
print(' '+regionName) |
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.
print(' '+regionName) | |
print(f' {regionName}') |
plt.savefig(outDirectory+'/'+field['prefix']+'_'+self.season+'_'+regionName.replace(' ','_')+'.png') | ||
f = open(outDirectory+'/'+field['prefix']+'_'+self.season+'_'+regionName.replace(' ','_')+'.txt','w') | ||
heights = [patch.get_height() for patch in ax.patches] | ||
widths = [patch.get_width() for patch in ax.patches] | ||
xloc = [patch.get_xy()[0] for patch in ax.patches] | ||
for h,w,x in zip(heights,widths,xloc): | ||
f.write('{} {} {}\n'.format(x,w,h)) | ||
f.close() |
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.
plt.savefig(outDirectory+'/'+field['prefix']+'_'+self.season+'_'+regionName.replace(' ','_')+'.png') | |
f = open(outDirectory+'/'+field['prefix']+'_'+self.season+'_'+regionName.replace(' ','_')+'.txt','w') | |
heights = [patch.get_height() for patch in ax.patches] | |
widths = [patch.get_width() for patch in ax.patches] | |
xloc = [patch.get_xy()[0] for patch in ax.patches] | |
for h,w,x in zip(heights,widths,xloc): | |
f.write('{} {} {}\n'.format(x,w,h)) | |
f.close() | |
regionSuffix = regionName.replace(' ','_') | |
filePrefix = os.path.join( | |
outDirectory, f'{prefix}_{self.season}_{regionSuffix}') | |
plt.savefig(f'{filePrefix}.png') | |
with open(f'{filePrefix}.txt', 'w') as f: | |
heights = [patch.get_height() for patch in ax.patches] | |
widths = [patch.get_width() for patch in ax.patches] | |
xloc = [patch.get_xy()[0] for patch in ax.patches] | |
for h, w, x in zip(heights, widths, xloc): | |
f.write(f'{x} {w} {h}\n') |
@sbrus89, it looks like you rebased onto |
@xylar, yes. thanks for catching that. Force of habit, I guess. |
- Started with climatology_map_antarctic_melt.py - Partially complete
- Hack to get around standard region group
@xylar - I hope this is getting closer, but I'm sure it needs another round of suggestions from you when you have a chance. If you want to test, I have a config file here: Here's an example of what this should produce for |
Yay, with my latest suggestions, I'm no longer seeing seams in the Arctic/Antarctic observational plots: |
@xylar, I incorporated all your suggestions and tested again. The output is here: |
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 fantastic! I ran a test with just waves and things look great this time. Thanks for making the changes I requested.
I'm going to run my usual test suite. I won't merge just yet as we discussed because this won't go in until the next version (1.9.0).
@sbrus89, one thing I forgot is that you need to add some documentation. Could you find a similar analysis tasks in the docs and make a copy? The observations also need to be documented. That's a process we should talk through. |
@xylar, I was going to ask about that. Yes, I'll take care of that documentation for the analysis task and follow up with you on the observations. |
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'm seeing failures in main vs. control analysis. The issue is that the gallery title includes the obs_type
, but that isn't defined when you aren't comparing with obs.
It also might not make sense to have galleries for both sets of obs (and the names of the gallery groups may also not make sense) when you are doing a main vs. control run since the obs aren't included in the plots.
The situation with the obs isn't actually all that complicated. You need to fill in something in this XML file: Then, we need to run the python script there to generate the readme and the bibtex file that we'll put in the WAVES directory next to the obs files. Some documentation will also get generated automatically from the xml file. You should refer to that in your documentation for the analysis task. Again, find an example of another analysis task with obs to use as a template. |
@sbrus89, could you please change the |
Retesting looks good. I reran the same analysis I had done before and the changes look fine. I also ran the test suite again and everything except the docs worked as expected, and the docs were fine when I ran them manually so I think it's a fluke. |
Docs are also fine in CI here. |
Excellent work on this, @sbrus89! |
This adds climatology and regional analyses for E3SM runs with WAVEWATCH III.
Checklist (for @xylar) before merging:
/lcrc/group/e3sm/diagnostics/observations/Ocean/*
to/lcrc/group/e3sm/public_html/diagnostics/observations/Ocean/
obs.xml
and copy to/lcrc/group/e3sm/public_html/diagnostics/observations/Ocean/*