pyNLO / PyNLO

Python package for nonlinear optics
https://pynlo.readthedocs.io/en/latest/
GNU General Public License v3.0
103 stars 55 forks source link

issues with first use #27

Closed hn-88 closed 8 years ago

hn-88 commented 8 years ago

Hi, I've just installed anaconda2 and then pip install pynlo.

When I try to run python SCG1.py, where SCG1.py is the example given at http://pynlo.readthedocs.io/en/latest/example_simple.html

I got the following errors:

  1. IOError: [Errno 2] No such file or directory: '/home/hari/anaconda2/lib/python2.7/site-packages/pynlo/media/fibers/nist_fibers.txt' - So I just copied general_fibers.txt to nist_fibers.txt - after that, when I tried again, I got
  2. File "/home/hari/anaconda2/lib/python2.7/site-packages/pynlo/interactions/FourWaveMixing/SSFM.py", line 662, in conditional_fftshift assert chksum == np.sum(abs(x)) AssertionError

Since I'm a python newb, I'm stuck here. Any help would be welcome.

hn-88 commented 8 years ago

Complete tracebacks for the two errors are: Traceback (most recent call last): File "SCG1.py", line 48, in fiber1 = pynlo.media.fibers.fiber.FiberInstance() File "/home/hari/anaconda2/lib/python2.7/site-packages/pynlo/media/fibers/fiber.py", line 60, in init self.fiberloader = JSONFiberLoader.JSONFiberLoader('nist_fibers') File "/home/hari/anaconda2/lib/python2.7/site-packages/pynlo/media/fibers/JSONFiberLoader.py", line 33, in init file_handle = open(picklefile, 'r') IOError: [Errno 2] No such file or directory: '/home/hari/anaconda2/lib/python2.7/site-packages/pynlo/media/fibers/nist_fibers.txt'

and later, File "SCG1.py", line 57, in y, AW, AT, pulse_out = evol.propagate(pulse_in=pulse, fiber=fiber1, n_steps=Steps) File "/home/hari/anaconda2/lib/python2.7/site-packages/pynlo/interactions/FourWaveMixing/SSFM.py", line 475, in propagate self.setup_fftw(pulse_in, fiber, output_power) File "/home/hari/anaconda2/lib/python2.7/site-packages/pynlo/interactions/FourWaveMixing/SSFM.py", line 225, in setup_fftw self.A[:] = self.conditional_fftshift(pulse_in.AT, verify=True) File "/home/hari/anaconda2/lib/python2.7/site-packages/pynlo/interactions/FourWaveMixing/SSFM.py", line 662, in conditional_fftshift assert chksum == np.sum(abs(x)) AssertionError

hn-88 commented 8 years ago

Let me answer my own issue:

Problem solved by installing the latest version of pynlo from github, using pip install git+https://github.com/pyNLO/PyNLO.git

One more gotcha which might trouble newbies is that pynlo needs Python 2 and won't work out of the box with Python 3. It gives the classic error message about Print command needing parenthesis.

DanHickstein commented 8 years ago

Hi @hn-88! Thanks for bringing up these issues. Did getting the latest version also fix the issues with the "general_fibers.txt"?

Very good point about Python3. We have used lots of Py2-style print statements, and there are probably other issues with using PyNLO with Python3. In the long run, it shouldn't be too difficult to enable compatibility, but in the short run, we should certainly adjust the readme to point out that Py3 compatibility is currently not supported.

hn-88 commented 8 years ago

Yes. I installed the latest version after removing all python-related files, re-installing anaconda, and after all dependencies were met. Then, when I ran the example script, it ran without the need for any modifications.

ycasg commented 8 years ago

Thanks for pointing out the issues with the PyPi version of the code; it is slightly out-of-date. Please let us know how things go -- this code is still very much in development / research-grade!

hn-88 commented 8 years ago

Hello Dan & Gabriel,

Thanks for making this available. Please do let me know if you have any publications which you wish to be cited when citing pynlo, in case we use it for some of our research work.

I've written up details of my first use of pynlo at http://hnsws.blogspot.in/2016/05/installing-and-using-pynlo.html

DanHickstein commented 8 years ago

I put in a Pull-Request to fix the README: https://github.com/pyNLO/PyNLO/pull/28

Yes, you've got our names right :). We don't have a reference for PyNLO yet, but we'll try to get one out there soon. Check back when you need a reference.

Thanks for the write-up on your blog. I have found that FFTW is not a huge speed-up for the SSFM calculations. So, it's not super-important if it doesn't install.

Let us know how it goes! Out of curiosity, what are you hoping to use PyNLO to simulate?

hn-88 commented 8 years ago

I was planning to simulate SCG with Thorlabs PCF with lower power fs lasers on Matlab, and was googling PCF 1550 or something like that when pynlo documentation pdf with the supercontinuum example came up in the results :)

DanHickstein commented 8 years ago

Yup, that should be pretty straightforward if you have the dispersion profile of the fiber. That might actually make a really nice example for PyNLO.

Let us know how it goes!