Viewing contents of file '../idllib/contrib/esrg_ucsb/armbasetime.pro'
pro armbasetime,bt,time,yymmdd,doy=doy,yy=yy,mm=mm,dd=dd,file=file
;+
; ROUTINE:  armbasetime
;
; PURPOSE: The base_time variable provided by ARM net_cdf files is the
;          number of seconds since jan 1, 1970 00:00:00 UTC.  This
;          procedure converts base_time to the current date in yymmdd
;          format, and the number of hours since the most recent
;          Grenich midnight (00:00:00 UTC).
;
; USEAGE:  armbasetime,base_time,time,yymmdd,file=file
;
; INPUT:    
;   bt     number of seconds since jan 1, 1970 00:00:00 UTC.
;
; KEYWORD_INPUT
;
;  file    name arm net_cdf file. If this quantity is set the value
;          of bt is set from the value read from the file.
;
;
; OUTPUT:
;
;  time    time since Grenich midnight of the current day
;  yymmdd  date string in yymmdd format
;
;  
; EXAMPLE: 
;    file='/home/paul/arm/iop_97/mfrsr/sgpmfrsrC1.a1.970915.000000.cdf'
;    armbasetime,file=file,bt,time,yymmdd
;    print,bt,time,"   ",hms(3600*time)," ",yymmdd
;
; AUTHOR:   Paul Ricchiazzi                        05 Jun 98
;           Institute for Computational Earth System Science
;           University of California, Santa Barbara
;           paul@icess.ucsb.edu
;
; REVISIONS:
;
;-
;
if keyword_set(file) then ncdf_get_1field,file,'base_time',bt

spd=24l*3600l         ; number seconds in 1 day
time=bt mod spd       ; number of seconds since 00:00:00 of current day

juld=julday(1,1,1970)+fix((bt-time)/spd)
caldat,juld,mm,dd,yy
doy=julday(mm,dd,yy)-julday(1,0,yy)

yymmdd=string(f='(i2.2,i2.2,i2.2)',yy mod 100,mm,dd)

time=time/3600.

end