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

Make evenly spaced ticks when threshold_values are not evenly spaced in CSI plots #302

Merged
merged 10 commits into from
Nov 21, 2024
2 changes: 2 additions & 0 deletions docs/appendix/yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ for csi plot, list of model names (only) user choose to set as labels.

**score_name:** csi plot only. list of scores user can choose to plot. examples are "Critical Success Index' 'False Alarm Rate' 'Hit Rate'.

**threshold_tick_style:** csi plot only. (optional) control for spacing of threshold (x-axis) ticks. example: use ``nonlinear`` when nonlinear xticks including all thresholds are desired. Any other selection (default = None) will choose xticks that are equally spaced between min(threshold_list):max(threshold_list) and likely won't include all thresholds.

**data:** This a list of model / observation pairs to be plotted where the
observation label is first and the model label is second
(e.g., ['airnow_cmaq_expt', 'airnow_rrfs_13km', 'airnow_wrfchem_v4.2'])
Expand Down
4 changes: 2 additions & 2 deletions docs/applications/forecasts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ including a newly developed research forecast model called RAP-chem every day
in near real time against the AirNow surface observations of ozone, PM\ :sub:`2.5`\,
CO, and NO\ :sub:`2` and AERONET AOD measurements.

Check out the full analysis for each forecast `here <https://rapidrefresh.noaa.gov/RAPchemEPA/>`__.
Check out the full analysis for each forecast `here <https://rapidrefresh.noaa.gov/monet_rrfs_verif/>`__.

This includes a new feature developed by NOAA GSL summer student, Mackenzie Arnold,
to `interactively view plots for individual surface sites online <https://rapidrefresh.noaa.gov/RAPchemEPAsites/>`__.
to `interactively view plots for individual surface sites online <https://rapidrefresh.noaa.gov/monet_rrfs_verif/>`__.

The code to produce this analysis using MELODIES MONET is in the
``examples/forecast_evaluation`` folder on GitHub.
Expand Down
4 changes: 3 additions & 1 deletion melodies_monet/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,7 @@ def plotting(self):
threshold_list = grp_dict['threshold_list']
score_name = grp_dict['score_name']
model_name_list = grp_dict['model_name_list']
threshold_tick_style = grp_dict.get('threshold_tick_style',None)

# first get the observational obs labels
pair1 = self.paired[list(self.paired.keys())[0]]
Expand Down Expand Up @@ -2392,7 +2393,8 @@ def plotting(self):
text_dict=text_dict,
domain_type=domain_type,
domain_name=domain_name,
model_name_list=model_name_list)
model_name_list=model_name_list,
threshold_tick_style=threshold_tick_style)
#save figure
plt.tight_layout()
savefig(outname +'.'+score_name+'.png', loc=1, logo_height=100)
Expand Down
17 changes: 13 additions & 4 deletions melodies_monet/plots/surfplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ def Calc_Score(score_name_input,threshold_input, model_input, obs_input):

return output_score

def Plot_CSI(score_name_input,threshold_list_input, comb_bx_input,plot_dict,fig_dict,text_dict,domain_type,domain_name,model_name_list):
def Plot_CSI(score_name_input,threshold_list_input, comb_bx_input,plot_dict,fig_dict,text_dict,domain_type,domain_name,model_name_list,threshold_tick_style):

CSI_output = [] #(2, threshold len)
threshold_list = threshold_list_input
Expand Down Expand Up @@ -1566,7 +1566,10 @@ def Plot_CSI(score_name_input,threshold_list_input, comb_bx_input,plot_dict,fig_

#Make Plot
for i in range(len(CSI_output)):
plt.plot(threshold_list,CSI_output[i],'-*',label=model_name_list[i]) #CHANGE THIS ONE, MAIN PROGRAM
if threshold_tick_style == 'nonlinear':
plt.plot(range(len(threshold_list)),CSI_output[i],'-*',label=model_name_list[i])
else:
plt.plot(threshold_list,CSI_output[i],'-*',label=model_name_list[i])
ax.set_xlabel('Threshold',fontsize = text_kwargs['fontsize']*0.8)
ax.set_ylabel(score_name_input,fontsize = text_kwargs['fontsize']*0.8)
ax.tick_params(labelsize=text_kwargs['fontsize']*0.8)
Expand All @@ -1575,8 +1578,14 @@ def Plot_CSI(score_name_input,threshold_list_input, comb_bx_input,plot_dict,fig_
plt.grid()

#add '>' to xticks
labels = ['>'+item.get_text() for item in ax.get_xticklabels()]
ax.set_xticklabels(labels)
if threshold_tick_style == 'nonlinear':
threshold_string_array = [str(x) for x in threshold_list]
labels = ['>'+item for item in threshold_string_array]
ax.set_xticks(range(len(threshold_list)),labels=labels)
else:
labels = ['>'+item.get_text() for item in ax.get_xticklabels()]
ax.set_xticklabels(labels)

if domain_type is not None and domain_name is not None:
if domain_type == 'epa_region':
ax.set_title('EPA Region ' + domain_name,fontweight='bold',**text_kwargs)
Expand Down
Loading