Function radec_str2dbl, string_input, select
;+
;NAME:
; radec_str2dbl
;PURPOSE:
; transform string to double for RA or DEC
;CALLING SEQUENCE:
; rah=radec_str2dbl(ra)
;EXAMPLE:
; IDL> ra='00 06 23.0'
; IDL> rah=radec_str2dbl(ra,0)
; IDL> print,rah
; 0.10638889
;INPUT:
; string_input --- Right ascension (J2000)
; select ---- 0: blank space separated
; 1: hms separated
; 2: dms separated
; 3: : separated
;OUTPUT:
; outdata
;REVISION HISTORY:
; Original by DL.Wang,30-Dec-2008
;-
if n_elements(select) eq 0 then begin
print,'Please select the format input string'
print,'0: blank space separated'
print,'1: hms separated'
print,'2: dms separated'
print,'3: : separated'
stop
endif
n=n_elements(string_input)
x=strarr(n,3)
case select of
0:begin
for i=0L,n-1 do begin
x[i,*]=strsplit(string_input[i],'( )',/extract)
endfor
end
1:begin
for i=0L,n-1 do begin
x[i,*]=strsplit(string_input[i],'(h)(m)(s)( )',/extract)
endfor
end
2:begin
for i=0L,n-1 do begin
x[i,*]=strsplit(string_input[i],'(d)(m)(s)( )',/extract)
endfor
end
3:begin
for i=0L,n-1 do begin
x[i,*]=strsplit(string_input[i],'(:)( )',/extract)
endfor
end
endcase
hd=double(x[*,0])
mm=double(x[*,1])
ss=double(x[*,2])
outdata=tenv(hd,mm,ss)
return,double(outdata)
End
https://blog.sciencenet.cn/blog-456360-657709.html
上一篇:
多数组抽取相同下标得到新的多数组的IDL程序(原理傻瓜级)下一篇:
PS图上画出波长埃的IDL程序