;------------------------------------------------------------- ;+ ; NAME: ; TVMAP ; ; PURPOSE: ; TVMAP produces one of the following plots: ; (1) A color-pixel image, overlaid with a world map ; (2) A line-contour plot, overlaid with a world map ; (3) A filled-contour plot, overlaid with a world map ; ; CATEGORY: ; Plotting ; ; CALLING SEQUENCE: ; TVMAP, Data, [ Xarr, YArr [ [, keywords ] ] ; ; INPUTS: ; DATA -> 2-D array of values to be plotted as a color map. ; The first dimension is longitude, the second is latitude. ; ; XARR, YARR -> If plotting a line-contour map or filled-contour map, ; then XARR is the array of X-axis values, and YARR is the ; array of Y-Axis values that are needed to construct the ; the contours. XARR and YARR are not needed to produce a ; color-pixel image map. ; ; KEYWORD PARAMETERS: ; BLACK -> The color index corresponding to black. ; Default is 1 (for compatibility with MYCT!) ; ; /ERASE -> If set, will erase the graphics device before plotting ; the color image (or contour plot) and world map. ; ; _EXTRA=e -> Picks up extra keywords (not listed below) for ; BYTSCL, COLORBAR, TVIMAGE, MAP_SET, MAP_GRID, ; MAP_CONTINENTS, and CONTOUR. ; ; Keywords for both BYTSCL and COLORBAR: ; ====================================== ; MAXDATA -> Maximum value of the DATA array to use in the ; byte scaling. Default is max( DATA ). ; ; MINDATA -> Minimum value of the DATA array to use in the ; byte scaling. Default is min( DATA ). ; ; BOTTOM -> The lowest color index of the colors to be used ; for byte-scaling the color map and colorbar. Default ; is 20 (or !D.N_COLORS-1 if 20 is too large). ; ; NCOLORS -> This is the maximum color index that will be used. ; Default is 120 (or !D.N_COLORS-BOTTOM, if 120 is too large). ; ; /LOG -> Will create a color-pixel plot with logarithmic ; scaling. /LOG has no effect on line-contour or ; filled-contour plots, since the default contour levels ; are quasi-logarithmic. ; ; ; Additional keywords for COLORBAR: ; ================================= ; /CBAR -> If set, will plot the colorbar below the map in the ; position specified by CBPOSITION. Default is to NOT ; plot a colorbar. ; ; CBCOLOR -> Color index of the colorbar outline and ; characters. Defaults to BLACK (see above). ; ; CBPOSITION -> A four-element array of normalized coordinates ; that specifies the location of the colorbar. CBPOSITION ; has the same form as the POSITION keyword on a plot. ; Default is [0.1, 0.05, 0.9, 0.08]. ; ; CBUNIT -> Passes the Unit string to COLORBAR, which will be ; plotted to the right of the color bar. ; ; CBFORMAT -> format to use in call to colorbar. Default is I12 ; if abs(max(data)) < 1e4, else e12.2 (strings get trimmed) ; ; DIVISIONS -> Number of labels for the colorbar. Default is 4. ; ; Keywords for TVIMAGE: ; ===================== ; KEEP_ASPECT_RATIO: -> Normally, the image will be resized to fit ; the specified position in the window. If you prefer, you can ; force the image to maintain its aspect ratio in the window ; (although not its natural size) by setting this keyword. ; The image width is fitted first. If, after setting the ; image width, the image height is too big for the window, ; then the image height is fitted into the window. The ; appropriate values of the POSITION keyword are honored ; during this fitting process. Once a fit is made, the ; POSITION coordiates are re-calculated to center the image ; in the window. You can recover these new position coordinates ; as the output from the POSITION keyword. ; ; NOTE: KEEP_ASPECT_RATIO is automatically switched on ; if /ISOTROPIC is turned on. This is necessary in order ; to preserve the correct scaling of the image. ; ; Keywords for MAP_SET: ; ===================== ; COLOR -> Color index of the map outline and title characters. ; Defaults to BLACK (see above). ; ; MPARAM -> A 3 element vector containing values for ; [ P0Lat, P0Lon, Rot ]. Default is [ 0, 0, 0 ]. ; Elements not specified are automatically set to zero. ; ; /ISOTROPIC -> If set, will produce a map with the same scale ; in the X and Y directions. Default is not to plot an ; isotropic-scale map. ; ; LIMIT -> A four-element vector which specifies the latitude ; and longitude extent of the map. The elements of LIMIT ; are arranged thus: [ LatMin, LonMin, LatMax, LonMax ]. ; Default is to set LIMIT = [ -90, -180, 90, 180 ] (i.e. ; to include the entire globe). P0Lon will be computed ; to fit into the LIMIT range unless it is explicitely ; requested in MParam. ; ; POSITION -> A four-element array of normalized coordinates ; that specifies the location of the map. POSITION has ; the same form as the POSITION keyword on a plot. ; Default is [0.1, 0.1, 0.9, 0.9]. ; ; TITLE -> The title string that is to be placed atop the ; plot window. TITLE is passed explicitly to avoid keyword ; name duplication in the _EXTRA=e facility. ; ; Keywords for MAP_CONTINENTS: ; ============================ ; /CONTINENTS -> If set, will call MAP_CONTINENTS to plot ; continent outlines or filled boundaries. Default is 0. ; ; CCOLOR -> The color index of the continent outline or fill ; region. Default is BLACK (see above). ; ; CFILL -> Value passed to FILL_CONTINENTS keyword of MAP_CONTINENTS. ; If CFILL=1 then will fill continents with a solid color ; (as specified in CCOLOR above). If CFILL=2 then will fill ; continents with hatching. ; ; Keywords for MAP_GRID: ; ====================== ; /GRID -> If set, will call MAP_GRID to plot grid lines and ; labels. Labels can be turned off with /NOGLABELS. ; Default is _not_ to plot grid lines. ; ; GCOLOR -> The color index of the grid lines. Default is ; BLACK (see above). ; ; /NOGLABELS -> If set, TVMAP will print latitude/longitude ; labels for each grid line. ; ; Keywords for CONTOUR: ; ===================== ; /CONTOUR -> Will produce a line-contour map instead of the ; default color-pixel image map. ; ; /FCONTOUR -> Will produce a filled-contour map instead ; of the default color-pixel image map. ; ; C_LEVELS -> Vector containing the contour levels. If not ; specified, will use preset default levels. ; ; C_ANNOTATION -> Vector containing the contour labels. ; Default is to use string representations of C_LEVELS. ; ; C_FORMAT -> Format string used in converting C_LEVELS to ; the default C_ANNOTATION values. Default is '(f8.1)'. ; ; C_COLORS -> Index array of color levels for contour lines or ; fill regions. If not specified then will use uniformly ; spaced default color levels. If C_COLORS is set to a ; scalar value, then all contour lines will have the same ; color value. ; ; C_LABELS -> Specifies which contour levels should be labeled. ; By default, every other contour level is labeled. C_LABELS ; allows you to override this default and explicitly ; specify the levels to label. This parameter is a vector, ; converted to integer type if necessary. If the LEVELS ; keyword is specified, the elements of C_LABELS ; correspond directly to the levels specified, otherwise, ; they correspond to the default levels chosen by the ; CONTOUR procedure. Setting an element of the vector to ; zero causes that contour label to not be labeled. A ; nonzero value forces labeling. ; ; /NOLINES -> Will suppress overplotting a filled-contour map ; with lines. Default is to overlay filled-contour maps ; with lines. ; ; /NOLABELS -> Will suppress printing contour labels on both ; line-contour and filled-contour maps. ; ; OVERLAYCOLOR -> Color of the solid lines that will be ; overlaid atop a filled contour map. Default is BLACK. ; ; Keywords for REBIN: ; =================== ; /SAMPLE -> Used to rebin the byte-scaled image array to a ; larger size, for the PostScript printer. If /SAMPLE is ; set, then REBIN will use nearest-neighbor sampling ; rather than bilinear interpolation. ; ; ; Obsolete keywords (kept for compatibility) ; ========================================== ; DLON (obsolete) -> The length in degrees of a single longitude bin. ; Default is 5.0 degrees. ; ; LSHIFT (obsolete) -> just kept for historical reasons to avoid ; complaints by Isa ;-) LSHIFT once used to shift the data ; which was very bad. Then it was used to set P0Lon which ; should rather be done automatically or via the MParam ; keyword. ; ; /GLABELS (obsolete) -> kept for historical reasons. ; ; ; OUTPUTS: ; None ; ; SUBROUTINES: ; External subroutines required: ; ------------------------------ ; COLORBAR ( by Martin Schultz & David Fanning ) ; TVIMAGE ( by David Fanning ) ; RECTANGLE ( by Martin Schultz ) ; CONVERT_LON ( by Martin Schultz ) ; INV_INDEX ( function, by Martin Schultz ) ; MAP_LABELS ( by Martin Schultz & Bob Yantosca ) ; LOGLEVELS ( by Martin Schultz ) ; GET_DEFAULTFORMAT ( by Martin Schultz ) ; ; REQUIREMENTS: ; ; NOTES: ; (1) The _EXTRA facility now picks up keywords for multiple ; routines (this is a new feature in IDL v. 5.0+!!) ; ; (2) Some keywords are saved in local variables with ; slightly different names (e.g. MCONTOUR for /CONTOUR) ; to prevent confusion with routine names and/or keywords ; that are picked up by the _EXTRA=e facility. ; ; (3) At the present time, LONSHIFT only shifts the map center ; by an integral number of grid boxes. This restriction will ; probably be lifted in a future release (maybe...) ; ; (4) At present, TVMAP can only do a Cylindrical map over ; pixel plots, since TVIMAGE plots contain an integral number ; of pixels. Later on we will implement a modified algorithm ; to plot an arbitrary map projection. Note that contour plots ; can be used with any projection. ; ; EXAMPLE: ; TVMap, Data, $ ; LonShift=-70, $ ; /Erase, BLACK=1, $ ; MaxData=MaxData, MinData=MinData, $ ; NColors=120, Bottom=20, $ ; CBUnit='kg/m3', $ ; Divisions=4, Format='(f6.2)' , $ ; Title='O3 at 10 km', $ ; /Cylindrical, /Continents, $ ; /Grid ; ; MODIFICATION HISTORY: ; bmy, 13 Apr 1998: VERSION 1.00 ; bmy, 11 Jun 1998: - now returns if there is ; nothing to plot ; mgs, 15 Jun 1998: - bug fix: n_elements instead of ; keyword_set ; bmy, 22 Sep 1998: VERSION 1.10 ; - Now use _EXTRA=e to pass keywords to ; BYTSCL, TVIMAGE, MAP_SET, and COLORBAR ; - added MAPTITLE and UNIT keywords to ; avoid keyword name duplication in ; _EXTRA=e. ; bmy, 25 Sep 1998: VERSION 2.00 ; - now calls MAP_CONTINENTS and MAP_GRID ; - keywords renamed for consistency ; - reduced default size for CBPOSITION ; bmy, 28 Sep 1998: VERSION 2.01 ; - MPOSITION renamed to POSITION, MCOLOR to ; COLOR, MTITLE to TITLE for consistency ; - LONSHIFT renamed to LSHIFT to avoid ; problems with ambiguous keyword names ; bmy, 07 Sep 1998: VERSION 3.00 ; - now can plot contour map or color-pixel ; map (added CONTOUR and FCONTOUR keywords, ; and XARR and YARR parameters) ; - The colorbar is now optional, and is ; turned on via the /COLORBAR switch. ; bmy, 12 Nov 1998: VERSION 3.01 ; - added ISOTROPIC, SAMPLE, KEEP_ASPECT_RATIO, ; C_LABELS, and C_FORMAT keywords ; - now isotropic-scale color-image plots ; and isotropic-scale contour plots are ; handled correctly ; - Use mgs-style default levels & colors for ; contour and filled-contour maps. ; bmy, 13 Nov 1998: - updated comments ; - renamed C_LEVELS to C_ANNOTATION to ; prevent keyword name confusion ; - added NOLINES, NOLABELS, C_LABELS, ; and OVERLAYCOLOR keywords ; - contour lines and labels can be ; suppressed correctly ; - added mgs fix so that PostScript ; pixel-maps appear smoother ; - a border is now plotted around the ; map window, without inserting any of that ; annoying "cushion" space. ; - added LOG keyword for logarithmic ; contours and/or pixel colors ; - use KEYWORD_SET more often ; mgs, 17 Nov 1998: - re-arranged calls to map_set and tvimage ; in order to maximize size ; - output of title now seperate from map_set ; - added CBFormat keyword ; mgs, 19 Nov 1998: - CBFormat now handled in colorbar.pro ; mgs, 20 Nov 1998: - bug fix for map_set for contour plots ; mgs, 03 Dec 1998: - filled continents now added before contours ; - CFILL keyword checked for consistency ; bmy, 08 Feb 1999: - If /LOG is set, make sure that we don't ; take the log of zero and incur a math error ; - add call to function INV_INDEX ; bmy, 23 Feb 1999: - added /GLABELS keyword to turn on/off printing ; of labels for each grid line on the map ; - added call to CONVERT_LON for longitudes ; that straddle the date line ; bmy, 26 Feb 1999: - added LIMIT as an explicit keyword ; - now uses MAP_LABELS to construct grid labels ; - updated comments ; bmy, 04 Mar 1999: - added DEBUG keyword for debug output ; mgs, 17 Mar 1999: - some cleaning: ; - LSHIFT, DLON, and GLABELS made obsolete ; - new keyword NOGLABELS ; - P0Lon now computed from LIMIT information. ; - Updated call to map_labels ; - For contour plots: XArr, YArr no longer ; mandatory (although they should be provided) ; - much smarter default contour levels ; mgs, 22 Mar 1999: - added multi-panel ability through use of ; the new MULTIPANEL routine. This alters the ; meaning of MPosition and CB_Position: they now ; refer to positions in the current plot panel! ; mgs, 23 Mar 1999: - fixed a few minor things ; - charsize is now adjusted according to number ; of panels on page ; bmy, 25 Mar 1999: - If CBAR=0, then print unit string below ; plot (formerly was done in CTM_PLOT) ; - now use updated GET_DEFAULTFORMAT ; - updated comments ; - if NPANELS >=2 then place the plot title ; higher above the window, to allow for ; carriage-returned lines ; mgs, 23 Apr 1999: - added CBMin and CBMax keywords for tighter colorbar control ; ;- ; Copyright (C) 1998, 1999, Bob Yantosca, Harvard University ; This software is provided as is without any warranty ; whatsoever. It may be freely used, copied or distributed ; for non-commercial purposes. This copyright notice must be ; kept with any copy of this software. If this software shall ; be used commercially or sold as part of a larger package, ; please contact the author to arrange payment. ; Bugs and comments should be directed to bmy@io.harvard.edu ; with subject "IDL routine tvmap" ;------------------------------------------------------------- pro TVMap, Data, XArr, YArr, $ BLACK=BLACK, $ Erase=Erase, $ MaxData=MaxData, MinData=MinData, $ NColors=NColors, Bottom=Bottom, $ Log=Log, $ CBar=CBar, CBPosition=CBPosition, $ CBColor=CBColor, CBUnit=CBUnit, $ Divisions=Divisions, CBFormat=CBFormat, $ CBMin=CBMin, CBMax=CBMax, $ Keep_Aspect_Ratio=Keep_Aspect_Ratio, $ Color=MColor, MParam=MParam, $ Title=MTitle, Position=MPosition, $ Isotropic=Isotropic, Sample=Sample, $ Limit=Limit, $ Continents=Continents, CColor=CColor, $ CFill=CFill, $ Grid=Grid, GColor=GColor, $ NOGLabels=NOGLabels, $ Contour=MContour, FContour=FContour, $ C_Levels=C_Levels, C_Colors=C_Colors, $ C_Annotation=C_Annotation, C_Format=C_Format, $ C_Labels=C_Labels, NoLines=NoLines, $ NoLabels=NoLabels, OverLayColor=OverLayColor, $ _EXTRA=e, $ ; ; <<<< OBSOLETE KEYWORDS >>>> ; LShift=LShift, GLabels=GLabels, DLon=DLon ;==================================================================== ; Pass external functions (bmy, 2/25/99) ;==================================================================== FORWARD_FUNCTION Inv_Index, LogLevels, Get_DefaultFormat ;==================================================================== ; Error Checking: Arguments ;==================================================================== SData = Size( reform(Data), /Dimensions ) if ( N_Elements(SData) ne 2 ) then begin Message, 'DATA must be a 2-D array!!!', /Continue return endif ;==================================================================== ; Error Checking: Keywords ;==================================================================== ; ; Keywords for TVMAP if ( N_Elements( BLACK ) eq 0 ) then BLACK = 1 Debug = Keyword_Set( Debug ) ; Keywords for BYTSCL and COLORBAR if ( N_Elements( MaxData ) eq 0 ) then MaxData = max( Data ) if ( N_Elements( MinData ) eq 0 ) then MinData = min( Data ) if ( N_Elements( Bottom ) eq 0 ) $ then Bottom = 20 < ( !D.N_Colors-1 ) if ( N_Elements( NColors ) eq 0 ) $ then NColors = 120 < ( !D.N_Colors-Bottom ) Log = Keyword_Set( Log ) ; These keywords are for CONTOUR MContour = Keyword_Set( MContour ) FContour = Keyword_Set( FContour ) ; Extra keywords for COLORBAR if ( N_Elements( CBar ) eq 0 ) then CBar = 0 if ( N_Elements( CBColor ) eq 0 ) then CBColor = BLACK if ( N_Elements( CBPosition ) eq 0 ) $ then CBPosition = [ 0.25, 0.01, 0.75, 0.04 ] if ( N_Elements( Divisions ) eq 0 ) then Divisions = 2 ; Keywords for MAP_SET Isotropic = Keyword_Set( Isotropic ) if ( N_Elements( MColor ) eq 0 ) then MColor = BLACK if ( N_Elements( MTitle ) eq 0 ) then MTitle = '' if (!D.Name eq 'PS') then psoffset = 0.02 else psoffset = 0. if ( N_Elements( MPosition ) eq 0) then begin ;**** We also need to leave room for the unit string ;**** so comment these lines out (bmy, 3/25/99) ;**** if (MContour or FContour) then $ ;**** MPosition = [ 0.0, 0.05, 1.0, 1.0 ] $ ;****else $ MPosition = [ 0.0, 0.15+psoffset, 1.0, 1.0 ] ; room for colorbar endif else print,'Position passed: ',Mposition ; Get actual position of current plot panel ; MultiPanel,Position=position, margin=[0.05,0.05,0.02,0.07]; MultiPanel,Position=position, margin=[0.04,0.04,0.02,0.07] ;================================================================= ; Calculate true window position from position and MPosition ; Here we don't need to add a colorbar ... ;================================================================= ; get width of plot window wx = (position[2]-position[0]) wy = (position[3]-position[1]) Mposition[0] = position[0]+wx*MPosition[0] Mposition[1] = position[1]+wy*MPosition[1] Mposition[2] = position[0]+wx*MPosition[2] Mposition[3] = position[1]+wy*MPosition[3] ; same with CBPosition CBPosition[0] = position[0]+wx*CBPosition[0] CBPosition[1] = position[1]+wy*CBPosition[1] CBPosition[2] = position[0]+wx*CBPosition[2] CBPosition[3] = position[1]+wy*CBPosition[3] ; print,'position,MPosition,CBPosition=' ; print,position,MPosition,CBPosition ; print,'!P.MULTI=',!p.multi if ( N_Elements( Limit ) eq 0 ) then Limit = [ -90, -180, 90, 180 ] ; These keywords are for MAP_GRID Grid = Keyword_Set( Grid ) GLabels = 1 - Keyword_Set( NOGLabels ) if ( N_Elements( GColor ) eq 0 ) then GColor = BLACK ; These keywords are for MAP_CONTINENTS Continents = Keyword_Set( Continents ) if ( N_Elements( CColor ) eq 0 ) then CColor = BLACK if ( N_Elements( CFill ) eq 0 ) then CFill = 0 ; reset CFILL to zero if filled contours or image maps are drawn if (not MContour) then CFill = 0 ; Set P0Lat, P0Lon, Rot from MPARAM or LIMIT if ( N_Elements( MParam ) ge 2 ) then P0Lon = MParam[1] $ else P0Lon = total(LIMIT[[1,3]])/2. ; make sure it's at the map center if ( N_Elements( MParam ) eq 0 ) then $ MParam = [ 0,0,0 ] $ else $ MParam = ([Mparam,0,0,0])[0:2] P0Lat = Mparam[0] Rot = MParam[2] ; Make sure that KEEP_ASPECT_RATIO is also set if ISOTROPIC is set ; and vice versa. ; This will make sure the isotropic map and image plot will coincide. Keep_Aspect_Ratio = Keyword_Set( Keep_Aspect_Ratio ) Isotropic = Keyword_Set( Isotropic ) if (Isotropic) then Keep_Aspect_Ratio = 1 if (Keep_Aspect_Ratio ) then Isotropic = 1 ;==================================================================== ; Erase the screen if the Erase keyword is set. ;==================================================================== ; if ( Keyword_Set( Erase ) ) then Erase ;==================================================================== ; Make temporary copy of data (still necessary ???) ; ... maybe to get rid of extra dimensions ? ;==================================================================== TmpData = reform(Data) ;==================================================================== ; Return if TMPDATA is not a 2-D array ;==================================================================== sd = size( TmpData, /Dimensions ) if ( n_elements(sd) ne 2 ) then begin Message, 'No valid 2-D data to plot!', /Continue return endif npanels = !p.multi[1]*!p.multi[2] csfac = 1.0 if (npanels gt 1) then csfac = 0.9 if (npanels gt 4) then csfac = 0.75 if (npanels gt 9) then csfac = 0.6 if (!D.name ne 'PS') then csfac = csfac*1.2 if ( MContour OR FContour ) then begin ;================================================================= ; Here we are plotting a contour map! ; ; Make sure we have valid X and Y arrays ; Set default values for some contour input quantities ; ;================================================================= ;================================================================= ; Call MAP_SET to establish the map coordinates ;================================================================= Map_Set, P0lat, P0Lon, Rot, Position=MPosition, $ Continents=0, Grid=0, /NoErase, $ /NoBorder, XMargin=0, YMargin=0, $ Color=MColor, Limit=Limit, _EXTRA=e ;================================================================= ; Call MAP_CONTINENTS for filled continents at this point ; (they only make sense in contour plots) ;================================================================= if ( Continents AND CFill ge 1 ) then $ Map_Continents, Color=CColor, Fill=CFill, _EXTRA=e NewPosition = [ !X.Window[0], !Y.Window[0], $ !X.Window[1], !Y.Window[1] ] if ( N_Elements( XArr ) eq 0 ) then begin ; construct XARR from LIMIT and SD (dimensional information) XA0 = LIMIT[1] XA1 = LIMIT[3] if (XA1 lt 0 AND XA0 gt 0) then Convert_Lon,XA1,/Pacific XARR = findgen(SD[0])/SD[0]*(XA1-XA0) + XA0 if (XA1 lt 0 AND XA0 gt 0) then Convert_Lon,XARR,/Atlantic Message, 'Warning: XARR should be specified for CONTOUR plot!', $ /INFO endif if ( N_Elements( YArr ) eq 0 ) then begin YA0 = LIMIT[0] YA1 = LIMIT[2] YARR = findgen(SD[1])/SD[1]*(YA1-YA0) + YA0 Message, 'Warning: YARR should be specified for CONTOUR plot!', $ /INFO endif ; Default C_LEVELS...use quasi-logarithmic contour levels ; unless the range is very small if ( N_Elements( C_Levels ) eq 0 ) then $ C_Levels = loglevels([MinData, MaxData],coarse=4) if ( N_Elements( C_Levels ) lt 3 ) then $ C_Levels = (findgen(9)-1.)/9.*(MaxData-MinData) + MinData ; NCL is the number of elements in C_LEVELS NCL = N_Elements( C_Levels ) ; Default C_FORMAT if ( N_Elements( C_Format ) eq 0 ) then $ C_Format = get_defaultformat(C_Levels[0],C_Levels[NCL-1],$ DefaultLen=['14.2','8.1'], Log=Log) ; print,C_Levels,C_Format,mindata,maxdata ;----------------------------------------------------------- ; Default C_ANNOTATION...string representations of C_LEVELS ; Suppress printing labels by setting C_ANNOTATION(*) = '' ;----------------------------------------------------------- if ( Keyword_Set( NoLabels ) ) then begin C_Annotation = Replicate( '', NCL ) endif else begin if ( N_Elements( C_Annotation ) eq 0 ) then begin C_Annotation = StrTrim( String( C_Levels, Format=C_Format ), 2 ) endif endelse ;----------------------------------------------------------- ; Default C_LABELS...Set all elements to zero to suppress ; printing labels for each contour level, or one to enable ; printing labels for each contour level. ; ; Also, if C_LABELS is a scalar, then expand it so that ; it has the same number of elements as C_LEVELS ;----------------------------------------------------------- if ( N_Elements( C_Labels ) eq 0 ) then begin if ( Keyword_Set( NoLabels ) ) $ then C_Labels = Replicate( 0, NCL ) $ else C_Labels = Replicate( 1, NCL ) endif else begin if ( N_Elements( C_Labels ) eq 1 ) $ then C_Labels = Replicate( C_Labels[0], NCL ) endelse ; Default OVERLAYCOLOR = BLACK if ( N_Elements( OverLayColor ) eq 0 ) then OverLayColor = BLACK ;--------------------------------------------------------------- ; If C_COLORS is not passed, choose evenly spaced colors from ; the MYCT colortable for default colors. ; ; Otherwise, if C_COLORS is a scalar, then expand so that it ; has the same number of elements as C_LEVELS. ;--------------------------------------------------------------- if ( N_Elements( C_Colors ) eq 0 ) then begin C_Colors = Fix( ( IndGen( NCL ) / ( 1.0 * NCL ) ) * $ ( !D.N_COLORS - Bottom + 1 ) + Bottom ) endif else begin if ( N_Elements( C_Colors ) eq 1 ) $ then C_Colors = Replicate( C_Colors[0], NCL ) endelse ;================================================================= ; Overlay title ;================================================================= xpmid = (!x.window[1]+!x.window[0])/2. ;**** Place a little higher, for carriage return lines (bmy, 3/25/99) if ( NPanels lt 2 ) $ then yptop = !y.window[1]+0.025 $ else yptop = !y.window[1]+0.040 xyouts,xpmid,yptop,mtitle,color=MColor,/norm,align=0.5, $ charsize=1.2*csfac ;================================================================= ; Plot a border around the edge of the map, ; without inserting any "cushion" space. ;================================================================= Rectangle, NewPosition, XPoints, YPoints PlotS, XPoints, YPoints, Thick=2, Color=MColor, /Normal ;================================================================= ; If /FCONTOUR is set, then create a filled-contour ; plot atop the world map created above. ;================================================================= if ( FContour ) then begin Contour, TmpData, XArr, YArr, $ Levels=C_Levels, C_Colors=C_Colors, $ Fill=FContour, /OverPlot, _EXTRA=e ;------------------------------------------------------ ; If NOLINES=0, then overlay the filled-contour ; map with solid contour lines of color OVERLAYCOLOR ;------------------------------------------------------ if ( not Keyword_Set( NoLines ) ) then begin OverLayLines = Replicate( OverLayColor, NCL ) Contour, TmpData, XArr, YArr, $ Levels=C_Levels, C_Colors=OverLayLines, $ C_Annotation=C_Annotation, /OverPlot, $ C_Labels=C_Labels, _EXTRA=e endif endif $ ;================================================================= ; If /CONTOUR is set, then produce a ; line-contour plop atop the world map. ;================================================================= else if ( MContour ) then begin Contour, TmpData, XArr, YArr, $ Levels=C_Levels, C_Colors=C_Colors, $ C_Annotation=C_Annotation, /OverPlot, $ C_Labels=C_Labels, _EXTRA=e endif endif else begin ;================================================================= ; Here we are plotting a color-pixel image plot ; and overlaying a world map atop it!!! ; ; If /LOG is set, then take the log10 of TMPDATA. ; Store the extrema in LOGMINDATA and LOGMAXDATA, ; while leaving MINDATA and MAXDATA unaltered. ; ; First Byte-Scale the TMPDATA array, using the ; appropriate extrema for the byte scaling ;================================================================= if ( Log ) then begin ;============================================================== ; Make sure that we don't take the log10 of zero ;============================================================== Ind = Where( TmpData gt 0. ) if ( Ind[0] ge 0 ) then begin ; Elements that don't equal zero...take the log10 TmpData[ Ind ] = ALog10( TmpData[ Ind ] ) ; ** the following should be unnecessary (mgs, 03/17/99) ; ; Elements that are equal to zero...set to a small number ; Ind2 = Inv_Index( Ind, N_Elements( TmpData ) ) ; if ( Ind2[0] ge 0 ) then TmpData[ Ind2 ] = 1e-30 endif if ( MinData gt 0 ) $ then LogMinData = ALog10( MinData ) $ else LogMinData = 1e-30 if ( MaxData gt 0 ) $ then LogMaxData = ALog10( MaxData ) $ else LogMaxData = 1e-30 Image = BytScl( TmpData, Min=LogMinData, Max=LogMaxData, $ Top=NColors-1, _EXTRA=e ) + Bottom endif else begin ; (linear scale) Image = BytScl( TmpData, Min=MinData, Max=MaxData, $ Top=NColors-1, _EXTRA=e ) + Bottom endelse ;================================================================= ; Compute dithering factor (10 to ..) ; Formula may need to be improved (later on...) ;================================================================= S = Size( Image, /Dim ) BlowUp = 10 * ( ( Fix( 50/Min(S) ) > 1 ) < 20 ) ;================================================================= ; If /SAMPLE then rebin the data using nearest neighbor ; interpolation. Otherwise use bilateral interpolation ; (which takes longer but results in a finer grid). ;================================================================= if ( Keyword_Set( Sample ) ) then begin ; Screen (device with windows) needs rebin only if sample=1 ; since this will force a lower resolution plot if ( ( !D.FLAGS AND 256 ) gt 0 ) then $ Image = Rebin( Image, S[0]*BlowUp, S[1]*BlowUp, /Sample ) endif else begin ; PostScript needs rebin only for smoothing, since ; this will force a higher resolution plot if ( !D.NAME eq 'PS' ) then $ Image = Rebin( Image, S[0]*BlowUp, S[1]*BlowUp, Sample=0 ) endelse ;================================================================= ; Call David Fanning's TVIMAGE routine to draw a color ; scale plot. Use the NEWPOSITION values as defined ; from the extent of the map that was created above. ;================================================================= NewPosition = MPosition TVImage, Image, Position=NewPosition, $ Keep_Aspect_Ratio=Keep_Aspect_Ratio,/NoErase, _EXTRA=e ; Adjust position of colorbar so that it is placed 0.05 below plot cwy = CBPosition[3]-CBPosition[1] CBPosition[3] = NewPosition[1] - 0.05 CBPosition[1] = CBPosition[3] - cwy ;================================================================= ; We need to overlay the world map atop the color image. ; Also draw a frame around the map border, using the ; position vector from the window coordinates. ;================================================================= Map_Set, P0lat, P0Lon, Rot, Position=NewPosition, $ Continents=0, Grid=0, /NoErase, $ /NoBorder, XMargin=0, YMargin=0, $ Color=MColor, Limit=Limit, _EXTRA=e ;================================================================= ; Overlay title ;================================================================= npanels = !p.multi[1]*!p.multi[2] csfac = 1.0 if (npanels gt 1) then csfac = 0.9 if (npanels gt 4) then csfac = 0.75 if (npanels gt 9) then csfac = 0.6 xpmid = (!x.window[1]+!x.window[0])/2. ;**** Place a little higher, for carriage return lines (bmy, 3/25/99) if ( NPanels lt 2 ) $ then yptop = !y.window[1]+0.025 $ else yptop = !y.window[1]+0.040 xyouts,xpmid,yptop,mtitle,color=MColor,/norm,align=0.5, $ charsize=1.2*csfac ;================================================================= ; Plot a border around the edge of the map, ; without inserting any "cushion" space. ;================================================================= Rectangle, NewPosition, XPoints, YPoints PlotS, XPoints, YPoints, Thick=2, Color=MColor, /Normal endelse ;==================================================================== ; Call MAP_CONTINENTS to plot (or fill in) the continents ;==================================================================== if ( Continents AND CFill lt 1 ) then $ Map_Continents, Color=CColor, Fill=CFill, _EXTRA=e ;==================================================================== ; If /GRID and /GLABELS are set, then call MAP_LABELS to construct ; the latitude and longitude labels for each grid line, and also ; the normalized coordinates (NORM_XLAT, NORM_YLAT, NORM_XLON, and ; NORM_YLON) that will be used to plot the labels. Also call ; MAP_GRID to plot the grid lines, and print the labels next to ; each grid line. ; ; If /GRID is set, the default is to overlay labels as well. ;==================================================================== if ( Grid ) then begin if ( GLabels ) then begin LatRange = [ Limit[0], Limit[2] ] LonRange = [ Limit[1], Limit[3] ] ;**** Debug output if ( Debug ) then begin print, '### TVMAP : Limit : ', Limit print, '### TVMAP : LatRange : ', LatRange print, '### TVMAP : LonRange : ', LonRange endif Map_Labels, LatLabel, LonLabel, $ Lats=Lats, LatRange=LatRange, $ Lons=Lons, LonRange=LonRange, $ NormLats=NormLats, NormLons=NormLons, $ /MapGrid, _EXTRA=e XYOutS, NormLats[0,*], NormLats[1,*], LatLabel, $ Align=1.0, Color=MColor, /Normal, charsize=csfac XYOutS, NormLons[0,*], NormLons[1,*], LonLabel, $ Align=0.5, Color=MColor, /Normal, charsize=csfac endif Map_Grid, Color=GColor, Lats=Lats, Lons=Lons, _EXTRA=e endif ;==================================================================== ; Call COLORBAR to plot the colorbar below the map ; Otherwise, just print the unit string below the X-axis labels ;==================================================================== if ( CBar ) then begin if (n_elements(CBMin) eq 0) then CBMin = MinData if (n_elements(CBMax) eq 0) then CBMax = MaxData ColorBar, Max=CBMax, Min=CBMin, NColors=NColors, $ Bottom=Bottom, Color=CBColor, Position=CBPosition, $ Unit=CBUnit, Divisions=Divisions, Log=Log, $ Format=CBFormat, Charsize=csfac, _EXTRA=e endif else begin XPos = ( MPosition[2] + MPosition[0] ) * 0.5 YPos = ( CBPosition[3] + CBPosition[1] ) * 0.5 XYOutS, XPos, YPos, CBUnit, /Normal, $ Align=0.5, Color=MColor, CharSize=CsFac endelse ;==================================================================== ; Advance to the next plot position for the next plot ; Use NoErase so that we still see the results when the page is full ; (will be erased when we do next plot after page is full) ;==================================================================== MULTIPANEL,/Advance,/NoErase return end