FUNCTION EIVIND,source_in$,date$,ts,INFO$=info$ ;PRINT,'Baseline removal version of UITMAG loader. This version of the loader does not make or use cached SAV files.' ;Latitude and longitude of magnetic North Pole as given to us by Dag Lorentzen. magNPlat = 82.26 magNPlon = 277.23 source$ = source_in$ source$ = STRSPLIT(source$,':',/EXTRACT) CASE source$[0] OF 'query': retData = '^eivind' ELSE : BEGIN startdate = TIME_DOUBLE(date$) enddate = startdate + (ts * 60.) fileName$ = source$[1] PRINT,fileName$ savFName$ = fileName$ + '.sav' files = FINDFILE(savFName$, count=numFiles) IF numFiles EQ 0 THEN BEGIN ; PRINT,'No previous saveset file found; creating saveset file from ASCII file.' ;Load data in from file. OPENR, unit, fileName$, /GET_LUN header$ = '' baseDec$ = '' baseInc$ = '' baseTot$ = '' latLon$ = '' ; READF,unit,header$ ; READF,unit,year,month,day,hour,min,second ; IF year LE 90 THEN year = year + 2000 ELSE year = year + 1900 ; READF,unit,header$ ; baseDec = FLOAT(STRMID(baseDec$,16)) ; baseInc = FLOAT(STRMID(baseInc$,16)) ; baseTot = FLOAT(STRMID(baseTot$,16)) c = 0LL sec = 0D bx = 0D by = 0D bz = 0D REPEAT BEGIN line$='' READF,unit,line$ dataVec = STRSPLIT(line$,' /:,',/EXTRACT) ;DD/MM/YYYY HH:MM:SS Dec Horiz Vert Incl Total ;0 1 2 3 4 5 6 7 8 9 10 IF (c NE 0 ) THEN retData = [[retData], [dataVec]] ELSE retData = dataVec ++c ; print,c,' ',line$ ENDREP UNTIL EOF(unit) FREE_LUN,unit ;Transform time vector into epoch time. ;time0 = TIMEYMDHMSTOEPOCH(LONG(year),LONG(month),LONG(day),LONG(hour),LONG(min),LONG(second)) sec$ = STRARR(N_ELEMENTS(retData[0,*])) + '00' time$ = $ '20' + retData[2,*] + '-' + $ retData[0,*] + '-' + $ retData[1,*] + '/' + $ retData[3,*] + ':' + $ retData[4,*] + ':' + $ sec$ timeVec = TIME_DOUBLE(time$) ; ; Bx = retData[7,*] * COS(retData[6,*] * !DTOR) - (baseTot * COS(baseInc * !DTOR) * COS(baseDec * !DTOR)) ; By = retData[7,*] * SIN(retData[6,*] * !DTOR) - (baseTot * COS(baseInc * !DTOR) * SIN(baseDec * !DTOR)) ; Bz = retData[8,*] temp = retData[5,*] speed = retData[6,*] ;retData = TRANSPOSE([[timeVec], [Bx], [By], [Bz]]) retData = TRANSPOSE([timeVec, temp, speed]) ; ;Create a 4 column array containing: ; ; [TimeVector Bx By Bz] ; retData[*,0] = retData[*,0] + time0 SAVE,file=savFName$,retData ENDIF ELSE BEGIN RESTORE,file=savFName$ ENDELSE ;Ensure that the array only contains data within the specified time range. upper = WHERE(retData[*,0] GE startdate) retData = retData[upper,*] lower = WHERE(retData[*,0] LE enddate) retData = retData[lower,*] ;Select Magnetometer Component comp$ = source$[2] CASE comp$ OF 'temp' : BEGIN retData = [[retData[*,0]],[retData[*,1]]] name$ = STRUPCASE(source$[1]) + ' (' + source$[2] + ')' unit$ = 'Deg C' type$ = 'mag' END 'speed' : BEGIN retData = [[retData[*,0]],[retData[*,2]]] name$ = STRUPCASE(source$[1]) + ' (' + source$[2] + ')' unit$ = 'm/s' type$ = 'rdr' END ENDCASE ;Create Information Vector type$ = 'mag' print,'DEBUG' print,source$ name$ = STRUPCASE(source$[1]) + ' (' + source$[2] + ')' unit$ = 'Deg C' shortID$ = STRUPCASE(source$[1]) + ':' + source$[2] info$ = [source_in$, type$, name$, unit$, shortID$ ] END ENDCASE RETURN, retData END