Skip to content

Commit

Permalink
Style and doctring updates following review
Browse files Browse the repository at this point in the history
  • Loading branch information
rcooper295 committed Dec 12, 2024
1 parent 95d097e commit eda935c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/jwst/ami_analyze/description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions jwst/ami/ami_analyze_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions jwst/ami/instrument_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions jwst/ami/lg_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
21 changes: 12 additions & 9 deletions jwst/ami/mask_definition_ami.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand All @@ -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)

Expand All @@ -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
----------
Expand All @@ -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
Expand Down

0 comments on commit eda935c

Please sign in to comment.