Ejemplo n.º 1
0
    _catalogue = option.catalogue
    number1 = option.number1
    number2 = option.number2
    number3 = option.number3
    _t1 = option.tollerance1
    _t2 = option.tollerance2
    _minnum = option.match
    _xshift = option.xshift
    _yshift = option.yshift
    if _catalogue == 'inst':
        _catalogue2 = ['2mass', 'usnoa2', 'usnob1']
    else:
        _catalogue2 = [_catalogue]
    for img in imglist:
        hdr = lsc.readhdr(img)
        _wcserr = lsc.readkey3(hdr, 'wcserr')
        _astromet = lsc.readkey3(hdr, 'ASTROMET')
        if not int(_wcserr) and _redo == False:
            print '\n#####  astrometry already done'
        else:
            _instrume = lsc.readkey3(hdr, 'instrume')
            if 'fs' in _instrume or 'em' in _instrume:  # FT field are small, half number of star
                number1, number2, number3 = number1 / 2, number2 / 2, number3 / 2

            sexvec = lsc.lscastrodef.sextractor(img)
            try:
                for cat in _catalogue2:
                    rmsx3, rmsy3, num3, fwhmgess, ellgess, ccc, rasys3, decsys3, mbkg3 = lsc.lscastrodef.lscastroloop(
                        [img], cat, _interactive, number1, number2, number3,
                        'rxyscale', _t1, _t2, sexvec, True, _minnum, _method,
                        _xshift, _yshift)
Ejemplo n.º 2
0
                        if os.path.isfile(
                                _dirtemp +
                                imgtemp0.replace('.fits', '.sn2.fits')):
                            hdtempsn = fits.getheader(
                                _dirtemp +
                                imgtemp0.replace('.fits', '.sn2.fits'))
                        else:
                            hdtempsn = {}

                        data_targ, head_targ = fits.getdata(_dir + imgtarg0,
                                                            header=True)
                        exp_targ = lsc.util.readkey3(head_targ, 'exptime')
                        sat_targ = lsc.util.readkey3(head_targ, 'datamax')
                        gain_targ = lsc.util.readkey3(head_targ, 'gain')
                        rn_targ = lsc.readkey3(head_targ, 'ron')
                        max_fwhm = head_targ.get('L1FWHM', 3.0)

                        data_temp, head_temp = fits.getdata(_dirtemp +
                                                            imgtemp0,
                                                            header=True)
                        exp_temp = lsc.util.readkey3(head_temp, 'exptime')
                        sat_temp = lsc.util.readkey3(head_temp, 'datamax')
                        gain_temp = lsc.util.readkey3(head_temp, 'gain')
                        rn_temp = head_temp.get('rdnoise', 1)

                        imgtemp = '_temp.fits'
                        imgtarg = '_targ.fits'
                        imgout = '_out.fits'
                        tempmask = '_tempmask.fits'
                        targmask = '_targmask.fits'
Ejemplo n.º 3
0
#                        print "try flipping the template image\n cp flip.fits "+_dirtemp + imgtemp0+'\n and run again psf and cosmic'
                        #sys.exit()

                        if _show:
                            iraf.display(imgtemp, frame=4, fill='yes')
                            iraf.display(_dirtemp + imgtemp0, frame=3, fill='yes')
                            iraf.display(imgtarg, frame=2, fill='yes')
                            iraf.display(_dir + imgtarg0, frame=1, fill='yes')

                        ###########################################################

                        data_targ, head_targ = fits.getdata(imgtarg, header=True)
                        exp_targ  = lsc.util.readkey3(head_targ, 'exptime')
                        sat_targ = lsc.util.readkey3(head_targ, 'saturate')
                        gain_targ = lsc.util.readkey3(head_targ, 'gain')
                        rn_targ = lsc.readkey3(head_targ,'ron')

                        data_temp, head_temp = fits.getdata(imgtemp, header=True)
                        exp_temp = lsc.util.readkey3(head_temp, 'exptime')
                        sat_temp = lsc.util.readkey3(head_temp, 'saturate')
                        gain_temp = lsc.util.readkey3(head_temp, 'gain')

                        if 'rdnoise' in head_temp:
                            rn_temp   = head_temp['rdnoise']
                        else:
                            rn_temp   = 1

                        if 'L1FWHM' in head_targ: 
                            max_fwhm = head_targ['L1FWHM']  # to be check
                        else:                     
                            max_fwhm = 3.0
