California-Planet-Search / rvsearch

RV Planet Search Pipeline Based on RadVel
http://california-planet-search.github.io/rvsearch/
MIT License
10 stars 5 forks source link

Summary plot issue when no significant signals are detected (with potential fix) #201

Open JenniferBurt opened 2 years ago

JenniferBurt commented 2 years ago

When RVSearch does not find any significant signals to report, the process of creating the summary figure fails due to a gridspec error that claims:

Number of rows must be a positive integer, not {nrows}
ValueError: Number of rows must be a positive integer, not 0

Because RadVel's plot_multipanel() function has a default setting of nophase=False, gridspec tries to create rows in the summary figure equal to the number of planets detected. And if that number of planets is 0, then it throws the above error.

Updating the figure command just under the "#Generate an orbit plot" section in RVSearch to flip the nophase keyword depending on whether or not signals are discovered (as shown below) has fixed this issue for me and may help others as well :)

            if self.save_outputs:
                rvplot = orbit_plots.MultipanelPlot(self.post, saveplot=outdir +
                                                    '/orbit_plot{}.pdf'.format(
                                                    self.num_planets))
                if self.num_planets == 0:
                    multiplot_fig, ax_list = rvplot.plot_multipanel(nophase=True)
                else:
                    multiplot_fig, ax_list = rvplot.plot_multipanel()
                multiplot_fig.savefig(outdir+'/orbit_plot{}.pdf'.format(
                                                        self.num_planets))
zhexingli commented 2 years ago

Can confirm this fix works! Thanks Jen!!

bjfultn commented 2 years ago

Could one of you submit a PR for the fix?

zhexingli commented 1 year ago

Just submitted a PR on this with Jen's method.