function MapReadSurf,Rot,nLNG,nLAT,Z,Zflag,XCadj @compile_opt.pro ; On error, return to caller ;+ ; NAME: ; MapReadSurf ; PURPOSE: ; Read file with Stanford synoptic map data into 2D array ; CATEGORY: ; I/O ; CALLING SEQUENCE: ; I = MapReadSurf(Rot,nLNG,nLAT,Z,Zflag,XCadj) ; INPUTS: ; Rot integer Carrington rotation # ; nLNG integer # grid longitudes ; nLAT integer # grid latitudes ; XCadj(3)float (see PROCEDURE) ; OUTPUTS: ; I integer return status (0=Failure,1=Success) ; Z(nLNG,nLAT) ; float 2D synoptic map array ; Zflag float value used to indicate 'no fnc-value available' ; XCadj(3)float plot margins used by MAP_PLOT ; CALLS: ; flt_read, SearchLib ; RESTRICTIONS: ; See MapRead for instructions on how to create additional MapRead* ; functions for other data sets. ; PROCEDURE: ; > The MapRead* functions are called as external functions by MapRead ; > input value XCadj: ; > If XCadj(0) unequal zero, then nLAT must be equal mLAT70. ; If nLNG .ne. mLNG then the difference is interpreted as an extra margin ; on both sides of the map, e.g. if nLNG-mLNG=16 (i.e. 80 deg in ; longitude), then a margin of 40 degrees (extracted from preceeding and ; following Carrington rotation) is added to either side of the map. ; This is the option used to overplot the source surface on other ; synoptic maps. ; > If XCadj(0) = 0 then the array Z(nLNG,nLAT) is assumed to refer ; to a single rotation (i.e. [0,360] in longitude, [-90,+90] in latitude). ; Note that the part of the array above 70 and below -70 degree latitude ; will be flagged as invalid. This option can be used to change the ; resolution of the input maps (MapGrid_REGtoREG is used to change the ; resolution). ; MODIFICATION HISTORY: ; JUL-1993, Paul Hick (UCSD) ;- ; The input files contain a grid of 73x29 points; the grid has a resolution ; of 5 degrees, i.e. 73 longitudes cover [0,360] and 29 latitudes cover ; [-70,+70]. mLNG = 73 ; # longitudes mLAT70 = 29 ; (28-1)*5=2*70 mLAT90 = 37 ; (37-1)*5=2*90 Zflag = -1.E7 ; Used to indicate missing data File = '0000.SRF' ; File name template xData = 'X$'+strmid(File,strpos(File,'.')+1,3) ; X$SRF if XCadj[0] eq 0 then goto, SINGLE_MAP ; Check for extra margin ; If XCadj[0] unequal zero: overplot mode if nLAT ne mLAT70 then message, 'funny nLAT value; expected value is 29' Loff = ((nLNG-mLNG)/2) > 0 Rots = Rot+[0,-1,1] ; Main, previous, following rotation From = [0 ,1 ,mLNG-1-Loff] Rang = [mLNG,Loff ,Loff ]-1 To = [Loff,nLNG-Loff,0 ] Z = replicate(Zflag,nLNG,nLAT) ; Create output array Zfile for n=0, 2*(Loff<1) do begin strput, File, strcompress(Rots[n],/rem) stat = flt_read(File,Zread,nx=(mLAT70+3)/4,ny=mLNG*4,atleast=7,error=A) if not stat then begin ; File not found message, /info, A ; Search library only for main rotation SearchLib, File, xData+':','X$DAT:SRF.ARC',cFound if cFound ne '' then stat = flt_read(File,Zread,nx=(mLAT70+3)/4,ny=mLNG*4,atleast=7,error=A) endif if A ne '' then begin if n eq 0 then begin ; Return if main rotation not read message, /info, A & return, 0 endif endif else begin Zread = reform(Zread,mLAT70+3,mLNG) Zread = Zread[2:2+mLAT70-1,*] Zread = rotate(Zread,6) ; Spans latitude range [-70,70] Z[To[n]:To[n]+Rang[n],*] = Zread[From[n]:From[n]+Rang[n],*] endelse endfor XCadj = Loff*5./360. XCadj = [XCadj,-XCadj,XCadj] return, 1 SINGLE_MAP: ; XCadj(0) = 0 : read single rotation. strput, File, strcompress(Rot,/rem) if not flt_read(File,Z,nx=(mLAT70+3)/4,ny=mLNG*4,atleast=7,error=A) then begin message, /info, A & return, 0 endif n = size(Z) n = n[2]/4 ; # longitudes read from file Z = reform(Z,mLAT70+3,n) R = round(Z[0,*]) L = round(Z[1,*]) ; Extract rot # and longitudes n = R eq Rot+1 R = R-n L = L-360*n if R[0] ne Rot then message, 'rotation # in file does not match file name '+File Z = Z[2:2+mLAT70-1,*] ; Extract magnetic field data L = rotate(L/5,5) ; Convert longitude to index and reverse order Z = rotate(Z,6) ; Spans latitude range [-70,70] if n_elements(L) ne mLNG then begin ; Flag longitudes that are not present R = Z Z = replicate(Zflag,mLNG,mLAT70) Z[L,*] = R endif m = (mLAT90-mLAT70)/2 R = Z Z = replicate(Zflag,mLNG,mLAT90) Z[*,m:m+mLAT70-1] = R ; Spans latitude range [-90,90] XCadj = [0.,0.,0.] ; Average in case the spatial resolution has to be changed if nLNG ne mLNG or nLAT ne mLAT90 then Z = MapGrid_REGtoREG(1.,Z,nLNG,nLAT,Zflag) return, 1 & end