opticspy / lightpipes

LightPipes for Python, "Pure Python version"
https://opticspy.github.io/lightpipes/
BSD 3-Clause "New" or "Revised" License
228 stars 53 forks source link

HTML creation, Examples #13

Closed FredvanGoor closed 7 years ago

FredvanGoor commented 7 years ago

To create html documentation I installed and used Sphinx and made a new branch to edit and create examples and to put them on the html site.

  1. install Sphinx from www.sphinx-doc.org
  2. cd /docs
  3. make html
  4. the html documents are in _build/html

I modified conf.py:

  1. Added an absolute path, '../lightpipes' to the python path. Now after 'python setup.py build_ext --inplace' modifications in lightpipes.pyx, etc are transfered to the html site automatically (For that fftw3-3.dll must be in lightpipes as well (windows))
  2. Added to extensions: 'sphinx.ext.mathjax' for LaTex and 'matplotlib.sphinxext.plot_directive' for generating plot-images from the example output automatically.
  3. I choose theme: 'classic' which allows the 'stickysidebar' option.

You can see the site as it is now on http://pythonhosted.org/LightPipes

I will add more examples from my (large) collection.

Remarks and suggestions are welcome!

Fred

guyskk commented 7 years ago

Some code like this is useless, and should remove from document:

try:
    import LightPipes
except ImportError:
    print ("LightPipes not present")
    exit()
import sys
print(sys.path)
FredvanGoor commented 7 years ago

Ok, shall do so.

guyskk commented 7 years ago

And how about put this into LightPipes?

m=1
nm=1e-9*m
um=1e-6*m
mm=1e-3*m
cm=1e-2*m

then we can use from LightPipes import m,nm,um,mm,cm to replace the code above

FredvanGoor commented 7 years ago

Is that not too complicated? We can try. We have to put m=1.0 I found in one of my examples a round-off error in for example z=11*m. We expect a double in stead of an integer.

guyskk commented 7 years ago

Not complicated I think, this can reduce many duplication code. I'm in favor of use double.

FredvanGoor commented 7 years ago

Ok, can you do it?

guyskk commented 7 years ago

No problem.

FredvanGoor commented 7 years ago

Hi, I successfully build windows wheels with miniconda after modifications of: setup.py (I had to comment out the numpy requirement to prevent error) windows\tasks.py windows\__init__.py See: wheels_log3.txt for wheel creation process

Changed __init__.py such that LP=LightPipes.Init() can be omitted and all commands can be written like 'F=Forvard(z,F)' in stead of 'F=LP.Forvard(z,F)' looks nicer! (Old notation still works, see __init__.py and un-comment the old code in Young.py to check that)

Modified all examples.

Fred

guyskk commented 7 years ago

The code like this in __init__.py:

def Axicon(phi, n1, x_shift, y_shift, F):
    return LP.Axicon(phi, n1, x_shift, y_shift, F)

can be change to:

Axicon = LP.Axicon

so that help(Axicon) works.

guyskk commented 7 years ago

Don't know why build for py27 64bit failed, I will try it in my windows tomorrow. And did you build for py34 successfully?

FredvanGoor commented 7 years ago

No compiler installed on my laptop.