Commit 9f908876 authored by Kenneth Kehoe's avatar Kenneth Kehoe
Browse files

Add new file

parent 9cc1b884
pro get_dqr_timeranges, datastream=datastream, varname=varname, searchmetric=searchmetric, $
starttime=starttime, endtime=endtime, nranges=nranges, success=success
;
;+
; ROUTINE: get_dqr_timeranges
;
; PURPOSE: Provides array of start and end times for which caller could mark varname data as missing.
; These time values can be compared to values from an ARM file once base_time and time_offset have been combined.
; These arrays are either determined by calling the ARM DQR web service or by reading a local data store
; (perhaps local storage generated by perl front end in a '.anders' subdir).
; The metric used is decided by the user and can be DQR types: incorrect, suspect or both.
; program will stop if not able to connect to DQR webservice.
;
;
; KEYWORD INPUT:
; datastream valid ARM datastream name as encoded in filenames and DQR database
; varname valid ARM varname as stored in files and DQR database
; searchmetric either 'incorrect,suspect' or 'incorrect' or 'suspect'
;
; KEYWORD OUTPUT:
; starttime array of start times in seconds since 1970 (arm format) to be used for filtering
; endtime array of end times in seconds since 1970 (arm format) to be used for filtering
; nranges scalar indicating how many time ranges were found
; success If set true (1) then service was up and caller can trust results. If false (0), service wasn't working as expected.
;
; EXAMPLE:
; get_dqr_timeranges, datastream='nsamfrsrC2.b1',varname='direct_horizontal_broadband',searchmetric='suspect',starttime=starttime,endtime=endtime
;
; AUTHOR: Sean Moore, Ken Kehoe, June 2012, sean.moore@arm.gov
;
;-
query='datastream='+datastream
query=query+'&varname='+varname
query=query+'&searchmetric='+searchmetric
query=query+'&timeformat=armtime'
query=query+'&dqrfields=starttime,endtime'
query=query+'&responsetype=delimited'
success=1
oUrl = OBJ_NEW('IDLnetUrl')
oUrl->SetProperty, VERBOSE = 1, CONNECT_TIMEOUT = 10, TIMEOUT = 20, $
URL_SCHEME = 'http', URL_HOSTNAME='www.archive.arm.gov', $
URL_PATH='dqrws/ARMDQR',URL_QUERY=query
print, 'Query to DQR webservice: ',query
CATCH, errVal
IF errVal NE 0 THEN BEGIN
CATCH, /CANCEL
oUrl->GetProperty, RESPONSE_CODE=response_code,RESPONSE_HEADER=rspHeader
;PRINT, 'Response Code = ', response_code
;PRINT, 'Response Header = ', rspHeader
response = ''
if response_code NE 200 then success=0
ENDIF ELSE BEGIN
response = oUrl->Get(/STRING_ARRAY)
ENDELSE
oUrl->GetProperty, RESPONSE_CODE=response_code
OBJ_DESTROY, oUrl
;PRINT, 'Response Code = ', response_code
starttime=[]
endtime=[]
!NULL=STRSPLIT(response,'|',COUNT=count)
IF TOTAL(count) GT 0 THEN BEGIN
FOR ii=0, N_ELEMENTS(response)-1 DO BEGIN
rs = STRSPLIT(response[ii],'|',/EXTRACT)
starttime=[starttime,double(rs[0])]
endtime=[endtime,double(rs[1])]
ENDFOR ; ii
ENDIF ; response
nranges=n_elements(starttime)
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment