def coordshift(ra, dec, rashift, decshift):
  # shift ra and dec by rashift and decshift
  # ra: string in the hh:mm:ss.ss format
  # dec: string in the dd.mm.ss.ss format
  # rashift: float in arcsec
  # dechift: float in arcsec
  (hh, mm, ss) = cm.ratohms(cm.hmstora(*ra.split(":")) + rashift/3600)
  ra = str(hh)+":"+str(mm)+":"+ '%.3f' % ss
  (dd, mm, ss) = cm.dectodms(cm.dmstodec(*dec.split(".",2)) + decshift/3600)
  dec = "+"+str(dd)+"."+str(mm)+"."+ '%.3f' % ss
  return ra, dec
Example #2
0
def coordshift(ra, dec, rashift, decshift):
    # shift ra and dec by rashift and decshift
    # ra: string in the hh:mm:ss.ss format
    # dec: string in the dd.mm.ss.ss format
    # rashift: float in arcsec
    # dechift: float in arcsec
    (hh, mm, ss) = cm.ratohms(cm.hmstora(*ra.split(":")) + rashift / 3600)
    ra = str(hh) + ":" + str(mm) + ":" + '%.3f' % ss
    (dd, mm,
     ss) = cm.dectodms(cm.dmstodec(*dec.split(".", 2)) + decshift / 3600)
    dec = "+" + str(dd) + "." + str(mm) + "." + '%.3f' % ss
    return ra, dec
Example #3
0
# for each component find the relative mask pix, spidx pix and do the shift
for cc in bbsdata:
    name = cc['Name']
    ra = cc['Ra']
    dec = cc['Dec']

    # first do the coordinate shift (assuming mask and spidx image have correct coordinates!)
    if shift != None:
        (ra, dec) = coordshift(ra, dec, rashift, decshift)
        cc['Ra'] = ra
        cc['Dec'] = dec

    if mask != None:
        (a, b, _, _) = maskdata.toworld([0, 0, 0, 0])
        (_, _, pixY, pixX) = maskdata.topixel([a, b, \
       math.radians(cm.dmstodec(*dec.split(".",2))), math.radians(cm.hmstora(*ra.split(":")))])
        try:
            if not maskdata.getdata()[0][0][math.floor(pixY)][math.floor(
                    pixX)]:
                if verbose:
                    print "Removing component \"", name, "\" because is masked."
                continue
        except:
            print "WARNING: failed to find a good mask value for component \"", name, "\"."
            print "-> Removing this component"
            continue

    if spidximg != None:
        (a, b, _, _) = spidxdata.toworld([0, 0, 0, 0])
        (_, _, pixY, pixX) = spidxdata.topixel([a, b, \
       math.radians(cm.dmstodec(*dec.split(".",2))), math.radians(cm.hmstora(*ra.split(":")))])
# for each component find the relative mask pix, spidx pix and do the shift
for cc in bbsdata:
  name = cc['Name']
  ra = cc['Ra']
  dec = cc['Dec']
  
  # first do the coordinate shift (assuming mask and spidx image have correct coordinates!)
  if shift != None:
    (ra, dec) = coordshift(ra, dec, rashift, decshift)
    cc['Ra'] = ra; cc['Dec'] = dec

  if mask != None:
    (a,b,_,_) = maskdata.toworld([0,0,0,0])
    (_, _, pixY, pixX) = maskdata.topixel([a, b, \
	  math.radians(cm.dmstodec(*dec.split(".",2))), math.radians(cm.hmstora(*ra.split(":")))])
    try:
      if not maskdata.getdata()[0][0][math.floor(pixY)][math.floor(pixX)]:
	if verbose: print "Removing component \"",name,"\" because is masked."
	continue
    except:
      print "WARNING: failed to find a good mask value for component \"", name, "\"."
      print "-> Removing this component"
      continue
   
  if spidximg != None:
    (a,b,_,_) = spidxdata.toworld([0,0,0,0])
    (_, _, pixY, pixX) = spidxdata.topixel([a, b, \
	  math.radians(cm.dmstodec(*dec.split(".",2))), math.radians(cm.hmstora(*ra.split(":")))])
    try:
      val = round(spidxdata.getdata()[0][0][math.floor(pixY)][math.floor(pixX)],2)