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

From: Yi Wang <yiwang6_at_nyahnyahspammersnyahnyah>
Date: Mon Jun 07 2010 - 09:36:05 MDT

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 <res@cnFillMode=%22RasterFill>" ; 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@tiMainString=%22A20021612002192.L3m_R32_NSST_4.hdf>
*"

**res@gsnCenterString="field* <res@gsnCenterString=%22field>* name:
l3m_data" ; create center text*
*res@txString="(units* <res@txString=%22(units>*:" +
**eos_file@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*

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

problems.png
Received on Mon Jun 7 09:36:25 2010

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