faitdivers / pyao

PyAO - Adaptive Optics simulation package
6 stars 0 forks source link

[WFS] unsupported operand type(s) for -: 'list' and 'float' #66

Closed JaccovdS closed 10 years ago

JaccovdS commented 10 years ago
jacco@jacco-desktop:~/Development/pyao/src$ python main.py Running simulation step 0
Traceback (most recent call last):
  File "main.py", line 146, in <module>
    runClosedLoop()
  File "main.py", line 117, in runClosedLoop
    intensities = wfs(wfRes, sensorParameters)
  File "/home/jacco/Development/pyao/src/WFS/mainWFS.py", line 50, in wfs
    phPlateStx = lensCentx - D/2 # Start postions of each lenslet on x-axis [m]
TypeError: unsupported operand type(s) for -: 'list' and 'float'
herminarto commented 10 years ago

lensCentx is a list, not a matrix, so we can't compute lensCentx - D/2 directly. Try to conver lensCentx into matrix: lensCentx = np.asarray(lensCentx)

JaccovdS commented 10 years ago

Yes that is the problem. However I think @NKant13 or @amydeeb should fix this because I can't see what the consequences are for the rest of the code.

forcaeluz commented 10 years ago

Agree with @JaccovdS on this! It's their part of the code, and the sensorParameters are also used by DM, WRF, centroids, WFS and WFG, I think the changes should get inside their function, to avoid problems in other functions which could be using the same parameters. So I assigned this item to @NKant13. Please fix it ASAP as the main is not running at this moment due to this bug. Please follow the standard procedure with pull requests.

NKant13 commented 10 years ago

I only got a phone at hand today so if you wanna solve it ASAP i suggest you just change the centLensx from a list to a matrix in the main. Otherwise ill to it tomorrow.

forcaeluz commented 10 years ago

The extent of the problem is much bigger. Apparently if I fix the parameter the whole program crashes, but with a segmentation fault. I can get the main working by removing your merge from the main, but that seems a bit too hard. When I say ASAP I really mean the "Possible" part. If today is not possible, do it when it is possible. Monday is ok for me. But please be sure that all your functions are working when you make the pull request.

JaccovdS commented 10 years ago

I can unfortunately confirm @forcaeluz findings that it causes a segmentation error. Which even causes my Python to crash.

NKant13 commented 10 years ago

In the branch of issue 66 I added a test script to test the mainWFS.py. In here I also changed the centLensx/y to be an array which it should have been from the beginning my excuses. I suggest that we change it like this for the main.py to if you all agree? because I think I am the only one that uses it yet since I inserted them a few days ago (wrongly). Now for the mainWFS.py, if you run the testWFS.py you'll see it runs and put out two figures, one of the incoming phase and the other a diagonal of airy disks. So I wander what I am doing wrong because it looks to work correctly?

forcaeluz commented 10 years ago

The only difference I see right now is between the inputs of your test function, and the inputs in the main function. Are there checks that need to be performed to the input before you can actually perform the calculations? The main is still giving you a matrix with zeros in it, while your test function uses data you generate.

Besides that, I would suggest to not copy/paste your main function into the testWFS file, but to import it from there. That is the best way to be sure you are testing the actual function that is going into the main loop.

forcaeluz commented 10 years ago

Quick test shows me that the segmentation fault happens at: phIntpF = interpolate.interp2d(XfftTemp[0],YfftTemp[:,0],phaseInfft,kind='linear')

Maybe the returned values by the ffts are not wat you expect when you have only zeros as input?

NKant13 commented 10 years ago

Improved the test function to use the main and mainWFS files. Still even if I use zeros as a input it works perfectly. I cant reproduce the error so its difficult to look for the bug. Also there are no checks that need to be performed on the input for it to work, although big phase aberrations will give you nasty intensity profiles, but no errors.

faitdivers commented 10 years ago

Then we'll close this as soon as you make a pull request and everything checks out.

forcaeluz commented 10 years ago

Still getting segmentation fault, probably still originating from the same point in the code. Could it be that you assume the incoming phase matrix to have a size, but the matrix has another size?

NKant13 commented 10 years ago

@forcaeluz by updating your scipy is this problem than solved?

forcaeluz commented 10 years ago

Problem is solved, but the issue can only be closed after I made the merge to the master. Look into the pull request.

forcaeluz commented 10 years ago

Closing it. Fixed with the merge of #68.