;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef ("cstring_res") function cstring_res() ; internal function: sets the font height for the ; text_Top_*() center string. Will be passed to ; gsn_text_ndc() local txres begin txres = True ; text mods desired txres@txFontHeightF = 0.016 ; font smaller. default big return(txres) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef ("text_top_res") function text_top_res(res:logical) ; internal function: sets a few common resources ; for all plots that call text_Top_*() begin res@cnInfoLabelOn = False ; no contour info label res@gsnLeftString = " " ; turn off left string res@gsnRightString = " " ; turn off right string res@tiMainOffsetYF = 0.03 ; move title up (changed if lt axis) return(res) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef ("calc_time_label") function calc_time_label(in:file,tindex:integer) local mod_time,hr,minutes,label ; internal function only. calculates the ut label begin mod_time = (/in->mtime/) ; avoid bad coord varb info hr = mod_time(tindex,1) minutes = mod_time(tindex,2) label = hr + minutes/60. return(label) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef("ut_center_string") function ut_center_string(arg:logical) local label,fmt,CenterString ; internal function. creates ut center string begin if(isatt(arg,"ut"))then ; ut plots, don't add ut to center string return("") else label = calc_time_label(arg@file,arg@time) fmt = "%5.2f" CenterString = "UT= "+sprintf(fmt,label) return(CenterString) end if end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef("zplev_center_string") function zplev_center_string(cstring:string,arg:logical) local fmt,zpfloat ; internal function only: calculates zplev strings. ; Even though most plot templates have both zplev and ; avgZ in their top text, tgcmproc diff files can not, ; so the avgZ label has been separated into avgZ_center_string. begin fmt = "%5.2f" if(isatt(arg,"zplab"))then if(isdouble(arg@zplab))then zpfloat = doubletofloat(arg@zplab) else zpfloat = arg@zplab end if cstring = cstring + " ZP= "+sprintf(fmt,zpfloat) end if return(cstring) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef("avgZ_center_string") function avgZ_center_string(cstring:string,arg:logical) local fmt,zavg_float ; internal function only, calculates avgZ strings begin fmt = "%5.2f" if(isatt(arg,"zavg"))then if(arg@zavg.eq."na")then cstring = cstring + " AVEHT = below -7 zp" else if(.not.isatt(arg,"diff"))then ; don't add to diff files arg@zavg=arg@zavg/100000. ; scale in km if(isdouble(arg@zavg))then ; sprintf requires float zavg_float = doubletofloat(arg@zavg) else zavg_float = arg@zavg end if cstring = cstring + " AVEHT= "+sprintf(fmt,zavg_float)+" (km)" end if end if end if return(cstring) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef("height_center_string") function height_center_string(cstring:string,arg:logical) ; internal function only: adds a height value to center ; string if necessary begin if(isatt(arg,"height"))then cstring = cstring + " Height= "+arg@height +" (km)" end if return(cstring) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef("mag_center_string") function mag_center_string(cstring:string,arg:logical) ; internal function only: adds a magnetic indication to ; center string if necessary begin if(isatt(arg,"mag"))then if(arg@mag.eq.True)then cstring = cstring + " (mag coords)" end if end if return(cstring) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef("diff_center_string") function diff_center_string(cstring:string,arg:logical) ; internal function only: add a difference indication to ; center string if necessary. Differences are produced ; by tgcmproc. begin if(isatt(arg,"diff"))then cstring = cstring + " (difference)" end if return(cstring) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef("loc_center_string") function loc_center_string(cstring:string,arg:logical) ; internal function only: adds lat,lon,slt,zmean,or gmean ; to center string as necessary. begin if(isatt(arg,"lat"))then if(isatt(arg,"mag"))then if(arg@mag.eq.True)then cstring = cstring + " MLat= "+arg@lat else cstring = cstring + " Lat= "+arg@lat end if else cstring = cstring + " Lat= "+arg@lat end if end if if(isatt(arg,"lon"))then if(isatt(arg,"mag"))then if(arg@mag.eq.True)then cstring = cstring + " MLon= "+arg@lon else cstring = cstring + " Lon= "+arg@lon end if else cstring = cstring + " Lon= "+arg@lon end if end if if(isatt(arg,"slt"))then if(isatt(arg,"mag"))then if(arg@mag.eq.True)then cstring = cstring + " MLT= "+arg@slt +" (hrs)" else cstring = cstring + " SLT= "+arg@slt +" (hrs)" end if else cstring = cstring + " SLT= "+arg@slt +" (hrs)" end if end if if(isatt(arg,"zmean"))then if(arg@zmean.eq.True)then cstring = cstring + " Zonal Mean" end if end if if(isatt(arg,"gmean"))then if(arg@gmean.eq.True)then cstring = cstring + " Global Mean" end if end if return(cstring) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef("get_center_string") function get_center_string(arg:logical) local CenterString ; internal fucntion: groups common settings for the ; center string into one function for easier calling ; by the various text_Top*() routines begin CenterString = ut_center_string(arg) CenterString = zplev_center_string(CenterString,arg) CenterString = avgZ_center_string(CenterString,arg) CenterString = height_center_string(CenterString,arg) CenterString = mag_center_string(CenterString,arg) CenterString = diff_center_string(CenterString,arg) return(CenterString) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef ("textTop_polar") function textTop_polar(wks:graphic,arg:logical,res:logical) local ycoord,txres,perimlat,CenterString ; adds the hao specific text to the top of a polar plot. ; text is placed using gsn_text_ndc(). get_center_string() ; provides those center string components common to ; all plots. perimeter lat is added. Note that the ; ycoordinate of the string and the title offset vary by ; plot type. begin ;******************************************* ; part 1: get and draw the center string ;******************************************* ycoord = .875 ; default ndc coordinate for label CenterString = get_center_string(arg) ; get perimeter latitude and add to center string perimlat = "EQ" ; default label if(isatt(arg,"perimLat"))then perimlat = arg@perimLat end if CenterString = CenterString + " LAT = "+perimlat if(isatt(res,"vcRefMagnitudeF"))then ; reference vector ycoord = .9 end if gsn_text_ndc(wks,CenterString,.5,ycoord,cstring_res()) ;******************************************* ; part 2: adjust plot around center string ;******************************************* res = text_top_res(res) res@tiMainOffsetYF = 0.05 ; move title up (changed if lt axis) ; if local time labels on plot then... if(isatt(res,"gsnPolarUT"))then ; local time axis res@tiMainOffsetYF = 0.01 ; move title up end if ; if vector plot then... if(isatt(res,"vcRefMagnitudeF"))then ; reference vector res@tiMainFontHeightF = 0.019 ; adjust font height res@tiMainOffsetYF = 0.02 ; move main title up even more end if return(res) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef ("textTop_ce") function textTop_ce(wks:graphic,arg:logical,res:logical) local ycoord,CenterString ; adds the hao specific text to the top of a ce plot. ; text is placed using gsn_text_ndc(). get_center_string() ; provides those center string components common to ; all plots. Note that the ycoordinate of the string and the ; title offset vary by plot type. begin ;******************************************* ; part 1: get and draw the center string ;******************************************* ycoord = 0.73 ; default y coordinate for label CenterString = get_center_string(arg) if(isatt(res,"tmXTOn"))then ; lt axis exists, we move text up. ycoord = .79 end if gsn_text_ndc(wks,CenterString,.5,ycoord,cstring_res()) ;******************************************* ; part 2: adjust plot around center string ;******************************************* res = text_top_res(res) return(res) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef ("textTop_latut") function textTop_latut(wks:graphic,arg:logical,res:logical) local txres,ycoord,CenterString ; adds the hao specific text to the top of a lat vs. ut plot. ; text is placed using gsn_text_ndc(). get_center_string() ; provides those center string components common to ; all plots. Note that the ycoordinate of the string and the ; title offset vary by plot type. begin ;******************************************* ; part 1: get and draw the center string ;******************************************* ycoord = 0.85 ; default y coordinate for label CenterString = get_center_string(arg) CenterString = loc_center_string(CenterString,arg) if(isatt(res,"tmXTOn"))then ; has local time axis ycoord = .92 end if gsn_text_ndc(wks,CenterString,.5,ycoord,cstring_res()) ;******************************************* ; part 2: adjust plot around center string ;******************************************* res = text_top_res(res) return(res) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef ("textTop_prof") function textTop_prof(wks:graphic,arg:logical,res:logical) local txres,ycoord,CenterString ; adds the hao specific text to the top of a profile plot. ; text is placed using gsn_text_ndc(). get_center_string() ; provides those center string components common to ; all plots. loc_center_string() provides the location ; components such as lon/slt/zmean etc. Note that the ycoordinate ; of the string and the title offset vary by plot type. begin ;******************************************* ; part 1: get and draw the center string ;******************************************* ycoord = .85 CenterString = get_center_string(arg) CenterString = loc_center_string(CenterString,arg) gsn_text_ndc(wks,CenterString,.5,ycoord,cstring_res()) ;******************************************* ; part 2: adjust plot around center string ;******************************************* res@gsnLeftString = " " ; want only CenterString res@gsnRightString = " " ; want only CenterString res@tiMainOffsetYF = 0.03 ; move title up (changed if lt axis) return(res) end ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ undef ("textTop_zplon") function textTop_zplon(wks:graphic,arg:logical,res:logical) local txres,ycoord,CenterString ; adds the hao specific text to the top of a profile plot. ; text is placed using gsn_text_ndc(). get_center_string() ; provides those center string components common to ; all plots. loc_center_string() provides the location ; components such as lon/slt/zmean etc. Note that the ycoordinate ; of the string and the title offset vary by plot type. begin ;******************************************* ; part 1: get and draw the center string ;******************************************* ycoord = 0.85 CenterString = get_center_string(arg) CenterString = loc_center_string(CenterString,arg) if(isatt(res,"tmXTOn"))then ; has local time axis ycoord = 0.92 end if gsn_text_ndc(wks,CenterString,.5,ycoord,cstring_res()) ;******************************************* ; part 2: adjust plot around center string ;******************************************* res = text_top_res(res) return(res) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef ("textTop_zplat") function textTop_zplat(wks:graphic,arg:logical,res:logical) local CenterString,ycoord ; adds the hao specific text to the top of a profile plot. ; text is placed using gsn_text_ndc(). get_center_string() ; provides those center string components common to ; all plots. loc_center_string() provides the location ; components such as lon/slt/zmean etc. Note that the ycoordinate ; of the string and the title offset vary by plot type. begin ;******************************************* ; part 1: get and draw the center string ;******************************************* ycoord = .85 CenterString = get_center_string(arg) CenterString = loc_center_string(CenterString,arg) if(isatt(res,"tmXTOn"))then ; has local time axis ycoord = .79 end if gsn_text_ndc(wks,CenterString,.5,ycoord,cstring_res()) ;******************************************* ; part 2: adjust plot around center string ;******************************************* res = text_top_res(res) return(res) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef ("textTop_zput") function textTop_zput(wks:graphic,arg:logical,res:logical) local ycoord ; adds the hao specific text to the top of a profile plot. ; text is placed using gsn_text_ndc(). get_center_string() ; provides those center string components common to ; all plots. loc_center_string() provides the location ; components such as lon/slt/zmean etc. Note that the ycoordinate ; of the string and the title offset vary by plot type. begin ;******************************************* ; part 1: get and draw the center string ;******************************************* ycoord = .85 CenterString = get_center_string(arg) CenterString = loc_center_string(CenterString,arg) if(isatt(res,"tmXTOn"))then ; has local time axis ycoord = .92 end if gsn_text_ndc(wks,CenterString,.50,ycoord,cstring_res()) ;******************************************* ; part 2: adjust plot around center string ;******************************************* res = text_top_res(res) res@tiMainFontHeightF = 0.023 return(res) end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef("textBott") procedure textBott(wks:graphic,plot:graphic,var_x:numeric,time:integer,\ fname:string,f1:file,res:logical) local txres,spacing,vers,min_x,max_x ; adds the hao specific text at the bottom of the plot. This functions ; places this text 0.01 units w/in the plot boundary at a small font. ; the components of the string vary slightly by plot type. begin txres = True ; text mods desired txres@txFontHeightF = 0.012 ; font smaller. default big fmt = "%g" ; format for floats ; after plot is drawn retrieve contour interval for plot label. note that ; the contour interval is part of the contour object which is an attribute ; of the plot that is created. if(.not.isatt(var_x,"profile"))then if(isatt(plot,"contour"))then getvalues plot@contour "cnLevelSpacingF" : spacing end getvalues else getvalues plot "cnLevelSpacingF" : spacing end getvalues end if end if ; calc minimum/maximum of data for plot label min_tmp = min(var_x) max_tmp = max(var_x) if(isdouble(min_tmp))then min_x = doubletofloat(min_tmp) max_x = doubletofloat(max_tmp) else min_x = min_tmp max_x = max_tmp end if ; pull model version out of file attributes for plot label if(isatt(f1,"model_version"))then vers = f1@model_version else vers = "unknown" end if ; first choice is local file name. If this is blank, then pull model version ; out of file attributes for plot label if(fname.ne." ")then source = fname else if(isatt(f1,"mss_source"))then source = f1@mss_path else source ="unknown" end if end if ;******************************** ; latut ; zp vs. ut ; include spacing ; exclude ut label ;******************************** if(time.eq.-1)then label = vers + " Min = "+sprintf(fmt,min_x)+" Max = "+\ sprintf(fmt,max_x)+" int = "+spacing+" "+source txres@txFontHeightF = 0.015 time_type = time_interval(f1) gsn_text_ndc(wks,"UT (" +time_type+")",.5,.13,txres) txres@txFontHeightF = 0.012 else ;******************************** ; ce ; polar ; (zp vs. lat) ; (zp vs. lon) ; include ut label and spacing ;******************************** mod_time = (/f1->mtime/) day = mod_time(time,0) hr = mod_time(time,1) minute = mod_time(time,2) time_label = day+","+hr+","+minute if(isatt(var_x,"profile"))then label = "version = "+vers+" (Day,Hr,Min = "+time_label+") "+source else label = vers+" (Day,Hr,Min = "+time_label+") Min = "+\ sprintf(fmt,min_x)+" Max = "+sprintf(fmt,max_x)+" int = "+\ spacing+" "+source end if end if gsn_text_ndc(wks,label,.5,.01,txres) return end ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM undef("set_title") function set_title(x:numeric,name:string,res:logical) ; ideally, we want the main title to contain the ; long_name and units of the data. Not every variable ; has these attributes. If they do not exist, the ; title will default to the short_name of the data ; to be plotted e.g. "UN" begin if(isatt(x,"long_name"))then if(isatt(x,"units"))then res@tiMainString = x@long_name +" ("+x@units+")" else res@tiMainString = x@long_name end if else res@tiMainString = name end if return(res) end