diff --git a/docs/jwst/ami_analyze/description.rst b/docs/jwst/ami_analyze/description.rst index 36e9b6622c..2e4ec08636 100644 --- a/docs/jwst/ami_analyze/description.rst +++ b/docs/jwst/ami_analyze/description.rst @@ -52,7 +52,7 @@ other options: :--run_bpfix: Run Fourier bad pixel fix on cropped data (default=True) -Note that the `affine2d` default argument is a special case; 'commissioning' is currently the only string other than an ASDF filename that is accepted. +Note that the `affine2d` default argument is a special case; 'commissioning' is currently the only string other than an ASDF filename that is accepted. If `None` is passed, it will perform a rotation search (least-squares fit to a PSF model) and use that for the affine transform. Creating ASDF files diff --git a/jwst/ami/ami_analyze_step.py b/jwst/ami/ami_analyze_step.py index dd57ce894d..d5c009db7e 100755 --- a/jwst/ami/ami_analyze_step.py +++ b/jwst/ami/ami_analyze_step.py @@ -157,11 +157,10 @@ def process(self, input): # pull out parameters that are strings and change to floats psf_offset = [float(a) for a in self.psf_offset.split()] rotsearch_parameters = [float(a) for a in self.rotation_search.split()] + # handle command-line None input interpreted as string - if affine2d in ["None", "none"]: + if str(affine2d).lower() == 'none': affine2d = None - if bandpass in ["None", "none"]: - bandpass = None self.log.info(f"Oversampling factor = {oversample}") self.log.info(f"Initial rotation guess = {rotate} deg") diff --git a/jwst/ami/instrument_data.py b/jwst/ami/instrument_data.py index f2c41cff86..cbc253eabf 100755 --- a/jwst/ami/instrument_data.py +++ b/jwst/ami/instrument_data.py @@ -6,7 +6,7 @@ import logging import numpy as np -from .mask_definition_ami import NRM_definition +from .mask_definition_ami import NRMDefinition from . import utils from . import bp_fix from stdatamodels.jwst.datamodels import dqflags @@ -96,7 +96,7 @@ def __init__(self, self.instrument = "NIRISS" self.arrname = "jwst_ami" self.holeshape = 'hex' - self.mask = NRM_definition( + self.mask = NRMDefinition( self.nrm_model, maskname=self.arrname, chooseholes=self.chooseholes diff --git a/jwst/ami/lg_model.py b/jwst/ami/lg_model.py index c80e5f65ca..29170738dd 100755 --- a/jwst/ami/lg_model.py +++ b/jwst/ami/lg_model.py @@ -22,7 +22,7 @@ class LgModel: """ A class for conveniently dealing with an "NRM object" This should be able - to take an NRM_definition object for mask geometry. + to take an NRMDefinition object for mask geometry. Defines mask geometry and detector-scale parameters. Simulates PSF (broadband or monochromatic) Builds a fringe model - either by user definition, or automated to data @@ -65,14 +65,15 @@ def __init__( over: integer oversampling factor - pixweight: 2D float array, default is None + pixweight: 2D float array, default None weighting array phi: float 1D array distance of fringe from hole center in units of waves - chooseholes: list of strings - None, or e.g. ['B2', 'B4', 'B5', 'B6'] for a four-hole mask + chooseholes: list of strings, default None + E.g. ['B2', 'B4', 'B5', 'B6'] for a four-hole mask + If None, use the real seven-hole mask. affine2d: Affine2d object Affine2d object @@ -90,11 +91,11 @@ def __init__( # get these from mask_definition_ami instead if mask is None: log.info("Using JWST AMI mask geometry from LgModel") - mask = mask_definition_ami.NRM_definition(nrm_model, + mask = mask_definition_ami.NRMDefinition(nrm_model, maskname="jwst_ami", chooseholes=chooseholes ) elif isinstance(mask, str): - mask = mask_definition_ami.NRM_definition(nrm_model, + mask = mask_definition_ami.NRMDefinition(nrm_model, maskname=mask, chooseholes=chooseholes ) # retain ability to possibly use other named masks, for now self.ctrs = mask.ctrs diff --git a/jwst/ami/mask_definition_ami.py b/jwst/ami/mask_definition_ami.py index 59a33c44a0..140dc539af 100644 --- a/jwst/ami/mask_definition_ami.py +++ b/jwst/ami/mask_definition_ami.py @@ -13,11 +13,14 @@ um = 1.0e-6 * m -class NRM_definition(): +class NRMDefinition(): def __init__(self, nrm_model, maskname='jwst_ami', rotdeg=None, chooseholes=None): """ - Set attributes of NRM_definition class. + Set attributes of NRMDefinition class. + + Get hole centers and other mask geometry details from NRMModel, apply rotations/flips + as necessary and set them as attributes. Parameters ---------- @@ -29,12 +32,17 @@ def __init__(self, nrm_model, maskname='jwst_ami', rotdeg=None, chooseholes=None range of rotations to search (degrees), optional chooseholes: list None, or e.g. ['B2', 'B4', 'B5', 'B6'] for a four-hole mask, optional + If None, use real seven-hole mask """ if maskname not in ['jwst_ami','jwst_g7s6c']: raise ValueError("Mask name not supported") self.maskname = maskname # there's only one mask but this is used in oifits + self.hdia = nrm_model.flat_to_flat + self.activeD = nrm_model.diameter + self.OD = nrm_model.pupil_circumscribed + self.ctrs = [] self.read_nrm_model(nrm_model, chooseholes=chooseholes) @@ -43,10 +51,7 @@ def __init__(self, nrm_model, maskname='jwst_ami', rotdeg=None, chooseholes=None def read_nrm_model(self, nrm_model, chooseholes=None): """ - - Calculate hole centers with appropriate rotation, - set these and other mask geometry details from NRMModel as - attributes. + Calculate hole centers with appropriate rotation. Parameters ---------- @@ -71,9 +76,7 @@ def read_nrm_model(self, nrm_model, chooseholes=None): [nrm_model.x_a6, nrm_model.y_a6], # B2 -> B6 [nrm_model.x_a7, nrm_model.y_a7]]) # C1 -> C6 - self.hdia = nrm_model.flat_to_flat - self.activeD = nrm_model.diameter - self.OD = nrm_model.pupil_circumscribed + holedict = {} # as_built names, C2 open, C5 closed, but as designed coordinates # Assemble holes by actual open segment names (as_built). Either the full mask or the