Skip to content

Commit

Permalink
update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jemorrison committed Sep 19, 2024
1 parent 88e5202 commit e2b352d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
17 changes: 10 additions & 7 deletions jwst/cube_build/cube_build_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CubeBuildStep (Step):
search_output_file = boolean(default=false)
output_use_model = boolean(default=true) # Use filenames in the output models
suffix = string(default='s3d')
offset_file = string(default=None)
offset_file = string(default=None) # Filename containing a list of Ra and Dec offsets to apply to files.
debug_spaxel = string(default='-1 -1 -1') # Default not used
"""

Expand Down Expand Up @@ -239,7 +239,7 @@ def process(self, input):
# ________________________________________________________________________________
# If an offset file is provided do some basic checks on the file and its contents.
# The offset list contains a matching list to the files in the association
# used in calspec3 (or offline cube building).
# used in calspec3 (for offline cube building).
# Each row in the offset list contain a filename, ra offset and dec offset.
# The offset list is an asdf file.
self.offsets = None
Expand Down Expand Up @@ -546,15 +546,15 @@ def read_user_input(self):
# ________________________________________________________________________________

def check_offset_file(self):
"""Read in an optional ra and dec offsets for each file.
"""Read in an optional ra and dec offset for each file.
Summary
----------
Check that is file is asdf file.
check the file has the correct format:
Check the file has the correct format using an local schema file.
The schema file, ifuoffset.schema.yaml, is located in the jwst/cube_build directory.
For each file in the input assocation check that there is a corresponding
file in the offset file.
Also check that each file in the offset list contain a ra offset and dec offset.
"""

Expand All @@ -565,15 +565,18 @@ def check_offset_file(self):
af = asdf.open(self.offset_file, custom_schema=DATA_PATH/'ifuoffset.schema.yaml')
except:
schema_message = ('Validation Error for offset file. Fix the offset file. \n' + \
'The offset file needs to have the same number of elements the filename, raoffset and decoffset lists.\n' +\
'The offset file needs to have the same number of elements ' + \
'in the three lists: filename, raoffset and decoffset.\n' +\
'The units need to provided and only arcsec is allowed.')

raise Exception(schema_message)

offset_filename = af['filename']
offset_ra = af['raoffset']
offset_dec = af['decoffset']

# Note:
# af['units'] is checked by the schema validation. It must be arcsec or a validation error occurs.

# check that all the file names in input_model are in the offset filename
for model in self.input_models:
file_check = model.meta.filename
Expand Down
7 changes: 5 additions & 2 deletions jwst/cube_build/ifu_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1738,8 +1738,7 @@ def map_miri_pixel_to_sky(self, input_model, this_par1, subtract_background,
if offsets is not None:
raoffset, decoffset = self.find_ra_dec_offset(input_model.meta.filename)
log.info("Ra and Dec offset (arc seconds) applied to file :%8.6f, %8.6f, %s",
raoffset.value,
decoffset.value, input_model.meta.filename)
raoffset.value, decoffset.value, input_model.meta.filename)

# check if background sky matching as been done in mrs_imatch step
# If it has not been subtracted and the background has not been
Expand Down Expand Up @@ -2442,6 +2441,10 @@ def find_ra_dec_offset(self, filename):

# ********************************************************************************
def offset_coord(self, ra, dec, raoffset, decoffset):
""" Given an ra,dec and ra offset and dec offset, use astropy SkyCoord functions
to apply the offsets
"""

coord = SkyCoord(ra, dec, unit='deg')
coord_new = coord.spherical_offsets_by(raoffset, decoffset)

Expand Down

0 comments on commit e2b352d

Please sign in to comment.