sblunt / orbitize

Orbit-fitting for directly imaged objects
https://orbitize.info
Other
79 stars 44 forks source link

[code/astro] plot_orbit throws an error #171

Closed semaphoreP closed 4 years ago

semaphoreP commented 4 years ago

[this is a artificial bug report for the code/astro workshop]

I am trying to run this OFTI orbit fit and plot the results, but get the following error message:

Traceback (most recent call last): File "broken_repo.py", line 12, in s.results.plot_orbits(start_mjd=myDriver.system.data_table['epoch'][0]) File "/mnt/c/Users/Jason/Github/orbitize/orbitize/results.py", line 464, in plot_orbits plt.plot(yr_epochs, seps, color=sep_pa_color) File "/home/jwang/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2796, in plot is not None else {}), kwargs) File "/home/jwang/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 1665, in plot lines = [self._get_lines(args, data=data, kwargs)] File "/home/jwang/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 225, in call yield from self._plot_args(this, kwargs) File "/home/jwang/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 391, in _plot_args x, y = self._xy_from_xy(x, y) File "/home/jwang/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 270, in _xy_from_xy "have shapes {} and {}".format(x.shape, y.shape)) ValueError: x and y must have same first dimension, but have shapes (1,) and (100,)

To reproduce this bug, check out the broken_orbitize branch and run the following lines of code:

import matplotlib.pyplot as plt
import orbitize.driver

myDriver = orbitize.driver.Driver("broken_repo.csv", 'OFTI', 1, 1.22, 56.95, mass_err=0.08, plx_err=0.26)

s = myDriver.sampler
s.run_sampler(1000)

# test orbit plot generation
s.results.plot_orbits(start_mjd=myDriver.system.data_table['epoch'][0])
plt.show()

The data file "broken_repo.csv" is below:

epoch,object,sep,sep_err,pa,pa_err
81345.0,1,155.1,3.0,29.3,0.9
81399.79,1,148.1,3.0,39.3,1.0