Example #1
0
def test_basic_trace():
    # create an Experiment
    exp_1 = rt.Experiment(
    )  # a container to hold the instrument and results etc. and run tests
    exp_1.name = "basic_trace"  # this can be used in file names when saving things

    # bring in the instrument
    exp_1.add_instrument(
        deepcopy(ii.cass)
    )  # the instrument is defined in a different file to keep it simple and clean here

    # Make rays for this Experiment. In rendering lingo this is defining a light source, or multiple point light sources
    exp_1.set_ray_starts(deepcopy(ri.basic_paraxial_rays))

    # run and plot
    exp_1.reset()
    results = exp_1.run(
    )  # steps through all surfaces to find ray intersections and reflections

    # all points should be co-located to within machine precision
    assert np.nanmax(results.image) < 1E-13
Example #2
0
'''
Scott Carnahan
Experiment - Test Cassegrain with Rowland Circle Grating
'''

from srt_modules import experiment as rt
from srt_instances import instrument_instances as ii, ray_instances as ri
import numpy as np
from copy import deepcopy

exp = rt.Experiment()
exp.set_ray_starts(deepcopy(ri.basic_paraxial_rays))

exp.add_instrument(deepcopy(ii.grating_cassegrain))
grating = exp.instrument.surfaces[-2]
detector = exp.instrument.detector

grating.set_order(1)
grating.set_wavelength(1200.)
exp.trace_rays()

angstrom_per_mm = 1E7 / 3600. / 1000.

x1200 = detector.extract_image()[0, :]
dx_1200 = (np.nanmax(x1200) - np.nanmin(x1200)) * 1000.
resolution_1200 = dx_1200 * angstrom_per_mm
resolving_power_1200 = 1200. / resolution_1200


def test_grating_trace():
    assert np.fabs(resolving_power_1200 / 679.708744) - 1 < 1E-13
Example #3
0
'''
Scott Carnahan
For more descriptive comments, please see find_image_plane_30.py
'''

import numpy as np
import matplotlib.pyplot as plt
from srt_modules import experiment as rt
from srt_instances import instrument_instances as ii, ray_instances as ri

show_plots = True
save_plots = True
make_plots = show_plots or save_plots

# Make an Experiment to find the optimal (flat) image plane location with 30 arcsec FOV
exp_30 = rt.Experiment()

# bring in the instrument
exp_30.add_instrument(ii.cass)

# bring the 30 arcsecond rays
exp_30.set_ray_starts(ri.thirty_sec_rays)
nominal_results = exp_30.run()
f_num_2 = ii.cass_inputs.f_num_total - ii.cass_inputs.f_num_1
suggested_offset = f_num_2 * nominal_results.mean_spread
suggested_center = 3.15 - suggested_offset
delta = suggested_offset * .1
explore_space = np.arange(suggested_center, 3.15, 1E-6)
rms_list = []
for pt in explore_space:
    exp_30.instrument.detector.L_r_L[0][0] = pt
Spring 2019
This example traces paraxial rays from some start to the image plane through a basic cassegrain telescope.
The resulting plot should have exceedingly small dimensions that represent the machine error in tracing the rays
 to a focus on the image plane.
'''

import matplotlib.pyplot as plt
from srt_modules import experiment as rt
from srt_instances import instrument_instances as ii, ray_instances as ri

# plotting flags
show_plots = True
save_plots = True

# create an Experiment
exp_1 = rt.Experiment(
)  # a container to hold the instrument and results etc. and run tests
exp_1.name = "basic_trace"  # this can be used in file names when saving things

# bring in the instrument
exp_1.add_instrument(
    ii.cass
)  # the instrument is defined in a different file to keep it simple and clean here

# Make rays for this Experiment. In rendering lingo this is defining a light source, or multiple point light sources
exp_1.set_ray_starts(ri.basic_paraxial_rays)

# run and plot
results = exp_1.run(
)  # steps through all surfaces to find ray intersections and reflections
result_plot = exp_1.result_plot()
Example #5
0
the paraxial focus in [um] along the instrument axis.
'''

import numpy as np
import matplotlib.pyplot as plt
from srt_modules import experiment
from srt_instances import instrument_instances as ii, ray_instances as ri

show_plots = True
save_plots = True
make_plots = show_plots or save_plots

# Make an Experiment to find the optimal (flat) image plane location with 30 arcsec FOV
# This is not a fully defined problem, so I just minimize the rms of a set of rays that all come in at 30 arcsec off of
# parallel
exp_5 = experiment.Experiment()

# bring in the instrument
exp_5.add_instrument(ii.cass)

# bring the 30 arcsecond rays
rays_5 = ri.five_min_rays
exp_5.set_ray_starts(rays_5)
nominal_results = exp_5.run()
f_num_2 = ii.cass_inputs.f_num_total - ii.cass_inputs.f_num_1
suggested_offset = f_num_2 * nominal_results.mean_spread  # as a first guess, the offset required should be related to
# the spread with no offset and the f/# of the secondary
suggested_center = 3.15 - suggested_offset  # 3.15 is the paraxial focus
explore_space = np.arange(
    suggested_center, 3.15,
    1E-6)  # the assumption here is that I will only have the capability
than being projected to a flat x, y.
'''

import numpy as np
import matplotlib.pyplot as plt
from srt_modules import experiment, optical_surfaces as surfs
from srt_instances import instrument_instances as ii, ray_instances as ri
from mpl_toolkits import mplot3d

# plotting flags
show_plots = True
save_plots = True
make_plots = show_plots or save_plots

# create an experiment
exp_sph = experiment.Experiment()

# set up the instrument
exp_sph.add_instrument(ii.cass)

# choose some rays
exp_sph.set_ray_starts(ri.five_min_rays)

# make a spherical detector
spherical_detector = surfs.SphericalDetector([-np.pi / 2., 0., 0.],
                                             [0., 0., 0.])
spherical_detector.L_r_L = np.zeros(3).reshape([3, 1])
spherical_detector.DCM_SL = exp_sph.instrument.detector.DCM_SL
spherical_detector.w = .5
exp_sph.instrument.set_detector(spherical_detector)
Example #7
0
Experiment - Various Angles
Spring 2019
There is no goal here other than showing the aberrations on the focal plane due to non-paraxial rays with various
incoming angles. Coma should be quite evident.
'''

import matplotlib.pyplot as plt
from srt_modules import experiment as rt
from srt_instances import instrument_instances as ii, ray_instances as ri

# some figure flags
show_plots = True
save_plots = True

# make an Experiment
exp_2 = rt.Experiment()

# bring in the instrument
exp_2.add_instrument(ii.cass)

# get the rays to trace
ray_sets = ri.angled_ray_list
angle_set = ri.various_angles

# run the Experiments
result_plot_list = []
for angle, ray in zip(angle_set, ray_sets):
    exp_2.name = str(angle)
    exp_2.set_ray_starts(ray)
    exp_2.run()
    result_plot_list.append(exp_2.result_plot())