-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhsos_search.pro
86 lines (58 loc) · 2.15 KB
/
hsos_search.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
function HSOS_search,SearchResult,T0=T0,T1=T1,TYPE=TYPE,LEVEL=LEVEL,AR=AR,download=download,curl_path=curl_path
if N_elements(type) eq 0 then type='FITS'
if N_elements(level) eq 0 then level='C2'
if N_elements(AR) eq 0 then AR='NONE'
if N_elements(download) eq 0 then download=0
if N_elements(curl_path) eq 0 then curl_path='C:\Users\Thomas\work\HSOS\FSMT\calibration\curl-7.61.0-win64-mingw\bin\'
if N_elements(server) eq 0 then server='https://sun10.bao.ac.cn/HSOS/FsmtQueryData'
if N_elements(T0) eq 0 then T0='2017-07-12T00:00:00'
if N_elements(T1) eq 0 then T1='2017-07-12T23:59:59'
T0=anytim(T0,/CCSDS)
T1=anytim(T1,/CCSDS)
date0=strmid(T0,0,10)
time0=strmid(T0,11,8)
date1=strmid(T1,0,10)
time1=strmid(T1,11,8)
if level eq 'C3' then begin
query='date0='+date0+'&date1='+date1+'&time0='+time0+'&time1='+time1+'&type='+type+$
'&ar='+AR+'&level='+level
cmd=curl_path+'curl.exe -d '+'"'+query+'"'+' '+server
endif else begin
query='date0='+date0+'&date1='+date1+'&time0='+time0+'&time1='+time1+'&type='+type+$
'&ar=NONE&level='+level
cmd=curl_path+'curl.exe -d '+'"'+query+'"'+' '+server
endelse
print,cmd
print,'--------------'
spawn,cmd,/log_output,result
; print,result
if result eq 'NODATA' then begin
item='NONE'
print,'There is no data in this time range'
endif else begin
item=strsplit(result,'|',/extract)
endelse
if N_elements(item) GT 1 then item=item[uniq(item,sort(item))]
print,item
nn=N_elements(item)
if download eq 1 and item[0] ne 'NONE' then begin
filedownload=''
openw,lun,'download.log',/get_lun
for kk=0,nn-1 do printf,lun,item[kk]
free_lun,lun
for kk=0,nn-1 do begin
filedownload=filedownload+' -O '+item[kk]+' '
endfor
spawn,curl_path+'curl.exe -C - '+filedownload,/log_output
;print,curl_path+'curl.exe -C - '+filedownload
endif else begin
openw,lun,'download.log',/get_lun
for kk=0,nn-1 do printf,lun,item[kk]
free_lun,lun
endelse
;
;
;
SearchResult=item
return,SearchResult
end