-
Notifications
You must be signed in to change notification settings - Fork 0
Tickets/DM-49286: sparse Noll Zernike mode #53
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
Open
suberlak
wants to merge
11
commits into
develop
Choose a base branch
from
tickets/DM-49286
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4db69a4
add noll_indices to img_closed_loop
suberlak 14927c0
add noll_indices and read zernikes in closed_loop_task
suberlak 98e00b9
add noll_indices to imsim_cmpt
suberlak d8a923f
add noll_indices to sensor_wavefront_error
suberlak 1048190
update doc in get_zk_from_file
suberlak d70e5d5
update test for closed_loop_task
suberlak e6525c4
update tests for sensor_wavefront_error
suberlak bd9aff1
update test for imsim_cmpt
suberlak d83b1c6
update version history
suberlak cf789cb
isort fix for closed_loop_task
suberlak 9804b98
isort fix for test of closed_loop_task
suberlak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,5 +64,5 @@ | |
| args.raw_seeing, | ||
| args.imsim_log_file, | ||
| args.wep_estimator, | ||
| args.max_noll_index, | ||
| args.noll_indices, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,7 +47,7 @@ | |
| plot_fwhm_of_iters, | ||
| ) | ||
| from lsst.ts.ofc import OFC, OFCData | ||
| from lsst.ts.wep.utils import rotMatrix, runProgram | ||
| from lsst.ts.wep.utils import makeDense, rotMatrix, runProgram | ||
|
|
||
|
|
||
| class ClosedLoopTask: | ||
|
|
@@ -66,8 +66,8 @@ def __init__(self) -> None: | |
| # imSim Component | ||
| self.imsim_cmpt = None | ||
|
|
||
| # Maximum Noll index | ||
| self.max_noll_index = None | ||
| # Noll Zernike indices | ||
| self.noll_indices = None | ||
|
|
||
| # Ra/Dec/RotAng coordinates used in the simulation. | ||
| self.boresight_ra = None | ||
|
|
@@ -205,10 +205,8 @@ def config_ofc_calc(self, cam_type: CamType, controller_config_file: str) -> Non | |
| Path(get_config_dir()) / "controllers" / controller_config_file | ||
| ) | ||
| self.ofc_calc = OFC(ofc_data) | ||
| self.ofc_calc.ofc_data.znmin = 4 | ||
| self.ofc_calc.ofc_data.zn_selected = np.arange( | ||
| self.ofc_calc.ofc_data.znmin, self.max_noll_index + 1 | ||
| ) | ||
| self.ofc_calc.ofc_data.znmin = min(self.noll_indices) | ||
| self.ofc_calc.ofc_data.zn_selected = np.array(self.noll_indices) | ||
|
|
||
| def map_filter_ref_to_g(self, filter_type_name: str) -> str: | ||
| """Map the reference filter to the G filter. | ||
|
|
@@ -525,9 +523,14 @@ def _run_sim( | |
| zk_file_name=wfs_zk_file_name, | ||
| ) | ||
|
|
||
| # Calculate the DOF | ||
| # Calculate the DOF. | ||
| # Need to switch to dense representation | ||
| # before passing on to OFC | ||
| wfe = np.array( | ||
| [sensor_wfe.annular_zernike_poly for sensor_wfe in list_of_wf_err] | ||
| [ | ||
| makeDense(sensor_wfe.annular_zernike_poly, self.noll_indices) | ||
| for sensor_wfe in list_of_wf_err | ||
| ] | ||
| ) | ||
|
|
||
| sensor_ids = np.array( | ||
|
|
@@ -886,7 +889,7 @@ def run_wep( | |
| butler = dafButler.Butler(butler_root_path) | ||
|
|
||
| dataset_refs = butler.registry.queryDatasets( | ||
| datasetType="zernikeEstimateAvg", collections=[f"ts_imsim_{seq_num}"] | ||
| datasetType="zernikes", collections=[f"ts_imsim_{seq_num}"] | ||
| ) | ||
|
|
||
| # Get the map for detector Id to detector name | ||
|
|
@@ -907,19 +910,26 @@ def run_wep( | |
| "visit": dataset.dataId["visit"], | ||
| } | ||
|
|
||
| zer_coeff = butler.get( | ||
| "zernikeEstimateAvg", | ||
| zernikes = butler.get( | ||
| "zernikes", | ||
| dataId=data_id, | ||
| collections=[f"ts_imsim_{seq_num}"], | ||
| ) | ||
|
|
||
| sensor_wavefront_data = SensorWavefrontError( | ||
| num_of_zk=self.max_noll_index - self.ofc_calc.ofc_data.znmin + 1 | ||
| # Read off which columns contain Zk values | ||
| zk_cols = [col for col in zernikes.columns if col.startswith("Z")] | ||
| # This is equivalent to self.noll_indices | ||
| noll_indices = [int(col[1:]) for col in zk_cols] | ||
| # The first row contains the detector average | ||
| zk_avg_row = zernikes[zernikes["label"] == "average"] | ||
| # Each QTable column contains units, hence we convert with astropo | ||
| zk_avg_microns = np.array( | ||
| [zk_avg_row[col].to(astropy.units.micron).value[0] for col in zk_cols] | ||
| ) | ||
| sensor_wavefront_data = SensorWavefrontError(noll_indices=noll_indices) | ||
| sensor_name = det_id_map[dataset.dataId["detector"]].getName() | ||
| sensor_wavefront_data.sensor_name = sensor_name | ||
| sensor_wavefront_data.sensor_id = det_name_map[sensor_name].getId() | ||
| sensor_wavefront_data.annular_zernike_poly = zer_coeff[0] | ||
| sensor_wavefront_data.annular_zernike_poly = zk_avg_microns | ||
|
|
||
| list_of_wf_err.append(sensor_wavefront_data) | ||
|
|
||
|
|
@@ -1013,7 +1023,7 @@ def write_wep_configuration( | |
| calcZernikesTask: | ||
| class: lsst.ts.wep.task.calcZernikesTask.CalcZernikesTask | ||
| config: | ||
| estimateZernikes.maxNollIndex: {self.max_noll_index} | ||
| estimateZernikes.nollIndices: {self.noll_indices} | ||
| python: | | ||
| from lsst.ts.wep.task import EstimateZernikesTieTask, EstimateZernikesDanishTask | ||
| config.estimateZernikes.retarget(EstimateZernikes{wep_estimator.value.title()}Task) | ||
|
|
@@ -1044,7 +1054,7 @@ def run_img( | |
| raw_seeing: float, | ||
| imsim_log_file: str, | ||
| wep_estimator_method: str, | ||
| max_noll_index: int, | ||
| noll_indices: int, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wrong type hint. Probably should be |
||
| ) -> None: | ||
| """Run the simulation of images. | ||
|
|
||
|
|
@@ -1100,8 +1110,8 @@ def run_img( | |
| wep_estimator_method : str | ||
| Specify the method used to calculate Zernikes in ts_wep. | ||
| Options are "tie" or "danish". | ||
| max_noll_index : int | ||
| Maximum Noll index to calculate Zernikes. | ||
| noll_indices : list | ||
| Noll indices used in Zernike estimation. | ||
| """ | ||
| cam_type = CamType(inst) | ||
| wep_estimator = WepEstimator(wep_estimator_method) | ||
|
|
@@ -1112,7 +1122,7 @@ def run_img( | |
| self.boresight_ra = boresight[0] | ||
| self.boresight_dec = boresight[1] | ||
| self.boresight_rot_ang = rot_cam_in_deg | ||
| self.max_noll_index = max_noll_index | ||
| self.noll_indices = noll_indices | ||
| # Remap the reference filter to g | ||
| filter_type_name = self.map_filter_ref_to_g(filter_type_name) | ||
|
|
||
|
|
@@ -1133,9 +1143,7 @@ def run_img( | |
| cam_type, obs_metadata, path_sky_file=path_sky_file, star_mag=star_mag | ||
| ) | ||
| self.config_ofc_calc(cam_type, controller_config_file) | ||
| self.imsim_cmpt = ImsimCmpt( | ||
| num_of_zk=self.max_noll_index - self.ofc_calc.ofc_data.znmin + 1 | ||
| ) | ||
| self.imsim_cmpt = ImsimCmpt(noll_indices=self.noll_indices) | ||
|
|
||
| # If path_sky_file using default OPD positions write this to disk | ||
| # so that the Butler can load it later | ||
|
|
@@ -1402,12 +1410,13 @@ def set_default_parser(parser: ArgumentParser) -> ArgumentParser: | |
| default=1, | ||
| help="Number of processor to run imSim and DM pipeline. (default: 1)", | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
| "--max_noll_index", | ||
| "--noll_indices", | ||
| type=int, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong type again |
||
| default=28, | ||
| help="Maximum Noll index to calculate Zernikes. (default: 28)", | ||
| nargs="+", | ||
| default=[4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 21, 22, 27, 28], | ||
| help="List of Noll Zernike indices used in the simulation.\ | ||
| (default: sparse selection as in ts_wep defaults, i.e. 4-16, 20-22, 27-28)", | ||
| ) | ||
|
|
||
| parser.add_argument( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo:
astropo-->astropy