FUNCTION GOESMAG,source_in$,date$,ts,INFO$=info$ ;For GOES Magnetic Field data from SPIDR (http://spidr.ngdc.noaa.gov/spidr/) ;;;;;;;; BEGIN SAMPLE DATA FILE HEADER ;;;;;;;;;; ;#> From Spidr (http://spidr.ngdc.noaa.gov/spidr/) - Retrieved 19AUG2010 ;#Element: he (Earthward) ;#Element: hn (Normal to HP,HE, points West(GOES 1-4) or East(GOES 5+) ) ;#Element: hp (Magnetic field: Parallel to satellite spin axis) ;#Element: ht Magnetic field: Magnitude of total magnetic field vector ;#Measure units: nT ;#Origin: ;#Station code: 10 ;#Station name: GOES-10 ;#Sampling: 1 minute ;#Missing value: 1.0E33 ;#> ;#yyyy-MM-dd HH:mm value qualifier description ; GMT he hn hp ht ; ;;;;;;;; END SAMPLE DATA FILE HEADER ;;;;;;;;;; source$ = source_in$ source$ = STRSPLIT(source$,':',/EXTRACT) CASE source$[0] OF 'query': retData = '^goesmag' ELSE : BEGIN startdate = TIME_DOUBLE(date$) enddate = startdate + (ts * 60.) fileName$ = source$[1] 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$ = '' nHeaderLines = 14 FOR kk=0,nHeaderLines-1 DO BEGIN READF,unit,header$ ENDFOR c = 0LL sec = 0D bx = 0D by = 0D bz = 0D REPEAT BEGIN line$='' READF,unit,line$ dataVec = STRSPLIT(line$,' ',/EXTRACT) ;YYYY-MM-DD HH:MM he hn hp ht ;0 1 2 3 4 5 IF (c NE 0 ) THEN retData = [[retData], [dataVec]] ELSE retData = dataVec ++c 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)) time$ = retData[0,*] + '/' + retData[1,*] ;Create a 4 column array containing: ; [TimeVector Bx By Bz] timeVec = TIME_DOUBLE(time$) retData = TRANSPOSE([timeVec, retData[2,*], retData[3,*], retData[4,*]]) 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$ = STRMID(source$[2],0,1,/REVERSE_OFFSET) retData = comp(retData,comp$) ;Create Information Vector type$ = 'mag' name$ = STRUPCASE(source$[1]) + ' (' + source$[2] + ')' unit$ = 'nT' shortID$ = STRUPCASE(source$[1]) + ':' + source$[2] info$ = [source_in$, type$, name$, unit$, shortID$ ] END ENDCASE RETURN, retData END