function gte_midtime,data,vardesc,local_time=local ; *** future options? JULTIME ? minval - -1.E30 ; test if data is valid and contains at least 4 variables if (n_elements(data) lt 2) then return,minval s = size(data) if (s[0] ne 2 OR s[2] lt 4) then begin message,'Data not 2D array or too few variables!',/CONT return,minval endif ; local time requested ? local = keyword_set(local) ; Test if required variables are there selind = ['JDAY','STARTHOUR','STARSEC','STOPSEC'] if (local) then selind = [ selind, 'LON' ] if ( (make_selection(vardesc.name,selind,/REQUIRED))[0] lt 0 ) then begin message,'Required variable not found!',/CONT return,minval endif ; Here, we assume that the first 4 variables are JDAY, STARTHOUR, ; STARTSEC, STOPSEC starthour = data[*,1] startsec = data[*,2] stopsec = data[*,3] ; compute midtime as UTC time result = 3600.*starthour + 0.5*(startsec+stopsec) ; compute local time if requested if (local) then begin ; get longitudes lon = data[*,where(vardesc.name eq 'LON')] result = result + (lon/15.) ; make sure it's within a day's range result = (result + 86400.) mod 86400. endif return,result end