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

Add histogram plot type and ocean histogram task #917

Merged
merged 26 commits into from
Oct 13, 2022

Conversation

cbegeman
Copy link
Collaborator

@cbegeman cbegeman commented Oct 3, 2022

Adds the ability to create histogram plots from 2-d ocean variables.

@cbegeman
Copy link
Collaborator Author

cbegeman commented Oct 3, 2022

I've tested this out on chrysalis.

Using this cfg section:

[oceanHistogram]
obsList = ['AVISO']
variableList = ['ssh', 'pressureAdjustedSSH']
weightList = ['areaCell','areaCell']
regionGroups = ['Ocean Basins']
regionNames = ['Atlantic_Basin','Pacific_Basin']
seasons =  ['ANN','JFM']
bins = 40

You can create the figures shown here:
https://web.lcrc.anl.gov/public/e3sm/diagnostic_output/ac.cbegeman/analysis/A_WCYCL1850.ne4_oQU480.anvil/clim_3-5_ts_1-5_histRegionWeight/ocean/index.html
image

@cbegeman cbegeman mentioned this pull request Oct 3, 2022
5 tasks
@cbegeman cbegeman requested a review from xylar October 3, 2022 00:19
Copy link
Collaborator

@xylar xylar left a comment

Choose a reason for hiding this comment

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

@cbegeman, this is really great work, and it will be such a nice capability to have!

I tested this out and ran across a few things that could be done to improve the task a bit. The main one is that you need to make sure the plot subtasks only run after the weight subtasks.

But it also seems like it would be a good idea to make sure the subtask names and file names include the region group, since some regions are in multiple region groups so there could be conflicts.

I'll re-test as soon as these changes are in place.

mpas_analysis/__main__.py Outdated Show resolved Hide resolved
mpas_analysis/ocean/histogram.py Outdated Show resolved Hide resolved
mpas_analysis/ocean/histogram.py Outdated Show resolved Hide resolved
mpas_analysis/ocean/histogram.py Outdated Show resolved Hide resolved
mpas_analysis/ocean/histogram.py Show resolved Hide resolved
@cbegeman
Copy link
Collaborator Author

@xylar Thanks for your review! I made the changes you suggested. After rebasing, there were still problematic typos in sea ice climatology addressed by this commit dd29f0c. Feel free to pull that out of this branch since it is not related to the histogram task.

@xylar
Copy link
Collaborator

xylar commented Oct 10, 2022

@cbegeman, oh, great, thanks for fixing the sea-ice typo! I think that's fine to fix here. I can't believe we missed that!

@xylar
Copy link
Collaborator

xylar commented Oct 10, 2022

I'll re-test now and then run the full test suite if everything goes well.

Copy link
Collaborator

@xylar xylar left a comment

Choose a reason for hiding this comment

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

Great! Just 2 small things I noticed when I ran my test, now that the web page came up. Almost done...

mpas_analysis/ocean/histogram.py Outdated Show resolved Hide resolved
mpas_analysis/ocean/histogram.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@xylar xylar left a comment

Choose a reason for hiding this comment

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

I thought we had it but that's why we do testing...

Two more little things. Please double check my suggestions, I'm not 100% sure they're right, well formatted and typo free.

mpas_analysis/ocean/histogram.py Outdated Show resolved Hide resolved
mpas_analysis/ocean/histogram.py Outdated Show resolved Hide resolved
@xylar
Copy link
Collaborator

xylar commented Oct 11, 2022

One more request would be to add some documentation, both in the API:
https://github.com/MPAS-Dev/MPAS-Analysis/blob/develop/docs/developers_guide/api.rst
and in the user's guide, similar to:
https://github.com/MPAS-Dev/MPAS-Analysis/blob/develop/docs/users_guide/tasks/regionalTSDiagrams.rst

@cbegeman
Copy link
Collaborator Author

@xylar I added the task to the docs and fixed up a couple config-related issues in the code. This is ready for your review.

@xylar
Copy link
Collaborator

xylar commented Oct 13, 2022

Running one last set of tests, then I think this will be ready to merge!

Other config options include ``lineWidth``, ``mainColor``, ``obsColor``,
``controlColor``, ``titleFontSize``, ``defaultFontSize``. For more details on
the remaining config options, see
* :ref:`config_seasons`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm seeing:

/gpfs/fs1/home/ac.xylar/mpas-work/MPAS-Analysis/add_ocean_hisogram_task/docs/users_guide/tasks/oceanHistogram.rst:113: ERROR: Unexpected indentation.

But this line looks perfectly fine to me. I'm going to ignore it but figured I'd note this in case you can spot the problem for a later clean-up PR.

@xylar
Copy link
Collaborator

xylar commented Oct 13, 2022

I thought we were there but I'm seeing an error when testing this without ncclimo:

Traceback (most recent call last):
  File "/gpfs/fs1/home/ac.xylar/chrysalis/mambaforge/envs/test_mpas_analysis_py3.9/lib/python3.9/site-packages/mpas_analysis/shared/analysis_task.py", line 322, in run
    self.run_task()
  File "/gpfs/fs1/home/ac.xylar/chrysalis/mambaforge/envs/test_mpas_analysis_py3.9/lib/python3.9/site-packages/mpas_analysis/ocean/histogram.py", line 539, in run_task
    xLabel = f"{ds[var_name].attrs['long_name']} " \
KeyError: 'long_name'

I don't think this error has anything directly to do with this PR. I think the long_name attribute isn't getting retained when we compute climatologies with python code. I'll try to fix this soon. But since this isn't a mode we actually run with very often, I'm going to let this go in with this note.

Copy link
Collaborator

@xylar xylar left a comment

Choose a reason for hiding this comment

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

Results of the test suite on Chrysalis are here:
https://web.lcrc.anl.gov/public/e3sm/diagnostic_output/ac.xylar/analysis_testing/chrysalis/add_ocean_hisogram_task/
All runs except no_ncclimo ran great, and the new documentation looks good.

@xylar xylar merged commit de9c469 into MPAS-Dev:develop Oct 13, 2022
@xylar xylar self-assigned this Oct 13, 2022
@cbegeman
Copy link
Collaborator Author

Thanks, @xylar!

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