California-Planet-Search / radvel

General Toolkit for Modeling Radial Velocity Data
http://radvel.readthedocs.io
MIT License
57 stars 52 forks source link

Multipanel plot does not respect uparams unless it reads a a status file #370

Open sealauren opened 1 year ago

sealauren commented 1 year ago

I passed the following to multipanel plot:

fig = MultipanelPlot(post,epoch=2454833,show_rms=True,yscale_auto=True,phase_ncols=2,phase_nrows=ceil(npl/2.), phasetext_size='small',saveplot=os.path.join(outdir,figdir,"%s_multipanel.png"%system),uparams=post.uparams).plot_multipanel(nophase=False)

where

post.uparams {'per1': 0.0, 'tc1': 0.0, 'secosw1': 0.0, 'sesinw1': 0.0, 'k1': 0.3, 'per2': -3.6e-15, 'tc2': 0.0, 'secosw2': 0.0, 'sesinw2': 0.0, 'k2': 0.31, 'dvdt': 0.0, 'curv': 0.0, 'gamma_harpsn': 0.27, 'jit_harpsn': 0.21, 'gamma_j': 0.43, 'jit_j': 0.26, 'tp1': 0.0, 'e1': 0.0, 'w1': 0.0, 'tp2': 0.0, 'e2': 0.0, 'w2': 0.0, 'mpsini1': 0.41, 'a1': 7.6e-09, 'musini1': 1.4e-06, 'rhop1': 0.83, 'mpsini2': 1.6, 'a2': 4.3e-07, 'musini2': 5.4e-06, 'rhop2': 0.79}

and

In [11]: post.maxparams Out[11]: {'per1': 0.837491225, 'tc1': 131.57500000018626, 'secosw1': 0.0, 'sesinw1': 0.0, 'k1': 2.6, 'per2': 45.29422297, 'tc2': 138.67900000000373, 'secosw2': 0.0, 'sesinw2': 0.0, 'k2': 2.22, 'dvdt': 0.0, 'curv': 0.0, 'gamma_harpsn': 0.57, 'jit_harpsn': 2.58, 'gamma_j': -0.55, 'jit_j': 3.6, 'tp1': 131.36562719393626, 'e1': 0.0, 'w1': 0.0, 'tp2': 127.35544425750372, 'e2': 0.0, 'w2': 0.0, 'mpsini1': 3.59, 'a1': 0.0168191516, 'musini1': 1.19e-05, 'rhop1': 6.2, 'mpsini2': 11.6, 'a2': 0.24053546, 'musini2': 3.84e-05, 'rhop2': 4.9}

The behavior I expected was for the plot to display a value and error for msini of each planet (as provided in the posterior object). However, the multipanel plot did not include information about my provided parameters and errors. This appears to be because multipanel explicitly only plots P, K, and e at first: print_params = ['per', 'k', 'e'] units = {'per': 'days', 'k': plot.latex['ms'], 'e': ''} which can only be augmented by reading in the MCMC chains (assuming a status file correctly pointing to the chains is provided in the expected location): if hasattr(self.post, 'derived'): chains = pd.read_csv(self.status['derive']['chainfile']) # This is the line where multipanel assumes there is a status file in a particular location, but this is only generated via the CLI self.post.nplanets = self.num_planets dp = mcmc_plots.DerivedPlot(chains, self.post) labels = dp.labels texlabels = dp.texlabels units = dp.units derived_params = ['mpsini'] for l, par in enumerate(derived_params):

sealauren commented 1 year ago

a possible fix is to also pass a "params" dict to multipanel plot, which could include derived parameters