Skip to content
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

Error with pystan #24

Open
gabriel-fontinele opened this issue Sep 26, 2023 · 4 comments
Open

Error with pystan #24

gabriel-fontinele opened this issue Sep 26, 2023 · 4 comments

Comments

@gabriel-fontinele
Copy link

Hello, when I run the program the error message described below appears, and I apparently installed Pystan correctly, but when I go to import I can't, so if I just use import stan, then it works. Should I install the previous version of this module?

gabriel@gabriel-Aspire-A515-51G:/astrosoft/pyproffit-master/validation$ python test_script.py
WARNING: FITSFixedWarning: RADECSYS= 'FK5 ' / Equatorial system reference
the RADECSYS keyword is deprecated, use RADESYSa. [astropy.wcs.wcs]
File reading test passed
Excluded 2 sources
Region file test passed
Applying high-pass filter
/home/gabriel/miniconda3/lib/python3.10/site-packages/pyproffit/data.py:259: RuntimeWarning: invalid value encountered in divide
img_smoothed = np.nan_to_num(np.divide(gsb, gsexp))
Interpolating in the masked regions
Filling holes
Dmfilth test passed
Computing centroid and ellipse parameters using principal component analysis
Will search for the centroid within a region of 20 arcmin centered on RA=55.5399, DEC=-53.5573
Denoising image...
Running PCA...
Centroid position: 276.6758121528362 282.19710486450094
Corresponding FK5 coordinates: 55.688756583569834 -53.62322183974974
Ellipse axis ratio and position angle: 1.167875137382187 -170.89745485625753
Centroid calculation test failed, difference RA=0.00359309 , difference DEC=0.00077744
Determining X-ray peak
Coordinates of surface-brightness peak: 272.0 281.0
Corresponding FK5 coordinates: 55.72147733144434 -53.628226297404545
SB peak test passed
Corresponding pixels coordinates: 277.18944608325205 282.3833169452636
Surface brightness profile test passed
/home/gabriel/miniconda3/lib/python3.10/site-packages/pyproffit/fitting.py:58: VisibleDeprecationWarning: make_func_code is deprecated: Use of func_code attribute to declare parameters is deprecated. Use _parameters instead, which is a dict of parameter names to limits.
self.func_code = iminuit.util.make_func_code(iminuit.util.describe(self.model)[1:])
┌─────────────────────────────────────────────────────────────────────────┐
│ Migrad │
├──────────────────────────────────┬──────────────────────────────────────┤
│ FCN = 120.7 │ Nfcn = 263 │
│ EDM = 4.05e-05 (Goal: 0.0002) │ │
├──────────────────────────────────┼──────────────────────────────────────┤
│ Valid Minimum │ Below EDM threshold (goal x 10) │
├──────────────────────────────────┼──────────────────────────────────────┤
│ No parameters at limit │ Below call limit │
├──────────────────────────────────┼──────────────────────────────────────┤
│ Hesse ok │ Covariance accurate │
└──────────────────────────────────┴──────────────────────────────────────┘
┌───┬──────┬───────────┬───────────┬────────────┬────────────┬─────────┬─────────┬───────┐
│ │ Name │ Value │ Hesse Err │ Minos Err- │ Minos Err+ │ Limit- │ Limit+ │ Fixed │
├───┼──────┼───────────┼───────────┼────────────┼────────────┼─────────┼─────────┼───────┤
│ 0 │ beta │ 0.750 │ 0.022 │ │ │ │ │ │
│ 1 │ rc │ 4.23 │ 0.20 │ │ │ │ │ │
│ 2 │ norm │ -1.471 │ 0.015 │ │ │ │ │ │
│ 3 │ bkg │ -3.688 │ 0.015 │ │ │ │ │ │
└───┴──────┴───────────┴───────────┴────────────┴────────────┴─────────┴─────────┴───────┘
┌──────┬─────────────────────────────────────┐
│ │ beta rc norm bkg │
├──────┼─────────────────────────────────────┤
│ beta │ 0.000504 4.3e-3 -0.19e-3 0.21e-3 │
│ rc │ 4.3e-3 0.0404 -2.37e-3 1.55e-3 │
│ norm │ -0.19e-3 -2.37e-3 0.000239 -0.06e-3 │
│ bkg │ 0.21e-3 1.55e-3 -0.06e-3 0.000234 │
└──────┴─────────────────────────────────────┘
Best fit chi-squared: 120.679 for 100 bins and 96 d.o.f
Reduced chi-squared: 1.25707
Fitting test passed, output written to file test_plot_fit.pdf
Saving model image test passed, test image written to test_outmod.fits
PSF calculation test passed
WARNING: VerifyWarning: Keyword name 'ROT_ANGLE' is greater than 8 characters or contains characters not allowed by the FITS standard; a HIERARCH card will be created. [astropy.io.fits.card]
WARNING: VerifyWarning: Keyword name 'ELL_RATIO' is greater than 8 characters or contains characters not allowed by the FITS standard; a HIERARCH card will be created. [astropy.io.fits.card]
Output profile saving test passed, file written to test_sb.fits
Determining X-ray peak
Coordinates of surface-brightness peak: 272.0 281.0
Corresponding FK5 coordinates: 55.72147733144434 -53.628226297404545
Running PyMC3 reconstruction
JAX not found, using default sampler
Running MCMC...
|█████████████| 100.00% [360/360 00:00<00:00 logp = -637.88, ||grad|| = 1.5661]
Only 100 samples in chain.
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (4 chains in 4 jobs)
NUTS: [coefs, bkg]
Sampling 4 chains for 500 tune and 100 draw iterations (2_000 + 400 draws total) took 135 seconds.
The rhat statistic is larger than 1.01 for some parameters. This indicates problems during sampling. See https://arxiv.org/abs/1903.08008 for details
The effective sample size per chain is smaller than 100 for some parameters. A higher number is needed for reliable rhat and ess computation. See https://arxiv.org/abs/1903.08008 for details
There were 40 divergences after tuning. Increase target_accept or reparameterize.
Chain 0 reached the maximum tree depth. Increase max_treedepth, increase target_accept or reparameterize.
Chain 1 reached the maximum tree depth. Increase max_treedepth, increase target_accept or reparameterize.
Chain 2 reached the maximum tree depth. Increase max_treedepth, increase target_accept or reparameterize.
Chain 3 reached the maximum tree depth. Increase max_treedepth, increase target_accept or reparameterize.
Done.
Total computing time is: 2.420164668560028 minutes
/home/gabriel/astrosoft/pyproffit-master/validation/test_script.py:147: RuntimeWarning: invalid value encountered in divide
check_pymc3_sb=np.nan_to_num(ref_pymc3[:,0]/depr.sb)
Possible issue with PyMC3 reconstruction, check plots
Possible issue with gas density calculation, check plots
Possible issue with Mgas calculation, check plots
Density profile outputted to test_density.pdf
Mgas profile outputted to test_mgas.pdf
Reconstruction test passed, results written to file test_save_all.fits
Running Onion Peeling test
Running Stan reconstruction
Traceback (most recent call last):
File "/home/gabriel/astrosoft/pyproffit-master/validation/test_script.py", line 261, in
run()
File "/home/gabriel/astrosoft/pyproffit-master/validation/test_script.py", line 231, in run
depr_stan.Multiscale(backend='stan', nmcmc=1000, bkglim=25.)
File "/home/gabriel/miniconda3/lib/python3.10/site-packages/pyproffit/deproject.py", line 948, in Multiscale
Deproject_Multiscale_Stan(self,bkglim=bkglim,back=back,nmcmc=nmcmc,samplefile=samplefile,nrc=nrc,nbetas=nbetas,depth=depth,min_beta=min_beta)
File "/home/gabriel/miniconda3/lib/python3.10/site-packages/pyproffit/deproject.py", line 477, in Deproject_Multiscale_Stan
import stan_utility as su
File "/home/gabriel/miniconda3/lib/python3.10/site-packages/stan_utility/init.py", line 1, in
from stan_utility.utils import compile_model, check_all_diagnostics
File "/home/gabriel/miniconda3/lib/python3.10/site-packages/stan_utility/utils.py", line 1, in
import pystan
ModuleNotFoundError: No module named 'pystan'
gabriel@gabriel-Aspire-A515-51G:
/astrosoft/pyproffit-master/validation$ python
Python 3.10.11 (main, May 16 2023, 00:28:57) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import stan
import pystan
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'pystan'
exit()

@domeckert
Copy link
Owner

Seems like a duplicate from this issue:

#21

Try the following:

pip install pystan<3.0

@gabriel-fontinele
Copy link
Author

the command doesn't work, it said nonexistent file or directory

@domeckert
Copy link
Owner

Add quotes

pip install "pystan<3.0"

@ktrehaeven
Copy link

Hi. I'm getting a similar error. Any work-arounds @gabriel-fontinele ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants