Skip to content

lat & lon profiles plot as Diagnostic tool #1934

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

Draft
wants to merge 51 commits into
base: main
Choose a base branch
from
Draft

Conversation

mcadau
Copy link
Collaborator

@mcadau mcadau commented May 15, 2025

PR description:

The aim of this PR is to make the zonal and longitudinal profiles plot from the Tropical Rainfall diagnostic part of the AQUA diagnostic tools.


  • Tests are included if a new feature is included.
  • Documentation is included if a new feature is included.
  • Docstrings are updated if needed.
  • Changelog is updated.
  • Notebooks which requires changes are updated.

Issues closed by this pull request:

Close #1923

@mcadau mcadau self-assigned this May 15, 2025
logger = log_configure(loglevel, 'plot_lat_lon_profiles')
ConfigStyle(style=style, loglevel=loglevel)

def data_coordinate_means(data, mean_type : str):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Defining this function inside the other is not really the style which we used in AQUA. If this functuon is used only by plot_lat_lon_profiles() the start its name with "_" (ie def _data_coordinate_means(...) )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes my plan was to move it in one of the util folders, so that other functions might be able to use it, also because is not a super specific computation. You think it would be better to keep it here and private?

raise ValueError("mean_type must be 'zonal' or 'meridional'")


if data_list is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

If data_list is not none what is plotted monthly data or annual_data? I would pass only one "data" object. Then you can test if it a slist (and iterate over it) or do only one plot

if mean_type == 'zonal':
return data.mean(dim='lon')
elif mean_type == 'meridional':
return data.mean(dim='lat')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am pretty sure that this is wrong ... the mean should be a weighted mean (weighting by cell areas)!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep I agree with you. I was trying to display the plots on the notebook first, and now I'll compute the weighted-area mean

@mcadau
Copy link
Collaborator Author

mcadau commented May 16, 2025

@jhardenberg thanks for your review. Yes you may have noticed that this PR is still quite draft, and it still needs some work. Thanks for your suggestions!

@mnurisso mnurisso added diagnostic improvement Improvement to existing functionality labels Jun 5, 2025
@mnurisso mnurisso added this to the AQUA Diagnostic refactoring milestone Jun 5, 2025
logger = log_configure(loglevel, 'plot_lat_lon_profiles')
ConfigStyle(style=style, loglevel=loglevel)

def data_coordinate_means(data, mean_type : str):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Idk if this is worth an entire function. Btw, is this defined inside the other function? If yes I'd avoid this

from .styles import ConfigStyle

def plot_lat_lon_profiles(monthly_data: xr.DataArray = None,
annual_data: xr.DataArray = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

use only data argument instead of monthly and annual


def plot_lat_lon_profiles(monthly_data: xr.DataArray = None,
annual_data: xr.DataArray = None,
data_labels: list = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing reference arguments

Copy link
Collaborator

Choose a reason for hiding this comment

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

also missing the std argument for the reference

from .styles import ConfigStyle
from .lat_lon_profiles import plot_lat_lon_profiles

def plot_multi_lines(data_arrays_list,
Copy link
Collaborator

Choose a reason for hiding this comment

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

check if this can be totally removed

lat_limits=lat_limits)

# Initialize the possible results
self.hourly = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

only self. annual and self.seasonal

else:
self.data.attrs['standard_name'] = var

def compute_std(self, freq: str, exclude_incomplete: bool = True, center_time: bool = True,
Copy link
Collaborator

Choose a reason for hiding this comment

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

keep it commented for now

elif str_freq == 'annual':
self.std_annual = data

def save_netcdf(self, diagnostic: str, freq: str,
Copy link
Collaborator

Choose a reason for hiding this comment

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

to correct according to your new results

with various data arrays for different frequencies (hourly, daily,
monthly, annual, seasonal annual) and their standard deviations.
"""
def __init__(self, hourly_data=None, daily_data=None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

change input args

from aqua.logger import log_configure
from .plot_base import PlotBaseMixin

class PlotLatLonProfiles(PlotBaseMixin):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove mixin, take the individual class taking care of annual plot and seasonal plot with two methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostic improvement Improvement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extract latitudinal and longitudinal plots from tropical rainfall as an Diagnostic tool
3 participants