/usr/share/ncarg/nclex/ngmath/nm11n.ncl is in libncarg-data 6.3.0-6build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | ;
; $Id: nm11n.ncl,v 1.5 2010-03-15 22:49:24 haley Exp $
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Copyright (C) 1998 ;
; University Corporation for Atmospheric Research ;
; All Rights Reserved ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; File: nm11n.ncl
;
; Author: Fred Clare
; National Center for Atmospheric Research
; PO 3000, Boulder, Colorado
;
; Date: Fri Jan 9 17:16:41 MST 1998
;
; Description: This program illustrates the use of ftkurvp and ftkurvpd.
;
procedure drw_text(label:string, xpos:float, ypos:float, height:float, \
output:graphic)
begin
;
; Create a label for the graph of function values.
;
label1 = create "Label" textItemClass output
"txPosXF": xpos
"txPosYF": ypos
"txFont": 21
"txJust" : "centercenter"
"txString": label
"txFontHeightF": height
end create
draw(label1)
update(output)
destroy(label1)
end
;
; Main program
;
begin
;
; Specify the input data.
;
x = (/ 13.0, 9.0, 9.0, 16.0, 21.0, 27.0, \
34.0, 36.0, 34.0, 26.0, 19.5 /)
y = (/ 35.0, 31.0, 18.0, 12.0, 9.6, 8.4, \
13.2, 21.6, 30.0, 37.2, 37.4 /)
;
; Create an array of parameterized values where interpolated values
; are desired.
;
npts = 201
u = fspan(0.,1.,npts)
;
; Interpolate.
;
xo = new( (/ npts /), float)
yo = new( (/ npts /), float)
ftkurvp(x, y, u, xo, yo)
;
; Get the derivatives (this returns the interpolsted values as well).
;
xs = new( (/ npts /), float)
ys = new( (/ npts /), float)
xd = new( (/ npts /), float)
yd = new( (/ npts /), float)
xdd = new( (/ npts /), float)
ydd = new( (/ npts /), float)
ftkurvpd(x, y, u, xs, ys, xd, yd, xdd, ydd)
;
; Create a color map.
;
cmap = (/ (/1.0,1.0,1.0/), \
(/0.0,0.0,0.0/), \
(/1.0,0.0,0.0/), \
(/0.0,1.0,0.0/), \
(/0.0,0.0,1.0/), \
(/1.0,1.0,0.0/) /)
;
; Default is to display output to an X workstation
;
wks_type = "ncgm"
if (str_lower(wks_type).eq."ncgm") then
;
; Create an ncgmWorkstation object.
;
xworkid = create "nm11Work" ncgmWorkstationClass defaultapp
"wkMetaName" : "nm11n.ncgm"
"wkColorMap" : cmap
end create
end if
if (str_lower(wks_type).eq."x11") then
;
; Create an X11 workstation.
;
xworkid = create "nm11Work" windowWorkstationClass defaultapp
"wkPause" : True
"wkColorMap" : cmap
end create
end if
if (str_lower(wks_type).eq."oldps") then
;
; Create an older-style PostScript workstation.
;
xworkid = create "nm11Work" psWorkstationClass defaultapp
"wkPSFileName" : "nm11n.ps"
"wkColorMap" : cmap
end create
end if
if (str_lower(wks_type).eq."oldpdf") then
;
; Create an older-style PDF workstation.
;
xworkid = create "nm11Work" pdfWorkstationClass defaultapp
"wkPDFFileName" : "nm11n.pdf"
"wkColorMap" : cmap
end create
end if
if (str_lower(wks_type).eq."pdf".or.str_lower(wks_type).eq."ps") then
;
; Create a cairo PS/PDF Workstation object.
;
xworkid = create "nm11Work" documentWorkstationClass defaultapp
"wkFileName" : "nm11n"
"wkFormat" : wks_type
"wkColorMap" : cmap
end create
end if
if (str_lower(wks_type).eq."png") then
;
; Create a cairo PNG Workstation object.
;
xworkid = create "nm11Work" imageWorkstationClass defaultapp
"wkFileName" : "nm11n"
"wkFormat" : wks_type
"wkColorMap" : cmap
end create
end if
;
;
; Draw two graphs:
; 1.) The interpolated function values.
; 2.) The first derivatives with respect to the parameter variable.
;
;
; Define data objects:
; dataid1(0) - coordinates of the original points.
; dataid1(1) - coordinates of the interpolated points.
; dataid2(0) - zero line for derivative plots.
; dataid2(1) - coordinates of the first derivative wrt u.
; dataid3(0) - zero line for derivative plots.
; dataid3(1) - coordinates of the first derivative wrt u.
;
dataid1 = new(2,graphic)
dataid2 = new(2,graphic)
dataid3 = new(2,graphic)
; Define a data object with the original points. The id for this
; object will later be used as the value for an XYPlot data resource,
; 'xyCoordData'.
;
dataid1(0) = create "OriginalPoints" coordArraysClass defaultapp
"caXArray": x
"caYArray": y
end create
;
; Define a data object with the interpolated points. The id for this
; object will later be used as the value for an XYPlot data resource,
; 'xyCoordData'.
;
dataid1(1) = create "InterpolatedPoints" coordArraysClass defaultapp
"caXArray": xo
"caYArray": yo
end create
;
; Define a data object to mark the zero line in the derivative plots.
;
xz = new(2,float)
yz = new(2,float)
xz(0) = 0.
xz(1) = 1.
yz(0) = 0.
yz(1) = 0.
dataid2(0) = create "ZeroLine" coordArraysClass defaultapp
"caXArray": xz
"caYArray": yz
end create
dataid3(0) = dataid2(0)
;
; Define a data object with the derivatives of X wrt the parameter
; variable.
;
dataid2(1) = create "XDerivatives" coordArraysClass defaultapp
"caXArray": u
"caYArray": xd
end create
;
; Define a data object with the derivatives of X wrt the parameter
; variable.
;
dataid3(1) = create "YDerivatives" coordArraysClass defaultapp
"caXArray": u
"caYArray": yd
end create
;
; Create an XyPlot object for drawing a curve with the interpolated
; points.
;
plotid_function = create "xyPlot" xyPlotClass xworkid
"vpXF": .15
"vpYF": .85
"vpWidthF" : .7
"vpHeightF" : .7
"trYMaxF" : 40.
"trYMinF" : 0.
"trXMaxF" : 40.
"trXMinF" : 0.
"xyCoordData": dataid1
"tmXTBorderOn": False
"tmYRBorderOn": False
"tmXBMinorPerMajor": 5
"tmYLMinorPerMajor": 5
"tmBorderThicknessF": 1.
"tmXMajorGridThicknessF": 1.
"tmXBMajorLengthF": 0.015
"tmYLMajorLengthF": 0.015
"tmXBMinorLengthF": 0.0075
"tmXBMajorThicknessF": 1.0
"tmYLMajorThicknessF": 1.0
"tmXTOn": False
"tmYROn": False
"tmXBLabelFont": 21
"tmXBLabelFontHeightF": 0.025
"tmYLLabelFont": 21
"tmYLLabelFontHeightF": 0.025
"tmYLMode": "Manual"
"tmYLTickStartF": 0.
"tmYLTickSpacingF": 10.0
"tmYLTickEndF": 40.
"tmXBMode": "Manual"
"tmXBTickStartF": 0.
"tmXBTickSpacingF": 10.0
"tmXBTickEndF": 40.
end create
getvalues plotid_function
"xyCoordDataSpec": dataspec
end getvalues
setvalues dataspec(0)
"xyMarkLineMode": "markers"
"xyMarkerColor": 4
"xyMarkerSizeF": 0.025
end setvalues
;
; Draw a graph of the interpolated points.
;
draw(plotid_function)
drw_text("Demo for ftkurvp",0.5,0.93,0.04,xworkid)
frame(xworkid)
;
; Draw a graph of the X derivative.
;
setvalues plotid_function
"trYMaxF" : 100.
"trYMinF" : -100.
"trXMaxF" : 1.
"trXMinF" : 0.
"xyCoordData": dataid2
"tmYLTickStartF": -100.
"tmYLTickSpacingF": 50.0
"tmYLTickEndF": 100.
"tmXBTickStartF": 0.
"tmXBTickSpacingF": 0.2
"tmXBTickEndF": 1.
"tmXBMajorLengthF": 0.020
"tmXBMinorLengthF": 0.010
"tmYLMajorLengthF": 0.020
"tmYLMinorLengthF": 0.010
"tmXBMinorPerMajor": 4
"tmYLMinorPerMajor": 4
"vpXF": .15
"vpYF": .87
"vpWidthF" : .7
"vpHeightF" : .32
"tmYLLabelFontHeightF": 0.023
"tmXBLabelFontHeightF": 0.023
end setvalues
getvalues plotid_function
"xyCoordDataSpec": dataspec
end getvalues
setvalues dataspec(0)
"xyLineColor": 2
end setvalues
draw(plotid_function)
;
; Draw a graph of the Y derivative.
;
setvalues plotid_function
"trYMinF" : -100.
"xyCoordData": dataid3
"tmYLTickStartF": -100.
"vpXF": .15
"vpYF": .42
"vpHeightF" : .32
end setvalues
getvalues plotid_function
"xyCoordDataSpec": dataspec
end getvalues
setvalues dataspec(0)
"xyLineColor": 2
end setvalues
drw_text("Derivatives from ftcurvpd",0.5,0.95,0.04,xworkid)
drw_text("dx/du",0.65,0.82,0.033,xworkid)
drw_text("dy/du",0.34,0.37,0.033,xworkid)
draw(plotid_function)
frame(xworkid)
;
; End NCL script.
;
end
|