From 942dcb8d88343d80446a72d8e09f736b056038fd Mon Sep 17 00:00:00 2001 From: Marshall Perrin Date: Fri, 25 Oct 2024 09:20:34 -0400 Subject: [PATCH] add find_apernames function --- docs/pysiaf/index.rst | 15 +++++++++++++++ pysiaf/siaf.py | 7 ++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/pysiaf/index.rst b/docs/pysiaf/index.rst index c260b638..1a44bfce 100644 --- a/docs/pysiaf/index.rst +++ b/docs/pysiaf/index.rst @@ -84,6 +84,21 @@ Frame transformations (``det``, ``sci``, ``idl``, ``tel`` are supported frames): # transform from Science frame to Ideal frame idl_x, idl_y = nis_cen.sci_to_idl(sci_x, sci_y) +Finding Available Apertures +*************************** + +Each Siaf instance has an attribute ``apernames`` giving all available aperture names. There are often many of these:: + + siaf = pysiaf.Siaf('NIRSpec') + print (len(siaf.apernames)) + # output: 75 + +The ``find_apernames`` method allows quick lookup of aperture names matching some substring:: + + siaf = pysiaf.Siaf('NIRSpec') + siaf.find_apernames('S200') + # output: ['NRS_S200A1_SLIT', 'NRS_S200A2_SLIT', 'NRS_S200B1_SLIT'] + Using sky transforms ******************** diff --git a/pysiaf/siaf.py b/pysiaf/siaf.py index a99eb23c..3cc34cc5 100644 --- a/pysiaf/siaf.py +++ b/pysiaf/siaf.py @@ -522,4 +522,9 @@ def plot_detector_channels(self, frame=None, ax=None): for ap in self._getFullApertures(): ap.plot_detector_channels(frame=frame, ax=ax) - \ No newline at end of file + + def find_apernames(self, substring): + """ Return aperture names containing some substring. + Simple utility function to search through names of available apertures. + """ + return [name for name in self.apernames if substring in name]