pro Make_Ulysses, u, cmon, udat, nosort=nosort, nowrite=nowrite, $ readonly=readonly @compile_opt.pro ; On error, return to caller ;+ ; NAME: ; MAKE_ULYSSES ; PURPOSE: ; Process ASCII file with Ulysses plasma data (ULY.DAT). ; CALLING SEQUENCE: ; make_ulysses, u, cmon, udat, /nosort, /nowrite, /readonly ; INPUTS: ; u float array ; cmon string array ; Output from a previous run of make_ulysses. The arrays contain ; the content of the file ULY.DAT extracted by the flt_read ; procedure. If these arrays exist on input the call to flt_read ; is bypassed, unless the keyword /readonly is set. ; OPTIONAL INPUT PARAMETERS: ; /nosort by default the output array is sorted using the Ulysses `source' ; Carrington variable. Setting `nosort' will retain the order ; of the input file (i.e. the output would be sorted with respect ; to the time of observation ; /nowrite if set no IDL save file is created. ; /readonly if set the file ULY.DAT is read. The data are not ; processed (i.e. array udat is not created) ; (/readonly will force reading of ULY.DAT even if ; u and cmon exist) ; OUTPUTS: ; udat 2D float array containing the processed Ulysses data ; Unless the keyword /nowrite is set, this array is saved into ; the file X$DAT:ULYSSES.SAV using the IDL save command. ; Also saved are the scalars pUlysRot, pUlysFrac, pEarthRot, ; pEarthFrac, pYr, pDoy, pLat, pDist, pSpeed, pDens, pTemp ; (see PROCEDURE) ; CALLS: ; flt_read, data_doy, n_carrington ; PROCEDURE: ; The array udat contains the following data (the p* scalars are saved ; in the IDL save file, together with array udat): ; udat(pUlysRot ,*) Carrington rotation containing source location ; udat(pUlysFrac ,*) Carrington position of source location ; (= (360.-heliographic longitude)/360. ) ; udat(pEarthRot ,*) Carrington rotation containing sub-Earth point ; udat(pEarthFrac ,*) Carrington positiion of sub-Earth point ; udat(pYr ,*) year and ... ; udat(pDoy ,*) ... day of year of source time ; udat(pLat ,*) Ulysses latitude ; udat(pDist ,*) Ulysses distance to Sun (AU) ; udat(pSpeed ,*) solar wind velocity (km/s) ; udat(pDens ,*) density normalized to 1 AU (cm^-3) ; udat(pTemp ,*) temperature (K) ; MODIFICATION HISTORY: ; FEB-1995, Paul Hick (UCSD) ;- InitVar, nosort, /key InitVar, nowrite, /key InitVar, readonly, /key if read_only or n_elements(u) eq 0 or n_elements(cmon) eq 0 then begin file = 'X$DAT:ULY.DAT stat = flt_read(file,u,/exp,crumbs=cmon); All the numbers cmon = strmid( cmon[3,*] ,1,3) ; 3-char month ID (JAN, etc.) if readonly then return endif nY = n_elements(cmon) iYr = 6 & iDay = 5 & iHr = 7 & iMin = 8 & iSec = 9 iSpeed = 10 & iDens = 11 & iTemp = 13 & iDist = 14 iLat = 15 & iLon = 17 yr = -fix(u[iYr,*]) ; source time: year imon = -1 date_doy,0,yr,cmon,imon,u(iDay,*), doy ; get source time: doy doy = doy+((u[iSec,*]/60.+u[iMin,*])/60.+u[iHr,*])/24. ; add time of day to doy nEarth = n_carrington(yr, doy, frac=fEarth, /keepyrdoy) ; get Carrington rots for sub-Earth point fUlys = (360.d0-u[iLon,*])/360.d0 ; source location fUlys = fUlys-fEarth fUlys = (fUlys lt -0.5) *(fUlys+1.) + $ (-0.5 le fUlys and fUlys le 0.5)* fUlys + $ (fUlys gt 0.5) *(fUlys-1.) dUlys = fUlys fUlys = nEarth+fEarth+fUlys xUlys = fUlys nUlys = floor(fUlys) ; Ulysses Carrington rots fUlys = fUlys-nUlys ; Ulysses Carrington pos ; the algorithm for asigning a Carrington rotation to the Ulysses source ; location will cause a jump in nUlys+fUlys of -1 rotation when the ; source location is on the opposite side of the sub-Earth point. ; As a result there will be some Carrington rotations with two sets of points, ; seperated by almost a month in time of observation. ; The second of these `double' rotations is tagged by adding 10000 to the ; Carrington rotation number. xUlys = xUlys-shift(xUlys,1) ni = where(xUlys lt -.75) ; Probably not foolproof if ni[0] eq 0 then ni = ni[1:*] n = n_elements(ni) for i=0,n-1 do begin nRots = nUlys[0:(ni[i]-1)] nRots = rem_dble(nRots) nR = n_elements(nRots) for j=((nR-3)>0),nR-1 do begin iUlys = nUlys[ni[i]:*] tag = iUlys eq nRots[j] if max(tag) eq 1 then message, /info, 'Tagging rotation'+strcompress(nRots[j]) nUlys[ni[i]:*] = iUlys+tag*10000 endfor endfor sUlys = sort(nUlys+fUlys) ; Used to sort the file on output fEarth = float(fEarth) fUlys = float(fUlys) pN = 11 pUlysRot = 0 & pUlysFrac = 1 pEarthRot = 2 & pEarthFrac = 3 pYr = 4 & pDoy = 5 pLat = 6 & pDist = 7 pSpeed = 8 & pDens = 9 & pTemp = 10 udat = fltarr( pN, nY, /nozero ) help, udat udat[pUlysRot ,*] = nUlys udat[pUlysFrac ,*] = fUlys udat[pEarthRot ,*] = nEarth udat[pEarthFrac,*] = fEarth udat[pYr ,*] = yr udat[pDoy ,*] = doy udat[pLat ,*] = u[iLat,*] udat[pDist ,*] = u[iDist,*] udat[pSpeed ,*] = u[iSpeed,*] udat[pDens ,*] = u[iDens,*] udat[pTemp ,*] = u[iTemp,*] if not nosort then udat = udat[*, sUlys] if not nowrite then begin file = 'X$DAT:ULYSSES.SAV strsort = ['','Un'] message, /info, 'Writing '+strsort(nosort)+ $ 'Sorted data to IDl save file '+file save,file=file,udat, pUlysRot, pUlysFrac, pEarthRot, pEarthFrac, $ pYr, pDoy, pLat, pDist, pSpeed, pDens, pTemp endif return & end