function ReadEarthFileSubset, dt, tt_tomo, dd_tomo, file, FileRange, directory=directory ;+ ; NAME: ; ReadEarthFileSubset ; PURPOSE: ; Read ea* file ; CALLING SEQUENCE: ; A = ReadEarthFileSubset(dt, tt_tomo, dd_tomo, FileRange,directory=directory) ; ; OPTIONAL INPUTS: ; dt specify time interval to get the ; desired record # ; FileRange array[2]; subset of file to pick for analyze ; FileRange[0]: Starting point ; FileRange[1]: End point ; directory Directory of the files to be compared, if ; no directory is given, $DAT/nagoya/forecast ; is the default directory ; OUTPUTS: ; tt_tomo=tt_tomo array[n]; type: time structure ; times read from file ; dd_tomo=dd_tomo array[n,6]; type: float ; density, velocity, radial magnetic field, ; tangential magnetic field at times tt_tomo ; CALLS: ; SetFileSpec, GetFileSpec, filepath, flt_read, TimeSet, tagarray ; PROCEDURE: ; MODIFICATION HISTORY: ; NOV-1999, Paul Hick (UCSD) ; DEC-2000, Kevin ;- on_error, 2 ; Do not modify the input argument file_in !! bad = [-9999.999,-9999.999, -999.999, -999.999] NOF = n_elements(FileRange) if n_elements(dt) eq 0 then dt = 0 dt = round(dt*24/6.) dtcenter = 80 dn = dt + dtcenter if n_elements(directory) eq 0 then directory = $ filepath(root=getenv('DAT'), subdir=['nagoya','slow','raw'], '') wildcard = filepath(root=directory, 'ea*.*') fileSet = file_search(wildcard, count=nfile) if nfile eq 0 then message, 'no ea*.* files found in '+directory if NOF ne 0 then begin FileNumPos = strlen(fileSet(0)) - 8 ; print, strmid(fileSet(1), FileNumPos, 8) index2 = 0 index1 = 0 ifile = 0 while(ifile lt nfile) and (float(strmid(fileSet(ifile), FileNumPos, 8)) lt FileRange[0]) do begin index1 = ifile ifile = ifile + 1 endwhile if (ifile eq nfile) and (float(strmid(fileSet(index1), FileNumPos, 8)) lt FileRange[0]) then begin print, 'Invalid subset' endif else begin while(ifile lt nfile) and (float(strmid(fileSet(ifile), FileNumPos, 8)) lt FileRange[1]) do begin index2 = ifile print, fileSet[ifile] ifile = ifile + 1 endwhile endelse fileSet = extrac(fileSet, index1, index2 - index1) endif else $ fileSet = fileSet(sort(fileSet)) nfile = n_elements(fileSet) file = fileSet[nfile-1] dd_tomo = fltarr(nfile, 4) tt_tomo = replicate(!TheTime,nfile) for ifile=0, nfile-1 do begin stat = flt_read(fileSet[ifile],data,/silent) tt_data = TimeSet(yr=reform(data[0, *]), doy=reform(data[1, *]), hour=reform(data[2, *])) tt_tomo[ifile] = tt_data[dn] dd_tomo[ifile, 0] = data[7, dn] ; Velocity dd_tomo[ifile, 1] = data[6, dn] ; Density dd_tomo[ifile, 2] = data[8, dn] dd_tomo[ifile, 3] = data[9, dn] endfor message, /info, 'processed'+strcompress(nfile)+' ea*.* files in '+directory for i=0,n_elements(bad)-1 do begin tmp = where(dd_tomo[*,i] eq bad[i]) if tmp[0] ne -1 then dd_tomo[tmp,i] = BadValue(bad[i]) endfor ;good = where(dd_tomo gt 0) ;if good[0] eq -1 then message, 'no data' ;tt_tomo = tt_tomo[good] ;dd_tomo = dd_tomo[good, *] return, 1 & end