/usr/share/ncarg/nclex/xyplot/xy06n.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 | ; $Id: xy06n.ncl,v 1.12 2010-03-15 22:49:25 haley Exp $
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; Copyright (C) 1995 ;
; University Corporation for Atmospheric Research ;
; All Rights Reserved ;
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;; File: xy06n.ncl
;;
;; Author: Mary Haley
;; National Center for Atmospheric Research
;; PO 3000, Boulder, Colorado
;;
;; Date: Mon Feb 13 09:24:47 MST 1995
;;
;; Description: This example shows how to do several things:
;;
;; 1) How to create an XyPlot object with multiple
;; lines using the CoordArrays and Data objects.
;; 2) How to change the data to create a different
;; plot, without having to create a new data object
;; (using the NhlSetValues call).
;; 3) How to overlay a Legend object and to tweak
;; several kinds of resources (see "xy06.res").
;; 4) How to use ncl interface routines to open
;; and access a netCDF file.
;; 5) How to use a kludgy method for using the resource
;; file to specify which stations you want to observe.
;
; Begin NCL script
;
begin
;
; Create variables for stations information. "NSTATIONS" is the number
; of stations we want data vales for, and "spv" is the special value
; for missing values. If you want to plot data values for
; other cities, change the "stations" variable accordingly, and
; also change "NSTATIONS" if you change the number of stations.
;
NHOURS = 24
NSTATIONS = 8
NCOLORS = NSTATIONS+2
spv = -9999.0
;
; Create variable for holding data values.
;
temp = new((/NSTATIONS,NHOURS/),float,spv)
pressure = new((/NSTATIONS,NHOURS/),float,spv)
wind_speed = new((/NSTATIONS,NHOURS/),float,spv)
;
; We need to initialize a non-constant dummy array for our Data
; object, otherwise we'll get error messages.
;
temp(0,:) = ispan(0,NHOURS-1,1)
;
; Modify the color map. Color indices '0' and '1' are the background
; and foreground colors respectively.
;
cmap = (/ (/0.00,0.00,0.00/), \
(/1.00,1.00,1.00/), \
(/0.00,0.00,1.00/), \
(/0.00,1.00,0.00/), \
(/0.00,1.00,0.75/), \
(/0.50,0.50,0.63/), \
(/1.00,0.00,0.00/), \
(/0.75,0.38,0.25/), \
(/0.75,0.00,0.75/), \
(/1.00,1.00,0.00/) /)
;
; Default is to display output to an X workstation
;
wks_type = "x11"
;
; Create application object. The application name is used to
; determine the name of the resource file which will be "xy06.res"
; in this case.
;
appid = create "xy06" appClass defaultapp
"appDefaultParent" : True
"appUsrDir" : "./"
end create
if (str_lower(wks_type).eq."ncgm") then
;
; Create an ncgmWorkstation object.
;
xworkid = create "xy06Work" ncgmWorkstationClass defaultapp
"wkMetaName" : "xy06n.ncgm"
"wkColorMap" : cmap
end create
end if
if (str_lower(wks_type).eq."x11") then
;
; Create an X workstation
;
xworkid = create "xy06Work" 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 "xy06Work" psWorkstationClass defaultapp
"wkPSFileName" : "xy06n.ps"
"wkColorMap" : cmap
end create
end if
if (str_lower(wks_type).eq."oldpdf") then
;
; Create an older-style PDF workstation.
;
xworkid = create "xy06Work" pdfWorkstationClass defaultapp
"wkPDFFileName" : "xy06n.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 "xy06Work" documentWorkstationClass defaultapp
"wkFileName" : "xy06n"
"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 "xy06Work" imageWorkstationClass defaultapp
"wkFileName" : "xy06n"
"wkFormat" : wks_type
"wkColorMap" : cmap
end create
end if
;
; Define a dummy Data object. We do this so a DataSpec object is
; created automatically and then we can use a NhlFGetValues call to
; get the names of the stations we want data values for.
;
dataid = create "xyData" coordArraysClass defaultapp
"caYArray" : temp(0,:)
end create
;
; The id for this dummy Data object will now become the resource
; value for "xyCoordData".
;
plotid = create "xyPlot1" xyPlotClass xworkid
"xyCoordData": dataid
end create
;
; Get the DataSpec object id.
;
getvalues plotid
"xyCoordDataSpec" : dspec
end getvalues
;
; Get station id names that have been set in resource file. This
; is a round-about way of doing things, but it makes it convenient to
; be able to specify the stations we want. We used the
; 'xyExplicitLegendLabels' resource, because we also want to use the
; station names to label the lines in the legend.
;
getvalues dspec(0)
"xyExplicitLegendLabels" : station_abrev
end getvalues
numids = dimsizes(station_abrev)
;
; Set date.
;
date = "950318"
;
; Define procedure for getting the daily data values from a particular
; station.
;
temp@_FillValue = spv
pressure@_FillValue = spv
wind_speed@_FillValue = spv
filedir = ncargpath("data")
do j = 0,NHOURS-1
if((j.lt.10))
filename = filedir + "/cdf/" + date + "0" + j + "_sao.cdf"
else
filename = filedir + "/cdf/" + date + j + "_sao.cdf"
end if
;
; Open data file containing grid of global data values.
;
tmpfile = addfile(filename,"r")
rdstations = chartostring(tmpfile->id)
do l = 0, numids-1
i = ind(rdstations.eq.station_abrev(l))
print("station " + station_abrev(l))
if(.not.all(ismissing(i)))
print("loaded hour " + j)
temp(l,j) = (/tmpfile->T(i(0))/)
pressure(l,j) = (/tmpfile->PSL(i(0))/)
wind_speed(l,j) = (/tmpfile->SPD(i(0))/)
else
print("missing hour " + j)
temp(l,j) = spv
pressure(l,j) = spv
wind_speed(l,j) = spv
end if
delete(i)
end do
delete(rdstations)
delete(tmpfile)
end do
;
; Define the Data object. Since only the Y values are specified here,
; each Y value will be paired with its integer array index. The data
; id from this object will become the value for the XyPlot resource
; "xyCoordData".
;
dataid = create "xyData" coordArraysClass noparent
"caYArray" : temp
"caYMissingV" : spv
end create
;
; The id for this Data object is now the resource value for
; xyCoordData. Tweak some XyPlot resources in the resource file
; ("xy06.res").
;
plotid = create "xyPlot1" xyPlotClass xworkid
"xyCoordData": dataid
end create
;
; Draw the plot.
;
draw(plotid)
frame(xworkid)
;
; Change the data in our Data object. Notice we use setvalues
; instead of create, so our data object will have the same
; name as when we originally created it, "xyData".
;
setvalues dataid
"caYArray" : pressure
end setvalues
;
; Create another XyPlot object with this new Data object. We have to
; create another object instead of just changing the current one,
; because we want to change some resource values to title our axes
; differently.
;
plotid = create "xyPlot2" xyPlotClass xworkid
"xyCoordData": dataid
end create
;
; Draw the plot.
;
draw(plotid)
frame(xworkid)
;
; Change the data in our Data object. Notice we use setvalues
; instead of create, so our data object will have the same
; name as when we originally created it, "xyData".
;
setvalues dataid
"caYArray" : wind_speed
end setvalues
;
; Create another XyPlot object with this new Data object. We have to
; create another object instead of just changing the current one,
; because we want to change some resource values to title our axes
; differently.
;
plotid = create "xyPlot3" xyPlotClass xworkid
"xyCoordData": dataid
end create
;
; Draw the plot.
;
draw(plotid)
frame(xworkid)
;
; End NCL script
;
end
|