You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What command was run:
I am running plot_ts, and it produced an inaccurate timescale display (look at the boundaries vs. age)
fig=plt.figure(figsize=(9,12), dpi=60) # make the figure
ax=fig.add_subplot(121) # make the first of three subplots
pmagplotlib.plot_ts(ax,0.1,1.0,timescale='gts12')
What happened:
Changing agemin and agemax parameters in plot_ts produces wrong magnetostratigraphic cycle boundaries.
What I expected to happen:
A correct magnetostratigraphic boundary regardless of agemin and agemax parameters in plot_ts.
Data file(s):
Not applicable
PmagPy version: pmagpy-4.2.109, plus jupyter lab 3.5.3 and matplotlib 3.6.2
Possible workaround
Use sharey in the plot_ts
Use boolean to filter values within agemin and agemax limits.
Separate the text creation and line creation into a series of ifs (probably inefficient?)
Use a slightly modified timescale-chron format: [[chron_name_0, up_bound_0], [chron_name_1, up_bound_1], ..., [chron_name_N, up_bound_N], [chron_name_N, lower_bound_N]]. The gts22 timescale already adopted this.
Example timescale-chron formatting in pmag.py file, section get_ts
This is taken from ICS 2022 Magnetostratigraphic chart, ignoring the small excursions.
Proposed plot_ts for Line 3669 in pmagplotlib.py Edited Line
def plot_ts(ax, agemin, agemax, step=1.0, timescale='gts12', ylabel="Age (Ma)"):
"""
Make a time scale plot between specified ages.
Parameters:
------------
ax : figure object
agemin : Minimum age for timescale in Ma
agemax : Maximum age for timescale in Ma
step : Y tick label spacing in Ma
timescale : Time Scale [ default is Gradstein et al., (2012), gts12 ], other options are ck95, gts04, ics22, or gts12
ylabel : if set, plot as ylabel
"""
ax.set_title(timescale.upper())
column_bnd = 0.8
ax.axis([-.25, 1.5, agemax, agemin])
ax.axes.get_xaxis().set_visible(False)
# get dates and chron names for timescale
TS, Chrons = pmag.get_ts(timescale)
X, Y, Y2 = [0, column_bnd], [], []
cnt = 0
if agemin < TS[1]: # in the Brunhes
Y = [agemin, agemin] # minimum age
Y1 = [TS[1], TS[1]] # age of the B/M boundary
ax.fill_between(X, Y, Y1, facecolor='black') # color in Brunhes, black
for d in TS[1:]:
pol = cnt % 2
cnt += 1
if d <= agemax and d >= agemin:
ind = TS.index(d)
Y = [TS[ind], TS[ind]]
Y1 = [TS[ind+1], TS[ind+1]]
if pol:
# fill in every other time
ax.fill_between(X, Y, Y1, facecolor='black')
ax.plot([0, column_bnd, column_bnd, 0, 0], [agemin, agemin, agemax, agemax, agemin], 'k-')
max_y_tick = agemin + np.floor((agemax-agemin)/step)*step
total_step = np.rint(((max_y_tick-agemin)/step)+1).astype(int)
plt.yticks(np.linspace(agemin, max_y_tick, total_step))
ax.set_ylim(agemin, agemax)
if ylabel != "":
ax.set_ylabel(ylabel)
ax2 = ax.twinx()
ax2.sharey(ax)
ax2.axis('off')
"""
NEW STUFF
"""
within_range = [(age[1]>=agemin)&(age[1]<=agemax) for age in Chrons]
ticker_num = 0
for k in range(len(Chrons)-1):
c = Chrons[k]
cnext = Chrons[k+1]
d_plot = cnext[1]-(cnext[1]-c[1])
if (d_plot >= agemin) and (d_plot < agemax):
# make the Chron boundary tick
ax2.plot([column_bnd, 1.5], [c[1], c[1]], 'k-')
if ((within_range[k]==False)&(within_range[k+1]==True))&(ticker_num == 0):
d_txt = agemin + 0.5*np.abs(cnext[1]-agemin)
ax2.text(column_bnd+0.05, d_txt, c[0], verticalalignment='center')
ticker_num += 1
elif ((within_range[k]==True)&(within_range[k+1]==False))&(ticker_num == 1):
d_txt = agemax - 0.5*np.abs(agemax-c[1])
ax2.text(column_bnd+0.05, d_txt, c[0], verticalalignment='center')
ticker_num += 1
elif (within_range[k]==True)&(within_range[k+1]==True):
d_txt = cnext[1]-(cnext[1]-c[1])/2.5
ax2.text(column_bnd+0.05, d_txt, c[0], verticalalignment='center')
ax2.axis([-.25, 1.5, agemax, agemin])
The text was updated successfully, but these errors were encountered:
What command was run:
I am running
plot_ts
, and it produced an inaccurate timescale display (look at the boundaries vs. age)What happened:
Changing
agemin
andagemax
parameters inplot_ts
produces wrong magnetostratigraphic cycle boundaries.What I expected to happen:
A correct magnetostratigraphic boundary regardless of
agemin
andagemax
parameters inplot_ts
.Data file(s):
Not applicable
PmagPy version:
pmagpy-4.2.109, plus jupyter lab 3.5.3 and matplotlib 3.6.2
Possible workaround
sharey
in theplot_ts
agemin
andagemax
limits.if
s (probably inefficient?)[[chron_name_0, up_bound_0], [chron_name_1, up_bound_1], ..., [chron_name_N, up_bound_N], [chron_name_N, lower_bound_N]]
. Thegts22
timescale already adopted this.Example timescale-chron formatting in
pmag.py
file, sectionget_ts
This is taken from ICS 2022 Magnetostratigraphic chart, ignoring the small excursions.
Proposed
plot_ts
for Line 3669 inpmagplotlib.py
Edited Line
The text was updated successfully, but these errors were encountered: