def test_hrc_asn(self): rootname = 'j8bt06010' asn_file = rootname + '_asn.fits' # Prepare input files. input_file = self.get_data('input', asn_file) for raw_file in raw_from_asn(asn_file, suffix='_flt.fits'): self.get_input_file('input', raw_file) # run astrodrizzle now... parObj = teal.load('astrodrizzle', defaults=True) # get all default values parObj['build'] = True parObj['runfile'] = 'drizzlepac.run' parObj['STATE OF INPUT FILES']['preserve'] = False parObj['STATE OF INPUT FILES']['clean'] = True parObj['STEP 1: STATIC MASK']['static_sig'] = 3.0 parObj['STEP 2: SKY SUBTRACTION']['skywidth'] = 0.1 parObj['STEP 2: SKY SUBTRACTION']['skylower'] = -50.0 parObj['STEP 2: SKY SUBTRACTION']['skyupper'] = 200.0 parObj['STEP 3: DRIZZLE SEPARATE IMAGES']['driz_sep_bits'] = 8578 parObj['STEP 4: CREATE MEDIAN IMAGE']['combine_maskpt'] = 0.7 parObj['STEP 4: CREATE MEDIAN IMAGE']['combine_nsigma'] = '6 3' parObj['STEP 4: CREATE MEDIAN IMAGE']['combine_nhigh'] = 1 parObj['STEP 6: REMOVE COSMIC RAYS WITH DERIV, DRIZ_CR']['driz_cr_snr'] = '3.0 2.5' parObj['STEP 7: DRIZZLE FINAL COMBINED IMAGE']['final_bits'] = 8578 parObj['STEP 7: DRIZZLE FINAL COMBINED IMAGE']['final_units'] = 'counts' astrodrizzle.AstroDrizzle(asn_file, configobj=parObj) # Compare results outputs = [('j8bt06011_drz.fits', 'reference_asn_regress.fits')] self.compare_outputs(outputs)
def test_acs_narrowband(self): rootname = 'j8dw01010' asn_file = rootname + '_asn.fits' # Prepare input files. # TODO: Why is input_file not referenced? input_file = self.get_data('input', asn_file) for raw_file in raw_from_asn(asn_file, suffix='_flt.fits'): self.get_input_file('input', raw_file) # run astrodrizzle now... parObj = teal.load('astrodrizzle', defaults=True) # get all default values parObj['build'] = True parObj['runfile'] = 'drizzlepac.run' parObj['STATE OF INPUT FILES']['preserve'] = False parObj['STATE OF INPUT FILES']['clean'] = True parObj['STEP 2: SKY SUBTRACTION']['use_static'] = False parObj['STEP 2: SKY SUBTRACTION']['sky_bits'] = None parObj['STEP 4: CREATE MEDIAN IMAGE']['combine_maskpt'] = 0.7 parObj['STEP 4: CREATE MEDIAN IMAGE']['combine_nsigma'] = '6 3' parObj['STEP 4: CREATE MEDIAN IMAGE']['combine_nhigh'] = 1 parObj['STEP 6: REMOVE COSMIC RAYS WITH DERIV, DRIZ_CR']['driz_cr_snr'] = '3.0 2.5' parObj['STEP 7: DRIZZLE FINAL COMBINED IMAGE']['final_bits'] = 8578 parObj['STEP 7a: CUSTOM WCS FOR FINAL OUTPUT']['final_wcs'] = True parObj['STEP 7a: CUSTOM WCS FOR FINAL OUTPUT']['final_rot'] = 0.0 astrodrizzle.AstroDrizzle(asn_file, configobj=parObj) # Compare results outputs = [('j8dw01010_drz.fits', 'reference_narrowband.fits')] self.compare_outputs(outputs)
def test_acs_narrowband(self): rootname = 'j8dw01010' asn_file = rootname + '_asn.fits' # Prepare input files. # TODO: Why is input_file not referenced? input_file = self.get_data('input', asn_file) for raw_file in raw_from_asn(asn_file, suffix='_flt.fits'): self.get_input_file('input', raw_file) # run astrodrizzle now... parObj = teal.load('astrodrizzle', defaults=True) # get all default values parObj['build'] = True parObj['runfile'] = 'drizzlepac.run' parObj['STATE OF INPUT FILES']['preserve'] = False parObj['STATE OF INPUT FILES']['clean'] = True parObj['STEP 2: SKY SUBTRACTION']['use_static'] = False parObj['STEP 2: SKY SUBTRACTION']['sky_bits'] = None parObj['STEP 4: CREATE MEDIAN IMAGE']['combine_maskpt'] = 0.7 parObj['STEP 4: CREATE MEDIAN IMAGE']['combine_nsigma'] = '6 3' parObj['STEP 4: CREATE MEDIAN IMAGE']['combine_nhigh'] = 1 parObj['STEP 6: REMOVE COSMIC RAYS WITH DERIV, DRIZ_CR'][ 'driz_cr_snr'] = '3.0 2.5' parObj['STEP 7: DRIZZLE FINAL COMBINED IMAGE']['final_bits'] = 8578 parObj['STEP 7a: CUSTOM WCS FOR FINAL OUTPUT']['final_wcs'] = True parObj['STEP 7a: CUSTOM WCS FOR FINAL OUTPUT']['final_rot'] = 0.0 astrodrizzle.AstroDrizzle(asn_file, configobj=parObj) # Compare results outputs = [('j8dw01010_drz.fits', 'reference_narrowband.fits')] self.compare_outputs(outputs)
def test_uvis_asn(self): rootname = 'iacr51010' asn_file = '{}_asn.fits'.format(rootname) output = '{}_drz.fits'.format(rootname) ref_file = 'reference_wfc3_uvis_asn.fits' runfile = ref_file.replace('.fits','.log') # Prepare input files. input_files = [] input_asn = self.get_data('input', asn_file) for raw_file in raw_from_asn(asn_file, suffix='_flt.fits'): input_files.append(os.path.basename(self.get_input_file('input', raw_file))) # define input parameters to be used input_pars = {'output': output, 'runfile':runfile, 'build':True, 'in_memory':False, 'preserve': False, 'clean':True, 'static':True, 'skysub':True, 'skywidth':0.3, 'use_static':False, 'sky_bits':None} # run astrodrizzle now... parObj = teal.load('astrodrizzle', defaults=True) # get all default values astrodrizzle.AstroDrizzle(asn_file, mdriztab=False, configobj=parObj, **input_pars) # Compare results outputs = [(output, ref_file)] self.compare_outputs(outputs)
def test_raw_from_asn(_jail): # Make a dummy input file (to avoid package data headache) tab = Table() tab['MEMNAME'] = ['J6LQ01NAQ', 'J6LQ01NDQ', 'J6LQ01011'] tab['MEMTYPE'] = ['EXP-CRJ', 'EXP-CRJ', 'PROD-CRJ'] tab['MEMPRSNT'] = [True, True, True] datafile = 'dummy_asn.fits' tab.write(datafile, format='fits', overwrite=True) raw_files = raw_from_asn(datafile) assert raw_files == ['j6lq01naq_raw.fits', 'j6lq01ndq_raw.fits'] # Make sure do not download existing file. # This will fail if download is attemped. download_crds(datafile)
def test_hrc_asn(self): rootname = 'j8bt06010' asn_file = rootname + '_asn.fits' # Prepare input files. input_file = self.get_data('input', asn_file) for raw_file in raw_from_asn(asn_file, suffix='_flt.fits'): self.get_input_file('input', raw_file) # run astrodrizzle now... parObj = teal.load('astrodrizzle', defaults=True) # get all default values parObj['build'] = True parObj['runfile'] = 'drizzlepac.run' parObj['STATE OF INPUT FILES']['preserve'] = False parObj['STATE OF INPUT FILES']['clean'] = True parObj['STEP 1: STATIC MASK']['static_sig'] = 3.0 parObj['STEP 2: SKY SUBTRACTION']['skywidth'] = 0.1 parObj['STEP 2: SKY SUBTRACTION']['skylower'] = -50.0 parObj['STEP 2: SKY SUBTRACTION']['skyupper'] = 200.0 parObj['STEP 3: DRIZZLE SEPARATE IMAGES']['driz_sep_bits'] = 8578 parObj['STEP 4: CREATE MEDIAN IMAGE']['combine_maskpt'] = 0.7 parObj['STEP 4: CREATE MEDIAN IMAGE']['combine_nsigma'] = '6 3' parObj['STEP 4: CREATE MEDIAN IMAGE']['combine_nhigh'] = 1 parObj['STEP 6: REMOVE COSMIC RAYS WITH DERIV, DRIZ_CR'][ 'driz_cr_snr'] = '3.0 2.5' parObj['STEP 7: DRIZZLE FINAL COMBINED IMAGE']['final_bits'] = 8578 parObj['STEP 7: DRIZZLE FINAL COMBINED IMAGE'][ 'final_units'] = 'counts' astrodrizzle.AstroDrizzle(asn_file, configobj=parObj) # Compare results outputs = [('j8bt06011_drz.fits', 'reference_asn_regress.fits')] self.compare_outputs(outputs)
def raw_from_asn(self, asn_file, suffix='_flt.fits'): return raw_from_asn(asn_file, suffix='_flt.fits')
def get_input_file(self, filename): """ Copy input file (ASN, RAW, etc) into the working directory. If ASN is given, RAW files in the ASN table is also copied. The associated CRDS reference files are also copied or downloaded, if necessary. Data directory layout for HSTCAL:: instrument/ detector/ input/ truth/ .. note:: If given filename has ".orig" suffix, the suffix is also automatically removed. Parameters ---------- filename : str Filename of the ASN/RAW/etc to copy over, along with its associated files. """ # Copy over main input file. dest = get_bigdata(self.env, self.instrument, self.detector, 'input', filename) # For historical reason, need to remove ".orig" suffix if it exists. if filename.endswith('.orig'): newfilename = filename.rstrip('.orig') os.rename(filename, newfilename) filename = newfilename if filename.endswith('_asn.fits'): all_raws = raw_from_asn(filename) for raw in all_raws: # Download RAWs in ASN. get_bigdata(self.env, self.instrument, self.detector, 'input', raw) else: all_raws = [filename] first_pass = ('JENKINS_URL' in os.environ and 'ssbjenkins' in os.environ['JENKINS_URL']) for raw in all_raws: ref_files = calref_from_image(raw) for ref_file in ref_files: # Special reference files that live with inputs. if ('$' not in ref_file and os.path.basename(ref_file) == ref_file): get_bigdata(self.env, self.instrument, self.detector, 'input', ref_file) continue # Jenkins cannot see Central Storage on push event, # and somehow setting, say, jref to "." does not work anymore. # So, we need this hack. if '$' in ref_file and first_pass: first_pass = False if not os.path.isdir('/grp/hst/cdbs'): ref_path = os.path.dirname(dest) + os.sep var = ref_file.split('$')[0] os.environ[var] = ref_path # hacky hack hack # Download reference files, if needed only. download_crds(ref_file, timeout=self.timeout)
def get_input_file(self, filename): """ Copy input file (ASN, RAW, etc) into the working directory. If ASN is given, RAW files in the ASN table is also copied. The associated CRDS reference files are also copied or downloaded, if necessary. Data directory layout for CALCOS:: detector/ input/ truth/ Parameters ---------- filename : str Filename of the ASN/RAW/etc to copy over, along with its associated files. """ # Copy over main input file. dest = get_bigdata('scsb-calcos', self.env, self.detector, 'input', filename) # TODO: This logic was based on ONE FUV test. Please revise as needed. if filename.endswith('_asn.fits'): all_raws = raw_from_asn(filename, '_rawtag_a.fits') all_raws += raw_from_asn(filename, '_rawtag_b.fits') for raw in all_raws: # Download RAWs in ASN. get_bigdata('scsb-calcos', self.env, self.detector, 'input', raw) for raw in raw_from_asn(filename, '_spt.fits'): # Input SPTs get_bigdata('scsb-calcos', self.env, self.detector, 'input', raw) else: all_raws = [filename] first_pass = ('JENKINS_URL' in os.environ and 'ssbjenkins' in os.environ['JENKINS_URL']) for raw in all_raws: ref_files = calref_from_image(raw) for ref_file in ref_files: # Special reference files that live with inputs. if ('$' not in ref_file and os.path.basename(ref_file) == ref_file): get_bigdata('scsb-calcos', self.env, self.detector, 'input', ref_file) continue # Jenkins cannot see Central Storage on push event, # and somehow setting, say, jref to "." does not work anymore. # So, we need this hack. if '$' in ref_file and first_pass: first_pass = False if not os.path.isdir('/grp/hst/cdbs'): ref_path = os.path.dirname(dest) + os.sep var = ref_file.split('$')[0] os.environ[var] = ref_path # hacky hack hack # Download reference files, if needed only. download_crds(ref_file, timeout=self.timeout)
def get_input_files(self, filenames): """ Copy input files (ASN, RAW, etc) into the working directory. If ASN is given, RAW files in the ASN table are also copied. The associated CRDS reference files are also copied or downloaded, if necessary. Data directory layout for CALCOS:: detector/ input/ truth/ Parameters ---------- filename : list List of filenames of the ASN/RAW/etc to copy over, along with their associated files. """ all_raws = [] for file in filenames: if file.endswith('_rawtag_a.fits') or file.endswith('_rawtag_b.fits'): all_raws.append(file) # List of filenames can include _rawtag, _asn and _spt files dest = get_bigdata('scsb-calcos', self.env, self.detector, 'input', file) # If file is an association table, download raw files specified in the table if file.endswith('_asn.fits'): asn_raws = raw_from_asn(file, '_rawtag_a.fits') asn_raws += raw_from_asn(file, '_rawtag_b.fits') for raw in asn_raws: # Download RAWs in ASN. get_bigdata('scsb-calcos', self.env, self.detector, 'input', raw) all_raws += asn_raws first_pass = ('JENKINS_URL' in os.environ and 'ssbjenkins' in os.environ['JENKINS_URL']) for raw in all_raws: ref_files = calref_from_image(raw) for ref_file in ref_files: # Special reference files that live with inputs. if ('$' not in ref_file and os.path.basename(ref_file) == ref_file): get_bigdata('scsb-calcos', self.env, self.detector, 'input', ref_file) continue # Jenkins cannot see Central Storage on push event, # and somehow setting, say, jref to "." does not work anymore. # So, we need this hack. if '$' in ref_file and first_pass: first_pass = False if not os.path.isdir('/grp/hst/cdbs'): ref_path = os.path.dirname(dest) + os.sep var = ref_file.split('$')[0] os.environ[var] = ref_path # hacky hack hack # Download reference files, if needed only. download_crds(ref_file, timeout=self.timeout)