function tykw_mvalid_clb,timej,dstt,dtclb

;+
; NAME:
;       TYKW_MVALID_CLB
;
; PURPOSE:
;       This function is to get the information if the data is valid or not
;       from the calibration info
;
; CALLING SEQUENCE:
;       mvalid=tykw_mvalid_clb(timej,dstt,dtclb)
;
; INPUTS:
;       timej: structure array with 'time internal format'.
;       dtclb: time margin for nclbi. 2 elements floating array.
;              dtclb(0) is before the calibration, dtclb(1) is after.
;       dstt: structure of the stt data of the specified frequency
;
; OPTIONAL INPUT KEYWORDS:
;
; OUTPUTS:
;       mvalid: 1-dimensional byte array
;               if 1 the data is valid
;
; 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
;
;-

; unset flag for calibration period
mvalid=bytarr(n_elements(timej))+1b
for mode=0,4 do begin
;for m=0,31 do begin
for m=0,30 do begin  ; 1999-8-4 by T. Y.
  t_st=dstt.ichng(mode,m,0)
  t_ed=dstt.ichng(mode,m,1)
  if (t_st lt t_ed) then begin
    n_st=norp_t2i(timej.time,t_st*10-dtclb(0))
    n_ed=norp_t2i(timej.time,t_ed*10+dtclb(1))
    mvalid(n_st:n_ed)=0
  endif
endfor
endfor

return,mvalid
end
