From 75707ab4f9574c048d6fb7382adebc93d132df0d Mon Sep 17 00:00:00 2001 From: Tyler Sutterley Date: Mon, 13 Jan 2025 15:57:20 -0800 Subject: [PATCH] fix: deprecated tick label resizing --- gravity_toolkit/associated_legendre.py | 32 ++++++++++++------------- gravity_toolkit/legendre.py | 4 ++-- gravity_toolkit/legendre_polynomials.py | 4 ++-- notebooks/GRACE-Harmonic-Plots.ipynb | 6 ++--- scripts/calc_degree_one.py | 23 ++++++------------ scripts/geocenter_compare_tellus.py | 11 ++++----- scripts/geocenter_monte_carlo.py | 11 ++++----- scripts/geocenter_ocean_models.py | 11 ++++----- scripts/geocenter_processing_centers.py | 11 ++++----- scripts/monte_carlo_degree_one.py | 12 ++++------ 10 files changed, 49 insertions(+), 76 deletions(-) diff --git a/gravity_toolkit/associated_legendre.py b/gravity_toolkit/associated_legendre.py index 33ae2898..cfb11abe 100644 --- a/gravity_toolkit/associated_legendre.py +++ b/gravity_toolkit/associated_legendre.py @@ -34,19 +34,19 @@ def associated_legendre(LMAX, x, Parameters ---------- LMAX: int - maximum degree of Legrendre polynomials + maximum degree of Legendre polynomials x: np.ndarray elements ranging from -1 to 1 Typically ``cos(theta)``, where ``theta`` is the colatitude in radians method: str, default 'holmes' - Method for computing the associated Legrendre polynomials + Method for computing the associated Legendre polynomials - ``'columbo'`` - ``'holmes'`` - ``'mohlenkamp'`` MMAX: int or NoneType, default None - maximum order of Associated Legrendre polynomials + maximum order of Associated Legendre polynomials astype: np.dtype, default np.float64 output variable data type @@ -76,21 +76,21 @@ def plm_colombo(LMAX, x, Parameters ---------- LMAX: int - maximum degree of Legrendre polynomials + maximum degree of Legendre polynomials x: np.ndarray elements ranging from -1 to 1 Typically ``cos(theta)``, where ``theta`` is the colatitude in radians MMAX: int or NoneType, default None - maximum order of Associated Legrendre polynomials + maximum order of Associated Legendre polynomials astype: np.dtype, default np.float64 output variable data type Returns ------- - plms: np.ndarray + plm: np.ndarray fully-normalized Legendre polynomials - dplms: np.ndarray + dplm: np.ndarray first derivative of Legendre polynomials """ @@ -155,21 +155,21 @@ def plm_holmes(LMAX, x, Parameters ---------- LMAX: int - maximum degree of Legrendre polynomials + maximum degree of Legendre polynomials x: np.ndarray elements ranging from -1 to 1 Typically ``cos(theta)``, where ``theta`` is the colatitude in radians MMAX: int or NoneType, default None - maximum order of Associated Legrendre polynomials + maximum order of Associated Legendre polynomials astype: np.dtype, default np.float64 output variable data type Returns ------- - plms: np.ndarray + plm: np.ndarray fully-normalized Legendre polynomials - dplms: np.ndarray + dplm: np.ndarray first derivative of Legendre polynomials """ @@ -277,21 +277,21 @@ def plm_mohlenkamp(LMAX, x, Parameters ---------- LMAX: int - maximum degree of Legrendre polynomials + maximum degree of Legendre polynomials x: np.ndarray elements ranging from -1 to 1 Typically ``cos(theta)``, where ``theta`` is the colatitude in radians MMAX: int or NoneType, default None - maximum order of Associated Legrendre polynomials + maximum order of Associated Legendre polynomials astype: np.dtype, default np.float64 output variable data type Returns ------- - plms: np.ndarray + plm: np.ndarray fully-normalized Legendre polynomials - dplms: np.ndarray + dplm: np.ndarray first derivative of Legendre polynomials """ @@ -308,7 +308,7 @@ def plm_mohlenkamp(LMAX, x, # Initialize the output Legendre polynomials plm = np.zeros((LMAX+1, MMAX+1, sx), dtype=astype) - dplm = np.zeros((LMAX+1,LMAX+1,sx), dtype=astype) + dplm = np.zeros((LMAX+1, LMAX+1, sx), dtype=astype) # Jacobi polynomial for the recurrence relation jlmm = np.zeros((LMAX+1, MMAX+1, sx)) # for x=cos(th): u= sin(th) diff --git a/gravity_toolkit/legendre.py b/gravity_toolkit/legendre.py index ebb6a9d3..c78246ba 100644 --- a/gravity_toolkit/legendre.py +++ b/gravity_toolkit/legendre.py @@ -10,7 +10,7 @@ Oceanography, Institute for Geophysics and Planetary Physics, UCSD. 1993 INPUTS: - l: degree of Legrendre polynomials + l: degree of Legendre polynomials x: elements ranging from -1 to 1 typically cos(theta), where theta is the colatitude in radians @@ -50,7 +50,7 @@ def legendre(l, x, NORMALIZE=False): Parameters ---------- l: int - degree of Legrendre polynomials + degree of Legendre polynomials x: np.ndarray elements ranging from -1 to 1 diff --git a/gravity_toolkit/legendre_polynomials.py b/gravity_toolkit/legendre_polynomials.py index c2e429b5..2aaedc2d 100755 --- a/gravity_toolkit/legendre_polynomials.py +++ b/gravity_toolkit/legendre_polynomials.py @@ -11,7 +11,7 @@ Pl,dPl = legendre_polynomials(lmax, np.cos(theta)) INPUTS: - lmax: maximum degree of Legrendre polynomials + lmax: maximum degree of Legendre polynomials x: elements ranging from -1 to 1 typically cos(theta), where theta is the colatitude in radians @@ -54,7 +54,7 @@ def legendre_polynomials(lmax, x, ASTYPE=np.float64): Parameters ---------- lmax: int - maximum degree of Legrendre polynomials + maximum degree of Legendre polynomials x: np.ndarray elements ranging from -1 to 1 diff --git a/notebooks/GRACE-Harmonic-Plots.ipynb b/notebooks/GRACE-Harmonic-Plots.ipynb index 0dbe58f1..3882815d 100644 --- a/notebooks/GRACE-Harmonic-Plots.ipynb +++ b/notebooks/GRACE-Harmonic-Plots.ipynb @@ -453,10 +453,8 @@ "# add x and y labels\n", "ax1.set_ylabel('Degree [l]', fontsize=13)\n", "ax1.set_xlabel('Order [m]', fontsize=13)\n", - "for tick in ax1.xaxis.get_major_ticks():\n", - " tick.label.set_fontsize(13)\n", - "for tick in ax1.yaxis.get_major_ticks():\n", - " tick.label.set_fontsize(13)\n", + "ax1.tick_params(axis='both', which='both',\n", + " labelsize=13, direction='in')\n", "\n", "# Add horizontal colorbar and adjust size\n", "# extend = add extension triangles to upper and lower bounds\n", diff --git a/scripts/calc_degree_one.py b/scripts/calc_degree_one.py index cf48ff3d..bf0f5386 100755 --- a/scripts/calc_degree_one.py +++ b/scripts/calc_degree_one.py @@ -1,7 +1,7 @@ #!/usr/bin/env python u""" calc_degree_one.py -Written by Tyler Sutterley (06/2024) +Written by Tyler Sutterley (01/2025) Calculates degree 1 variations using GRACE coefficients of degree 2 and greater, and ocean bottom pressure variations from ECCO and OMCT/MPIOM @@ -167,6 +167,7 @@ https://doi.org/10.1029/2007JB005338 UPDATE HISTORY: + Updated 01/2025: fixed deprecated tick label resizing Updated 06/2024: use wrapper to importlib for optional dependencies Updated 10/2023: generalize mission variable to be GRACE/GRACE-FO Updated 09/2023: output comprehensive netCDF4 files with all components @@ -1062,13 +1063,8 @@ def calc_degree_one(base_dir, PROC, DREL, MODEL, LMAX, RAD, prop=dict(size=16,weight='bold'), frameon=False, loc=2) ax[i].add_artist(artist) # axes tick adjustments - for tick in ax[i].xaxis.get_major_ticks(): - tick.label.set_fontsize(14) - for tick in ax[i].yaxis.get_major_ticks(): - tick.label.set_fontsize(14) - # adjust ticks - ax[i].get_xaxis().set_tick_params(which='both', direction='in') - ax[i].get_yaxis().set_tick_params(which='both', direction='in') + ax[i].tick_params(axis='both', which='both', + labelsize=14, direction='in') # labels and set limits to Swenson range ax[2].set_xlabel('Time [Yr]', fontsize=14) ax[2].set_xlim(2003, 2007) @@ -1113,13 +1109,8 @@ def calc_degree_one(base_dir, PROC, DREL, MODEL, LMAX, RAD, prop=dict(size=16,weight='bold'), frameon=False, loc=2) ax[i].add_artist(artist) # axes tick adjustments - for tick in ax[i].xaxis.get_major_ticks(): - tick.label.set_fontsize(14) - for tick in ax[i].yaxis.get_major_ticks(): - tick.label.set_fontsize(14) - # adjust ticks - ax[i].get_xaxis().set_tick_params(which='both', direction='in') - ax[i].get_yaxis().set_tick_params(which='both', direction='in') + ax[i].tick_params(axis='both', which='both', + labelsize=14, direction='in') # labels and set limits ax[2].set_xlabel('Grace Month', fontsize=14) xmin = np.floor(GSM_Ylms.month[0]/10.)*10. @@ -1475,7 +1466,7 @@ def arguments(): models['HDF5'] = 'reformatted GIA in HDF5 format' # GIA model type parser.add_argument('--gia','-G', - type=str, metavar='GIA', default='AW13-ICE6G', choices=models.keys(), + type=str, metavar='GIA', choices=models.keys(), help='GIA model type to read') # full path to GIA file parser.add_argument('--gia-file', diff --git a/scripts/geocenter_compare_tellus.py b/scripts/geocenter_compare_tellus.py index d5714594..992df24d 100644 --- a/scripts/geocenter_compare_tellus.py +++ b/scripts/geocenter_compare_tellus.py @@ -1,7 +1,7 @@ #!/usr/bin/env python u""" geocenter_compare_tellus.py -Written by Tyler Sutterley (05/2023) +Written by Tyler Sutterley (01/2025) Plots the GRACE/GRACE-FO geocenter time series for different GRACE/GRACE-FO processing centers comparing with the JPL GRACE Tellus product @@ -17,6 +17,7 @@ -M X, --missing X: Missing GRACE months in time series UPDATE HISTORY: + Updated 01/2025: fixed deprecated tick label resizing Updated 05/2023: use pathlib to define and operate on paths Updated 03/2023: place matplotlib import within try/except statement Updated 12/2022: single implicit import of gravity toolkit @@ -182,12 +183,8 @@ def geocenter_compare_tellus(grace_dir,DREL,START_MON,END_MON,MISSING): ax[j].set_xlim(xmin, xmax) ax[j].set_ylim(-9.5,8.5) # axes tick adjustments - ax[j].get_xaxis().set_tick_params(which='both', direction='in') - ax[j].get_yaxis().set_tick_params(which='both', direction='in') - for tick in ax[j].xaxis.get_major_ticks(): - tick.label.set_fontsize(14) - for tick in ax[j].yaxis.get_major_ticks(): - tick.label.set_fontsize(14) + ax[j].tick_params(axis='both', which='both', + labelsize=14, direction='in') # add legend lgd = ax[0].legend(loc=3,frameon=False) diff --git a/scripts/geocenter_monte_carlo.py b/scripts/geocenter_monte_carlo.py index 6befef94..925627a1 100644 --- a/scripts/geocenter_monte_carlo.py +++ b/scripts/geocenter_monte_carlo.py @@ -1,7 +1,7 @@ #!/usr/bin/env python u""" geocenter_monte_carlo.py -Written by Tyler Sutterley (05/2023) +Written by Tyler Sutterley (01/2025) CALLING SEQUENCE: python geocenter_monte_carlo.py --start 4 --end 237 @@ -15,6 +15,7 @@ -M X, --missing X: Missing GRACE months in time series UPDATE HISTORY: + Updated 01/2025: fixed deprecated tick label resizing Updated 05/2023: use pathlib to define and operate on paths Updated 03/2023: place matplotlib import within try/except statement Updated 12/2022: single implicit import of gravity toolkit @@ -142,12 +143,8 @@ def geocenter_monte_carlo(grace_dir,PROC,DREL,START_MON,END_MON,MISSING): ax[j].set_xlim(xmin, xmax) ax[j].set_ylim(-9.5,8.5) # axes tick adjustments - ax[j].get_xaxis().set_tick_params(which='both', direction='in') - ax[j].get_yaxis().set_tick_params(which='both', direction='in') - for tick in ax[j].xaxis.get_major_ticks(): - tick.label.set_fontsize(14) - for tick in ax[j].yaxis.get_major_ticks(): - tick.label.set_fontsize(14) + ax[j].tick_params(axis='both', which='both', + labelsize=14, direction='in') # labels and set limits ax[0].set_ylabel(f'{PROC} Geocenter Variation [mm]', fontsize=14) diff --git a/scripts/geocenter_ocean_models.py b/scripts/geocenter_ocean_models.py index a12f2ac0..cbbeb7b6 100644 --- a/scripts/geocenter_ocean_models.py +++ b/scripts/geocenter_ocean_models.py @@ -1,7 +1,7 @@ #!/usr/bin/env python u""" geocenter_ocean_models.py -Written by Tyler Sutterley (05/2023) +Written by Tyler Sutterley (01/2025) Plots the GRACE/GRACE-FO geocenter time series comparing results using different ocean bottom pressure estimates @@ -19,6 +19,7 @@ -O X, --ocean X: ocean bottom pressure products to use UPDATE HISTORY: + Updated 01/2025: fixed deprecated tick label resizing Updated 05/2023: use pathlib to define and operate on paths Updated 03/2023: place matplotlib import within try/except statement Updated 12/2022: single implicit import of gravity toolkit @@ -128,12 +129,8 @@ def geocenter_ocean_models(grace_dir,PROC,DREL,MODEL,START_MON,END_MON,MISSING): ax[j].set_xlim(xmin, xmax) ax[j].set_ylim(-9.5,8.5) # axes tick adjustments - ax[j].get_xaxis().set_tick_params(which='both', direction='in') - ax[j].get_yaxis().set_tick_params(which='both', direction='in') - for tick in ax[j].xaxis.get_major_ticks(): - tick.label.set_fontsize(14) - for tick in ax[j].yaxis.get_major_ticks(): - tick.label.set_fontsize(14) + ax[j].tick_params(axis='both', which='both', + labelsize=14, direction='in') # add legend lgd = ax[0].legend(loc=3,frameon=False) diff --git a/scripts/geocenter_processing_centers.py b/scripts/geocenter_processing_centers.py index 66db9e5b..252c9d0d 100644 --- a/scripts/geocenter_processing_centers.py +++ b/scripts/geocenter_processing_centers.py @@ -1,7 +1,7 @@ #!/usr/bin/env python u""" geocenter_processing_centers.py -Written by Tyler Sutterley (05/2023) +Written by Tyler Sutterley (01/2025) Plots the GRACE/GRACE-FO geocenter time series for different GRACE/GRACE-FO processing centers @@ -17,6 +17,7 @@ -M X, --missing X: Missing GRACE months in time series UPDATE HISTORY: + Updated 01/2025: fixed deprecated tick label resizing Updated 05/2023: use pathlib to define and operate on paths Updated 03/2023: place matplotlib import within try/except statement Updated 12/2022: single implicit import of gravity toolkit @@ -139,12 +140,8 @@ def geocenter_processing_centers(grace_dir,PROC,DREL,START_MON,END_MON,MISSING): ax[j].set_xlim(xmin, xmax) ax[j].set_ylim(-9.5,8.5) # axes tick adjustments - ax[j].get_xaxis().set_tick_params(which='both', direction='in') - ax[j].get_yaxis().set_tick_params(which='both', direction='in') - for tick in ax[j].xaxis.get_major_ticks(): - tick.label.set_fontsize(14) - for tick in ax[j].yaxis.get_major_ticks(): - tick.label.set_fontsize(14) + ax[j].tick_params(axis='both', which='both', + labelsize=14, direction='in') # add legend lgd = ax[0].legend(loc=3,frameon=False) diff --git a/scripts/monte_carlo_degree_one.py b/scripts/monte_carlo_degree_one.py index ad1a3e3a..7ecb2b6f 100644 --- a/scripts/monte_carlo_degree_one.py +++ b/scripts/monte_carlo_degree_one.py @@ -1,7 +1,7 @@ #!/usr/bin/env python u""" monte_carlo_degree_one.py -Written by Tyler Sutterley (06/2024) +Written by Tyler Sutterley (01/2025) Calculates degree 1 errors using GRACE coefficients of degree 2 and greater, and ocean bottom pressure variations from OMCT/MPIOM in a Monte Carlo scheme @@ -157,6 +157,7 @@ https://doi.org/10.1029/2005GL025305 UPDATE HISTORY: + Updated 01/2025: fixed deprecated tick label resizing Updated 06/2024: use wrapper to importlib for optional dependencies Updated 10/2023: generalize mission variable to be GRACE/GRACE-FO Updated 09/2023: add more root level attributes to output netCDF4 files @@ -904,13 +905,8 @@ def monte_carlo_degree_one(base_dir, PROC, DREL, LMAX, RAD, frameon=False, loc=2, prop=dict(size=16,weight='bold')) ax[i].add_artist(artist) # axes tick adjustments - for tick in ax[i].xaxis.get_major_ticks(): - tick.label.set_fontsize(14) - for tick in ax[i].yaxis.get_major_ticks(): - tick.label.set_fontsize(14) - # adjust ticks - ax[i].get_xaxis().set_tick_params(which='both', direction='in') - ax[i].get_yaxis().set_tick_params(which='both', direction='in') + ax[i].tick_params(axis='both', which='both', + labelsize=14, direction='in') # adjust locations of subplots and save to file fig.subplots_adjust(left=0.12,right=0.94,bottom=0.06,top=0.98,hspace=0.1) args = (PROC,DREL,model_str,ds_str)