function norp_rdt2timej,rdata,date

;+
; NAME:
;       NORP_RDT2TIMEJ
;
; PURPOSE:
;       This function is for getting the JST time array from the NoRP raw data
;
; CALLING SEQUENCE:
;       timej=norp_rdt2timej(rdata,date)
;
; INPUTS:
;       rdata: structure of the raw data
;       date: observation date of the data
;
; OPTIONAL INPUT KEYWORDS:
;
; OUTPUTS:
;       timej: structure array with 'time internal format'. Time is in JST.
;
; HISTORY:
;       programmed by T. Kosugi in 1984 May as Fortran program 
;       for old NoRP data format
;       re-programmed by H.Sekiguchi 1987 July - 1988 Dec.
;
;       1995 July,20    N,Shinox for new format NoRP data
;       95.04.19   ed.  add ATT correction for pol data ,correction data type
;                    changed intarr() to fltarr().,
;       95.09.04 Ver.2.0  M. Nishio and K. Hori
;       95.11.10 Ver.3.0  M. Nishio refernce level at 9.4GHz= amb -> zero
;  <<Caution: ambient level at 9.4GHz is incorrect. Use zero as ref. level>>
;       95.12.12 Ver.3.1  M. Nishio and K. Shibasaki (1GHz ATT 7dB -> 4.3)
;       98.09.03          sekix  & shinox   add 80GHz
;       98.11.20  K. Hori
;       1999-1-12 TY unify program for old/new NoRP data
;
;-

case tag_names(rdata,/structure_name) of
'NORP0' : version =0
'NORP' : version =1
endcase

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; time
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
nmax=n_elements(rdata)

hh = (ishft(rdata.hours,-4) and 'f'x) * 10 +(rdata.hours and 'f'x)
mm = (ishft(rdata.minut,-4) and 'f'x) * 10 +(rdata.minut and 'f'x)
ss = (ishft(rdata.secnd,-4) and 'f'x) * 10 +(rdata.secnd and 'f'x)
imsec1 = (ishft(rdata.msec1,-4) and 'f'x) * 10 +(rdata.msec1 and 'f'x)
imsec2 = (ishft(rdata.msec2,-4) and 'f'x) * 10 +(rdata.msec2 and 'f'x)
ms=long(double(imsec1)*double(10.) + double(imsec2)/double(10.))
case version of
 0: jhh = hh+9
 1: jhh = hh
endcase
whr=where((jhh ge 24),count)
if (count ge 1) then jhh(whr)=jhh(whr)-24

ex=anytim(date,/ex)
dd=ex(4) & mn=ex(5) & ccyy=ex(6)

timej=anytim(transpose([[jhh],[mm],[ss],[ms] $
  ,[replicate(dd,nmax)],[replicate(mn,nmax)],[replicate(ccyy,nmax)]]),/int)

return,timej
end
