Skip to content

Commit

Permalink
more minor style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rcooper295 committed Sep 1, 2023
1 parent a1b5ce0 commit b54db76
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 24 deletions.
6 changes: 4 additions & 2 deletions jwst/ami/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from .ami_analyze_step import AmiAnalyzeStep
from .ami_average_step import AmiAverageStep
# from .ami_average_step import AmiAverageStep
from .ami_normalize_step import AmiNormalizeStep

__all__ = ['AmiAnalyzeStep', 'AmiAverageStep', 'AmiNormalizeStep']
__all__ = ['AmiAnalyzeStep',
# 'AmiAverageStep',
'AmiNormalizeStep']
3 changes: 1 addition & 2 deletions jwst/ami/ami_analyze_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from ..stpipe import Step
from . import ami_analyze
from .utils import Affine2D

__all__ = ["AmiAnalyzeStep"]

Expand Down Expand Up @@ -71,7 +70,7 @@ def process(self, input):
raise RuntimeError(f"{err}. Input unable to be read into a DataModel.")

# Make sure oversample is odd
if value % 2 == 0:
if oversample % 2 == 0:
raise ValueError("Oversample value must be an odd integer.")

# Apply the LG+ methods to the data
Expand Down
5 changes: 4 additions & 1 deletion jwst/ami/instrument_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ def read_data_model(self, input_model):
# apply bp fix here
if self.run_bpfix:
log.info('Applying Fourier bad pixel correction to cropped data, updating DQ array')
scidata_ctrd, bpdata_ctrd = bp_fix.fix_bad_pixels(scidata_ctrd,bpdata_ctrd,input_model.meta.instrument.filter, self.pscale_mas)
scidata_ctrd, bpdata_ctrd = bp_fix.fix_bad_pixels(scidata_ctrd,
bpdata_ctrd,
input_model.meta.instrument.filter,
self.pscale_mas)
else:
log.info('Not running Fourier bad pixel fix')

Expand Down
2 changes: 1 addition & 1 deletion jwst/ami/leastsqnrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def matrix_operations(img, model, flux = None, verbose=False, linfit=False, dqm=

# uniform weight
wy = weights
S = np.mat(np.diag(wy));
S = np.mat(np.diag(wy))
# matrix of independent variables
C = np.mat(flatmodeltransp)

Expand Down
5 changes: 2 additions & 3 deletions jwst/ami/oifits.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def populate_nrm_dict(self):

theta = np.linspace(0, 2*np.pi, 100)

x = D/2. * np.cos(theta) # Primary mirror display
y = D/2. * np.sin(theta)
# x = D/2. * np.cos(theta) # Primary mirror display
# y = D/2. * np.sin(theta)

bl_vis = ((ucoord**2 + vcoord**2)**0.5)

Expand Down Expand Up @@ -523,7 +523,6 @@ def populate_oimodel(self):
m.target['SPECTYP'] = self.oifits_dct['OI_TARGET']['SPECTYP']

# oi_vis extension data
nrows = 21
m.vis['TARGET_ID'] = self.oifits_dct['OI_VIS']['TARGET_ID']
m.vis['TIME'] = self.oifits_dct['OI_VIS']['TIME']
m.vis['MJD'] = self.oifits_dct['OI_VIS']['MJD']
Expand Down
57 changes: 42 additions & 15 deletions jwst/ami/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,10 +1198,18 @@ def img_median_replace(img_model, box_size):

def get_filt_spec(filt, verbose=False):
"""
Short Summary
------------
Load WebbPSF filter throughput into synphot spectrum object
filt: string, known NIRISS AMI filter name
Returns:
synphot Spectrum object
Parameters
----------
filt: string
Known AMI filter name
Returns
-------
band: synphot Spectrum object
"""
goodfilts = ["F277W", "F380M", "F430M", "F480M"]
# make uppercase
Expand All @@ -1223,11 +1231,19 @@ def get_filt_spec(filt, verbose=False):

def get_src_spec(sptype):
"""
Modified from poppy's spectrum_from_spectral_type
src: either valid source string (e.g. "A0V") or existing synphot Spectrum object
Defaults to A0V spectral type if input string not recognized.
Returns:
synphot Spectrum object
Short Summary
------------
Retrieve source spectrum. Modified from poppy's spectrum_from_spectral_type
Parameters
----------
src: string or synphot.Spectrum
valid source string (e.g. "A0V") or existing synphot Spectrum object
Defaults to A0V spectral type if input string not recognized.
Returns
-------
synphot Spectrum object
"""
# check if it's already a synphot spectrum
if isinstance(sptype, synphot.spectrum.SourceSpectrum):
Expand Down Expand Up @@ -1301,17 +1317,28 @@ def get_src_spec(sptype):

def combine_src_filt(bandpass, srcspec, trim=0.01, nlambda=19, verbose=False, plot=False):
"""
Short Summary
------------
Get the observed spectrum through a filter.
Largely copied from Poppy instrument.py
Define nlambda bins of wavelengths, calculate effstim for each, normalize by effstim total.
nlambda should be calculated so there are ~10 wavelengths per resolution element (19 should work)
Inputs:
bandpass: synphot Spectrum (from get_filt_spec)
srcspec: synphot Spectrum (from get_src_spec)
trim: if not None, trim bandpass to where throughput greater than trim
nlambda: number of wavelengths across filter to return
Returns:
finalsrc: numpy array of shape (nlambda,2) containing wavelengths, final throughputs
Parameters
----------
bandpass: synphot Spectrum
filter bandpass (from get_filt_spec)
srcspec: synphot Spectrum
source spectrum (from get_src_spec)
trim: float, None
if not None, trim bandpass to where throughput greater than trim
nlambda: integer
number of wavelengths across filter to return
Returns
-------
finalsrc: numpy array
Array of shape (nlambda,2) containing wavelengths, final throughputs
"""

Expand Down

0 comments on commit b54db76

Please sign in to comment.