diff --git a/batoid/data/LSST/ComCam_g.yaml b/batoid/data/LSST/ComCam_g.yaml index d1f848b7..07d2e266 100644 --- a/batoid/data/LSST/ComCam_g.yaml +++ b/batoid/data/LSST/ComCam_g.yaml @@ -40,7 +40,7 @@ opticalSystem: outer: 1.71 inner: 0.9 coordSys: - z: 6.1559766921647 + z: 6.155977 - type: Mirror name: M3 @@ -59,19 +59,19 @@ opticalSystem: type: CompoundOptic name: ComCam coordSys: - z: 4.1097066396 + z: 4.109701294941687 items: - type: Lens name: L1 medium: &silica type: SellmeierMedium - B1: 0.696183020 - B2: 0.407925877 - B3: 0.897464057 - C1: 0.00467926519 - C2: 0.0135122244 - C3: 97.9323636 + B1: 0.696182877 + B2: 0.407926020 + B3: 0.897462254 + C1: 0.00467926421 + C2: 0.0135122230 + C3: 97.9321695 items: - type: RefractiveInterface @@ -81,16 +81,17 @@ opticalSystem: R: 0.744422 obscuration: type: ClearCircle - radius: 0.192 + # radius: 0.20004 + radius: 0.189 - type: RefractiveInterface name: L1_exit surface: type: Sphere - R: 4.18068 + R: 4.180678 obscuration: type: ClearCircle - radius: 0.192 + radius: 0.20004 coordSys: z: 0.032 - @@ -98,17 +99,18 @@ opticalSystem: name: L2 medium: *silica coordSys: - z: 0.08896479090387038 + z: 0.088965 items: - type: RefractiveInterface name: L2_entrance surface: type: Sphere - R: -5.99534 + R: -5.995343 obscuration: type: ClearCircle - radius: 0.166 + # radius: 0.175 + radius: 0.161 - type: RefractiveInterface name: L2_exit @@ -117,7 +119,8 @@ opticalSystem: R: 0.639028 obscuration: type: ClearCircle - radius: 0.155 + # radius: 0.175 + radius: 0.152 coordSys: z: 0.009 - @@ -125,7 +128,7 @@ opticalSystem: name: Filter medium: *silica coordSys: - z: 0.19626409289185995 + z: 0.196264 items: - type: RefractiveInterface @@ -150,26 +153,26 @@ opticalSystem: name: L3 medium: *silica coordSys: - z: 0.27026409289185995 + z: 0.270264 items: - type: RefractiveInterface name: L3_entrance surface: type: Sphere - R: 6.10983 + R: 6.109828 obscuration: type: ClearCircle - radius: 0.108 + radius: 0.108025 - type: RefractiveInterface name: L3_exit surface: type: Sphere - R: -1.52259 + R: -1.522589 obscuration: type: ClearCircle - radius: 0.108 + radius: 0.108025 coordSys: z: 0.0155 - @@ -181,4 +184,4 @@ opticalSystem: type: ClearCircle radius: 0.11 coordSys: - z: 0.30770909289185965 + z: 0.307709 diff --git a/batoid/data/LSST/ComCam_i.yaml b/batoid/data/LSST/ComCam_i.yaml index 0cbdbe58..8513012a 100644 --- a/batoid/data/LSST/ComCam_i.yaml +++ b/batoid/data/LSST/ComCam_i.yaml @@ -40,7 +40,7 @@ opticalSystem: outer: 1.71 inner: 0.9 coordSys: - z: 6.1559766921647 + z: 6.155977 - type: Mirror name: M3 @@ -59,19 +59,19 @@ opticalSystem: type: CompoundOptic name: ComCam coordSys: - z: 4.10903938251 + z: 4.1090347440789 items: - type: Lens name: L1 medium: &silica type: SellmeierMedium - B1: 0.696183020 - B2: 0.407925877 - B3: 0.897464057 - C1: 0.00467926519 - C2: 0.0135122244 - C3: 97.9323636 + B1: 0.696182877 + B2: 0.407926020 + B3: 0.897462254 + C1: 0.00467926421 + C2: 0.0135122230 + C3: 97.9321695 items: - type: RefractiveInterface @@ -81,16 +81,17 @@ opticalSystem: R: 0.744422 obscuration: type: ClearCircle - radius: 0.192 + # radius: 0.20004 + radius: 0.189 - type: RefractiveInterface name: L1_exit surface: type: Sphere - R: 4.18068 + R: 4.180678 obscuration: type: ClearCircle - radius: 0.192 + radius: 0.20004 coordSys: z: 0.032 - @@ -98,17 +99,18 @@ opticalSystem: name: L2 medium: *silica coordSys: - z: 0.08896479090387038 + z: 0.088965 items: - type: RefractiveInterface name: L2_entrance surface: type: Sphere - R: -5.99534 + R: -5.995343 obscuration: type: ClearCircle - radius: 0.166 + # radius: 0.175 + radius: 0.161 - type: RefractiveInterface name: L2_exit @@ -117,7 +119,8 @@ opticalSystem: R: 0.639028 obscuration: type: ClearCircle - radius: 0.155 + # radius: 0.175 + radius: 0.152 coordSys: z: 0.009 - @@ -125,7 +128,7 @@ opticalSystem: name: Filter medium: *silica coordSys: - z: 0.19626409289185995 + z: 0.196264 items: - type: RefractiveInterface @@ -144,32 +147,32 @@ opticalSystem: type: ClearCircle radius: 0.1325 coordSys: - z: 0.009 + z: 0.007 - type: Lens name: L3 medium: *silica coordSys: - z: 0.27026409289185995 + z: 0.270264 items: - type: RefractiveInterface name: L3_entrance surface: type: Sphere - R: 6.10983 + R: 6.109828 obscuration: type: ClearCircle - radius: 0.108 + radius: 0.108025 - type: RefractiveInterface name: L3_exit surface: type: Sphere - R: -1.52259 + R: -1.522589 obscuration: type: ClearCircle - radius: 0.108 + radius: 0.108025 coordSys: z: 0.0155 - @@ -181,4 +184,4 @@ opticalSystem: type: ClearCircle radius: 0.11 coordSys: - z: 0.30770909289185965 + z: 0.307709 diff --git a/batoid/data/LSST/ComCam_r.yaml b/batoid/data/LSST/ComCam_r.yaml index 01bd6b79..669fb554 100644 --- a/batoid/data/LSST/ComCam_r.yaml +++ b/batoid/data/LSST/ComCam_r.yaml @@ -40,7 +40,7 @@ opticalSystem: outer: 1.71 inner: 0.9 coordSys: - z: 6.1559766921647 + z: 6.155977 - type: Mirror name: M3 @@ -59,19 +59,19 @@ opticalSystem: type: CompoundOptic name: ComCam coordSys: - z: 4.109697 + z: 4.109690049447229 items: - type: Lens name: L1 medium: &silica type: SellmeierMedium - B1: 0.696183020 - B2: 0.407925877 - B3: 0.897464057 - C1: 0.00467926519 - C2: 0.0135122244 - C3: 97.9323636 + B1: 0.696182877 + B2: 0.407926020 + B3: 0.897462254 + C1: 0.00467926421 + C2: 0.0135122230 + C3: 97.9321695 items: - type: RefractiveInterface @@ -81,16 +81,17 @@ opticalSystem: R: 0.744422 obscuration: type: ClearCircle - radius: 0.192 + # radius: 0.20004 + radius: 0.189 - type: RefractiveInterface name: L1_exit surface: type: Sphere - R: 4.18068 + R: 4.180678 obscuration: type: ClearCircle - radius: 0.192 + radius: 0.20004 coordSys: z: 0.032 - @@ -98,17 +99,18 @@ opticalSystem: name: L2 medium: *silica coordSys: - z: 0.08896479090387038 + z: 0.088965 items: - type: RefractiveInterface name: L2_entrance surface: type: Sphere - R: -5.99534 + R: -5.995343 obscuration: type: ClearCircle - radius: 0.166 + # radius: 0.175 + radius: 0.161 - type: RefractiveInterface name: L2_exit @@ -117,7 +119,8 @@ opticalSystem: R: 0.639028 obscuration: type: ClearCircle - radius: 0.155 + # radius: 0.175 + radius: 0.152 coordSys: z: 0.009 - @@ -125,7 +128,7 @@ opticalSystem: name: Filter medium: *silica coordSys: - z: 0.19626409289185995 + z: 0.196264 items: - type: RefractiveInterface @@ -150,26 +153,26 @@ opticalSystem: name: L3 medium: *silica coordSys: - z: 0.27026409289185995 + z: 0.270264 items: - type: RefractiveInterface name: L3_entrance surface: type: Sphere - R: 6.10983 + R: 6.109828 obscuration: type: ClearCircle - radius: 0.108 + radius: 0.108025 - type: RefractiveInterface name: L3_exit surface: type: Sphere - R: -1.52259 + R: -1.522589 obscuration: type: ClearCircle - radius: 0.108 + radius: 0.108025 coordSys: z: 0.0155 - @@ -181,4 +184,4 @@ opticalSystem: type: ClearCircle radius: 0.11 coordSys: - z: 0.30770909289185965 + z: 0.307709 diff --git a/batoid/data/LSST/ComCam_u.yaml b/batoid/data/LSST/ComCam_u.yaml index fa149df9..f4b7d205 100644 --- a/batoid/data/LSST/ComCam_u.yaml +++ b/batoid/data/LSST/ComCam_u.yaml @@ -40,7 +40,7 @@ opticalSystem: outer: 1.71 inner: 0.9 coordSys: - z: 6.1559766921647 + z: 6.155977 - type: Mirror name: M3 @@ -59,19 +59,19 @@ opticalSystem: type: CompoundOptic name: ComCam coordSys: - z: 4.10971713635 + z: 4.10971405528362 items: - type: Lens name: L1 medium: &silica type: SellmeierMedium - B1: 0.696183020 - B2: 0.407925877 - B3: 0.897464057 - C1: 0.00467926519 - C2: 0.0135122244 - C3: 97.9323636 + B1: 0.696182877 + B2: 0.407926020 + B3: 0.897462254 + C1: 0.00467926421 + C2: 0.0135122230 + C3: 97.9321695 items: - type: RefractiveInterface @@ -81,16 +81,17 @@ opticalSystem: R: 0.744422 obscuration: type: ClearCircle - radius: 0.192 + # radius: 0.20004 + radius: 0.189 - type: RefractiveInterface name: L1_exit surface: type: Sphere - R: 4.18068 + R: 4.180678 obscuration: type: ClearCircle - radius: 0.192 + radius: 0.20004 coordSys: z: 0.032 - @@ -98,17 +99,18 @@ opticalSystem: name: L2 medium: *silica coordSys: - z: 0.08896479090387038 + z: 0.088965 items: - type: RefractiveInterface name: L2_entrance surface: type: Sphere - R: -5.99534 + R: -5.995343 obscuration: type: ClearCircle - radius: 0.166 + # radius: 0.175 + radius: 0.161 - type: RefractiveInterface name: L2_exit @@ -117,7 +119,8 @@ opticalSystem: R: 0.639028 obscuration: type: ClearCircle - radius: 0.155 + # radius: 0.175 + radius: 0.152 coordSys: z: 0.009 - @@ -125,7 +128,7 @@ opticalSystem: name: Filter medium: *silica coordSys: - z: 0.19626409289185995 + z: 0.196264 items: - type: RefractiveInterface @@ -150,26 +153,26 @@ opticalSystem: name: L3 medium: *silica coordSys: - z: 0.27026409289185995 + z: 0.270264 items: - type: RefractiveInterface name: L3_entrance surface: type: Sphere - R: 6.10983 + R: 6.109828 obscuration: type: ClearCircle - radius: 0.108 + radius: 0.108025 - type: RefractiveInterface name: L3_exit surface: type: Sphere - R: -1.52259 + R: -1.522589 obscuration: type: ClearCircle - radius: 0.108 + radius: 0.108025 coordSys: z: 0.0155 - @@ -181,4 +184,4 @@ opticalSystem: type: ClearCircle radius: 0.11 coordSys: - z: 0.30770909289185965 + z: 0.307709 diff --git a/batoid/data/LSST/ComCam_y.yaml b/batoid/data/LSST/ComCam_y.yaml index 75e99baf..42958d08 100644 --- a/batoid/data/LSST/ComCam_y.yaml +++ b/batoid/data/LSST/ComCam_y.yaml @@ -1,9 +1,8 @@ opticalSystem: type: CompoundOptic name: RubinComCam - inMedium: &air - type: Air - medium: *air + inMedium: &vacuum 1.0 + medium: *vacuum backDist: 15.0 # distance from global vertex to use to start tracing rays sphereRadius: 5.0 # reference sphere radius to use for wavefront calculation pupilSize: 8.36 # Pupil fits inside a square with this side length @@ -41,7 +40,7 @@ opticalSystem: outer: 1.71 inner: 0.9 coordSys: - z: 6.1559766921647 + z: 6.155977 - type: Mirror name: M3 @@ -60,19 +59,19 @@ opticalSystem: type: CompoundOptic name: ComCam coordSys: - z: 4.10903560817 + z: 4.109030025999346 items: - type: Lens name: L1 medium: &silica type: SellmeierMedium - B1: 0.696183020 - B2: 0.407925877 - B3: 0.897464057 - C1: 0.00467926519 - C2: 0.0135122244 - C3: 97.9323636 + B1: 0.696182877 + B2: 0.407926020 + B3: 0.897462254 + C1: 0.00467926421 + C2: 0.0135122230 + C3: 97.9321695 items: - type: RefractiveInterface @@ -82,16 +81,17 @@ opticalSystem: R: 0.744422 obscuration: type: ClearCircle - radius: 0.192 + # radius: 0.20004 + radius: 0.189 - type: RefractiveInterface name: L1_exit surface: type: Sphere - R: 4.18068 + R: 4.180678 obscuration: type: ClearCircle - radius: 0.192 + radius: 0.20004 coordSys: z: 0.032 - @@ -99,17 +99,18 @@ opticalSystem: name: L2 medium: *silica coordSys: - z: 0.08896479090387038 + z: 0.088965 items: - type: RefractiveInterface name: L2_entrance surface: type: Sphere - R: -5.99534 + R: -5.995343 obscuration: type: ClearCircle - radius: 0.166 + # radius: 0.175 + radius: 0.161 - type: RefractiveInterface name: L2_exit @@ -118,7 +119,8 @@ opticalSystem: R: 0.639028 obscuration: type: ClearCircle - radius: 0.155 + # radius: 0.175 + radius: 0.152 coordSys: z: 0.009 - @@ -126,7 +128,7 @@ opticalSystem: name: Filter medium: *silica coordSys: - z: 0.19626409289185995 + z: 0.196264 items: - type: RefractiveInterface @@ -145,32 +147,32 @@ opticalSystem: type: ClearCircle radius: 0.1325 coordSys: - z: 0.009 + z: 0.007 - type: Lens name: L3 medium: *silica coordSys: - z: 0.27026409289185995 + z: 0.270264 items: - type: RefractiveInterface name: L3_entrance surface: type: Sphere - R: 6.10983 + R: 6.109828 obscuration: type: ClearCircle - radius: 0.108 + radius: 0.108025 - type: RefractiveInterface name: L3_exit surface: type: Sphere - R: -1.52259 + R: -1.522589 obscuration: type: ClearCircle - radius: 0.108 + radius: 0.108025 coordSys: z: 0.0155 - @@ -182,4 +184,4 @@ opticalSystem: type: ClearCircle radius: 0.11 coordSys: - z: 0.30770909289185965 + z: 0.307709 diff --git a/batoid/data/LSST/ComCam_z.yaml b/batoid/data/LSST/ComCam_z.yaml index abb4c5c3..c2b019e0 100644 --- a/batoid/data/LSST/ComCam_z.yaml +++ b/batoid/data/LSST/ComCam_z.yaml @@ -40,7 +40,7 @@ opticalSystem: outer: 1.71 inner: 0.9 coordSys: - z: 6.1559766921647 + z: 6.155977 - type: Mirror name: M3 @@ -59,19 +59,19 @@ opticalSystem: type: CompoundOptic name: ComCam coordSys: - z: 4.1090370964 + z: 4.109031863823618 items: - type: Lens name: L1 medium: &silica type: SellmeierMedium - B1: 0.696183020 - B2: 0.407925877 - B3: 0.897464057 - C1: 0.00467926519 - C2: 0.0135122244 - C3: 97.9323636 + B1: 0.696182877 + B2: 0.407926020 + B3: 0.897462254 + C1: 0.00467926421 + C2: 0.0135122230 + C3: 97.9321695 items: - type: RefractiveInterface @@ -81,16 +81,17 @@ opticalSystem: R: 0.744422 obscuration: type: ClearCircle - radius: 0.192 + # radius: 0.20004 + radius: 0.189 - type: RefractiveInterface name: L1_exit surface: type: Sphere - R: 4.18068 + R: 4.180678 obscuration: type: ClearCircle - radius: 0.192 + radius: 0.20004 coordSys: z: 0.032 - @@ -98,17 +99,18 @@ opticalSystem: name: L2 medium: *silica coordSys: - z: 0.08896479090387038 + z: 0.088965 items: - type: RefractiveInterface name: L2_entrance surface: type: Sphere - R: -5.99534 + R: -5.995343 obscuration: type: ClearCircle - radius: 0.166 + # radius: 0.175 + radius: 0.161 - type: RefractiveInterface name: L2_exit @@ -117,7 +119,8 @@ opticalSystem: R: 0.639028 obscuration: type: ClearCircle - radius: 0.155 + # radius: 0.175 + radius: 0.152 coordSys: z: 0.009 - @@ -125,7 +128,7 @@ opticalSystem: name: Filter medium: *silica coordSys: - z: 0.19626409289185995 + z: 0.196264 items: - type: RefractiveInterface @@ -144,32 +147,32 @@ opticalSystem: type: ClearCircle radius: 0.1325 coordSys: - z: 0.009 + z: 0.007 - type: Lens name: L3 medium: *silica coordSys: - z: 0.27026409289185995 + z: 0.270264 items: - type: RefractiveInterface name: L3_entrance surface: type: Sphere - R: 6.10983 + R: 6.109828 obscuration: type: ClearCircle - radius: 0.108 + radius: 0.108025 - type: RefractiveInterface name: L3_exit surface: type: Sphere - R: -1.52259 + R: -1.522589 obscuration: type: ClearCircle - radius: 0.108 + radius: 0.108025 coordSys: z: 0.0155 - @@ -181,4 +184,4 @@ opticalSystem: type: ClearCircle radius: 0.11 coordSys: - z: 0.30770909289185965 + z: 0.307709 diff --git a/tests/test_zemax.py b/tests/test_zemax.py index 23e89099..ab1631e1 100644 --- a/tests/test_zemax.py +++ b/tests/test_zemax.py @@ -610,6 +610,74 @@ def test_CBP_trace(): ) +@timer +def test_ComCam_trace(): + surfaces = { + 5:'M1', + 6:'M2', + 8:'M3', + 10:'L1_entrance', + 11:'L1_exit', + 12:'L2_entrance', + 13:'L2_exit', + 14:'Filter_entrance', + 15:'Filter_exit', + 16:'L3_entrance', + 17:'L3_exit', + 18:'Detector', + } + indices = {v:k for k, v in surfaces.items()} + + for band in 'ugrizy': + optic = batoid.Optic.fromYaml(f"ComCam_{band}.yaml") + + for i in range(1, 3): + fn = os.path.join(directory, "testdata", f"ComCam_SRT{i}_{band.upper()}.txt") + with open(fn, encoding='utf-16-le') as f: + wavelength = np.genfromtxt(f, skip_header=8, max_rows=1, usecols=(2,)) + with open(fn, encoding='utf-16-le') as f: + Hx, Hy, Px, Py = np.genfromtxt(f, skip_header=13, max_rows=4, usecols=(6,)) + with open(fn, encoding='utf-16-le') as f: + idxs, x, y, z, xcos, ycos, zcos, nx, ny, nz, cos, path = np.genfromtxt( + f, skip_header=22, max_rows=18, usecols=list(range(0, 12)), unpack=True + ) + # Switch to batoid conventions. x, y, z -> -x, y, -z + Hx *= -1 + Px *= -1 + x *= -1 + z *= -1 + xcos *= -1 + zcos *= -1 + nx *= -1 + nz *= -1 + # Wavelength to meters + wavelength *= 1e-6 + # distances to meters + x *= 1e-3 + y *= 1e-3 + z *= 1e-3 + + # Initial ray conditions + r = np.r_[x[0], y[0], z[0]] + dr = np.r_[x[1]-x[0], y[1]-y[0], z[1]-z[0]] + v = dr/np.linalg.norm(dr) + ray = batoid.RayVector(*r, *v, t=0, wavelength=wavelength) + + tf = optic.traceFull(ray) + for k in tf: + idx = indices[k]-1 + np.testing.assert_allclose( + tf[k]['out'].toCoordSys(batoid.globalCoordSys).r[0], + np.array([x[idx], y[idx], z[idx]]), + rtol=0, atol=1e-9 + ) + sx, sy = batoid.spot( + optic, np.deg2rad(Hx), np.deg2rad(Hy), wavelength, nx=128 + ) + assert np.sqrt(np.nanvar(sx)+np.nanvar(sy)) < 10e-6 # Spot size smaller than 1 pixel + + + if __name__ == '__main__': from argparse import ArgumentParser parser = ArgumentParser() @@ -629,4 +697,5 @@ def test_CBP_trace(): test_LSST_trace(verbose=False) test_DECam_trace(verbose=False) test_DECam_exit_pupil_pos() - test_CBP_trace() \ No newline at end of file + test_CBP_trace() + test_ComCam_trace() diff --git a/tests/testdata/ComCam_SRT1_G.txt b/tests/testdata/ComCam_SRT1_G.txt new file mode 100644 index 00000000..456dbc75 Binary files /dev/null and b/tests/testdata/ComCam_SRT1_G.txt differ diff --git a/tests/testdata/ComCam_SRT1_I.txt b/tests/testdata/ComCam_SRT1_I.txt new file mode 100644 index 00000000..7c968291 Binary files /dev/null and b/tests/testdata/ComCam_SRT1_I.txt differ diff --git a/tests/testdata/ComCam_SRT1_R.txt b/tests/testdata/ComCam_SRT1_R.txt new file mode 100644 index 00000000..ca2bd7c6 Binary files /dev/null and b/tests/testdata/ComCam_SRT1_R.txt differ diff --git a/tests/testdata/ComCam_SRT1_U.txt b/tests/testdata/ComCam_SRT1_U.txt new file mode 100644 index 00000000..f02f353f Binary files /dev/null and b/tests/testdata/ComCam_SRT1_U.txt differ diff --git a/tests/testdata/ComCam_SRT1_Y.txt b/tests/testdata/ComCam_SRT1_Y.txt new file mode 100644 index 00000000..83291a0c Binary files /dev/null and b/tests/testdata/ComCam_SRT1_Y.txt differ diff --git a/tests/testdata/ComCam_SRT1_Z.txt b/tests/testdata/ComCam_SRT1_Z.txt new file mode 100644 index 00000000..323bf24d Binary files /dev/null and b/tests/testdata/ComCam_SRT1_Z.txt differ diff --git a/tests/testdata/ComCam_SRT2_G.txt b/tests/testdata/ComCam_SRT2_G.txt new file mode 100644 index 00000000..f7e16dc1 Binary files /dev/null and b/tests/testdata/ComCam_SRT2_G.txt differ diff --git a/tests/testdata/ComCam_SRT2_I.txt b/tests/testdata/ComCam_SRT2_I.txt new file mode 100644 index 00000000..bff8116b Binary files /dev/null and b/tests/testdata/ComCam_SRT2_I.txt differ diff --git a/tests/testdata/ComCam_SRT2_R.txt b/tests/testdata/ComCam_SRT2_R.txt new file mode 100644 index 00000000..e66f5bf9 Binary files /dev/null and b/tests/testdata/ComCam_SRT2_R.txt differ diff --git a/tests/testdata/ComCam_SRT2_U.txt b/tests/testdata/ComCam_SRT2_U.txt new file mode 100644 index 00000000..2a829a47 Binary files /dev/null and b/tests/testdata/ComCam_SRT2_U.txt differ diff --git a/tests/testdata/ComCam_SRT2_Y.txt b/tests/testdata/ComCam_SRT2_Y.txt new file mode 100644 index 00000000..c0c6e366 Binary files /dev/null and b/tests/testdata/ComCam_SRT2_Y.txt differ diff --git a/tests/testdata/ComCam_SRT2_Z.txt b/tests/testdata/ComCam_SRT2_Z.txt new file mode 100644 index 00000000..0a45edb8 Binary files /dev/null and b/tests/testdata/ComCam_SRT2_Z.txt differ