function tykw_gt_npa,timej,dstt

;+
; NAME:
;       TYKW_GT_NPA
;
; PURPOSE:
;       This function is for getting the mode number of ATT
;
; CALLING SEQUENCE:
;       npa=tykw_gt_npa(timej,dstt)
;
; INPUTS:
;       timej: structure array with 'time internal format'. Time is in JST.
;       dstt: TYKW structure including the status information
;
; OPTIONAL INPUT KEYWORDS:
;
; OUTPUTS:
;       npa: 1-dimensional integer array indicating the ATT mode
;
; HISTORY:
;    4/6/79        ver.0.0 K. Shibasaki as fortran program
;    Sep. 09, 1994 ver.1.0 M. Nishio
;    Jan. 10, 1995 ver.2.0 M. Nishio
;    Apr. 13, 1995 ver.3.2 M. Nishio
;    Apr. 13, 1995 ver.4.0 M. Nishio
;    May. 23, 1995 ver.5.0 M. Nishio
;    May  01, 1995 ver.5.2 M. Nishio
;    Apr. 25, 1995 ver.5.0 M. Nishio
;
;    1999-01-12 ported to IDL by TY
;
;-

npa=bytarr(n_elements(timej))
for mode=0,4 do begin
for m=0,31 do begin
  t_st=dstt.iachng(mode,m,0)
  t_ed=dstt.iachng(mode,m,1)
  if (t_st lt t_ed) then begin
    whr=where((timej.time ge t_st*10) and  (timej.time lt t_ed*10),count)
    if (count ge 1) then npa(whr)=mode+1
  endif
endfor
endfor


return,npa
end
