Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added function to allow irisao command to be plotted in a subplot of … #275

Merged
merged 4 commits into from
May 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions catkit/hardware/iris_ao/segmented_dm_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,19 +377,10 @@ def display(self, display_wavefront=True, display_psf=True, psf_rotation_angle=0
:param save_figures: bool, If true, save out the figures in the directory specified
by out_dir
"""
# Grab the units of the DM for the piston, tip, tilt values and check that
# they don't exceed the DM hardware limits
display_data = set_to_dm_limits(self.data)
# Convert the PTT list from DM to Poppy units
converted_list = convert_ptt_units(display_data, tip_factor=1, tilt_factor=-1,
starting_units=self.dm_command_units,
ending_units=(u.m, u.rad, u.rad))
# We want to round to four significant digits when in DM units (um, mrad, mrad).
# Here, we are in SI units (m, rad, rad), so we round to the equivalent, 10 decimals.
rounded_list = round_ptt_list(converted_list, decimals=10)
for seg, values in zip(self.aperture.segmentlist, rounded_list):
self.aperture.set_actuator(seg, values[0], values[1], values[2])

# update opd on mirror
self.apply_current_wavefront()

# make figure
if figure_name_prefix:
figure_name_prefix = f'{figure_name_prefix}_'
if display_wavefront:
Expand Down Expand Up @@ -417,6 +408,28 @@ def plot_wavefront(self, figure_name_prefix, out_dir, vmax=0.5e-6*u.meter, save_
plt.close()
else:
plt.show()

def apply_current_wavefront(self):
"""
Get the deployed mirror state (wavefront error)
To make plot:
total_iris = iris_ao.HicatSegmentedDmCommand()
total_iris.read_initial_command([tuple(row) for row in command_to_plot])
total_iris.apply_current_wavefront()
command = total_iris.aperture.sample(what='opd')
image = ax.matshow(command)
"""
display_data = set_to_dm_limits(self.data)
# Convert the PTT list from DM to Poppy units
converted_list = convert_ptt_units(display_data, tip_factor=1, tilt_factor=-1,
starting_units=self.dm_command_units,
ending_units=(u.m, u.rad, u.rad))
# We want to round to four significant digits when in DM units (um, mrad, mrad).
# Here, we are in SI units (m, rad, rad), so we round to the equivalent, 10 decimals.
rounded_list = round_ptt_list(converted_list, decimals=10)
for seg, values in zip(self.aperture.segmentlist, rounded_list):
self.aperture.set_actuator(seg, values[0], values[1], values[2])


@poppy.utils.quantity_input(display_wavelength=u.nm) # decorator provides a check on input units
def plot_psf(self, wavelength=640*u.nm, figure_name_prefix=None, rotation_angle=0, out_dir=None, vmin=1e-8,
Expand Down