How to use stwcs - 3 common examples

To help you get started, we’ve selected a few stwcs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gbrammer / grizli / grizli / prep.py View on Github external
TBD
    """
    from drizzlepac import updatehdr
    from stwcs import updatewcs
    from drizzlepac.astrodrizzle import AstroDrizzle
    
    wcs_log = Table.read('{0}_wcs.log'.format(direct['product']),
                         format='ascii.commented_header')
                         
    wcs_hdu = pyfits.open('{0}_wcs.fits'.format(direct['product']))
    
    if get_fresh_flt:
        for file in grism['files']:
            fresh_flt_file(file)
            updatewcs.updatewcs(file, verbose=False)
        
    direct_flt = pyfits.open(direct['files'][0])
    ref_catalog = direct_flt['SCI',1].header['WCSNAME']
    
    #### User-defined shifts
    if xyscale is not None:
        # Use user-defined shifts
        xsh, ysh, rot, scale = xyscale
        
        tmp_wcs = '/tmp/{0}_tmpwcs.fits'.format(str(direct['product']))
        ext = len(wcs_hdu)-1
        wcs_hdu[ext].writeto(tmp_wcs, clobber=True)
        
        for file in grism['files']:
            updatehdr.updatewcs_with_shift(file, tmp_wcs,
                                      xsh=xsh,
github gbrammer / grizli / grizli / prep.py View on Github external
if isACS:
                flc = pyfits.open(file, mode='update')
                if flc[0].header['INSTRUME'] == 'ACS':
                    changed_filter = True
                    flc[0].header['FILTER1'] = 'CLEAR1L'
                    flc[0].header['FILTER2'] = 'F814W'
                    flc.flush()
                    flc.close()
                else:
                    changed_filter = False
                    flc.close()
            else:
                changed_filter = False
                     
            # Run updatewcs 
            updatewcs.updatewcs(file, verbose=False)
            
            # Change back
            if changed_filter:
                flc = pyfits.open(file, mode='update')
                flc[0].header['FILTER1'] = 'CLEAR2L'
                flc[0].header['FILTER2'] = 'G800L'
                flc.flush()
                flc.close()
                
        ### Make ASN
        asn = asnutil.ASNTable(grism['files'], output=grism['product'])
        asn.create()
        asn.write()
            
    if isACS:
        bits = 64+32
github gbrammer / grizli / grizli / prep.py View on Github external
from drizzlepac import updatehdr
    from drizzlepac.astrodrizzle import AstroDrizzle
    
    ################# 
    ##########  Direct image processing
    #################
    
    ### Copy FLT files from ../RAW
    isACS = '_flc' in direct['files'][0]
    isWFPC2 = '_c0m' in direct['files'][0]
    
    if not skip_direct:
        for file in direct['files']:
            crclean = isACS & (len(direct['files']) == 1)
            fresh_flt_file(file, crclean=crclean)
            updatewcs.updatewcs(file, verbose=False)
    
        ### Make ASN
        if not isWFPC2:
            asn = asnutil.ASNTable(inlist=direct['files'], output=direct['product'])
            asn.create()
            asn.write()
    
    ### Initial grism processing
    skip_grism = (grism == {}) | (grism is None) | (len(grism) == 0)
    if not skip_grism:
        for file in grism['files']:
            fresh_flt_file(file)
            
            # Need to force F814W filter for updatewcs
            if isACS:
                flc = pyfits.open(file, mode='update')

stwcs

Computes the WCS of HST images.

BSD-2-Clause
Latest version published 7 months ago

Package Health Score

68 / 100
Full package analysis