Re: questions about plotting title, field name, and units, thanks

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Jun 07 2010 - 10:19:06 MDT

There are a few ways you can do this.

The "tiMainString" resource gives you a main title, and the three gsnLeftString, gsnCenterString, gsnRightString gives you three subtitles. You can use all four resources, or any combination of them.

The gsnCenterString will end up directly under tiMainString.

You can make these individual subtitles, or one long title.

Here's one way you might do the subtitles with a main title:

  filename = "A20021612002192.L3m_R32_NSST_4.hdf"
  res@gsnCenterString = "field name: l3m_data"
  res@gsnLeftString = "(units: " + eos_file@Units + ")"
  res@tiMainString = filename

You can also combine them into one long title. For example.

  res@tiMainString = filename + ": field name: l3m_data (" + eos_file@Units + ")"

You should also make sure you have a .hluresfile in your home directory so you don't get any PLCHHQ error messages.

See:

http://www.ncl.ucar.edu/Document/Graphics/hlures.shtml

--Mary

>
> ;;;;;;;;;;;the following codes have problems;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> res@tiMainString="A20021612002192.L3m_R32_NSST_4.hdf"
>
> res@gsnCenterString="field name: l3m_data" ; create center text
> res@txString="(units:" + eos_file@Units + ")"; create title

On Jun 7, 2010, at 9:36 AM, Yi Wang wrote:

> Hi friends,
>
> I met some problems. I want to plot the title, the field name: l3m_data, and the units: deg-C above the picture. The title, and the field name can be hard codes, however, the unites need to be obtained from the attributes. I post my codes and errors as below. Could anyone please help me see the codes? You can download the corresponding hdf file from ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/veer/MAP_DATA/files/OceanColor/MODISA/L3SMI/A20021612002192.L3m_R32_NSST_4.hdf. I hope to see the plot with text (see the attachment) when open the pdf file which is created by the ncl codes. Thank you so much!
>
> Best,
> Yi Wang
>
>
> load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> ; This is an example of a 2-D data field.
> ; It is assumed users know how to obtain information such as _FillValue from HDFView.
> ; For information about HDFView, visit http://www.hdfgroup.org/hdf-java-html/hdfview/.
>
> begin
> eos_file=addfile("A20021612002192.L3m_R32_NSST_4.hdf", "r") ; Read file.
> ;Not an HDFEOS file.
> ;For more information, consult section 4.3.2 of http://hdfeos.org/software/ncl.php.
>
> ;units=eos_file@Units
> data_unsigned=eos_file->l3m_data; read data field
> data_unsigned@_FillValue=65535h ; 'h' is appended to avoid type mismatching
> theIntercept=data_unsigned@Intercept ; Intercept=-2.0, given in the attributes of l3m_data
> theSlope=data_unsigned@Slope; Slope=7.17185E-4, given in the attributes of l3m_data
>
> data_signed=where(data_unsigned.lt.inttoshort(0), abs(data_unsigned)+32767, data_unsigned) ;
> ; Convert unsigned integer to signed integer for NCL to properly handle
>
> data=theIntercept+data_signed*theSlope
>
> data!0="lat" ; This file does not contain geolocation fields.
> data!1="lon" ; To properly display the data, the latitude/longitude must be remapped from its metadata.
> ; See http://www.ncl.ucar.edu/Applications/Scripts/regrid_10.ncl for more information
>
> nLat=eos_file@Number_of_Lines ;4320
> nLon=eos_file@Number_of_Columns ;8640
> latStep=eos_file@Latitude_Step ;0.041666668
> lonStep=eos_file@Longitude_Step ;0.041666668
> latStartpoint=eos_file@SW_Point_Latitude ;-89.979164
> lonStartpoint=eos_file@SW_Point_Longitude ;-179.97917
>
> lat=ispan(0,nLat-1,1)*latStep+latStartpoint
> lon=ispan(0,nLon-1,1)*lonStep+lonStartpoint
> ;about ispan, see http://www.ncl.ucar.edu/Document/Functions/Built-in/ispan.shtml
>
> lat@units = "degrees_north"
> ;lat@Latitude_Units="degrees_North" is wrong
> ;lat@units="degrees_North" is also wrong
>
> lon@units = "degrees_east"
> ;lon@Longitude_Units="degrees_East" is wrong
> ;lon@units="degrees_East" is also wrong
>
> lat=lat(::-1) ; use north-to-south latitude ordering
> data&lat=lat
> data&lon=lon
>
>
> xwks=gsn_open_wks("pdf","A20021612002192.L3m_R32_NSST_4_l3m_data") ; open workstation
> setvalues NhlGetWorkspaceObjectId() ; make maximum filesize larger
> "wsMaximumSize" : 200000000
> end setvalues
> res=True ; plot mods desired
> res@cnFillOn=True ; enable contour fill
> res@cnLinesOn=False ; turn off contour lines
> res@gsnSpreadColors=True ; use the entire color spectrum
> res@cnFillMode="RasterFill" ; faster
> res@lbLabelAutoStride=True ; ensure labels do not overlap
> res@lbOrientation = "vertical" ; vertical labels
> res@cnMissingValFillPattern = 0 ; missing value pattern is set to "SolidFill"
> res@cnMissingValFillColor=0; white color for missing values
> ;res@gsnLeftStringFontHeightF=10 ; make text smaller
> ;res@gsnCenterStringFontHeightF=10
> ;res@gsnRightStringFontHeightF=10
>
> gsn_define_colormap(xwks,"BlAqGrYeOrReVi200") ; define colormap
>
> ;;;;;;;;;;;the following codes have problems;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> res@tiMainString="A20021612002192.L3m_R32_NSST_4.hdf"
>
> res@gsnCenterString="field name: l3m_data" ; create center text
> res@txString="(units:" + eos_file@Units + ")"; create title
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> ;print(eos_file@Units)
>
> plot=gsn_csm_contour_map_ce(xwks,data,res)
>
> delete(plot) ; cleaning up resources used
> delete(lat)
> delete(lon)
> delete(xwks)
> delete(data)
> delete(res)
> delete(eos_file)
> end
>
>
> The errors are as below.
> PLCHHQ - CHARACTER NUMBER 16 (l) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 18 (m) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 19 (_) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 20 (d) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 21 (a) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 22 (t) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 23 (a) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 11 (d) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 12 (e) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 13 (g) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 14 (-) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 16 ()) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 11 (d) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 12 (e) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 13 (g) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 14 (-) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 16 ()) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 11 (d) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 12 (e) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 13 (g) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 14 (-) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 16 ()) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 11 (d) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 12 (e) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 13 (g) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 14 (-) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 16 ()) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 11 (d) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 12 (e) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 13 (g) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 14 (-) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 16 ()) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 11 (d) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 12 (e) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 13 (g) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 14 (-) IS NOT A LEGAL FUNCTION CODE
> PLCHHQ - CHARACTER NUMBER 16 ()) IS NOT A LEGAL FUNCTION CODE
> <problems.png>_______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jun 7 10:19:15 2010

This archive was generated by hypermail 2.1.8 : Mon Jun 07 2010 - 16:48:44 MDT