jmeyers314 / batoid

c++ backed python optical raytracer
BSD 2-Clause "Simplified" License
22 stars 13 forks source link

Field angle projection floating point errors #70

Closed dkirkby closed 1 year ago

dkirkby commented 5 years ago

Several of the field angle projections explicitly handle (u,v) = (0,0) as a special case for scalar u and v, but cause floating-point errors when (u,v) = (0,0) is included via array args:

np.seterr(all='raise')
for proj in 'postel', 'zemax', 'gnomonic', 'stereographic', 'lambert', 'orthographic':
    try:
        batoid.utils.fieldToDirCos(0., 0., projection=proj)
    except FloatingPointError:
        print(f'{proj} failed with scalar')
    try:
        batoid.utils.fieldToDirCos(np.zeros(3), 0., projection=proj)
    except FloatingPointError:
        print(f'{proj} failed with array')

The results are:

postel failed with array
stereographic failed with array
lambert failed with array