deliangwang的个人博客分享 http://blog.sciencenet.cn/u/deliangwang

博文

读取NVSSlist的输出文件(IDL程序)

已有 3035 次阅读 2013-1-30 12:40 |个人分类:编程笔记|系统分类:科研笔记| Field, Dec

Pro nvss_read,filename, ra, dec, dist, flux, major, minor, pa, res, $
              p_flux, p_ang, field, xpix, ypix, $
              nvss, not_nvss, type_trans=type_trans
;+
;NAME:
;     nvss_read
;PURPOSE:
;     read data from outfile by NVSSlist
;CLING SEQUENCE:
;     nvss_read,filename, ra, dec, dist, flux, major, minor, pa, res, $
;              p_flux, p_ang, field, xpix, ypix, $
;              nvss, not_nvss
;CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
;CC
;CC  Waring:
;CC
;CC        This code is used under the condition that one source have
;CC   only one matched source in the NVSS catalog
;CC
;CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
;INPUT:
;     filename  --  name of NVSSlist outfile
;OUTPUT:
;     ra     ---  RA in h:m:s
;     dec    ---  DEC in d:m:s
;     dist   ---  distance between matched source & NVSS source
;                 in Unit: arcsec
;     flux   ---  flux in Unit: mJy
;     major  --- 
;     minor  ---
;     pa     ---
;     res    ---  Residual (Res) code
;                 P* => high peak,
;                 R* => high RMS,
;                 S* => high integral
;     p_flux ---
;     p_ang  ---
;     field  ---
;     xpix   ---
;     ypix   ---
;     nvss   ---  index of detected source
;  not_nvss  ---  index of not detected source
;
;OPTIONAL KEYWORD OUTPUT:
;    type_trans  ---  if set it,dist,flux,p_flux will be float,
;                     default it,they will be string
;
;EXAMPLE:
;     IDL> filename='rgb_nvss.dat'
;     IDL> nvss_read,filename, ra, dec, dist, flux, major, minor, pa, res,
;              p_flux, p_ang, field, xpix, ypix, nvss, not_nvss
;
;PROCESS:
;     extract_multarr
;REVISION HISTORY:
;     Original by DL.Wang,Aug-29-2007
;    
;-
    nlines = NUMLINES( filename )
    if nlines LT 0 then return
;##########################
;## definite arrary
    keep=lonarr(nlines)
    index0=lonarr(nlines)
    radec=strarr(nlines)
    ra=strarr(nlines)
    dec=strarr(nlines)
    dist=strarr(nlines)
    flux=strarr(nlines)
    major=strarr(nlines)
    minor=strarr(nlines)
    pa=strarr(nlines)
    res=strarr(nlines)
    p_flux=strarr(nlines)
    p_ang=strarr(nlines)
    field=strarr(nlines)
    xpix=strarr(nlines)
    ypix=strarr(nlines)
temp = ''
openr,lun,filename,/get_lun  
for j = 0L, nlines-1 do begin
    readf, lun, temp
;###########################################
;########### blank row
             pos=strpos(temp,'')
             if pos eq -1L then begin
;             length=strlen(temp)
;             if length eq 0L then begin
                 index0[j]=0L
                 keep[j]=0L
                 ra[j]=''
                 dec[j]=''
                 dist[j]=''
                 flux[j]=''
                 major[j]=''
                 minor[j]=''
                 pa[j]=''
                 res[j]=''
                 p_flux[j]=''
                 p_ang[j]=''
                 field[j]=''
                 xpix[j]=''
                 ypix[j]=''
             endif
;###########################################
;######### Source row
           unpos=strpos(temp,'SOURCE NOT FOUND')
             if unpos ne -1L then begin
                 index0[j]=1L
                 keep[j]=0L
                 ra[j]=''
                 dec[j]=''
                 dist[j]=''
                 flux[j]=''
                 major[j]=''
                 minor[j]=''
                 pa[j]=''
                 res[j]=''
                 p_flux[j]=''
                 p_ang[j]=''
                 field[j]=''
                 xpix[j]=''
                 ypix[j]=''
             endif
        rapos=strpos(temp,'|')
        if rapos ne -1 then begin
              dat=strsplit(temp,'|',/extract)
              if n_elements(dat) eq 13 then begin
                 index0[j]=1L
                 keep[j]=1L
                 ra[j]=dat[0]
                 dec[j]=dat[1]
                 dist[j]=dat[2]
                 flux[j]=dat[3]
                 major[j]=dat[4]
                 minor[j]=dat[5]
                 pa[j]=dat[6]
                 res[j]=dat[7]
                 p_flux[j]=dat[8]
                 p_ang[j]=dat[9]
                 field[j]=dat[10]
                 xpix[j]=dat[11]
                 ypix[j]=dat[12]
                 ;print,ra[j]
               ;pause
              endif
              if n_elements(dat) ne 13 then begin
                 index0[j]=0L
                 keep[j]=0L
                 ra[j]=''
                 dec[j]=''
                 dist[j]=''
                 flux[j]=''
                 major[j]=''
                 minor[j]=''
                 pa[j]=''
                 res[j]=''
                 p_flux[j]=''
                 p_ang[j]=''
                 field[j]=''
                 xpix[j]=''
                 ypix[j]=''
               endif
        endif
endfor
free_lun,lun
;######################################################
;######### pick out needed data
      nvssindex=where(index0 eq 1L and ra ne '   RA_2000 ' and ra ne ' h  m    s ',cp)
      print,'match',cp
     
      index0=index0[nvssindex]
      keep=keep[nvssindex]
      ra=ra[nvssindex]
      dec=dec[nvssindex]
      dist=dist[nvssindex]
      flux=flux[nvssindex]
      major=major[nvssindex]
      minor=minor[nvssindex]
      pa=pa[nvssindex]
      res=res[nvssindex]
      p_flux=p_flux[nvssindex]
      p_ang=p_ang[nvssindex]
      field=field[nvssindex]
      xpix=xpix[nvssindex]
      ypix=ypix[nvssindex]
      nvss=where(index0 eq 1L and keep eq 1L and ra ne '',count)
      print,'NVSS',count
      not_nvss=where(index0 eq 1L and keep eq 0L,count1)
      print,'not NVSS',count1
     
      ra=ra[nvss]
      dec=dec[nvss]
      dist=dist[nvss]
      flux=flux[nvss]
      major=major[nvss]
      minor=minor[nvss]
      pa=pa[nvss]
      res=res[nvss]
      p_flux=p_flux[nvss]
      p_ang=p_ang[nvss]
      field=field[nvss]
      xpix=xpix[nvss]
      ypix=ypix[nvss]
;#####################################################
;######## data type transformation
   if keyword_set(type_trans) then begin
    ;removes leading and trailing blank from the input String
      for i=0L,n_elements(ra)-1 do begin
          dist[i]=strtrim(dist[i],2)
          flux[i]=strtrim(flux[i],2)
          p_flux[i]=strtrim(p_flux[i],2)
      endfor
      dist=float(dist)
      flux=float(flux)
      p_flux=float(p_flux)
   endif
;stop
End


https://blog.sciencenet.cn/blog-456360-657865.html

上一篇:写一个与NVSS做位置匹配的源列表文件(IDL程序)
下一篇:网站文本抽取方法获得河外天体的银河系中性氢柱密度-IDL程序
收藏 IP: 159.226.148.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-11-23 19:25

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部