Skip to content

Commit

Permalink
Merge pull request #332 from sblunt/pl_rv_plotting_bugfix
Browse files Browse the repository at this point in the history
bugfix for making orbit plots when we have a pl rv
  • Loading branch information
semaphoreP committed Jul 19, 2023
2 parents 3eefbce + 3227e13 commit 5d86209
Showing 1 changed file with 42 additions and 28 deletions.
70 changes: 42 additions & 28 deletions orbitize/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,22 @@ def plot_orbits(results, object_to_plot=1, start_mjd=51544.,
)

sep_data[radec_inds] = sep_from_ra_data
sep_data = sep_data[astr_inds]
sep_err[radec_inds] = sep_err_from_ra_data
sep_err = sep_err[astr_inds]

pa_data[radec_inds] = pa_from_dec_data
pa_data = pa_data[astr_inds]
pa_err[radec_inds] = pa_err_from_dec_data
pa_err = pa_err[astr_inds]

# Transform Sep/PA points to RA/Dec
ra_data = np.copy(data['quant1'])
ra_err = np.copy(data['quant1_err'])
dec_data = np.copy(data['quant2'])
dec_err = np.copy(data['quant2_err'])


if len(seppa_inds[0] > 0):

ra_from_seppa_data, dec_from_seppa_data = orbitize.system.seppa2radec(
Expand All @@ -398,10 +403,16 @@ def plot_orbits(results, object_to_plot=1, start_mjd=51544.,
)

ra_data[seppa_inds] = ra_from_seppa_data
ra_data = ra_data[astr_inds]
ra_err[seppa_inds] = ra_err_from_seppa_data
ra_err = ra_err[astr_inds]

dec_data[seppa_inds] = dec_from_seppa_data
dec_data = dec_data[astr_inds]

dec_err[seppa_inds] = dec_err_from_seppa_data
dec_err = dec_err[astr_inds]


# For plotting different astrometry instruments
if plot_astrometry_insts:
Expand Down Expand Up @@ -487,12 +498,13 @@ def plot_orbits(results, object_to_plot=1, start_mjd=51544.,
ax1.set_ylabel('$\\rho$ [mas]')
ax2.set_xlabel('Epoch')

if plot_astrometry_insts:
ax1_colors = itertools.cycle(astr_colors)
ax1_symbols = itertools.cycle(astr_symbols)
if plot_astrometry:
if plot_astrometry_insts:
ax1_colors = itertools.cycle(astr_colors)
ax1_symbols = itertools.cycle(astr_symbols)

ax2_colors = itertools.cycle(astr_colors)
ax2_symbols = itertools.cycle(astr_symbols)
ax2_colors = itertools.cycle(astr_colors)
ax2_symbols = itertools.cycle(astr_symbols)

epochs_seppa = np.zeros((num_orbits_to_plot, num_epochs_to_plot))

Expand Down Expand Up @@ -534,36 +546,38 @@ def plot_orbits(results, object_to_plot=1, start_mjd=51544.,
plt.plot(yr_epochs, pas, color=sep_pa_color, zorder=1)

# Plot sep/pa instruments
if plot_astrometry_insts:
for i in range(len(astr_insts)):
sep = sep_data[astr_inst_inds[astr_insts[i]]]
pa = pa_data[astr_inst_inds[astr_insts[i]]]
epochs = astr_epochs[astr_inst_inds[astr_insts[i]]]
if plot_astrometry:
if plot_astrometry_insts:

for i in range(len(astr_insts)):
sep = sep_data[astr_inst_inds[astr_insts[i]]]
pa = pa_data[astr_inst_inds[astr_insts[i]]]
epochs = astr_epochs[astr_inst_inds[astr_insts[i]]]
if plot_errorbars:
serr = sep_err[astr_inst_inds[astr_insts[i]]]
perr = pa_err[astr_inst_inds[astr_insts[i]]]
else:
yerr = None
perr = None

plt.sca(ax1)
plt.errorbar(Time(epochs,format='mjd').decimalyear,sep,yerr=serr,ms=5, linestyle='',marker=next(ax1_symbols),c=next(ax1_colors),zorder=10,label=astr_insts[i], capsize=2)
plt.sca(ax2)
plt.errorbar(Time(epochs,format='mjd').decimalyear,pa,yerr=perr,ms=5, linestyle='',marker=next(ax2_symbols),c=next(ax2_colors),zorder=10, capsize=2)
plt.sca(ax1)
plt.legend(title='Instruments', bbox_to_anchor=(1.3, 1), loc='upper right')
else:
if plot_errorbars:
serr = sep_err[astr_inst_inds[astr_insts[i]]]
perr = pa_err[astr_inst_inds[astr_insts[i]]]
serr = sep_err
perr = pa_err
else:
yerr = None
perr = None

plt.sca(ax1)
plt.errorbar(Time(epochs,format='mjd').decimalyear,sep,yerr=serr,ms=5, linestyle='',marker=next(ax1_symbols),c=next(ax1_colors),zorder=10,label=astr_insts[i], capsize=2)
plt.errorbar(Time(astr_epochs,format='mjd').decimalyear,sep_data,yerr=serr,ms=5, linestyle='',marker='o',c='purple',zorder=2, capsize=2)
plt.sca(ax2)
plt.errorbar(Time(epochs,format='mjd').decimalyear,pa,yerr=perr,ms=5, linestyle='',marker=next(ax2_symbols),c=next(ax2_colors),zorder=10, capsize=2)
plt.sca(ax1)
plt.legend(title='Instruments', bbox_to_anchor=(1.3, 1), loc='upper right')
else:
if plot_errorbars:
serr = sep_err
perr = pa_err
else:
yerr = None
perr = None

plt.sca(ax1)
plt.errorbar(Time(astr_epochs,format='mjd').decimalyear,sep_data,yerr=serr,ms=5, linestyle='',marker='o',c='purple',zorder=2, capsize=2)
plt.sca(ax2)
plt.errorbar(Time(astr_epochs,format='mjd').decimalyear,pa_data,yerr=perr,ms=5, linestyle='',marker='o',c='purple',zorder=2, capsize=2)
plt.errorbar(Time(astr_epochs,format='mjd').decimalyear,pa_data,yerr=perr,ms=5, linestyle='',marker='o',c='purple',zorder=2, capsize=2)

if rv_time_series:

Expand Down

0 comments on commit 5d86209

Please sign in to comment.