Ejemplo n.º 1
0
        # Read in image header and data:
        hdulist = pyfits.open(fitsfile)
        # Check for empty extension, if so advance to next extension:
        k, NAXIS = -1, 0
        while NAXIS == 0:
            k += 1
            hdr = hdulist[k].header
            NAXIS = hdr['NAXIS']
        img = hdulist[k].data
        bad = (img != img)
        img[bad] = 0.0

        # Read WCS, and measure pixel scale:
        wcs = pywcs.WCS(hdr)
        cell = proto.pixscale(hdr)

        # Extract MJD from FITS header:
        if hdr.has_key('PSCAMERA'):
            # PS1 data:
            MJD = hdr['MJD-OBS']
            filter = hdr['HIERARCH FPA.FILTER']
            band = string.split(filter, '.')[0]
        else:
            MJD = hdr['MJD']
            band = hdr['FILTER']
        MJDstring = "%.5f" % MJD

        # Write output png filename:
        pngfile = fitsfile.replace('.fits', '_annotated.png')
Ejemplo n.º 2
0
    # Read in image header:
    hdulist = pyfits.open(input)
    # Check for empty extension, if so advance to next extension:
    k,NAXIS = -1,0
    while NAXIS == 0 :
      k += 1
      hdr = hdulist[k].header
      NAXIS = hdr['NAXIS']

    if vb: print "Read in header from extension",k,"of",input
    
    # Read WCS, and measure pixel scale:
    wcs = pywcs.WCS(hdr)
    #  wcs.wcs.print_contents()
    cell = proto.pixscale(hdr) 
    if vb: print "Pixel scale =",cell
    
    iw = 2*int(0.5*w/cell) + 1
    ww = iw*cell
    if vb: print "Cutout size  =",iw,"pixels, or",ww,"arcsec"
        
    # Check if sky position is in image:
    footprint = wcs.calcFootprint(hdr)
    
    print "footprint = ",footprint
    
    if proto.point_inside_polygon(ra0,dec0,footprint):
      if vb: print "Object centre does lie in footprint of image"

      # Find central pixel:
Ejemplo n.º 3
0
    for scifile in inputfiles:

        # Read in image header:
        hdulist = pyfits.open(scifile)
        # Check for empty extension, if so advance to next extension:
        k, NAXIS = -1, 0
        while NAXIS == 0:
            k += 1
            hdr = hdulist[k].header
            NAXIS = hdr['NAXIS']

        # if vb: print "Read in header from extension",k,"of",scifile

        # Read WCS, and measure pixel scale:
        wcs = pywcs.WCS(hdr)
        pltscale = proto.pixscale(hdr)
        # if vb: print "Pixel scale =",pltscale

        # Extract filter, MJD, GAIN and zero point from FITS header:
        if hdr.has_key('PSCAMERA'):
            # PS1 data:
            filter = hdr['HIERARCH FPA.FILTER']
            # filter = string.split(filter,'.')[0]
            MJD = hdr['MJD-OBS']
            zpt = hdr['HIERARCH FPA.ZP']
            if zpt == 'NaN': zpt = 30.0  # HACK.
            gain = hdr['HIERARCH CELL.GAIN']
            FWHM = hdr['HIERARCH CHIP.SEEING'] * pltscale  # in arcsec
            if (FWHM <= 0 or FWHM > 100): FWHM = 0.999999  # red flag value
        else:
            filter = hdr['FILTER']
Ejemplo n.º 4
0
   for scifile in inputfiles:

      # Read in image header:
      hdulist = pyfits.open(scifile)
      # Check for empty extension, if so advance to next extension:
      k,NAXIS = -1,0
      while NAXIS == 0 :
        k += 1
        hdr = hdulist[k].header
        NAXIS = hdr['NAXIS']

      # if vb: print "Read in header from extension",k,"of",scifile

      # Read WCS, and measure pixel scale:
      wcs = pywcs.WCS(hdr)
      pltscale = proto.pixscale(hdr) 
      # if vb: print "Pixel scale =",pltscale

      # Extract filter, MJD, GAIN and zero point from FITS header:
      if hdr.has_key('PSCAMERA') :
        # PS1 data:
        filter = hdr['HIERARCH FPA.FILTER']
        # filter = string.split(filter,'.')[0]
        MJD = hdr['MJD-OBS']
        zpt = hdr['HIERARCH FPA.ZP']
        if zpt == 'NaN': zpt = 30.0  # HACK.
        gain = hdr['HIERARCH CELL.GAIN']
        FWHM = hdr['HIERARCH CHIP.SEEING']*pltscale # in arcsec
        if (FWHM <= 0 or FWHM > 100): FWHM = 0.999999 # red flag value
      else :
        filter = hdr['FILTER']