djones1040 / PythonPhot

Simple DAOPHOT-type photometry in Python translated from IDL AstroLib photometry algorithms. Please email me with bugs, suggestions, omissions, etc. The code is citable as part of the Astrophysics Source Code Library (http://ascl.net/1501.010).
40 stars 25 forks source link

"import exceptions" fails #9

Closed stefanocovino closed 8 years ago

stefanocovino commented 8 years ago

Dear all,

I am trying to install PythonPhot on a Mac OS X desktop under python 3.4 (anaconda distribution). Apparently everything is fine, yet as soon as I try to import some module I get the following error message:

from PythonPhot import * Traceback (most recent call last): File "", line 1, in File "/Users/covino/anaconda/envs/py3k/lib/python3.3/site-packages/PythonPhot-1.0.dev0-py3.3-macosx-10.5-x86_64.egg/PythonPhot/init.py", line 16, in from . import djs_angle_match File "/Users/covino/anaconda/envs/py3k/lib/python3.3/site-packages/PythonPhot-1.0.dev0-py3.3-macosx-10.5-x86_64.egg/PythonPhot/djs_angle_match.py", line 82, in import exceptions ImportError: No module named 'exceptions'

What is this 'exceptions' module missing?

Thanks a lot, Stefano

djones1040 commented 8 years ago

Hi Stefano,

Looks like the module has been removed in python 3 because all exceptions are imported automatically. This seems to be the case in python 2 as well so I removed the 'import exceptions' lines from the code. You may have other issues as this code was all written in python 2, so just let me know if anything else comes up.

David

stefanocovino commented 8 years ago

Hi David,

many thanks.

I get this error now. Easy to fix, I guess!

from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/anaconda/envs/py3k/lib/python3.4/site-packages/PythonPhot-1.0.dev0-py3.4-macosx-10.5-x86_64.egg/PythonPhot/init.py", line 17, in from . import find File "/Users/covino/anaconda/envs/py3k/lib/python3.4/site-packages/PythonPhot-1.0.dev0-py3.4-macosx-10.5-x86_64.egg/PythonPhot/find.py", line 127 temp = row2 + i**2 ^ TabError: inconsistent use of tabs and spaces in indentation

Stefano

djones1040 commented 8 years ago

Hi Stefano,

I tried to fix it, but this doesn't pop up as an error when I run the code so could you fix this yourself and send me a merge request if it still returns an error after pulling my latest change? Thanks,

David

stefanocovino commented 8 years ago

Solved! But now here:

from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/anaconda/envs/py3k/lib/python3.4/site-packages/PythonPhot-1.0.dev0-py3.4-macosx-10.5-x86_64.egg/PythonPhot/init.py", line 17, in from . import find File "/Users/covino/anaconda/envs/py3k/lib/python3.4/site-packages/PythonPhot-1.0.dev0-py3.4-macosx-10.5-x86_64.egg/PythonPhot/find.py", line 227 stars = np.where (np.greater_equal(h[index[0][hgood],index[1][hgood]],h[hy[hgood],hx[hgood]])) ^ TabError: inconsistent use of tabs and spaces in indentation

S.

djones1040 commented 8 years ago

There may be many of these - could you fix them in the code and then let me know the line numbers for all of them?

stefanocovino commented 8 years ago

Yes, of course. Glad to help, if I can.

After that I just have:

from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/anaconda/envs/py3k/lib/python3.4/site-packages/PythonPhot-1.0.dev0-py3.4-macosx-10.5-x86_64.egg/PythonPhot/init.py", line 17, in from . import find File "/Users/covino/anaconda/envs/py3k/lib/python3.4/site-packages/PythonPhot-1.0.dev0-py3.4-macosx-10.5-x86_64.egg/PythonPhot/find.py", line 234 index = np.array([index[0][hgood][stars],index[1][hgood][stars]]) ^ TabError: inconsistent use of tabs and spaces in indentation

but later:

from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/init.py", line 15, in from . import aper File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/aper.py", line 21, in import pixwt ImportError: No module named 'pixwt'

Bye, Stefano

djones1040 commented 8 years ago

fixed! Any other bugs?

stefanocovino commented 8 years ago

After having fixed in aper.py

from . import pixwt from . import mmm

we now have again in find.py

from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/init.py", line 17, in from . import find File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/find.py", line 388 for i in range(nstar+1): ^ TabError: inconsistent use of tabs and spaces in indentation

and after having fixed it we have:

from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/init.py", line 18, in from . import getpsf File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/getpsf.py", line 212 print 'STAR X Y MAG SKY' ^ SyntaxError: Missing parentheses in call to 'print'

I fixed it with:

    print ('STAR  X  Y  MAG  SKY')
    print (istar, xc[istar], yc[istar], mag[istar], sky[istar])
    print ('')

and the same later at line 333.

Stefano

djones1040 commented 8 years ago

ok, fixed!

stefanocovino commented 8 years ago

I have a new set of minor things:

from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/init.py", line 18, in from . import getpsf File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/getpsf.py", line 7, in import daoerf, rinter, pkfit, pkfit_noise ImportError: No module named 'daoerf'

fixed with:

from . import daoerf, rinter, pkfit, pkfit_noise

And:

from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/init.py", line 18, in from . import getpsf File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/getpsf.py", line 7, in from . import daoerf, rinter, pkfit, pkfit_noise File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/pkfit.py", line 417 if debug: print niter,x,y,scale,errmag,chiold,sharp ^ SyntaxError: Missing parentheses in call to 'print'

fixed as:

        if debug: print (niter,x,y,scale,errmag,chiold,sharp)

Then again:

from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/init.py", line 18, in from . import getpsf File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/getpsf.py", line 7, in from . import daoerf, rinter, pkfit, pkfit_noise File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/pkfit.py", line 105, in import dao_value ImportError: No module named 'dao_value'

that becomes:

from . import dao_value

So, keeping trying:

from PythonPhot getpsf File "", line 1 from PythonPhot getpsf ^ SyntaxError: invalid syntax from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/init.py", line 18, in from . import getpsf File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/getpsf.py", line 7, in from . import daoerf, rinter, pkfit, pkfit_noise File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/pkfit.py", line 105, in from . import dao_value File "/Users/covino/Desktop/PythonPhot-master/PythonPhot/dao_value.py", line 5, in import daoerf ImportError: No module named 'daoerf'

that is now corrected with:

from . import daoerf from . import rinter

S.

djones1040 commented 8 years ago

OK, these should also be fixed now. Thanks!

stefanocovino commented 8 years ago

Ok, more bugs:

from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/init.py", line 18, in from . import getpsf File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/getpsf.py", line 7, in from . import daoerf, rinter, pkfit, pkfit_noise File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/pkfit_noise.py", line 448 if debug: print niter,x,y,scale,errmag,chiold,sharp ^ SyntaxError: Missing parentheses in call to 'print'


from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/init.py", line 18, in from . import getpsf File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/getpsf.py", line 7, in from . import daoerf, rinter, pkfit, pkfit_noise File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/pkfit_noise.py", line 109, in import dao_value ImportError: No module named 'dao_value'


from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/init.py", line 18, in from . import getpsf File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/getpsf.py", line 15, in from make_2d import make_2d ImportError: No module named 'make_2d'

and probably here the whole set of imports should be:

from . import make_2d from . import rebin from . import daoerf from . import rinter from . import pkfit from . import pkfit_noise


from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/init.py", line 18, in from . import getpsf File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/getpsf.py", line 15, in from . import make_2d File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/make_2d.py", line 5, in import rebin ImportError: No module named 'robin'


from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/init.py", line 21, in from . import pkfit_norecenter File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/pkfit_norecenter.py", line 629 print niter, x, y, scale, errmag, chiold, sharp ^ SyntaxError: Missing parentheses in call to 'print'


from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/init.py", line 21, in from . import pkfit_norecenter File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/pkfit_norecenter.py", line 109, in import dao_value ImportError: No module named 'do_value'


from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/init.py", line 22, in from . import pkfit_norecent_noise File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/pkfit_norecent_noise.py", line 222 print 'good', good[0] ^ SyntaxError: Missing parentheses in call to 'print'


Stefano

djones1040 commented 8 years ago

all finished

stefanocovino commented 8 years ago

Again!

from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/init.py", line 22, in from . import pkfit_norecent_noise File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/pkfit_norecent_noise.py", line 110, in import dao_value ImportError: No module named 'dao_value'


from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/init.py", line 27, in from . import rdpsf File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/rdpsf.py", line 6, in import dao_value ImportError: No module named 'dao_value'


from PythonPhot import getpsf Traceback (most recent call last): File "", line 1, in File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/init.py", line 32, in from . import photfunctions File "/Users/covino/Desktop/PythonPhot-master-2/PythonPhot/photfunctions.py", line 17, in from aper import aper ImportError: No module named 'aper'


Stefano

djones1040 commented 8 years ago

fixed

stefanocovino commented 8 years ago

fixed

Apparently now the imports are fine.

Tomorrow I’ll try it on real data and let you know.

Thanks a lot!

Stefano
stefanocovino commented 8 years ago

Hi David, here I am...

the aperture photometry seems to work fine.

I just get this warning:

/Users/covino/anaconda/envs/py3k/lib/python3.3/site-packages/PythonPhot-1.0.dev0-py3.3-macosx-10.5-x86_64.egg/PythonPhot/mmm.py:121: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future skymid = 0.5_sky[(nsky-1)/2] + 0.5_sky[nsky/2] #Median value of all sky values

that in a future might need to be fixed.

I am carrying out more tests.

Bye, Stefano

stefanocovino commented 8 years ago

Hi David,

even the psf photometry seems to work fine!

Again many thanks for your support.

I then have one more naive (final?) question: I see that getpsf always prints on the screen some data about the chosen objects (#, X, Y, MAG, SKY). It can be useful, but occasionally annoying too. Is it not possible to avoid it?

Bye, Stefano

djones1040 commented 8 years ago

OK, great! There are certainly still some quirks to the code, but it should produce reliable results. I'm going to add an ipython notebook with a tutorial in the near future. I also made some modest changes to pkfit yesterday that need to be tested more thoroughly, which I will do in the next couple days.

Please let me know if you find any more issues, and thanks for helping me get this Python 3-compatible!

stefanocovino commented 8 years ago

A pleasure!

Do you think to upload the code to pypi too in a future?

Bye, Stefano


Mobilis in mobile

Il giorno 24 feb 2016, alle ore 21:08, David Jones notifications@github.com ha scritto:

OK, great! There are certainly still some quirks to the code, but it should produce reliable results. I'm going to add an ipython notebook with a tutorial in the near future. I also made some modest changes to pkfit yesterday that need to be tested more thoroughly, which I will do in the next couple days.

Please let me know if you find any more issues, and thanks for helping me get this Python 3-compatible!

— Reply to this email directly or view it on GitHub.

stefanocovino commented 8 years ago

Dear David,

I found one more tab/space inconsistency:

Sorry: TabError: inconsistent use of tabs and spaces in indentation (iterstat.py, line 36)

Bye, Stefano

djones1040 commented 8 years ago

great, fixed! I'll try and get this on PyPI in the near future, I just need some free time to figure out how it all works.

stefanocovino commented 8 years ago

Again thank you a lot!

Another question (sorry...). Can the code at the present status manage PSF photometry of multiple objects simultaneously? The examples only show how to make it for single objects sequentially.

Cheers, Stefano


Mobilis in mobile

Il giorno 02 mar 2016, alle ore 21:19, David Jones notifications@github.com ha scritto:

great, fixed! I'll try and get this on PyPI in the near future, I just need some free time to figure out how it all works.

— Reply to this email directly or view it on GitHub.

djones1040 commented 8 years ago

IDL has an NSTAR code that does simultaneous fitting. I translated this to python a while back but it didn't seem to work very well so I gave it up, so unfortunately PSF fitting has to be one source at a time with this code. If you're worried about crowded fields you can likely shrink the fitting radius to solve this problem, but if it's just a speed issue then there's no solution at this point.

stefanocovino commented 8 years ago

Ok, thanks.

Stefano


Mobilis in mobile

Il giorno 02 mar 2016, alle ore 21:42, David Jones notifications@github.com ha scritto:

IDL has an NSTAR code that does simultaneous fitting. I translated this to python a while back but it didn't seem to work very well so I gave it up, so unfortunately PSF fitting has to be one source at a time with this code. If you're worried about crowded fields you can likely shrink the fitting radius to solve this problem, but if it's just a speed issue then there's no solution at this point.

— Reply to this email directly or view it on GitHub.