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

Curtain plot (model) with Observations overlaid as scatter & Updated Violin Plot with bigger label fonts and ticks consistent with other plots #254

Merged
merged 22 commits into from
Sep 18, 2024

Conversation

quaz115
Copy link
Collaborator

@quaz115 quaz115 commented Mar 26, 2024

image

… other plots in aircraftplots
Copy link
Collaborator

@rschwant rschwant left a comment

Choose a reason for hiding this comment

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

Can you fix the plot title to be based on text_kwargs too. To make it look nice I also had the tickparams a bit smaller than the title and x/y labels at 0.8*. You can look at make_boxplot subroutine in surfplots.py for how to do this.

@quaz115
Copy link
Collaborator Author

quaz115 commented Apr 9, 2024

Can you fix the plot title to be based on text_kwargs too. To make it look nice I also had the tickparams a bit smaller than the title and x/y labels at 0.8*. You can look at make_boxplot subroutine in surfplots.py for how to do this.

image
Made this fix in the make_violin_plot() in aircraftplots.py (see 5f32335)

@quaz115 quaz115 requested a review from rschwant April 9, 2024 15:43
… each model-obs pair like scatter plots
@quaz115 quaz115 changed the title Updated Violin Plot with bigger label fonts and ticks consistent with other plots Curtain plot (model) with Observations overlaid as scatter & Updated Violin Plot with bigger label fonts and ticks consistent with other plots Apr 16, 2024
…ring words such as, Parameters & Returns
@quaz115
Copy link
Collaborator Author

quaz115 commented Apr 16, 2024

Curtain plot added:

The interpolate_and_clean_model_data function is responsible for preparing the model data for visualization, which involves creating a meshgrid from the time and altitude data, interpolating over any gaps, and cleaning the dataset by replacing any non-numerical values with appropriate limits. The make_curtain_plot function takes this prepared data and produces the actual visualization, plotting the model data as a contour plot (a curtain plot) and overlaying observational data as a scatter plot on top of this. The function uses the matplotlib library for plotting, allowing for a custom (color_map_custom as True) or predefined colormap (color_map_custom as False), and ensures the plot is correctly normalized using the minimum and maximum data values. The appearance of the plot(s) (e.g., labels, titles) are customized using the parameters specified in the YAML configuration.

Currently, it prints for each model-obs pair as done for scatter plots earlier. For example:


Processing curtain plot for model 'wrfchem_v4.2' and observation 'firexaq'...

image

Saving Curtain plot (Model) with Scatter Overlay (Observation) to /wrk/qrasool/output_testaircraft_PR189_uptoviolin_multiplemodels/plot_grp5.curtain.O3_CL_RYERSON.2019-09-05_12.2019-09-06_00.all.CONUS_firexaq_vs_wrfchem_v4.2.png...

@quaz115
Copy link
Collaborator Author

quaz115 commented Apr 16, 2024

Also @rschwant the test data used here is for FIREX 2019-09-05, I think model results might be a bit old for this: /wrk/qrasool/firex_mech_qzhu/run_CONUS_fv19_BEIS_1.0xISO_RACM_v4.2.2_racm_berk_vcp_noI_phot_soa/0905/* (on Meiyu)

@quaz115
Copy link
Collaborator Author

quaz115 commented Jun 11, 2024

@colin-harkins @rschwant For the latest commits to fix curtain plot, i am able to generate model curtain plot (pressure as y-axis and time as x-axis) with model scatter as overlay aligned with obs scatter (in the second subplot). Curtain and scatter profiles all share common colorbar (vmin and vmax can be user-defined or dynamically set based on the data min max) for each variable set: An example here: a) using default Spectral_r cmap:
image
image
image

  b) using user-defined custom_color_map in YAML set to True:  

image

image

image

Copy link
Collaborator

@rschwant rschwant left a comment

Choose a reason for hiding this comment

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

Great job, pulling in a very complicated plot! I had a couple questions still. I'll be in the office tomorrow if you want to talk about my comments. If you can just address these this week that works well we can work on the spatial plot another time.

@rschwant
Copy link
Collaborator

Also I just noticed can you make sure the vmin and vmax for the pressure on the y-axis for both plots are the same so it is easier to compare them?

quaz115 added 2 commits July 22, 2024 18:06
…aircraftplots
…ir separately as png now
@quaz115
Copy link
Collaborator Author

quaz115 commented Jul 24, 2024

Also I just noticed can you make sure the vmin and vmax for the pressure on the y-axis for both plots are the same so it is easier to compare them?

Lines 373-375 in aircraftplots.py now addresses this issue: # Set the same y-tick labels for both subplots and exclude the minimum value
y_ticks = axs[0].get_yticks()
y_lim = axs[0].get_ylim()
axs[1].set_yticks(y_ticks)
axs[1].set_ylim(y_lim)

…stom is used.
quaz115 added 3 commits July 30, 2024 14:07
…color_map True statement in aircratplots more explicit, colobar minima not forced to be zero now
…y list in YAML for different variables plotted
…ot types, Also in aircraftplots make_curtain_plot() now fontsize, fontweight and labelsize all linked via YAML
@quaz115
Copy link
Collaborator Author

quaz115 commented Aug 1, 2024

Latest output example (note how changed y-axis target pressure levels (y-axis) to 500 via YAML now): Pressure MIN:<xarray.DataArray 'pressure_model' ()> Size: 8B
array(5582.80372111), max: <xarray.DataArray 'pressure_model' ()> Size: 8B
array(101160.20015191), interval: 500
Saving curtain plot to /wrk/qrasool/output_testaircraft_PR189_uptoviolin_multiplemodels_racmesrlvcpFTPnew/plot_grp5.curtain.O3_CL_RYERSON.2019-09-05_12.2019-09-06_00.all.CONUS_firexaq_vs_wrfchem_v4.2.png...
time shape: (1901,), ndims: 1
altitude shape: (500,), ndims: 1
model_data_2d shape: (1901, 500), ndims: 2
pairdf shape: (1901, 648), ndims: 2
cmin and cmax set dynamically based on model and observation data to 0 and 100
Saving curtain plot to /wrk/qrasool/output_testaircraft_PR189_uptoviolin_multiplemodels_racmesrlvcpFTPnew/plot_grp5.curtain.O3_CL_RYERSON.2019-09-05_12.2019-09-06_00.all.CONUS_firexaq_vs_wrfchem_v4.2.png...
image

Copy link
Collaborator

@rschwant rschwant left a comment

Choose a reason for hiding this comment

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

Just had a couple small comments to fix for the vmin, vmax, cmin, and cmax variables and everything else looks great! Thanks for updating everything. Once these things are fixed, I can fully approve and we can merge this in.

"#343434", "#606060", "#8c8c8c", "#b8b8b8", "#e4e4e4"] #,
#"#ffffff"] #['blue','royalblue', 'cyan', 'yellow', 'orange', 'red'] ##['#440154', '#3b528b', '#21908d', '#5dc963', '#fde725'] #['purple', 'blue', 'green', 'yellow'] # Example gradient
color_levels: 30 #31 #15 #10 # Define the number of distinct colors in the color bar
#color_map: 'Spectral_r' #'jet' # This can be set instead of color_map_custom, color_levels and color_levels to set a colormap defined in matplotlob.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should one of the color_levels here be colors instead in the comment?

from .util.tools import resample_stratify
from .util.tools import vert_interp
import matplotlib.dates as mdates
import numpy as np
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you use all of these? I looks like numpy is already pulled in at the top. mdates is not used and vert_interp is not used.

#color_map: 'Spectral_r' #'jet' # This can be set instead of color_map_custom, color_levels and color_levels to set a colormap defined in matplotlob.
vmin: 120000 #Pressure in Pa #0 #Optional (y-axis limits)
vmax: 5000 # Optional #need to be edited as per min and max altitude (i.e., vmin and vmax)
interval : 500 #Pressure in Pa; target pressure interpolation steps for model curtain 2d plot
Copy link
Collaborator

Choose a reason for hiding this comment

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

It does not look like these vmin and vmax values are used in the code right now. Do you want to correct this or just take this option out?


if vmin is not None and vmax is not None:
plot_dict['ylim'] = [vmin, vmax]

Copy link
Collaborator

Choose a reason for hiding this comment

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

The vmin and vmax values from your yaml file are not linked to the vmin and vmax values used here and this code is not used later on either. So likely should delete this line. And fix this connection like specified above.

Copy link
Collaborator

@colin-harkins colin-harkins left a comment

Choose a reason for hiding this comment

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

I think once you make the changes Becky requested this looks good. I'll approve on my end.

@colin-harkins
Copy link
Collaborator

I thought this would take two approvals to be able to merge so hold off on merging until you address Becky's comments but I'll leave as is with the approval on my end.

… limits, Tested with unit change Pa to hPa, cleaned up codes and yaml
@quaz115
Copy link
Collaborator Author

quaz115 commented Sep 17, 2024

@rschwant @colin-harkins Tested with fixes for previous comments on y-axes and colorbar labels. Tested with changing units of pressure (pressure_units via yaml, distinguished between 'intervals' as y-axis tick intervals and 'num_levels' as interpolation levels for target pressures as well). Updated single model yaml as well with curtain plot config options. An example result with customized y-axis limits working well:
image

However getting this CI/Check docs build error, which I don't think is related to my changes.

@colin-harkins
Copy link
Collaborator

It looks like there are broken links in the supported datasets page and the developers guide page on the readthedocs.

(develop/developers_guide: line  175) broken    https://github.com/NOAA-CSL/MELODIES-MONET/projects/2 - 404 Client Error: Not Found for url: https://github.com/NOAA-CSL/MELODIES-MONET/projects/2
(users_guide/supported_plots: line    8) broken    https://github.com/NOAA-CSL/MELODIES-MONET/projects/3 - 404 Client Error: Not Found for url: https://github.com/NOAA-CSL/MELODIES-MONET/projects/3
(users_guide/supported_datasets: line   58) redirect  https://github.com/NOAA-CSL/MELODIES-MONET/projects/4 - permanently to https://github.com/orgs/NOAA-CSL/projects/7
(users_guide/supported_datasets: line   33) ok        https://aeronet.gsfc.nasa.gov/
(users_guide/supported_datasets: line   34) redirect  http://vista.cira.colostate.edu/Improve/ - permanently to https://vista.cira.colostate.edu/Improve/
(users_guide/supported_datasets: line   64) broken    https://github.com/NOAA-CSL/MELODIES-MONET/projects/6 - 404 Client Error: Not Found for url: https://github.com/NOAA-CSL/MELODIES-MONET/projects/6
(users_guide/supported_datasets: line   44) broken    https://github.com/NOAA-CSL/MELODIES-MONET/projects/7 - 404 Client Error: Not Found for url: https://github.com/NOAA-CSL/MELODIES-MONET/projects/7
(users_guide/supported_datasets: line   23) broken    https://github.com/NOAA-CSL/MELODIES-MONET/projects/8 - 404 Client Error: Not Found for url: https://github.com/NOAA-CSL/MELODIES-MONET/projects/8

I think potentially this is related to some restructuring of the project board link? The project board that exists now seems to be: https://github.com/orgs/NOAA-CSL/projects/6

I'm not sure if this is related to something we changed or github changed about the project board. @rschwant do you know?

Regardless, hopefully it shouldn't be too hard to find new links for these items in the project board.

@rschwant
Copy link
Collaborator

Yes, I asked Quazi to update these links. Github got rid of their classic project boards, but luckily we had already migrated to one project board, so we just need to update the ReadTheDocs for this.

@quaz115
Copy link
Collaborator Author

quaz115 commented Sep 18, 2024

@colin-harkins i did try to resolve conflicts but not sure why they are still visible on the PR?

…ject board link with text edit works
quaz115 and others added 6 commits September 18, 2024 13:10
…ODIES-MONET project board link with text edit works"

This reverts commit 79ca49e.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link
Collaborator

@rschwant rschwant left a comment

Choose a reason for hiding this comment

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

Looks great!

@quaz115 quaz115 merged commit a558c3f into NOAA-CSL:develop Sep 18, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants