Exemple #1
0
def finder(myfile,searchrad=0.2/60.):
    
    ra, dec = coordinates_conversor.hour2deg(fitsutils.get_par(myfile, "OBJRA"), fitsutils.get_par(myfile, "OBJDEC"))


    hdulist = pf.open(myfile)[0]
    img = hdulist.data * 1.            
    img = img.T

    wcs = pywcs.WCS(hdulist.header)

    target_pix = wcs.wcs_sky2pix([(np.array([ra,dec], np.float_))], 1)[0]
    corner_pix = wcs.wcs_sky2pix([(np.array([ra,dec+searchrad], np.float_))], 1)[0]
    dx = int(np.abs(np.ceil(corner_pix[1] - target_pix[1])))
    
    imgslice = img[int(target_pix[0])-2*dx:int(target_pix[0])+2*dx, int(target_pix[1])-2*dx:int(target_pix[1])+2*dx]
    #zmin, zmax = zscale.zscale()
    zmin = np.percentile(imgslice.flatten(), 5)
    zmax = np.percentile(imgslice.flatten(), 98)
   
    print "Min: %.1f, max: %.1f"%(zmin, zmax) 
    gc = aplpy.FITSFigure(myfile, figsize=(10,9), north=True)
    gc.show_grayscale(vmin=zmin, vmax=zmax, smooth=1, kernel="gauss")
    gc.show_scalebar(0.1/60.)
    gc.scalebar.set_label('10 arcsec')
    gc.scalebar.set_color('white')
    gc.recenter(ra, dec, searchrad)
    #gc.show_markers(ra,dec+searchrad/20.,edgecolor='red',facecolor='none',marker="|",s=250, lw=10)
    #gc.show_markers(ra-(searchrad/20.)/np.cos(np.deg2rad(dec)),dec,edgecolor='red',facecolor='none',marker="_",s=250, lw=10)

    ras = np.array([ra , ra])
    decs = np.array([dec, dec])
    dxs = np.array([0, searchrad/10 / np.cos(np.deg2rad(dec))])
    dys = np.array([searchrad/10, 0])

    gc.show_arrows(ras, decs, dxs, dys, edgecolor="red", facecolor="red", head_width=0)

    ras = np.array([ra+searchrad*0.7/ np.cos(np.deg2rad(dec)), ra+searchrad*0.7/ np.cos(np.deg2rad(dec))])
    decs = np.array([dec-searchrad*0.9, dec-searchrad*0.9])
    dxs = np.array([0, searchrad/5 / np.cos(np.deg2rad(dec))])
    dys = np.array([searchrad/5, 0])

    gc.show_arrows(ras, decs, dxs, dys, edgecolor="k", facecolor="k")
    gc.add_label(ras[0]+dxs[0]*1.1, decs[0]+dys[0]*1.1, 'N', relative=False, color="k", horizontalalignment="center")
    gc.add_label(ras[1]+dxs[1]*1.1, decs[1]+dys[1]*1.1, 'E', relative=False, color="k", horizontalalignment="center")


    name = fitsutils.get_par(myfile, "NAME")
    filter = fitsutils.get_par(myfile, "FILTER")
    gc.add_label(0.05, 0.95, 'Object: %s'%(name), relative=True, color="white", horizontalalignment="left")                   
    gc.add_label(0.05, 0.9, 'Coordinates: RA=%s DEC=%s'%(coordinates_conversor.deg2hour(ra, dec)), relative=True, color="white", horizontalalignment="left")
    gc.add_label(0.05, 0.84, 'Filter: SDSS %s'%filter, relative=True, color="white", horizontalalignment="left")
    
    findername = 'finders/finder_%s_%s.jpg'%(name, filter)

    gc.save(findername)
    
    return findername
Exemple #2
0
def finder(myfile,searchrad=0.2/60.):
    
    ra, dec = coordinates_conversor.hour2deg(fitsutils.get_par(myfile, "RA"), fitsutils.get_par(myfile, "DEC"))


    hdulist = pf.open(myfile)[0]
    img = hdulist.data * 1.            
    
    wcs = pywcs.WCS(hdulist.header)

    target_pix = wcs.wcs_sky2pix([(np.array([ra,dec], np.float_))], 1)[0]
    corner_pix = wcs.wcs_sky2pix([(np.array([ra,dec+searchrad], np.float_))], 1)[0]
    dx = int(np.abs(np.ceil(corner_pix[1] - target_pix[1])))
    
    imgslice = img[int(target_pix[0])-2*dx:int(target_pix[0])+2*dx, int(target_pix[1])-2*dx:int(target_pix[1])+2*dx]
    #zmin, zmax = zscale.zscale()
    zmin = np.percentile(imgslice.flatten(), 5)
    zmax = np.percentile(imgslice.flatten(), 99)
    
    gc = aplpy.FITSFigure(myfile, figsize=(10,9), north=True)
    gc.show_grayscale(vmin=zmin, vmax=zmax)
    gc.show_scalebar(0.1/60.)
    gc.scalebar.set_label('10 arcsec')
    gc.scalebar.set_color('white')
    gc.recenter(ra, dec, searchrad)
    gc.show_markers(ra,dec+searchrad/20.,edgecolor='red',facecolor='none',marker="|",s=250, lw=10)
    gc.show_markers(ra-(searchrad/20.)/np.cos(np.deg2rad(dec)),dec,edgecolor='red',facecolor='none',marker="_",s=250, lw=10)

    ras = np.array([ra , ra])
    decs = np.array([dec, dec])
    dxs = np.array([0, searchrad/10 / np.cos(np.deg2rad(dec))])
    dys = np.array([searchrad/10, 0])

    gc.show_arrows(ras, decs, dxs, dys, edgecolor="red", facecolor="red", head_width=0)

    ras = np.array([ra+searchrad*0.7/ np.cos(np.deg2rad(dec)), ra+searchrad*0.7/ np.cos(np.deg2rad(dec))])
    decs = np.array([dec-searchrad*0.9, dec-searchrad*0.9])
    dxs = np.array([0, searchrad/5 / np.cos(np.deg2rad(dec))])
    dys = np.array([searchrad/5, 0])

    gc.show_arrows(ras, decs, dxs, dys, edgecolor="k", facecolor="k")
    gc.add_label(ras[0]+dxs[0]*1.1, decs[0]+dys[0]*1.1, 'N', relative=False, color="k", horizontalalignment="center")
    gc.add_label(ras[1]+dxs[1]*1.1, decs[1]+dys[1]*1.1, 'E', relative=False, color="k", horizontalalignment="center")


    name = fitsutils.get_par(myfile, "OBJECT")
    gc.add_label(0.05, 0.95, 'Object: %s'%(name), relative=True, color="white", horizontalalignment="left")                   
    gc.add_label(0.05, 0.9, 'Coordinates: RA=%s DEC=%s'%(coordinates_conversor.deg2hour(ra, dec)), relative=True, color="white", horizontalalignment="left")
    gc.add_label(0.05, 0.84, 'Filter: SDSS r', relative=True, color="white", horizontalalignment="left")
    
    findername = '%s_finder.jpg'%(name)
    gc.save(findername)
    
    return findername
Exemple #3
0
def get_sao(radius=2000):
    
    '''
    Uses the current time and the latitude of Palomar to find the best SAO stars at zenith.
    
    Palomar.lon, Palomar.lat = '243.1361', '33.3558'    
    
    '''
   

    #Log into a file
    FORMAT = '%(asctime)-15s %(levelname)s [%(name)s] %(message)s'
    root_dir = _logpath
    now = datetime.datetime.utcnow()
    timestamp=datetime.datetime.isoformat(now)
    timestamp=timestamp.split("T")[0]
    logging.basicConfig(format=FORMAT, filename=os.path.join(root_dir, "listener_{0}.log".format(timestamp)), level=logging.INFO)
    logger = logging.getLogger('sao')
 
    d = datetime.datetime.now()
    utc = d.utcnow()
    
    #Get reasonably high target
    ra = 15*((utc.hour+10)%24) + 15*(utc.minute/60.) 
    dec = 40
    
    hra, hdec  =  coordinates_conversor.deg2hour(ra, dec)

    logger.info( "Coordinates to search %s %s"%(hra,hdec))

    sao = get_sao_rec(hra, hdec, radius)
    while (len(sao) == 0):
        radius = radius+1000
        sao = get_sao_rec(hra, hdec, radius)
    logger.info( "Found %d"%len(sao))
    if np.ndim(sao) > 1:
        np.random.shuffle(sao)
    
    logger.info( "Returning %s %s"%(sao[0][1], sao[0][2]))
    
    saora, saodec  =  coordinates_conversor.hour2deg(sao[0][1], sao[0][2])
    

    return "SAO%s"%(sao[0][0]), saora, saodec