Ejemplo n.º 4
0
    number1 = option.number1
    number2 = option.number2
    number3 = option.number3
    _t1 = option.tollerance1
    _t2 = option.tollerance2
    _minnum = option.match
    _xshift = option.xshift
    _yshift = option.yshift
    if _catalogue in ['inst']:
        _catalogue2 = ['2mass', 'usnoa2', 'usnob1']
    # elif _catalogue in ['2mass','usnoa2','usnob1']:   _catalogue2=_catalogue
    else:
        _catalogue2 = [_catalogue]
    for img in imglist:
        hdr = lsc.readhdr(img)
        _wcserr = lsc.readkey3(hdr, 'wcserr')
        _astromet = lsc.readkey3(hdr, 'ASTROMET')
        done = 0
        if float(_wcserr) == 0: done = 1
        if done == 0:
            if _astromet:
                if float(string.split(_astromet)[0]) < 2 and float(string.split(_astromet)[1]) < 2:
                    done = 1

        if done == 1 and _redo == False:
            print '\n#####  astrometry already done'
        else:
            _instrume = lsc.readkey3(hdr, 'instrume')
            if 'fs' in _instrume or 'em' in _instrume:  # FT field are small, half number of star
                number1, number2, number3 = number1 / 2, number2 / 2, number3 / 2
Ejemplo n.º 5
0
def sloanimage(img, survey='sloan', frames=[], show=False, force=False):
    import sys
    from lsc import readhdr, readkey3, deg2HMS, display_image
    if show:
        display_image(img, 1, True, '', '')
    hdr = readhdr(img)
    _ra = readkey3(hdr, 'RA')
    _dec = readkey3(hdr, 'DEC')
    _object = readkey3(hdr, 'object')
    _instrume = readkey3(hdr, 'instrume')
    _filter = readkey3(hdr, 'filter')
    _radius = 1100
    filt = {'up': 'u', 'gp': 'g', 'rp': 'r', 'ip': 'i', 'zs': 'z'}

    if _filter in filt.keys():
        _band = filt[_filter]
    else:
        _band = _filter

    if 'fs' in _instrume:
        _telescope = 'spectral'
    elif 'fl' in _instrume:
        _telescope = 'sinistro'
    elif 'kb' in _instrume:
        _telescope = 'sbig'

    print _ra, _dec, _band, _radius
    if survey == 'sloan':
        frames = downloadsdss(_ra, _dec, _band, _radius, force)
    elif survey == 'ps1':
        if len(frames) == 0:
            delta = 0.22
            DR = delta / np.cos(_dec * np.pi / 180)
            DD = delta
            f = open(_object + '_' + _band + '_ps1request.txt', 'w')
            f.write('%s   %s   %s\n' % (str(_ra), str(_dec), str(_band)))
            f.write('%s   %s   %s\n' %
                    (str(_ra + DR), str(_dec + DD), str(_band)))
            f.write('%s   %s   %s\n' %
                    (str(_ra - DR), str(_dec - DD), str(_band)))
            f.write('%s   %s   %s\n' %
                    (str(_ra + DR), str(_dec - DD), str(_band)))
            f.write('%s   %s   %s\n' %
                    (str(_ra - DR), str(_dec + DD), str(_band)))
            f.close()
            print '#' * 20
            print "Please submit file:" + _object + '_' + _band + '_ps1request  at this link (you need an account)\n'
            print "   http://psps.ifa.hawaii.edu/PSI/postage_stamp.php    "
            print "   select:\n       Survey ID:    3PI          3PI.PV3  \n  "
            print "   Image Type:       Total Stacked Image, 1 pixel 0.250 "
            print "   Method of Image Selection by:   Coordinate- Images are selected based on supplied Ra and DEC   "
            print "   Size of the Postage Stamp:   (x) Arc-Second             Width:  2000         Height: 2000    pixel"
            print "   Center Coordinate of Image  - Input coordinate From: "
            print "                  (x)  Upload File           "
            print "        Choose File:    " + _object + '_' + _band + '_ps1request.txt'
            print '#' * 20
            answ = raw_input(
                'Do you want to wait that the frames are downloded [y/n]  [y] ? '
            )
            if not answ:
                answ = 'y'
            if answ in ['Yes', 'yes', 'Y', 'y']:
                print 'Which is the last req_name at this page: '
                answ1 = raw_input(
                    'http://psps.ifa.hawaii.edu/PSI/postage_stamp_results.php ? '
                )
                if not answ1:
                    sys.exit(
                        'no name provided, no PS1 images have been downloaded')
                else:
                    print 'try download........'
                    frames = downloadPS1('./', answ1)
        else:
            frames2 = []
            for img in frames:
                if '_' + _band + '_' in img:
                    frames2.append(img)

            frames = frames2
    if len(frames):
        out, varimg = sdss_swarp(frames,
                                 _telescope,
                                 _ra,
                                 _dec,
                                 '',
                                 _object,
                                 survey,
                                 show=show)
    else:
        sys.exit('exit, no PS1 images have been downloaded')
    return out, varimg
Ejemplo n.º 6
0
def sloanimage(img,survey='sloan',frames=[], show=False, force=False):
   import sys
   from lsc import readhdr, readkey3,deg2HMS,display_image
   if show:
      display_image(img,1,True,'','')
   hdr = readhdr(img)
   _ra = readkey3(hdr,'RA')
   _dec = readkey3(hdr,'DEC')
   _object = readkey3(hdr,'object')
   _instrume = readkey3(hdr,'instrume')
   _filter = readkey3(hdr,'filter')
   _radius = 1100
   filt={'up':'u','gp':'g','rp':'r','ip':'i','zs':'z'}

   if _filter in filt.keys():
      _band = filt[_filter]
   else:
      _band = _filter

   if 'fs' in _instrume:
      _telescope = 'spectral'
   elif 'fl' in _instrume:
      _telescope = 'sinistro'
   elif 'fa' in _instrume:
      _telescope = 'sinistro'
   elif 'kb' in _instrume:
      _telescope = 'sbig'

   print _ra, _dec, _band, _radius
   if survey == 'sloan':
      frames =  downloadsdss(_ra, _dec, _band, _radius, force)
   elif survey == 'ps1':
      if len(frames) == 0:
         delta= 0.22
         DR = delta/np.cos(_dec*np.pi/180)
         DD = delta
         f=open(_object+'_'+_band+'_ps1request.txt','w')
         f.write('%s   %s   %s\n' %(str(_ra),str(_dec),str(_band)))
         f.write('%s   %s   %s\n' %(str(_ra+DR),str(_dec+DD),str(_band)))
         f.write('%s   %s   %s\n' %(str(_ra-DR),str(_dec-DD),str(_band)))
         f.write('%s   %s   %s\n' %(str(_ra+DR),str(_dec-DD),str(_band)))
         f.write('%s   %s   %s\n' %(str(_ra-DR),str(_dec+DD),str(_band)))
         f.close()
         print '#'*20
         print "Please submit file:"+_object+'_'+_band+'_ps1request  at this link (you need an account)\n'
         print "   http://psps.ifa.hawaii.edu/PSI/postage_stamp.php    "
         print "   select:\n       Survey ID:    3PI          3PI.PV3  \n  "
         print "   Image Type:       Total Stacked Image, 1 pixel 0.250 "
         print "   Method of Image Selection by:   Coordinate- Images are selected based on supplied Ra and DEC   "
         print "   Size of the Postage Stamp:   (x) Arc-Second             Width:  2000         Height: 2000    pixel"
         print "   Center Coordinate of Image  - Input coordinate From: "
         print "                  (x)  Upload File           "
         print "        Choose File:    "+_object+'_'+_band+'_ps1request.txt'
         print '#'*20
         answ = raw_input('Do you want to wait that the frames are downloded [y/n]  [y] ? ')
         if not answ: 
             answ= 'y'
         if answ in ['Yes','yes','Y','y']:
              print 'Which is the last req_name at this page: '
              answ1 = raw_input('http://psps.ifa.hawaii.edu/PSI/postage_stamp_results.php ? ' )
              if not answ1:  
                  sys.exit('no name provided, no PS1 images have been downloaded')
              else:
                  print 'try download........'
                  frames = downloadPS1('./',answ1)
      else:
          frames2 = []
          for img in frames:
               if '_'+_band+'_' in img:
                    frames2.append(img)

          frames = frames2
   if len(frames):
         out, varimg = sdss_swarp(frames,_telescope,_ra,_dec,'',_object, survey, show=show)
   else:
       sys.exit('exit, no PS1 images have been downloaded')
   return out, varimg