-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to fix the period? #121
Comments
Hi @AstroJLin - here's a small example: https://gist.github.com/56707a370423d883a33bcc9049bdbf7a |
Hi,  File "/home/jlin/xinglong/RV/fixP.py", line 110, in builtins.ValueError: cannot reshape array of size 0 into shape (0,newaxis) Thanks! |
What versions of cython, numpy, and thejoker do you have installed? |
Hi, Thanks! |
What type is your variable P = xu.with_unit(pm.Constant('P', float(_P)), u.day) ? |
Hi, Although have named it something else, it still reports this error. Here I attach my data and code, could you help me to see what is happen? Thanks! from astropy.io import ascii import pymc3 as pm import thejoker as tj tbl = ascii.read( data = tj.RVData( data.plot(markersize=3) |
Oh interesting - there is something weird about the way Try changing the definitions of e and P to: e = xu.with_unit(pm.Deterministic('e', tt.as_tensor_variable(0)), u.one)
P = xu.with_unit(pm.Deterministic('P', tt.as_tensor_variable(period)), u.day) Also added your example to the bottom here: |
Hi Adrian, I have been able to fixed the period after using your suggestions. And then, when I try to run the pmx.sample() in the mcmc, it throw an error (builtins.TypeError: ('Wrong number of dimensions: expected 0, got 1 with shape (256,).', 'Container name "K"')). ###
with pm.Model():
e = xu.with_unit(pm.Deterministic('e', tt.constant(0)),
P = xu.with_unit(pm.Deterministic('P', tt.constant(period)), u.day)
prior_mcmc = tj.JokerPrior.default(
sigma_K0=100*u.km/u.s,
sigma_v=50*u.km/u.s,
pars={'e': e, 'P':P}
)
joker_mcmc = tj.TheJoker(prior_mcmc, random_state=rnd)
mcmc_init = joker_mcmc.setup_mcmc(data, samples)
print (mcmc_init)
(an error??? ) trace = pmx.sample(
tune=500, draws=1000,
start=mcmc_init,
random_seed=seed,
cores=1, chains=2)
print (az.summary(trace, var_names=prior_mcmc.par_names))
mcmc_samples = joker_mcmc.trace_to_samples(trace, data=data)
mcmc_samples.wrap_K()
print (mcmc_samples.mean().tbl['P', 'e', 'omega', 'M0', 's', 'K', 'v0'])
df = mcmc_samples.tbl.to_pandas()
df = df.drop(columns=['e', 's', 'omega','M0'])
_ = corner.corner(df,quantiles=(0.16,0.5,0.84),show_titles=True, title_kwargs={"fontsize": 12})
plt.show()
fig = plt.figure(figsize=(10, 8))
_ = tj.plot_phase_fold(mcmc_samples.median(), data)
plt.xlabel('Phase')
plt.ylabel('Radial Velocity (km/s)')
plt.show()
### ###The error??? builtins.NotImplementedError During handling of the above exception, another exception occurred:  File "/home/jlin/xinglong/RV/fixP.py", line 161, in builtins.TypeError: ('Wrong number of dimensions: expected 0, got 1 with shape (256,).', 'Container name "K"') |
For your data, mcmc_init = joker_mcmc.setup_mcmc(data, samples[0]) or by taking the MAP or maximum likelihood sample, e.g., loglike = samples.ln_unmarginalized_likelihood(data)
mcmc_init = joker_mcmc.setup_mcmc(data, samples[loglike.argmax()]) |
Hi Adrian, Here, I have two questions. First, when I using the maximum likelihood sample, I do not use the median MCMC sample to fold the data and plot residuals relative to our inferred RV model. Here, an error is report as follow:  File "/home/jlin/xinglong/RV/fixP.py", line 202, in which means that I should set up the number of samples ( mcmc_samples.median()[?]). However, I do not know which samples corresponding to the median MCMC sample? Second, If I do not try to fix the period, I do not need to set up the maximum likelihood sample as an example from the Thompson et al. 2019. So, I want to know the reason for this. Thanks! |
Hi,
I want to fix the period, which should how to set up?
Thanks!
The text was updated successfully, but these errors were encountered: