Lenscalc is a more universal version of Edmund Optics' Focal Length Calculator.
Unlike the original version, lenscalc gives you the option to enter any set of parameters. Now you don't have to slightly adjust the surface radius to get your desired back focal length, you can just type it in. In the background there are the exact same equations.
The variables used to define the lens are the same as in the original calculator. Some of them have been renamed to be easier to type (e.g. ΦOS → D1). Only the variables that have been renamed have all three columns filled in.
Lenscalc name | Original name | Description |
---|---|---|
D1 | ΦOS | Surface 1 (object) power |
D2 | ΦIS | Surface 2 (image) power |
D | Φ | Lens power |
n1 | nOS | Object space index |
nL | Lens index | |
n2 | nIS | Image space index |
r1 | R1 | Surface 1 (object) radius |
r2 | R2 | Surface 2 (image) radius |
CT | Central thickness | |
P1 | P | Primary principle point |
P2 | P" | Secondary principle point |
f1 | fF | Front (object) focal point |
f2 | fR | Back (image) focal point |
EFL | Effective focal length | |
FFL | Front focal length | |
BFL | Back focal length | |
NPS | Shift in nodal point |
If you are using lenscalc in your code (i.e. you aren't using the web version),
the variables have the same name, they are just written without the subscript,
(e.g. D1 → D1
).
All variables except refractive indexes (n1, nL, n2) have the same unit (usually mm or cm).
Lenscalc requires Python version 3.8 or above.
There are a few ways how you can use the calculator.
The web app currently runs here.
$ python -m pip install -r requirements.txt
from lenscalc import Lens
# The first one
lens = Lens(
n1 = 1.0003,
nL = 1.5,
n2 = 1.0003,
r1 = 50,
r2 = -40,
CT = 3
)
# The second one
lens = Lens()
lens.n1 = 1.0003
lens.nL = 1.5
lens.n2 = 1.0003
lens.r1 = 50
lens.r2 = -40
lens.CT = 3
calculate
method.
lens.calculate()
print(lens)
for all variables
or print(lens.BFL)
and similar to get them one by one.$ python -m pip install -r requirements-web.txt
set
instead of export
.)
$ export FLASK_APP=lenscalc_web
$ export FLASK_ENV=development
$ export FLASK_DEBUG=1
$ flask run
$ python -m pip install -r requirements-dev.txt
$ python -m pip install -r requirements-extra.txt
$ python -m pytest
$ python -m pytest -v --durations=5
ignore
switch, use the path
to the test_variable_combinations.py
file).
Example for running the tests from the root of the repository.
$ python -m pytest --ignore=tests/test_variable_combinations.py
$ python -m pytest -n <Number of CPUs>
Have you found something that doesn't work as expected? Don't hesitate to open an issue or send a Pull Request!
This project is licensed under the MIT License.