Skip to content

Commit

Permalink
fix: deprecated tick label resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
tsutterley committed Jan 13, 2025
1 parent 1de93a8 commit 75707ab
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 76 deletions.
32 changes: 16 additions & 16 deletions gravity_toolkit/associated_legendre.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
"""

Expand Down Expand Up @@ -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
"""

Expand Down Expand Up @@ -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
"""

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions gravity_toolkit/legendre.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions gravity_toolkit/legendre_polynomials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions notebooks/GRACE-Harmonic-Plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 7 additions & 16 deletions scripts/calc_degree_one.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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',
Expand Down
11 changes: 4 additions & 7 deletions scripts/geocenter_compare_tellus.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions scripts/geocenter_monte_carlo.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions scripts/geocenter_ocean_models.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions scripts/geocenter_processing_centers.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 4 additions & 8 deletions scripts/monte_carlo_degree_one.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 75707ab

Please sign in to comment.