def test_pixel_scale_ratio_spec(miri_rate, ratio): im = AssignWcsStep.call(miri_rate, sip_approx=False) result1 = ResampleSpecStep.call(im) result2 = ResampleSpecStep.call(im, pixel_scale_ratio=ratio) assert_allclose(np.array(result1.data.shape), np.array(result2.data.shape) * ratio, rtol=1, atol=1)
def output_hdul(set_inandout_filenames, config): set_inandout_filenames_info = core_utils.read_info4outputhdul(config, set_inandout_filenames) step, txt_name, step_input_file, step_output_file, run_calwebb_spec2, outstep_file_suffix = set_inandout_filenames_info skip_runing_pipe_step = config.getboolean("tests_only", "_".join((step, "tests"))) # Only run step if data is not IFU inhdu = core_utils.read_hdrfits(step_input_file, info=False, show_hdr=False) end_time = '0.0' print("Is the input file IFU? = ", core_utils.check_IFU_true(inhdu)) if not core_utils.check_IFU_true(inhdu): stp = ResampleSpecStep() # if run_calwebb_spec2 is True calwebb_spec2 will be called, else individual steps will be ran step_completed = False if run_calwebb_spec2: # read the assign wcs fits file local_step_output_file = core_utils.read_completion_to_full_run_map("full_run_map.txt", step) hdul = core_utils.read_hdrfits(local_step_output_file, info=False, show_hdr=False) # move the output file into the working directory working_directory = config.get("calwebb_spec2_input_file", "working_directory") step_output_file = os.path.join(working_directory, local_step_output_file) print ("Step product was saved as: ", step_output_file) subprocess.run(["mv", local_step_output_file, step_output_file]) return hdul else: if config.getboolean("steps", step): print ("*** Step "+step+" set to True") if os.path.isfile(step_input_file): if not skip_runing_pipe_step: # get the right configuration files to run the step local_pipe_cfg_path = config.get("calwebb_spec2_input_file", "local_pipe_cfg_path") # start the timer to compute the step running time start_time = time.time() if local_pipe_cfg_path == "pipe_source_tree_code": result = stp.call(step_input_file) else: result = stp.call(step_input_file, config_file=local_pipe_cfg_path+'/resample_spec.cfg') result.save(step_output_file) # end the timer to compute the step running time end_time = repr(time.time() - start_time) # this is in seconds print("Step "+step+" took "+end_time+" seconds to finish") step_completed = True core_utils.add_completed_steps(txt_name, step, outstep_file_suffix, step_completed, end_time) hdul = core_utils.read_hdrfits(step_output_file, info=False, show_hdr=False) return hdul else: core_utils.add_completed_steps(txt_name, step, outstep_file_suffix, step_completed, end_time) pytest.skip("Skipping "+step+" because the input file does not exist.") else: core_utils.add_completed_steps(txt_name, step, outstep_file_suffix, step_completed, end_time) pytest.skip("Skipping "+step+". Step set to False in configuration file.") else: pytest.skip("Skipping "+step+" because data is IFU data and the resample will be done in cube_build.")
def test_miri_wcs_roundtrip(miri_rate): im = AssignWcsStep.call(miri_rate) im = ResampleSpecStep.call(im) x, y = grid_from_bounding_box(im.meta.wcs.bounding_box) ra, dec, lam = im.meta.wcs(x, y) xp, yp = im.meta.wcs.invert(ra, dec, lam) assert_allclose(x, xp, atol=1e-8) assert_allclose(y, yp, atol=1e-8)
def test_nirspec_wcs_roundtrip(nirspec_rate): im = AssignWcsStep.call(nirspec_rate) im = Extract2dStep.call(im) im = ResampleSpecStep.call(im) for slit in im.slits: x, y = grid_from_bounding_box(slit.meta.wcs.bounding_box) ra, dec, lam = slit.meta.wcs(x, y) xp, yp = slit.meta.wcs.invert(ra, dec, lam) assert_allclose(x, xp, atol=1e-8) assert_allclose(y, yp, atol=1e-8)
def test_spatial_transform(): """ Calling the backwards WCS transform gives the same results for ``negative RA`` and ``negative RA + 360``. """ im = ImageModel() im.meta.wcsinfo._instance.update(wcsinfo) im.meta.instrument._instance.update(instrument) im.meta.exposure._instance.update(exposure) im.meta.observation._instance.update(observation) im.meta.subarray._instance.update(subarray) im = AssignWcsStep.call(im) im.data = np.random.rand(416, 72) im.error = np.random.rand(416, 72) im.dq = np.random.rand(416, 72) im = ResampleSpecStep.call(im) x, y = grid_from_bounding_box(im.meta.wcs.bounding_box) ra, dec, lam = im.meta.wcs(x, y) ra1 = np.where(ra < 0, 360 + ra, ra) assert_allclose(im.meta.wcs.invert(ra, dec, lam), im.meta.wcs.invert(ra1, dec, lam))
def output_hdul(set_inandout_filenames, config): set_inandout_filenames_info = core_utils.read_info4outputhdul( config, set_inandout_filenames) step, txt_name, step_input_file, step_output_file, run_calwebb_spec2, outstep_file_suffix = set_inandout_filenames_info run_pipe_step = config.getboolean("run_pipe_steps", step) # determine which tests are to be run resample_spec_completion_tests = config.getboolean( "run_pytest", "_".join((step, "completion", "tests"))) #resample_spec_reffile_tests = config.getboolean("run_pytest", "_".join((step, "reffile", "tests"))) #resample_spec_validation_tests = config.getboolean("run_pytest", "_".join((step, "validation", "tests"))) run_pytests = [ resample_spec_completion_tests ] #, resample_spec_reffile_tests, resample_spec_validation_tests] end_time = '0.0' # Only run step if data is not IFU or BOTS mode_used = config.get("calwebb_spec2_input_file", "mode_used").lower() working_directory = config.get("calwebb_spec2_input_file", "working_directory") initial_input_file = config.get("calwebb_spec2_input_file", "input_file") initial_input_file = os.path.join(working_directory, initial_input_file) detector = fits.getval(initial_input_file, "DETECTOR", 0) if not os.path.isfile(initial_input_file): pytest.skip( "Skipping " + step + " because the initial input file given in PTT_config.cfg does not exist." ) if mode_used != "bots" and mode_used != "ifu": # if run_calwebb_spec2 is True calwebb_spec2 will be called, else individual steps will be ran step_completed = False # check if the filter is to be changed change_filter_opaque = config.getboolean("calwebb_spec2_input_file", "change_filter_opaque") if change_filter_opaque: is_filter_opaque, step_input_filename = change_filter_opaque2science.change_filter_opaque( step_input_file, step=step) if is_filter_opaque: filter_opaque_msg = "With FILTER=OPAQUE, the calwebb_spec2 will run up to the extract_2d step. Resample pytest now set to Skip." print(filter_opaque_msg) core_utils.add_completed_steps(txt_name, step, outstep_file_suffix, step_completed, end_time) pytest.skip("Skipping " + step + " because the input file does not exist.") if run_calwebb_spec2: hdul = core_utils.read_hdrfits(step_output_file, info=False, show_hdr=False) return hdul, step_output_file, run_pytests else: if run_pipe_step: # Create the logfile for PTT, but erase the previous one if it exists PTTcalspec2_log = os.path.join( working_directory, 'PTT_calspec2_' + detector + '_' + step + '.log') if os.path.isfile(PTTcalspec2_log): os.remove(PTTcalspec2_log) print( "Information outputed to screen from PTT will be logged in file: ", PTTcalspec2_log) for handler in logging.root.handlers[:]: logging.root.removeHandler(handler) logging.basicConfig(filename=PTTcalspec2_log, level=logging.INFO) # print pipeline version import jwst pipeline_version = "\n *** Using jwst pipeline version: " + jwst.__version__ + " *** \n" print(pipeline_version) logging.info(pipeline_version) if change_filter_opaque: logging.info(filter_opaque_msg) if os.path.isfile(step_input_file): msg = " *** Step " + step + " set to True" print(msg) logging.info(msg) stp = ResampleSpecStep() # check that previous pipeline steps were run up to this point core_utils.check_completed_steps(step, step_input_file) # get the right configuration files to run the step local_pipe_cfg_path = config.get( "calwebb_spec2_input_file", "local_pipe_cfg_path") # start the timer to compute the step running time start_time = time.time() if local_pipe_cfg_path == "pipe_source_tree_code": result = stp.call(step_input_file) else: result = stp.call(step_input_file, config_file=local_pipe_cfg_path + '/resample_spec.cfg') result.save(step_output_file) # end the timer to compute the step running time end_time = repr(time.time() - start_time) # this is in seconds msg = "Step " + step + " took " + end_time + " seconds to finish" print(msg) logging.info(msg) step_completed = True hdul = core_utils.read_hdrfits(step_output_file, info=False, show_hdr=False) # rename and move the pipeline log file try: calspec2_pilelog = "calspec2_pipeline_" + step + "_" + detector + ".log" pytest_workdir = os.getcwd() logfile = glob(pytest_workdir + "/pipeline.log")[0] os.rename( logfile, os.path.join(working_directory, calspec2_pilelog)) except: IndexError # add the running time for this step core_utils.add_completed_steps(txt_name, step, outstep_file_suffix, step_completed, end_time) return hdul, step_output_file, run_pytests else: msg = " The input file does not exist. Skipping step." print(msg) logging.info(msg) core_utils.add_completed_steps(txt_name, step, outstep_file_suffix, step_completed, end_time) pytest.skip("Skipping " + step + " because the input file does not exist.") else: msg = "Skipping running pipeline step " + step print(msg) logging.info(msg) end_time = core_utils.get_stp_run_time_from_screenfile( step, detector, working_directory) if os.path.isfile(step_output_file): hdul = core_utils.read_hdrfits(step_output_file, info=False, show_hdr=False) step_completed = True # add the running time for this step core_utils.add_completed_steps(txt_name, step, outstep_file_suffix, step_completed, end_time) return hdul, step_output_file, run_pytests else: step_completed = False # add the running time for this step core_utils.add_completed_steps(txt_name, step, outstep_file_suffix, step_completed, end_time) pytest.skip() else: pytest.skip("Skipping " + step + " because data is either IFU or BOTS.")
def test_spatial_transform_miri(): wcsinfo = { 'dec_ref': -0.00601415671349804, 'ra_ref': -0.02073605215697509, 'roll_ref': -0.0, 'v2_ref': -453.5134, 'v3_ref': -373.4826, 'v3yangle': 0.0, 'vparity': -1 } instrument = {'detector': 'MIRIMAGE', 'filter': 'P750L', 'name': 'MIRI'} observation = {'date': '2019-01-01', 'time': '17:00:00'} subarray = { 'fastaxis': 1, 'name': 'SUBPRISM', 'slowaxis': 2, 'xsize': 72, 'xstart': 1, 'ysize': 416, 'ystart': 529 } exposure = { 'duration': 11.805952, 'end_time': 58119.85416, 'exposure_time': 11.776, 'frame_time': 0.11776, 'group_time': 0.11776, 'groupgap': 0, 'integration_time': 11.776, 'nframes': 1, 'ngroups': 100, 'nints': 1, 'nresets_between_ints': 0, 'nsamples': 1, 'readpatt': 'FAST', 'sample_time': 10.0, 'start_time': 58119.8333, 'type': 'MIR_LRS-SLITLESS', 'zero_frame': False } im = ImageModel() im.data = np.random.rand(416, 72) im.error = np.random.rand(416, 72) im.dq = np.random.rand(416, 72) im.meta.wcsinfo._instance.update(wcsinfo) im.meta.instrument._instance.update(instrument) im.meta.observation._instance.update(observation) im.meta.exposure._instance.update(exposure) im.meta.subarray._instance.update(subarray) out = AssignWcsStep.call(im) out = ResampleSpecStep.call(out) x, y = grid_from_bounding_box(out.meta.wcs.bounding_box) ra, dec, lam = out.meta.wcs(x, y) ra1 = np.where(ra < 0, 360 + ra, ra) assert_allclose(out.meta.wcs.invert(ra, dec, lam), out.meta.wcs.invert(ra1, dec, lam))
def test_spatial_transform_nirspec(): wcsinfo = { 'dec_ref': -0.00601415671349804, 'ra_ref': -0.02073605215697509, 'roll_ref': -0.0, 'v2_ref': -453.5134, 'v3_ref': -373.4826, 'v3yangle': 0.0, 'vparity': -1 } instrument = { 'detector': 'NRS1', 'filter': 'CLEAR', 'grating': 'PRISM', 'name': 'NIRSPEC', 'gwa_tilt': 37.0610, 'gwa_xtilt': 0.0001, 'gwa_ytilt': 0.0001 } subarray = { 'fastaxis': 1, 'name': 'SUBS200A1', 'slowaxis': 2, 'xsize': 72, 'xstart': 1, 'ysize': 416, 'ystart': 529 } observation = {'date': '2016-09-05', 'time': '8:59:37'} exposure = { 'duration': 11.805952, 'end_time': 58119.85416, 'exposure_time': 11.776, 'frame_time': 0.11776, 'group_time': 0.11776, 'groupgap': 0, 'integration_time': 11.776, 'nframes': 1, 'ngroups': 100, 'nints': 1, 'nresets_between_ints': 0, 'nsamples': 1, 'readpatt': 'NRSRAPID', 'sample_time': 10.0, 'start_time': 58119.8333, 'type': 'NRS_FIXEDSLIT', 'zero_frame': False } im = ImageModel() im.data = np.random.rand(2048, 2048) im.error = np.random.rand(2048, 2048) im.dq = np.random.rand(2048, 2048) im.meta.wcsinfo._instance.update(wcsinfo) im.meta.instrument._instance.update(instrument) im.meta.observation._instance.update(observation) im.meta.exposure._instance.update(exposure) im.meta.subarray._instance.update(subarray) im = AssignWcsStep.call(im) im = Extract2dStep.call(im) im = ResampleSpecStep.call(im) for slit in im.products: x, y = grid_from_bounding_box(slit.meta.wcs.bounding_box) ra, dec, lam = slit.meta.wcs(x, y) ra1 = np.where(ra < 0, 360 + ra, ra) assert_allclose(slit.meta.wcs.invert(ra, dec, lam), slit.meta.wcs.invert(ra1, dec, lam))
def test_nirspec_masterbackground_mos_user1d(self): """ Regression test of master background subtraction for NRS MOS when a user 1-D spectrum is provided. """ # input file has 2-D background image added to it input_file = self.get_data(*self.test_dir, 'nrs_mos_sci+bkg_cal.fits') # user provide 1-D background was created from the 2-D background image input_1dbkg_file = self.get_data(*self.test_dir, 'nrs_mos_bkg_x1d.fits') result = MasterBackgroundStep.call(input_file, user_background=input_1dbkg_file, save_results=True) # _________________________________________________________________________ # One of out tests is to compare the 1-D extracted spectra from # the science image (no background added) and the masterbackground subtracted # data. # run resample_spec on results from MasterBackground step result_2d = ResampleSpecStep.call(result) # run 1-D extract on results from MasterBackground step result_1d = Extract1dStep.call(result_2d) # get input science data with background added input_sci_cal_file = self.get_data(*self.test_dir, 'nrs_mos_sci_cal.fits') # get 1-D extract on original science data without background # this reference data was also run through ResampleSpec input_sci_1d_file = self.get_data(*self.ref_loc, 'nrs_mos_sci_extract1dstep.fits') input_sci = datamodels.open(input_sci_cal_file) sci_cal_1d = datamodels.open(input_sci_1d_file) num_spec = len(sci_cal_1d.spec) # the user 1D spectrum may not cover the entire wavelength range of the # science data. Find the wavelength range of user 1-D spectra input_1dbkg_1d = datamodels.open(input_1dbkg_file) user_wave = input_1dbkg_1d.spec[0].spec_table['wavelength'] user_flux = input_1dbkg_1d.spec[0].spec_table['flux'] user_wave_valid = np.where(user_flux > 0) min_user_wave = np.amin(user_wave[user_wave_valid]) max_user_wave = np.amax(user_wave[user_wave_valid]) input_1dbkg_1d.close() # loop over each slit and perform 2 tests on each slit for i in range(num_spec): # ______________________________________________________________________ # Test 1 compare extracted spectra data from the science data # to extracted spectra from the output # from MasterBackground subtraction. sci_spec_1d = sci_cal_1d.spec[i].spec_table['flux'] sci_wave = sci_cal_1d.spec[i].spec_table['wavelength'] result_spec_1d = result_1d.spec[i].spec_table['flux'] # find the waverange covered by both user 1-D and science slit sci_wave_valid = np.where(sci_spec_1d > 0) min_wave = np.amin(sci_wave[sci_wave_valid]) max_wave = np.amax(sci_wave[sci_wave_valid]) if min_user_wave > min_wave: min_wave = min_user_wave if max_user_wave < max_wave: max_wave = max_user_wave sub_spec = sci_spec_1d - result_spec_1d valid = np.where( np.logical_and(sci_wave > min_wave, sci_wave < max_wave)) sub_spec = sub_spec[valid] mean_sub = np.nanmean(sub_spec) atol = 1.5 assert_allclose(mean_sub, 0, atol=atol) # ______________________________________________________________________ # Test 2 compare the science data with no background # to the output from the masterBackground Subtraction step # background subtracted science image. bb = input_sci.slits[i].meta.wcs.bounding_box x, y = grid_from_bounding_box(bb) ra, dec, lam = input_sci.slits[i].meta.wcs(x, y) valid = np.isfinite(lam) sci = input_sci.slits[i].data result_slit = result.slits[i].data # check for outliers in the science image that could cause test # to fail. These could be cosmic ray hits or other yeck that # messes up the science data - ignores these cases sci_mean = np.nanmean(sci[valid]) sci_std = np.nanstd(sci[valid]) upper = sci_mean + sci_std * 5.0 lower = sci_mean - sci_std * 5.0 mask_clean = np.logical_and(sci[valid] < upper, sci[valid] > lower) # for this slit subtract the background subtracted data from # the science data with no background added sub = result_slit - sci # do not look at outliers - they confuse things sub_valid = sub[valid] mean_sub = np.mean(sub_valid[mask_clean]) atol = 0.1 assert_allclose(np.absolute(mean_sub), 0, atol=atol) # ______________________________________________________________________ # Test 3 Compare background sutracted science data (results) # to a truth file. This data is MultiSlit data result_file = result.meta.filename ref_file = self.get_data(*self.ref_loc, 'nrs_mos_sci+bkg_masterbackgroundstep.fits') outputs = [(result_file, ref_file)] self.compare_outputs(outputs) input_sci.close() result.close()
def test_nirspec_masterbackground_mos_user1d(self): """ Regression test of master background subtraction for NRS MOS when a user 1-D spectrum is provided. """ # input file has 2-D background image added to it input_file = self.get_data(*self.test_dir, 'nrs_mos_sci+bkg_cal.fits') # user provide 1-D background was created from the 2-D background image input_1dbkg_file = self.get_data(*self.test_dir, 'nrs_mos_bkg_x1d.fits') result = MasterBackgroundStep.call(input_file, user_background=input_1dbkg_file, save_results=True) # _________________________________________________________________________ # One of out tests is to compare the 1-D extracted spectra from # the science image (no background added) and the masterbackground subtracted # data. # run resample_spec on results from MasterBackground step result_2d = ResampleSpecStep.call(result) # run 1-D extract on results from MasterBackground step result_1d = Extract1dStep.call(result_2d) # get input science data with background added input_sci_cal_file = self.get_data(*self.test_dir, 'nrs_mos_sci_cal.fits') # get 1-D extract on original science data without background # this reference data was also run through ResampleSpec input_sci_1d_file = self.get_data(*self.ref_loc, 'nrs_mos_sci_extract1dstep.fits') input_sci = datamodels.open(input_sci_cal_file) sci_cal_1d = datamodels.open(input_sci_1d_file) num_spec = len(sci_cal_1d.spec) # the user 1D spectrum may not cover the entire wavelength range of the # science data. Find the wavelength range of user 1-D spectra input_1dbkg_1d = datamodels.open(input_1dbkg_file) user_wave = input_1dbkg_1d.spec[0].spec_table['wavelength'] user_flux = input_1dbkg_1d.spec[0].spec_table['flux'] user_wave_valid = np.where(user_flux > 0) min_user_wave = np.amin(user_wave[user_wave_valid]) max_user_wave = np.amax(user_wave[user_wave_valid]) input_1dbkg_1d.close() # loop over each slit and perform 2 tests on each slit for i in range(num_spec): # ______________________________________________________________________ # Test 1 compare extracted spectra data from the science data # to extracted spectra from the output # from MasterBackground subtraction. sci_spec_1d = sci_cal_1d.spec[i].spec_table['flux'] sci_wave = sci_cal_1d.spec[i].spec_table['wavelength'] result_spec_1d = result_1d.spec[i].spec_table['flux'] # find the waverange covered by both user 1-D and science slit sci_wave_valid = np.where(sci_spec_1d > 0) min_wave = np.amin(sci_wave[sci_wave_valid]) max_wave = np.amax(sci_wave[sci_wave_valid]) if min_user_wave > min_wave: min_wave = min_user_wave if max_user_wave < max_wave: max_wave = max_user_wave sub_spec = sci_spec_1d - result_spec_1d valid = np.where(np.logical_and(sci_wave > min_wave, sci_wave < max_wave)) sub_spec = sub_spec[valid] mean_sub = np.nanmean(sub_spec) atol = 1.5 assert_allclose(mean_sub, 0, atol=atol) # ______________________________________________________________________ # Test 2 compare the science data with no background # to the output from the masterBackground Subtraction step # background subtracted science image. bb = input_sci.slits[i].meta.wcs.bounding_box x, y = grid_from_bounding_box(bb) ra, dec, lam = input_sci.slits[i].meta.wcs(x, y) valid = np.isfinite(lam) sci = input_sci.slits[i].data result_slit = result.slits[i].data # check for outliers in the science image that could cause test # to fail. These could be cosmic ray hits or other yeck that # messes up the science data - ignores these cases sci_mean = np.nanmean(sci[valid]) sci_std = np.nanstd(sci[valid]) upper = sci_mean + sci_std*5.0 lower = sci_mean - sci_std*5.0 mask_clean = np.logical_and(sci[valid] < upper, sci[valid] > lower) # for this slit subtract the background subtracted data from # the science data with no background added sub = result_slit - sci # do not look at outliers - they confuse things sub_valid = sub[valid] mean_sub = np.mean(sub_valid[mask_clean]) atol = 0.1 assert_allclose(np.absolute(mean_sub), 0, atol=atol) # ______________________________________________________________________ # Test 3 Compare background sutracted science data (results) # to a truth file. This data is MultiSlit data result_file = result.meta.filename ref_file = self.get_data(*self.ref_loc, 'nrs_mos_sci+bkg_masterbackgroundstep.fits') outputs = [(result_file, ref_file)] self.compare_outputs(outputs) input_sci.close() result.close()
def test_spatial_transform_nirspec(): wcsinfo = { 'dec_ref': 40, 'ra_ref': 100, 'roll_ref': 0, 'v2_ref': -453.5134, 'v3_ref': -373.4826, 'v3yangle': 0.0, 'vparity': -1 } instrument = { 'detector': 'NRS1', 'filter': 'CLEAR', 'grating': 'PRISM', 'name': 'NIRSPEC', 'gwa_tilt': 37.0610, 'gwa_xtilt': 0.0001, 'gwa_ytilt': 0.0001 } subarray = { 'fastaxis': 1, 'name': 'SUBS200A1', 'slowaxis': 2, 'xsize': 72, 'xstart': 1, 'ysize': 416, 'ystart': 529 } observation = {'date': '2016-09-05', 'time': '8:59:37'} exposure = { 'duration': 11.805952, 'end_time': 58119.85416, 'exposure_time': 11.776, 'frame_time': 0.11776, 'group_time': 0.11776, 'groupgap': 0, 'integration_time': 11.776, 'nframes': 1, 'ngroups': 100, 'nints': 1, 'nresets_between_ints': 0, 'nsamples': 1, 'readpatt': 'NRSRAPID', 'sample_time': 10.0, 'start_time': 58119.8333, 'type': 'NRS_FIXEDSLIT', 'zero_frame': False } im = ImageModel((2048, 2048)) im.meta.wcsinfo = wcsinfo im.meta.instrument = instrument im.meta.observation = observation im.meta.exposure = exposure im.meta.subarray = subarray im = AssignWcsStep.call(im) im = Extract2dStep.call(im) im = ResampleSpecStep.call(im) for slit in im.slits: x, y = grid_from_bounding_box(slit.meta.wcs.bounding_box) ra, dec, lam = slit.meta.wcs(x, y) xp, yp = slit.meta.wcs.invert(ra, dec, lam) assert_allclose(x, xp, atol=1e-8) assert_allclose(y, yp, atol=1e-8)
def test_spatial_transform_miri(): wcsinfo = { 'dec_ref': 40, 'ra_ref': 100, 'roll_ref': 0.0, 'v2_ref': -453.5134, 'v3_ref': -373.4826, 'v3yangle': 0.0, 'vparity': -1 } instrument = {'detector': 'MIRIMAGE', 'filter': 'P750L', 'name': 'MIRI'} observation = {'date': '2019-01-01', 'time': '17:00:00'} subarray = { 'fastaxis': 1, 'name': 'SLITLESSPRISM', 'slowaxis': 2, 'xsize': 72, 'xstart': 1, 'ysize': 416, 'ystart': 529 } exposure = { 'duration': 11.805952, 'end_time': 58119.85416, 'exposure_time': 11.776, 'frame_time': 0.11776, 'group_time': 0.11776, 'groupgap': 0, 'integration_time': 11.776, 'nframes': 1, 'ngroups': 100, 'nints': 1, 'nresets_between_ints': 0, 'nsamples': 1, 'readpatt': 'FAST', 'sample_time': 10.0, 'start_time': 58119.8333, 'type': 'MIR_LRS-SLITLESS', 'zero_frame': False } im = ImageModel((416, 72)) im.meta.wcsinfo = wcsinfo im.meta.instrument = instrument im.meta.observation = observation im.meta.exposure = exposure im.meta.subarray = subarray im = AssignWcsStep.call(im) im = ResampleSpecStep.call(im) x, y = grid_from_bounding_box(im.meta.wcs.bounding_box) ra, dec, lam = im.meta.wcs(x, y) xp, yp = im.meta.wcs.invert(ra, dec, lam) assert_allclose(x, xp, atol=1e-8) assert_allclose(y, yp, atol=1e-8)