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 figure preprocessing scripts to precip variability metrics #1069

Merged
merged 10 commits into from
Mar 22, 2024

Conversation

acordonez
Copy link
Collaborator

@acordonez acordonez commented Mar 12, 2024

This PR add three scripts to pcmdi_metrics/precip_variability/scripts_pcmdi/. These scripts can be used to postprocess the netcdf outputs from the precip variability metrics into data to make Figure 6. This PR only includes the custom defined regional metrics case where each region is in a separate run. It does not address postprocessing for the default zonal average regions.
Scripts:
calc_ps_area.freq.mean.regional.py
calc_ps_area.mean.regional.py
calc_ps_freq.mean.regional.py

@acordonez acordonez requested review from msahn and lee1043 March 13, 2024 00:00
@lee1043
Copy link
Contributor

lee1043 commented Mar 13, 2024

Thanks for adding these scripts. Can you rename file names to use underscores instead of periods in the middle of file names?

del psdmfm[frc][mip][dat][var][dom]
psdmfm[frc][mip][dat][var][dom] = {}
print(dom)
for frq in frqs:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@msahn In this loop, lines 74-130, I would like to double-check that all the time scales are being correctly sliced. If you could review this section I would greatly appreciate it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For semi-annual and annual, I use np.amax instead of np.nanmean to select maximum power within their range as below. This is to handle CMIP models that have different periods for semi-annual and annual cycles because they use different calendars (e.g., 360-day, 365-day, and Gregorian).

elif frq == "semi-annual": # 180day=<pr=<183day
idx2 = prdday_to_frqidx(180, frequency, ntd)
idx1 = prdday_to_frqidx(183, frequency, ntd)
amfm = np.amax(am[idx1 : idx2 + 1])
elif frq == "annual": # 360day=<pr=<366day
idx2 = prdday_to_frqidx(360, frequency, ntd)
idx1 = prdday_to_frqidx(366, frequency, ntd)
amfm = np.amax(am[idx1 : idx2 + 1])

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@msahn Thank you for pointing this out! I have another question about the sub-daily timescale indices. If I'm interpreting this correctly, are we getting the average of data at frequencies equal to or larger than the sub-daily frequency?

amfm = np.nanmean(am[idx1 + 1 :])

Copy link
Collaborator

Choose a reason for hiding this comment

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

For the sub-daily timescale, we average frequencies larger than 1 day (pr<1day). The frequency of 1day is included in the synoptic timescale (1day=<pr<20day). This information is written as comments in the code.

@acordonez
Copy link
Collaborator Author

Thanks for adding these scripts. Can you rename file names to use underscores instead of periods in the middle of file names?

Done

@lee1043
Copy link
Contributor

lee1043 commented Mar 13, 2024

Looks good to me!

@acordonez acordonez merged commit d05a7fe into main Mar 22, 2024
5 checks passed
@acordonez acordonez deleted the 1064_ao_fig_scripts branch March 22, 2024 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants