function MapRead, MapReadFile, XCbeg, RotN, nLng, nLat, XCadj @compile_opt.pro ; On error, return to caller ;+ ; NAME: ; MapRead ; PURPOSE: ; Read files containing a Carrington map as a 2D array ; CALLING SEQUENCE: ; Z = MapRead(MapReadFile,XCbeg,RotN,nLng,nLat,Blank,Zmin,Zmax) ; INPUTS: ; MapReadFile scalar; type: string ; name of function to read data file for single rotation ; XCbeg scalar; type: float ; start Carrington variable ; RotN scalar; type: integer; default: 1 ; # rotations to be averaged ; nLng scalar; type: integer ; nLat scalar; type: integer ; # longitudes and latitudes in output array ; OUTPUTS: ; Z array[nLng,nLat]; type: float ; function value array for averaged synoptic map ; CALLS: ; RESTRICTIONS: ; > The external integer*4 function MapReadFile is called with the ; following syntax ; ; I = MapReadFile(Rot,nLng,nLat,Zread,XCadj) ; ; with input arguments ; Rot integer Carrington rotation number ; nLng integer # grid longitudes ; nLat integer # grid latitudes ; and output arguments ; I integer return status ; 0 : failure ; 1 : success ; Zread(nLng,nLat) ; float 2D array for synoptic map ; > The output array Zread must cover the full heliographic longitude range ; [0,360], i.e. Zread(0,*) corresponds to 0 deg; Zread(nLng-1,*) to 360 deg. ; > If this is not the case for the array on the input file, some ; interpolation scheme must be used to remap the data array read ; from file (see e.g. the Fe XIV data) ; > The latitude range must be the same for all files of a ; particular data type (otherwise the averaging scheme in MapRead ; gives wrong results), but can be less than the full [-90,90] range. ; > The longitude grid must be evenly spaced in degrees ; > The latitude grid must be evenly space in latitude or sin(latitude) ; PROCEDURE: ; > MapRead creates a file Z ready for input in the MapPlot synoptic map ; plotting subroutine, in case the synoptic maps are available as ; seperate files of 2D arrays. ; > The user-written external function MapReadFile reads each seperate file ; into the scratch array Zread (see RESTRICTIONS) ; > MapRead extracts data in the range [XCbeg,XCbeg+RotN] from Zread and ; accumulates averages for RotN rotations in the Z array. ; > The output array Z will be such that Z(1,*) corresponds to ; Carrington variable XCbeg+1 and Z(nLng,*) to XCbeg, i.e. it ; covers a full 360 deg in heliographic longitude. ; > Currently three types of synoptic data can be read: ; - Stanford source surface maps (MapReadFile = MapReadSurf) ; - Greg's Yohkoh synoptic maps (MapReadFile = MapReadYohkoh) ; - Sac Peak Fe XIV maps (MapReadFile = MapReadFe) ; MODIFICATION HISTORY: ; JUL-1993, Paul Hick (UCSD) ;- FrstRot = fix(XCbeg) ; First Carrington rotation LastRot = fix(XCbeg+round(RotN > 1)) ; Last Carrington rotation ICbeg = round((1-(XCbeg-FrstRot))*(nLng-1)) ; Start longitude index if ICbeg eq nLng-1 then LastRot = LastRot-1 Z = fltarr(nLng,nLat) B = intarr(nLng,nLat) for Rot=FrstRot,LastRot do begin ; Loop over Carrington rotations if call_function( MapReadFile,Rot,nLng,nLat,Zread,XCadj ) then begin ; File read succesfully if ICbeg eq nLng-1 then begin ; Pick up entire rotation Lo = 0 Hi = nLng-1 endif else begin if Rot eq FrstRot then begin Lo = nLng-ICbeg ; Copy ICbeg columns Hi = nLng-1 Zread = Zread[1:ICbeg,*] ; Skip 0 deg column (taken from next rotations) endif else if Rot eq LastRot then begin Lo = 0 Hi = nLng-ICbeg-1 ; Copy nLng-iCbeg columns Zread = Zread[ICbeg:*,*] ; Includes 360 deg column endif else begin Lo = 0 Hi = nLng-1 ; Copy all nLng columns if ICbeg lt nLng/2 then begin; Swap left and right portions of map Ztmp = Zread[1:ICbeg,*] Zread[Lo:nLng-1-ICbeg,*] = Zread[ICbeg:*,*] Zread[nLng-ICbeg:Hi,*] = Ztmp endif else begin Ztmp = Zread[ICbeg:*,*] Zread[nLng-ICbeg:Hi,*] = Zread[1:ICbeg,*] Zread[Lo:nLng-1-ICbeg,*] = Ztmp endelse endelse endelse Zok = finite(Zread) n = where(not Zok) if n[0] ne -1 then Zread[n] = 0. Z[Lo:Hi,*] = Z[Lo:Hi,*]+Zread B[Lo:Hi,*] = B[Lo:Hi,*]+Zok endif endfor n = where(B ne 0) if n[0] eq -1 then $ Z = -1 $ else begin Z[n] = Z[n]/B[n] n = where(B eq 0) if n[0] ne -1 then Z[n] = ValuesNaN(size(Z)) endelse return, Z & end