def test_run_msaflagging(self, caplog): """Test msa flagging operation""" # Retrieve the data. collect_pipeline_cfgs('cfgs') self.get_data( *self.test_dir, 'jw95065006001_0_msa_twoslit.fits' ) asn_path = self.get_data( *self.test_dir, 'mos_udf_g235m_twoslit_spec2_asn.json' ) with open(asn_path) as fp: asn = load_asn(fp) for product in asn['products']: for member in product['members']: self.get_data( *self.test_dir, 'level2a_twoslit', member['expname'] ) # Run step. args = [ op.join('cfgs', 'calwebb_spec2.cfg'), asn_path, '--steps.msa_flagging.skip=false' ] Step.from_cmdline(args) # Test. assert 'Step msa_flagging running with args' in caplog.text assert 'Step msa_flagging done' in caplog.text for product in asn['products']: prod_name = product['name'] + '_cal.fits' assert op.isfile(prod_name)
def test_run_msaflagging(self, caplog): """Test msa flagging operation""" # Retrieve the data. collect_pipeline_cfgs('cfgs') self.get_data(*self.test_dir, 'jw95065006001_0_msa_twoslit.fits') asn_path = self.get_data(*self.test_dir, 'mos_udf_g235m_twoslit_spec2_asn.json') with open(asn_path) as fp: asn = load_asn(fp) for product in asn['products']: for member in product['members']: self.get_data(*self.test_dir, 'level2a_twoslit', member['expname']) # Run step. args = [ op.join('cfgs', 'calwebb_spec2.cfg'), asn_path, '--steps.msa_flagging.skip=false' ] Step.from_cmdline(args) # Test. assert 'Step msa_flagging running with args' in caplog.text assert 'Step msa_flagging done' in caplog.text for product in asn['products']: prod_name = product['name'] + '_cal.fits' assert op.isfile(prod_name)
def test_msa_missing(self, caplog): """Test MSA missing failure""" input_file = self.get_data( *self.test_dir, 'level2a_twoslit', 'F170LP-G235M_MOS_observation-6-c0e0_001_DN_NRS1_mod.fits') collect_pipeline_cfgs('cfgs') args = [op.join('cfgs', 'calwebb_spec2.cfg'), input_file] with pytest.raises(Exception): Step.from_cmdline(args) assert 'Missing MSA meta (MSAMETFL) file' in caplog.text
def test_msa_missing_skip(self, caplog): """Test MSA missing failure""" input_file = self.get_data( *self.test_dir, 'level2a_twoslit', 'F170LP-G235M_MOS_observation-6-c0e0_001_DN_NRS1_mod.fits') collect_pipeline_cfgs('cfgs') args = [ op.join('cfgs', 'calwebb_spec2.cfg'), input_file, '--steps.assign_wcs.skip=true' ] Step.from_cmdline(args) assert 'Aborting remaining processing for this exposure.' in caplog.text
def test_msa_missing_nofail(self, caplog): """Test MSA missing failure""" input_file = self.get_data( *self.test_dir, 'level2a_twoslit', 'F170LP-G235M_MOS_observation-6-c0e0_001_DN_NRS1_mod.fits') collect_pipeline_cfgs('cfgs') args = [ op.join('cfgs', 'calwebb_spec2.cfg'), input_file, '--fail_on_exception=false' ] Step.from_cmdline(args) assert 'Unable to open MSA FITS file (MSAMETFL)' in caplog.text
def test_msa_missing_skip(self, caplog): """Test MSA missing failure""" input_file = self.get_data( *self.test_dir, 'level2a_twoslit', 'F170LP-G235M_MOS_observation-6-c0e0_001_DN_NRS1_mod.fits' ) collect_pipeline_cfgs('cfgs') args = [ op.join('cfgs', 'calwebb_spec2.cfg'), input_file, '--steps.assign_wcs.skip=true' ] Step.from_cmdline(args) assert 'Aborting remaining processing for this exposure.' in caplog.text
def test_msa_missing_nofail(self, caplog): """Test MSA missing failure""" input_file = self.get_data( *self.test_dir, 'level2a_twoslit', 'F170LP-G235M_MOS_observation-6-c0e0_001_DN_NRS1_mod.fits' ) collect_pipeline_cfgs('cfgs') args = [ op.join('cfgs', 'calwebb_spec2.cfg'), input_file, '--fail_on_exception=false' ] Step.from_cmdline(args) assert 'Unable to open MSA FITS file (MSAMETFL)' in caplog.text
def test_from_command_line_override(): """Test creating Step from command line using ASDF""" config_file = t_path( Path('steps') / 'jwst_generic_pars-makeliststep_0001.asdf') args = [config_file, '--par1=0.'] step = Step.from_cmdline(args) assert isinstance(step, MakeListStep) assert step.par1 == 0. assert step.par2 == 'Yes, a string' results = step.run() assert results == [0., DEFAULT_PAR2, False]
def test_asdf_roundtrip_pipeline(_jail): """Save a Pipeline pars and re-instantiate with the save parameters""" # Save the parameters par_path = 'mkp_pars.asdf' args = [ 'jwst.stpipe.tests.steps.MakeListPipeline', 'a.fits', 'b', '--steps.make_list.par1', '10.', '--steps.make_list.par2', 'par2', '--save-parameters', par_path ] Step.from_cmdline(args) # Rerun with the parameter file # Initial condition is that `Step.from_cmdline` # succeeds. args = [par_path, 'a.fits', 'b'] step = Step.from_cmdline(args) # As a secondary condition, ensure the required parameter # `par2` is set. assert step.make_list.par2 == 'par2'
def test_asn_naming(self): """Test a full run""" # Get the data collect_pipeline_cfgs('cfgs') asn_path = self.get_data( self.test_dir, 'wfs_3sets_asn.json' ) with open(asn_path) as fh: asn = load_asn(fh) for product in asn['products']: for member in product['members']: self.get_data( self.test_dir, member['expname'] ) input_files = glob('*') # Run the step. args = [ op.join('cfgs', 'calwebb_wfs-image3.cfg'), asn_path ] Step.from_cmdline(args) # Test. output_files = glob('*') for input_file in input_files: output_files.remove(input_file) print('output_files = {}'.format(output_files)) for product in asn['products']: prod_name = product['name'] prod_name = format_product(prod_name, suffix='wfscmb') prod_name += '.fits' assert prod_name in output_files output_files.remove(prod_name) # There should be no more files assert len(output_files) == 0