iconPlot 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 81daefe787ba86d077804f2afbb20f24bb8625e0
4
+ data.tar.gz: e2538b75ce60c906d8c90afd08654bc4a9f7a9f1
5
+ SHA512:
6
+ metadata.gz: b2a7478b62d8e95335816b006caeb81471f749cf1d014875647a9504a2efe03bca72c5a7db1036650407ff9c5e0a6d59a04865cef19b869de7163bf1213ae5aa
7
+ data.tar.gz: c7da25dd5cd29dcc0232e049bf86da2192ab56cab2ff232a5b1a2f247d1158d8d1ace670f39c7a664607fe5382b6628a934867a4f0cb3ce9705b23558a2b5ef0
File without changes
data/gemspec CHANGED
@@ -3,9 +3,10 @@ $:.unshift File.join(File.dirname(__FILE__),"..","lib")
3
3
 
4
4
  spec = Gem::Specification.new do |s|
5
5
  s.name = "iconPlot"
6
- s.version = '0.0.6'
6
+ s.version = '0.0.8'
7
7
  s.platform = Gem::Platform::RUBY
8
- s.files = ["lib/iconPlot.rb"] + ["gemspec"] + ["contrib/nclsh"] + Dir.glob("lib/*ncl")
8
+ s.files = ["lib/iconPlot.rb"] + ["gemspec"] + ["bin/nclsh"] + Dir.glob("lib/*ncl")
9
+ s.executables << 'nclsh'
9
10
  s.test_file = "test/test_iconPlot.rb"
10
11
  s.description = "Plot with ncl via Ruby: requires NCL 6.* and CDO 1.5.*"
11
12
  s.summary = "Plot ICON output with ncl via Ruby"
data/lib/iconPlot.rb CHANGED
@@ -6,19 +6,13 @@ require 'shellwords'
6
6
  class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug,:isIcon)
7
7
  VERSION = '0.0.4'
8
8
 
9
- def IconPlot.gemPath
10
- gemSearcher = Gem::GemPathSearcher.new
11
- gemspec = gemSearcher.find('iconPlot')
12
- gemspec.gem_dir
13
- end
14
9
  def initialize(*args)
15
10
  super(*args)
16
-
17
- gempath = IconPlot.gemPath
11
+
18
12
  defaults = {
19
- :caller => [gempath,'contrib','nclsh'].join(File::SEPARATOR),
20
- :plotter => [gempath,'lib','icon_plot.ncl'].join(File::SEPARATOR),
21
- :libdir => [gempath,'lib'].join(File::SEPARATOR),
13
+ :caller => Gem.bin_path('iconPlot','nclsh'),
14
+ :plotter => Gem.find_files("icon_plot.ncl")[0],
15
+ :libdir => File.dirname(Gem.find_files("icon_plot.ncl")[0]),
22
16
  :otype => 'png',
23
17
  :display => 'sxiv',
24
18
  :cdo => ENV['CDO'].nil? ? 'cdo' : ENV['CDO'],
@@ -41,7 +35,7 @@ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug
41
35
  raise ArgumentError
42
36
  end
43
37
 
44
- opts[:tStrg] =ofile
38
+ opts[:tStrg] =ofile if opts[:tStrg].nil?
45
39
 
46
40
  cmd = [self.caller,self.plotter].join(' ')
47
41
  cmd << " -altLibDir=#{self.libdir} #{varIdent} -iFile=#{ifile} -oFile=#{ofile} -oType=#{self.otype}"
@@ -52,7 +46,8 @@ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug
52
46
  out = IO.popen(cmd).read
53
47
  puts out if self.debug
54
48
 
55
- return [FileUtils.pwd,"#{ofile}.#{self.otype}"].join(File::SEPARATOR)
49
+ #return [FileUtils.pwd,"#{ofile}.#{self.otype}"].join(File::SEPARATOR)
50
+ return "#{ofile}.#{self.otype}"
56
51
  end
57
52
  def scalarPlot(ifile,ofile,varname,opts={})
58
53
  plot(ifile,ofile,varname,'scalar',opts)
data/lib/icon_plot.ncl CHANGED
@@ -9,23 +9,53 @@
9
9
  load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
10
10
  load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
11
11
 
12
+ ;------- lib location from the command line ------------------------------------------------------------------
13
+ libLoaded = False
14
+ if ( isvar("altLibDir") ) then
15
+ print("Load library: "+altLibDir+"/icon_plot_lib.ncl")
16
+ loadscript(altLibDir +"/icon_plot_lib.ncl")
17
+ libLoaded = True
18
+ end if
19
+ ;------------------------------------------------------------------------------
12
20
  ;------- config ---------------------------------------------------------------
13
21
  ; default settings from user file
14
- CONFIGFILE = getenv("HOME")+"/.icon_plot.rc"
15
- if (isfilepresent(CONFIGFILE)) then
16
- print("Found configfile:"+CONFIGFILE)
17
- loadscript(CONFIGFILE)
22
+ ; --- Skip any user configuration through a file
23
+ if (isvar("noConfig")) then
24
+ if ( isvar("DEBUG") .and. DEBUG) print("Subpress user configuration") end if
25
+ else
26
+ ; --- Use the configuration file from the commandline option
27
+ if ( isvar("configFile") ) then
28
+ if (isfilepresent(configFile)) then
29
+ print("Found configfile:"+configFile)
30
+ loadscript(configFile)
31
+ else
32
+ print("Could NOT find configfile:"+configFile)
33
+ exit()
34
+ end if
35
+ else
36
+ ; --- Use the default config file
37
+ CONFIGFILE = getenv("HOME")+"/.icon_plot.rc"
38
+ if (isfilepresent(CONFIGFILE)) then
39
+ print("Found configfile:"+CONFIGFILE)
40
+ loadscript(CONFIGFILE)
41
+ end if
42
+ end if
18
43
  end if
19
-
44
+ ;--- end config ---------------------------------------------------------------
45
+ ;--- default lib location ----------------------------------------------------
20
46
  if ( .not. isvar("altLibDir") ) then
21
47
  print("load default library from /pool/data/ICON/tools")
22
48
  loadscript("/pool/data/ICON/tools/icon_plot_lib.ncl")
23
49
  else
24
- print("Load library: "+altLibDir+"/icon_plot_lib.ncl")
25
- loadscript(altLibDir +"/icon_plot_lib.ncl")
50
+ if ( .not. libLoaded ) then
51
+ ;--- lib location from the config file ----------------------------------------
52
+ print("Load library: "+altLibDir+"/icon_plot_lib.ncl")
53
+ loadscript(altLibDir +"/icon_plot_lib.ncl")
54
+ end if
26
55
  end if
27
- ;--- end config ---------------------------------------------------------------
56
+ ;------------------------------------------------------------------------------
28
57
  ;==============================================================================
58
+ VERSION = "0.0.6"
29
59
  ;----- MAIN PROGRAM -----------------------------------------------------------
30
60
  if (isvar("help")) then
31
61
  dq = str_get_dq()
@@ -84,23 +114,28 @@
84
114
  print("; use -180 to 180 for longitude !")
85
115
  print("; secLC, secRC : start and and point of a vertical section (no default value)")
86
116
  print("; section is plotted it secLC and secRC are present")
117
+ print("; secMode : perform transection along a great crice or on a straight line")
118
+ print("; possible values: circle, straight (default)")
119
+ print("; : ATTENTION: using 'circle' for sections with a small angle wrt the equator is NOT RECOMMENDED")
87
120
  print("; showSecMap : display the location of the vertical section in an additional map (default:true)")
88
121
  print("; centerLon : center longitute for satelite view (default:30.)")
89
122
  print("; centerLat : center latitude for satelite view (default:20.)")
90
123
  print("; satDist : satelite distance (default:20.0)")
91
124
  print("; scaleFactor : optional scale factor")
125
+ print("; fillMode : how to color contour plots,i.e. sets cnFillMode: CellFill or RasterFill (default:RasterFill)")
92
126
  print("; selMode : mode for level spacing of the plot:")
93
127
  print("; halflog (uses half logarythmic levels,i.e. 1,2,5 per decade), ")
94
128
  print("; manual (automatic linear spacing with usage of minVar and maxVar)")
95
129
  print("; auto (default: let do ncl the spacing)")
96
130
  print("; scaleLimit : Limits the number of decades for levels in selMode-halflog")
97
- print("; minVar/maxVar : min/maximal Value to plot for selMode=manual or halflog")
131
+ print("; minVar/maxVar : min/maximal Value to plot for selMode = 'manual' or 'halflog'")
98
132
  print("; numLevs : set a number of labels for manual selMode only. NumCol=numLevs+2")
99
133
  print("; (Not set directly, but used for computing the contour level spacing. default=10)")
100
- print("; contLevs : set individual contour levels (not yet)")
134
+ print("; plotLevs : set individual contour levels, selMode is set to 'manual' automatically")
101
135
  print("; mapType : projection type (default: lonlat), other: ortho (not compatible with showGrid), NHps")
102
136
  print("; and SHps (polar stereographic projections centered at the north and south pole respectively),")
103
137
  print("; sat (satelite view, use option centerLat, centerLon and satDist)")
138
+ print("; hov : plot hovmoeller diagram, expects variable with two 'active' dimensions, i.e. var(:,:,0,0)")
104
139
  print("; mapLine : (logical) draws continent lines on the plot (foreground/transparent)")
105
140
  print("; maskName : variable to mask with. maskName is expected NOT to have time dimension")
106
141
  print("; 'maskName=" + dq + "none" + dq + "' is same as default (no mask variable)")
@@ -114,7 +149,10 @@
114
149
  print("; bStrg : base string - default is prgr name and time stamp only")
115
150
  print("; maxView : (logical) maximize plot area on paper (not for buildbot -> convert to png)")
116
151
  print("; colormap : string for predefined colormaps of the plot (e.g. 'colormap=" + dq + "BlAqGrYeOrReVi200" + dq + "')")
152
+ print("; withLines : draw lines between each contour color (default:True)")
153
+ print("; withLineLabels: label the countour lines with theri values (auto-enable withLines, default:False)")
117
154
  print("; showGrid : display polygon lines with filled colors instead of contour plot")
155
+ print("; markCells : mark cell centers with dots")
118
156
  print("; showNcd : display NDC Grid to find Normalized Device Coordinates on the plot")
119
157
  print("; k2c : if True, perform Kelvin2Celsius shift (default:True)")
120
158
  print(";")
@@ -122,11 +160,14 @@
122
160
  print("; atmLev : chooses vertical plot levels for atmosphere input (h: height,p:pressure,m:modellevel,default:p)")
123
161
  print(";---------------------------------------------------------------")
124
162
  print("; altLibDir : Alternative directory for loading icon_plot_lib.ncl")
163
+ print("; noConfig : subpress reading of any config file, i.e. use commandline options only (default:False)")
164
+ print("; Use +noConfig or -noConfig=True")
125
165
  print("; cdo : Path to an alternative cdo version")
126
166
  print(";---------------------------------------------------------------")
127
167
  print("; Authors : Ralf Mueller (ralf.mueller@zmaw.de)")
128
168
  print("; Stephan Lorenz (stephan.lorenz@zmaw.de)")
129
- print("; VERSION : r8012 (2012-01-26)")
169
+ print("; Einar Olason (einar.olason@zmaw.de)")
170
+ print("; VERSION : " + VERSION +" (2012-08-13)")
130
171
  print(";---------------------------------------------------------------")
131
172
  exit()
132
173
  end if
@@ -157,29 +198,34 @@
157
198
  end if
158
199
  print("Outputfile '"+str_concat((/oFile,".",oType/))+"' will be created in "+systemfunc("dirname "+iFile))
159
200
 
160
- if(.not. isvar("numLevs")) then
161
- numLevs = NUMLEVS
201
+ if (.not. isvar("DEBUG")) DEBUG = False end if
202
+ if (.not. isvar("showGrid")) showGrid = False end if
203
+ if (.not. isvar("markCells")) markCells = False end if
204
+ if (.not. isvar("showNdc")) showNdc = False end if
205
+ if (.not. isvar("maxView")) maxView = False end if
206
+ if (.not. isvar("scaleLimit")) scaleLimit = 2 end if
207
+ if (.not. isvar("selMode")) selMode = "auto" end if
208
+ if (.not. isvar("plotMode")) plotMode = "scalar" end if
209
+ if (.not. isvar("timeStep")) then
210
+ timeStep = 0
162
211
  else
163
- if (numLevs .lt. 1) then
164
- print("WARNING: numLevs must be >= 1")
165
- print(ABORTMSG)
166
- exit
167
- end if
212
+ t = floattointeger(timeStep)
213
+ delete(timeStep)
214
+ timeStep = t
168
215
  end if
169
-
170
- if (.not. isvar("DEBUG")) DEBUG = False end if
171
- if (.not. isvar("showGrid")) showGrid = False end if
172
- if (.not. isvar("showNdc")) showNdc = False end if
173
- if (.not. isvar("maxView")) maxView = False end if
174
- if (.not. isvar("scaleLimit")) scaleLimit = 2 end if
175
- if (.not. isvar("selMode")) selMode = "auto" end if
176
- if (.not. isvar("plotMode")) plotMode = "scalar" end if
177
- if (.not. isvar("timeStep")) timeStep = 0 end if
178
- if (.not. isvar("levIndex")) levIndex = 0 end if
179
- if (.not. isvar("scaleFactor")) scaleFactor = 1 end if
180
- if (.not. isvar("colormap")) colormap = "BlueDarkRed18" end if
181
- if (.not. isvar("k2c")) k2c = True end if
182
- if (.not. isvar("isIcon")) isIcon = False end if
216
+ if (.not. isvar("levIndex")) levIndex = 0 end if
217
+ if (.not. isvar("scaleFactor")) scaleFactor = 1 end if
218
+ if (.not. isvar("fillMode")) fillMode = "RasterFill" end if
219
+ if (.not. isvar("colormap")) then
220
+ colormap = DEFAULTCOLOR
221
+ userColors = False
222
+ else
223
+ userColors = True
224
+ end if
225
+ if (.not. isvar("withLines")) withLines = True end if
226
+ if (.not. isvar("withLineLabels")) withLineLabels = False end if
227
+ if (.not. isvar("k2c")) k2c = True end if
228
+ if (.not. isvar("isIcon")) isIcon = False end if
183
229
 
184
230
  if (.not.isvar("mapType")) mapType = "lonlat" end if
185
231
  if ( mapType .eq. "NHps" .and. .not.isvar("mapLLC")) mapLLC = (/-45., 45./) end if
@@ -198,14 +244,15 @@
198
244
  if (.not.isvar("vecColByLen")) vecColByLen = False end if
199
245
  if (.not.isvar("vecMinDist")) vecMinDist = 0.017 end if
200
246
  if (.not.isvar("streamLine")) streamLine = False end if
201
- if (.not.isvar("secPoints")) secPoints = 20 end if
202
- ; default + optional coordinates
203
- if (.not.isvar("lonCo")) lonCo = DEFAULTLON end if
204
- if (.not.isvar("latCo")) latCo = DEFAULTLAT end if
205
-
206
- if (.not.isvar("showSecMap")) showSecMap = True end if
207
- ; ATMOSPEHRE SETUP ----------------------------------------------------------
208
- if (.not.isvar("atmLev")) atmLev = "p" end if
247
+ if (.not.isvar("secPoints")) secPoints = 161 end if
248
+ ; default + optional coordinates
249
+ if (.not.isvar("lonCo")) lonCo = DEFAULTLON end if
250
+ if (.not.isvar("latCo")) latCo = DEFAULTLAT end if
251
+
252
+ if (.not.isvar("secMode")) secMode = "straight" end if
253
+ if (.not.isvar("showSecMap")) showSecMap = True end if
254
+ ; ATMOSPEHRE SETUP ----------------------------------------------------------
255
+ if (.not.isvar("atmLev")) atmLev = "p" end if
209
256
  if (.not.isvar("atmPLevs")) then
210
257
  atmPLevSetup = (/10000,100000,2500/); unit: Pa
211
258
  atmPLevs = ispan(atmPLevSetup(0),atmPLevSetup(1),atmPLevSetup(2))*1.0
@@ -280,6 +327,28 @@
280
327
  horizonalGridType = getHorizGridType(iFile,ivarname,isIcon)
281
328
  ;----------------------------------------------------------------------------
282
329
 
330
+ ; DETERMINE selMode automatically -------------------------------------------
331
+ if (isvar("minVar") .and. isvar("maxVar")) then
332
+ if (selMode .eq. "auto") then
333
+ selMode = "manual"
334
+ end if
335
+ end if
336
+ if (isvar("plotLevs") ) then
337
+ if (selMode .eq. "auto") then
338
+ selMode = "manual"
339
+ end if
340
+ end if
341
+ if(.not. isvar("numLevs")) then
342
+ numLevs = NUMLEVS
343
+ else
344
+ if (numLevs .lt. 1) then
345
+ print("WARNING: numLevs must be >= 1")
346
+ print(ABORTMSG)
347
+ exit
348
+ end if
349
+ end if
350
+ ;----------------------------------------------------------------------------
351
+
283
352
  ; DETERMINE THE PLOTMODE ----------------------------------------------------
284
353
  if (isvar("vecVars")) then
285
354
  ; expectes is a string or an array of size 2: "u-veloc v-veloc" or (/"u-veloc","v-veloc"/)
@@ -310,16 +379,16 @@
310
379
  exit
311
380
  end if
312
381
  if (isvar("secLC").and.isvar("secRC")) plotMode = "section" end if
313
- if (isvar("hoff")) plotMode = "hoffmueller" end if
382
+ if (isvar("hov")) plotMode = "hovmoeller" end if
314
383
 
315
- if (plotMode.eq."vector" .or. plotMode.eq."overlay" .or. plotMode.eq."section" .or. plotMode .eq. "hoffmueller") then
384
+ if (plotMode.eq."vector" .or. plotMode.eq."overlay" .or. plotMode.eq."section") then
316
385
  if (horizonalGridType .ne. "unstructured") then ; regular grid expected, i.e. remappgin is NOT required
317
386
  rFile = addfile(iFile+".nc","r")
318
387
  else
319
388
  ; performe some remapping to a regular grid because ncl cannot draw vector
320
389
  ; from unstructured grids
321
390
  ; TODO addVars=(/ "PS","PHIS"/)
322
- remapFilename = setRemapFilename(iFile,iType,atmLev)
391
+ remapFilename = setRemapFilename(iFile,iType,resolution,atmLev)
323
392
  print("remapFilename:"+remapFilename)
324
393
  if (.not. checkRemappedFile(iFile,remapFilename,ivarname,iType,atmLev,atmPLevs,atmHLevs) ) then
325
394
  addVars=(/""/)
@@ -328,10 +397,10 @@
328
397
  end if
329
398
  rFile = addfile( remapFilename+".nc", "r" )
330
399
  end if
331
- if (plotMode .eq. "hoffmueller") then ; perform zonmean
332
- zonmeanFilename = setZonmeanFilename(remapFilename,ivarname,atmLev)
333
- zonmean4HoffmuellerPlot(remapFilename,ivarname,zonmeanFilename)
334
- end if
400
+ ;if (plotMode .eq. "hoffmueller") then ; perform zonmean
401
+ ; zonmeanFilename = setZonmeanFilename(remapFilename,ivarname,atmLev)
402
+ ; zonmean4HoffmuellerPlot(remapFilename,ivarname,zonmeanFilename)
403
+ ;end if
335
404
  end if
336
405
  File = addfile( iFile+".nc", "r" )
337
406
 
@@ -369,7 +438,7 @@
369
438
  print("Graphics format is " +oType)
370
439
  print("plotMode = "+plotMode)
371
440
 
372
- if (plotMode.eq."scalar" .or. plotMode.eq."section") then
441
+ if (plotMode.eq."scalar" .or. plotMode.eq."section" .or. plotMode.eq."hovmoeller") then
373
442
  print("varName = "+varName)
374
443
  else
375
444
  print("vecVars = "+vecVars)
@@ -416,12 +485,6 @@
416
485
 
417
486
  scaleVar(var,scaleFactor)
418
487
 
419
- ; set selMode automatically
420
- if (isvar("minVar") .and. isvar("maxVar")) then
421
- if (selMode .eq. "auto") then
422
- selMode = "manual"
423
- end if
424
- end if
425
488
  ; set minVar_maxVar for plotting
426
489
  if(.not. isvar("minVar")) minVar = min(var) end if
427
490
  if(.not. isvar("maxVar")) maxVar = max(var) end if
@@ -435,6 +498,11 @@
435
498
  ;var = mask ( var, slm, 0.5)
436
499
  end if
437
500
  end if
501
+ if (plotMode.eq."hovmoeller") then
502
+ var = selRegularVar(varName,File,-1)
503
+ if(.not. isvar("minVar")) minVar = min(var) end if
504
+ if(.not. isvar("maxVar")) maxVar = max(var) end if
505
+ end if
438
506
  if (plotMode.eq."vector" .or. plotMode.eq."overlay") then; vector mode =======
439
507
  uvarname = vecVars(0)
440
508
  vvarname = vecVars(1)
@@ -488,11 +556,6 @@
488
556
  var = mask(var,maskVar,1)
489
557
  end if
490
558
  end if ; Reading data variables =============================================
491
- if (plotMode .eq. "hoffmueller") then ; create hoffmuelle diagram
492
- ; select the whole time series
493
- ; and plot it with
494
- ; plot = gsn_csm_lat_time(wks, shov(0,{-80:80},:), res)
495
- end if
496
559
  if (iType .eq. "atm" .and. ivarname .eq. "T" .and. k2c) var = var - 273.15 end if ;atmosphere used to write out Kelvin
497
560
 
498
561
  ;---------------------------------------------------------------
@@ -507,20 +570,18 @@
507
570
  drawNDCGrid(wks)
508
571
  end if
509
572
 
510
- ResC = True
573
+ ResC = setDefaultResource(True,withLines,withLineLabels,fillMode)
511
574
 
512
- setDefaultResource(ResC,True)
575
+ if (.not. userColors) setDefaultColors(ResC,minVar,maxVar,DEBUG) end if
513
576
 
514
577
  if (maxView) ResC@gsnMaximize = True end if
515
578
 
516
579
  if (useMask) setMaskColor(wks,ResC) end if
517
580
 
518
581
 
519
-
520
582
  if (getHorizGridType(iFile,ivarname,isIcon) .eq. "unstructured") then
521
583
  if (plotMode.eq."scalar" .or. plotMode.eq."overlay")
522
584
  setCoordinates(ResC,x,y)
523
- ;setBounds(ResC,File,x,y,DEBUG)
524
585
  end if
525
586
  end if
526
587
 
@@ -535,7 +596,7 @@
535
596
  print("Cannot plot vertical section of a 2D variable: "+varName)
536
597
  exit
537
598
  end if
538
- trans = setSection(secLC,secRC,secPoints,var)
599
+ trans = setSection(secLC,secRC,secPoints,var,secMode)
539
600
  vertdim = getVertDim(File,var)
540
601
  trans!0 = vertdim
541
602
  trans&$vertdim$ = var&$vertdim$
@@ -564,7 +625,11 @@
564
625
  else
565
626
  setDefaultVectorPlot(ResC,5.0,vecRefLength,"CurlyVector",vecMinDist)
566
627
 
567
- vc = plotVecOrStream(vecColByLen,streamLine,uvar,vvar,velocity,ResC,wks,True)
628
+ vc = plotVecOrStream(vecColByLen,streamLine,\
629
+ uvar,vvar, \
630
+ sqrt(uvar*uvar + vvar*vvar), \
631
+ ResC,wks,True)
632
+ draw(vc)
568
633
  end if
569
634
  end if
570
635
  if (plotMode.eq."overlay") then
@@ -577,7 +642,7 @@
577
642
 
578
643
  ResC@gsnDraw = False
579
644
  ResC@gsnFrame = False
580
- vc = plotVecOrStream(vecColByLen,streamLine,uvar,vvar,velocity,ResC2,wks,False)
645
+ vc = plotVecOrStream(vecColByLen,streamLine,uvar,vvar,var,ResC2,wks,False)
581
646
 
582
647
  plot = gsn_csm_contour_map(wks,var,ResC)
583
648
  if (showGrid) then
@@ -600,10 +665,19 @@
600
665
  end if
601
666
  plotGrid(wks,plot,var,x,bounds,File,ResC,DEBUG)
602
667
  end if
668
+ if ( markCells ) then
669
+ plotCellMarkers(x,y,wks,plot,True)
670
+ end if
603
671
  end if
604
672
  if (plotMode.eq."scatter") then
605
673
  plot = gsn_csm_xy(wks,xvar,yvar,ResC)
606
674
  end if
675
+ if (plotMode .eq. "hovmoeller") then ; create hoffmuelle diagram
676
+ ; select the whole time series
677
+ ; and plot it with
678
+ ResC@trYReverse = True
679
+ plot = gsn_csm_hov(wks, var(depth|:,time|:,lat|0,lon|0), ResC)
680
+ end if
607
681
  if (plotMode.eq."section") then
608
682
 
609
683
  if (showSecMap) then
@@ -627,20 +701,33 @@
627
701
 
628
702
  if (showSecMap) then
629
703
  ; map with section polygon
630
- mres = True
631
- mres@gsnFrame = False; don't turn page yet
632
- mres@gsnDraw = False; don't draw yet
633
- mres@vpWidthF = 0.8; set width of plot
634
- mres@vpHeightF = 0.3; set height of plot
635
- mres@vpXF = 0.1
636
- mres@vpYF = 0.4
637
- plot(1) = gsn_csm_map_ce(wks,mres)
704
+ mres = True
705
+ mres@gsnFrame = False; don't turn page yet
706
+ mres@gsnDraw = False; don't draw yet
707
+ mres@vpWidthF = 0.8; set width of plot
708
+ mres@vpHeightF = 0.3; set height of plot
709
+ mres@vpXF = 0.1
710
+ mres@vpYF = 0.4
711
+
712
+ newcolor = NhlNewColor(wks,0.85,0.85,0.85); add gray to colormap
713
+ mres@mpOutlineOn = True; (turn off continental outlines)
714
+ mres@mpFillOn = False; (turn on map fill)
715
+ mres@mpFillColors = (/"background","transparent","LightGray","transparent"/); (fill land in gray and ocean in transparent)
716
+ mres@mpGrid = False
717
+
718
+ ; plot(1) = gsn_map(wks,"CylindricalEquidistant",mres)
719
+ plot(1) = gsn_csm_map(wks,mres)
638
720
  pres = True; polyline mods desired
639
721
  pres@gsnFrame = False; don't turn page yet
640
722
  pres@gsnDraw = False; don't draw yet
641
723
  pres@gsLineColor = "black"; color of lines
642
724
  pres@gsLineThicknessF = 2.0; line thickness
643
- dummy = gsn_add_polyline(wks,plot(1),(/ secLC(0),secRC(0) /),(/ secLC(1),secRC(1) /),pres)
725
+ pathRes = getSectionPathForMap(secLC,secRC,secPoints,secMode)
726
+ if (DEBUG) then
727
+ print("PATHRES lon - lat")
728
+ print(pathRes@lon + " " + pathRes@lat)
729
+ end if
730
+ pathLine = gsn_add_polyline(wks,plot(1),pathRes@lon, pathRes@lat,pres)
644
731
 
645
732
  draw(plot(1))
646
733
  end if
@@ -16,14 +16,18 @@
16
16
  ;---------------------------------------------------------------
17
17
  ; Authors : Ralf Mueller (ralf.mueller@zmaw.de)
18
18
  ; Stephan Lorenz (stephan.lorenz@zmaw.de)
19
+ ; VERSION = "0.0.6"
19
20
  ;-------------------------------------------------------------------------------
20
21
  ; some global defaults
21
- DEFAULTLON = "clon"
22
- DEFAULTLAT = "clat"
23
- RAD2DEG = 45./atan(1.)
24
- ABORTMSG = "Abort Script."
25
- NUMLEVS = 10
26
- CDO = "cdo"
22
+ DEFAULTLON = "clon"
23
+ DEFAULTLAT = "clat"
24
+ RAD2DEG = 45./atan(1.)
25
+ ABORTMSG = "Abort Script."
26
+ NUMLEVS = 10
27
+ CDO = "cdo"
28
+ ; DEFAULTCOLOR = "BlWhRe" ; ncolors = 103
29
+ DEFAULTCOLOR = "BlueDarkRed18" ; ncolors = 256
30
+ DEFAULTCOLOR = "BlueWhiteOrangeRed" ; ncolors = 256
27
31
  ;-------------------------------------------------------------------------------
28
32
  procedure setCDO(path)
29
33
  begin
@@ -233,17 +237,19 @@ end
233
237
  undef("selRegularVar")
234
238
  function selRegularVar(varname,filehandle,timestep)
235
239
  begin
236
- dims = getfilevardims(filehandle,varname)
237
- noOfDims = dimsizes(dims)
238
- noOfDims = noOfDims(0)
239
- usableVar = False
240
- if ( has_time(dims) ) then
240
+ dims = getfilevardims(filehandle,varname)
241
+ noOfDims = dimsizes(dims)
242
+ noOfDims = noOfDims(0)
243
+ print(""+noOfDims)
244
+ usableVar = False
245
+ if ( has_time(dims) ) then
246
+ if (timestep.eq.-1) then
241
247
  if (noOfDims .eq. 4) then ; dims: (time,lev,x,y)
242
- var = filehandle->$varname$(timestep,:,:,:)
248
+ var = filehandle->$varname$
243
249
  usableVar = True
244
250
  end if
245
251
  if (noOfDims .eq. 3) then ; dims: (time,x,y)
246
- var = filehandle->$varname$(timestep,:,:)
252
+ var = filehandle->$varname$(:,:,:)
247
253
  usableVar = True
248
254
  end if
249
255
  if (noOfDims .eq. 2) then ; dims: (x,y)
@@ -255,24 +261,42 @@ begin
255
261
  usableVar = False
256
262
  end if
257
263
  else
258
- if (noOfDims .eq. 3) then ; dims: (lev,x,y)
259
- var = filehandle->$varname$(:,:,:)
264
+ if (noOfDims .eq. 4) then ; dims: (time,lev,x,y)
265
+ var = filehandle->$varname$(timestep,:,:,:)
266
+ usableVar = True
267
+ end if
268
+ if (noOfDims .eq. 3) then ; dims: (time,x,y)
269
+ var = filehandle->$varname$(timestep,:,:)
260
270
  usableVar = True
261
271
  end if
262
272
  if (noOfDims .eq. 2) then ; dims: (x,y)
263
273
  var = filehandle->$varname$(:,:)
264
274
  usableVar = True
265
275
  end if
266
- if (noOfDims .eq. 1) then ; dims: (x)
276
+ if (noOfDims .eq. 1) then ; dims: (time)
267
277
  var = filehandle->$varname$(:)
268
- usableVar = True
278
+ usableVar = False
269
279
  end if
270
280
  end if
271
- if (.not. usableVar) then
272
- print("Warning! Could not read " + varname + " from input file")
273
- exit
281
+ else
282
+ if (noOfDims .eq. 3) then ; dims: (lev,x,y)
283
+ var = filehandle->$varname$(:,:,:)
284
+ usableVar = True
274
285
  end if
275
- return var
286
+ if (noOfDims .eq. 2) then ; dims: (x,y)
287
+ var = filehandle->$varname$(:,:)
288
+ usableVar = True
289
+ end if
290
+ if (noOfDims .eq. 1) then ; dims: (x)
291
+ var = filehandle->$varname$(:)
292
+ usableVar = True
293
+ end if
294
+ end if
295
+ if (.not. usableVar) then
296
+ print("Warning! Could not read " + varname + " from lonlat input file")
297
+ exit
298
+ end if
299
+ return var
276
300
  end
277
301
  ;-------------------------------------------------------------------------------
278
302
  ; abstract Field selection
@@ -566,9 +590,9 @@ end
566
590
  ;---------------------------------------------------------------
567
591
  ; set filename for the automatically remapped file
568
592
  undef("setRemapFilename")
569
- function setRemapFilename(filename,itype,atmlev)
593
+ function setRemapFilename(filename,itype,resolution,atmlev)
570
594
  begin
571
- return setNewFilename(filename,"remapnn",itype,atmlev)
595
+ return setNewFilename(filename,"remapnn_"+resolution,itype,atmlev)
572
596
  end
573
597
  undef("setZonmeanFilename")
574
598
  function setZonmeanFilename(filename,itype,atmlev)
@@ -778,17 +802,24 @@ undef("setLevels")
778
802
  procedure setLevels(selmode,resource,minvar,maxvar,scalelimit,numlevs,debug)
779
803
  begin
780
804
  if (selmode .eq. "manual") then
781
- resource@cnLevelSelectionMode = "ManualLevels"
782
- resource@cnMinLevelValF = minvar
783
- resource@cnMaxLevelValF = maxvar
784
- ; diffLog10 = log10(abs(maxVar-minVar))
785
- ;; if (diffLog10 .lt. 0) then
786
- ; resource@cnLevelSpacingF = 10^(floor(diffLog10))/numLevs
787
- ;; else
788
- ;; resource@cnLevelSpacingF = 10^(floor(diffLog10))/numLevs
789
- ;; end if
790
- diffspacing = abs(maxvar-minvar)/(int2flt(numlevs))
791
- resource@cnLevelSpacingF = diffspacing
805
+ if ( .not. isvar("plotLevs") ) then
806
+ resource@cnLevelSelectionMode = "ManualLevels"
807
+ resource@cnMinLevelValF = minvar
808
+ resource@cnMaxLevelValF = maxvar
809
+ ; diffLog10 = log10(abs(maxVar-minVar))
810
+ ;; if (diffLog10 .lt. 0) then
811
+ ; resource@cnLevelSpacingF = 10^(floor(diffLog10))/numLevs
812
+ ;; else
813
+ ;; resource@cnLevelSpacingF = 10^(floor(diffLog10))/numLevs
814
+ ;; end if
815
+ diffspacing = abs(maxvar-minvar)/(int2flt(numlevs))
816
+ resource@cnLevelSpacingF = diffspacing
817
+ else
818
+ resource@cnLevelSelectionMode = "ExplicitLevels"
819
+ plotLevels = plotLevs
820
+ if (debug) print("plotlevels = "+plotLevels) end if
821
+ resource@cnLevels = plotLevels
822
+ end if
792
823
  end if
793
824
 
794
825
  if (selmode .eq. "halflog") then
@@ -810,17 +841,39 @@ end
810
841
  ;---------------------------------------------------------------
811
842
  ; Create a default NCL resource
812
843
  undef("setDefaultResource")
813
- procedure setDefaultResource(resource,verticallabelbar)
814
- begin
815
- resource@gsnMaximize = False
816
- ; resource@gsnPaperOrientation = "landscape" ; turns plot on paper
817
- ; resource@wkPaperSize = "A4"
818
- resource@gsnFrame = False
819
- resource@gsnSpreadColors = True
844
+ function setDefaultResource(verticallabelbar,withLines,withLineLabels,fillmode)
845
+ begin
846
+ resource = True
847
+ resource@gsnMaximize = False
848
+ resource@gsnFrame = False
849
+ resource@gsnDraw = True
850
+ resource@gsnSpreadColors = True
851
+ resource@cnFillOn = True
852
+
853
+ ; lines/labels inside the plot ================================================
854
+ if (withLines) then
855
+ resource@cnLinesOn = True
856
+ else
857
+ resource@cnLinesOn = False
858
+ end if
859
+ resource@cnLineLabelsOn = False
860
+ if (withLineLabels ) then
861
+ withLines = True
862
+ resource@cnLineLabelsOn = True
863
+ resource@cnLineLabelFontHeightF = 0.008
864
+ resource@cnLineLabelFontThicknessF = 0.006
865
+ end if
866
+ if (withLines) resource@cnLinesOn = True end if
820
867
 
821
- resource@cnFillOn = True ; writes labelbar, no contour labels
822
- resource@cnLinesOn = False
823
- resource@cnInfoLabelOn = False
868
+ ; representation of missing values ===========================================
869
+ delete(resource@cnMissingValFillPattern); no longer filling missing value areas
870
+ delete(resource@cnMissingValFillColor); no longer filling missing value areas
871
+ resource@cnMissingValPerimOn = True
872
+ resource@cnMissingValFillPattern = -1; set the missing value fill pattern to 5
873
+ resource@cnMissingValFillScaleF = 0.9; increase the density of the fill pattern (default = 1.0)
874
+ resource@cnMissingValPerimColor = "black"; change the missing value perimeter to black
875
+ resource@cnMissingValPerimDashPattern = 1; set the dash pattern of the missing value perimeter to 1
876
+ resource@cnMissingValPerimThicknessF = 1.0; increase the thickness of the missing value perimeter 3X
824
877
 
825
878
  FontHeight0 = 0.012
826
879
  FontHeight1 = 0.015
@@ -835,8 +888,7 @@ begin
835
888
  resource@gsnStringFontHeightF = FontHeight0
836
889
 
837
890
  resource@mpFillOn = True
838
- resource@cnFillOn = True
839
-
891
+ ; label settings ==============================================================
840
892
  resource@lbLabelBarOn = True
841
893
  if (verticallabelbar .eq. True) then
842
894
  resource@lbOrientation = "vertical"
@@ -848,11 +900,12 @@ begin
848
900
  resource@lbLabelAutoStride = True
849
901
  resource@lbLabelFontHeightF = FontHeight1 ; color bar labels
850
902
 
851
- resource@cnFillMode = "RasterFill"
852
- ;resource@cnFillMode = "CellFill"
903
+ resource@cnFillMode = fillmode
853
904
  resource@cnRasterSmoothingOn = True
854
905
  resource@mpGreatCircleLinesOn = True
855
906
  resource@stMinArrowSpacingF = 0.001
907
+
908
+ return resource
856
909
  end
857
910
  ;---------------------------------------------------------------
858
911
  undef("setDefaultSectionResource")
@@ -862,20 +915,32 @@ begin
862
915
  resource@gsnFrame = False; don't turn page yet
863
916
  resource@gsnDraw = False; don't draw yet
864
917
  resource@tmXBMode = "Explicit"; explicitly label x-axis
918
+ latDiff = stringtodouble(secrc(1)) - stringtodouble(seclc(1))
919
+ tic = latDiff/(stringtodouble(secpoints)-1)
920
+ p = (points * tic) + stringtodouble(seclc(1))
921
+ ; resource@tmXBValues = points
865
922
  resource@tmXBValues = (/points(0),points(secpoints-1)/); points to label values
923
+ labels = new(dimsizes(p),string)
924
+ labels = p
925
+ ;print(""+labels)
926
+ ;resource@tmXBLabels = labels
866
927
  resource@tmXBLabels = (/ seclc(1) +"N, "+ seclc(0)+"E" , secrc(1)+"N, "+secrc(0)+"E" /)
867
928
 
929
+ resource@tmXBLabelFontHeightF = 0.01
868
930
  resource@cnFillOn = True; turn on color
869
931
  resource@lbLabelAutoStride = True; nice label bar label stride
870
932
  resource@gsnSpreadColors = True; use full range of colormap
871
933
  resource@cnLinesOn = False; turn off countour lines
934
+ ; if (useContourLines)
935
+ resource@cnLinesOn = False
936
+ resource@cnLineLabelsOn = False
872
937
  resource@lbOrientation = "vertical"; vertical label bar
873
938
  resource@pmLabelBarOrthogonalPosF = -0.05; move label bar closer to plot
874
939
  resource@lbTitlePosition = "Bottom"
875
940
  ; resource@gsnYAxisIrregular2Log = True
876
941
 
877
- delete(resource@cnMissingValFillPattern); no longer filling missing value areas
878
- delete(resource@cnMissingValFillColor); no longer filling missing value areas
942
+ ; delete(resource@cnMissingValFillPattern); no longer filling missing value areas
943
+ ; delete(resource@cnMissingValFillColor); no longer filling missing value areas
879
944
  resource@cnMissingValFillColor = "gray30"
880
945
  resource@cnMissingValPerimOn = True
881
946
 
@@ -886,8 +951,11 @@ begin
886
951
  resource@cnMissingValPerimDashPattern = 1; set the dash pattern of the missing value perimeter to 1
887
952
  resource@cnMissingValPerimThicknessF = 3.0; increase the thickness of the missing value perimeter 3X
888
953
  ;resource@gsnYAxisIrregular2Log = True
954
+ resource@cnFillMode = "RasterFill"
955
+ resource@cnRasterSmoothingOn = False
889
956
  return resource
890
957
  end
958
+ ;---------------------------------------------------------------
891
959
  undef("setDefaultOverlayResource")
892
960
  procedure setDefaultOverlayResource(resource)
893
961
  begin
@@ -905,6 +973,30 @@ begin
905
973
  resource@lbLabelBarOn = False; switch of the vector label bar, because the speed is show as vector lenghts
906
974
  end
907
975
  ;---------------------------------------------------------------
976
+ undef("setDefaultColors")
977
+ procedure setDefaultColors(resource,minval,maxval,debug)
978
+ begin
979
+ ; white is color 135
980
+ if ((minval*maxval) .LT. 0.0) then ; data goes fro positiv to negative or vs.
981
+ if (abs(maxval) .GT. abs(minval)) then
982
+ resource@gsnSpreadColorStart = 135 - toint(126*(abs(minval)/abs(maxval)))
983
+ resource@gsnSpreadColorEnd = 255
984
+ else
985
+ resource@gsnSpreadColorStart = 2
986
+ resource@gsnSpreadColorEnd = 135 + toint(126*(abs(maxval)/abs(minval)))
987
+ end if
988
+ resource@gsnContourZeroLineThicknessF = 2.0
989
+ if (debug) then
990
+ print("===================== COMPUTE the COLORS to make zero WHITE:")
991
+ print("minval: "+minval)
992
+ print("maxval: "+maxval)
993
+ print("100*(toint(abs(minval)/abs(maxval))): "+toint(100*(abs(minval)/abs(maxval))))
994
+ print("resource@gsnSpreadColorStart:" + resource@gsnSpreadColorStart)
995
+ print("resource@gsnSpreadColorEnd :" + resource@gsnSpreadColorEnd)
996
+ end if
997
+ end if
998
+ end
999
+ ;---------------------------------------------------------------
908
1000
  undef("shift4SecMap")
909
1001
  procedure shift4SecMap(resource)
910
1002
  begin
@@ -1031,6 +1123,7 @@ begin
1031
1123
  else
1032
1124
  resource@lbTitleString = ""
1033
1125
  end if
1126
+ resource@tiMainFontHeightF = 0.02
1034
1127
  if (itype .eq. "atm" .and. varname .eq. "T" .and. k2c) resource@lbTitleString = "C" end if
1035
1128
 
1036
1129
  resource@lbTitlePosition = "Bottom"
@@ -1038,6 +1131,8 @@ begin
1038
1131
  resource@lbTitleFontHeightF = 0.02
1039
1132
  resource@lbLabelFontHeightF = 0.015
1040
1133
  resource@lbLeftMarginF = 0.01
1134
+ resource@cnLabelMasking = True
1135
+ resource@cnLabelMasking = True
1041
1136
  end
1042
1137
  ;---------------------------------------------------------------
1043
1138
  ; vertical axes label for section plot
@@ -1183,10 +1278,9 @@ end
1183
1278
  undef("setMaskColor")
1184
1279
  procedure setMaskColor(wks,resource)
1185
1280
  begin
1186
- newcolor = NhlNewColor(wks,0.85,0.85,0.85) ; add gray to colormap
1187
- ;resource@gsnSpreadColorStart = 1
1188
- resource@gsnSpreadColorEnd = 19 ; last color number not known?
1189
- resource@cnMissingValFillColor = 20 ; last color is used for missing values
1281
+ resource@cnMissingValFillColor = "gray90"
1282
+ resource@cnMissingValPerimOn = True; turn on missing value outlines
1283
+ resource@cnMissingValPerimThicknessF = 2.5; set the missing value outline thickness
1190
1284
  end
1191
1285
  ;---------------------------------------------------------------
1192
1286
  ; set the coordinates for an ICON data field
@@ -1298,31 +1392,92 @@ begin
1298
1392
  return gridtype
1299
1393
  end
1300
1394
  ;---------------------------------------------------------------
1395
+ ; compute the straight line between two corners
1396
+ undef("getStraightPath")
1397
+ function getStraightPath(startCorner,endCorner,npoints)
1398
+ begin
1399
+ startLat = tofloat(startCorner(1))
1400
+ endLat = tofloat(endCorner(1))
1401
+ startLon = tofloat(startCorner(0))
1402
+ endLon = tofloat(endCorner(0))
1403
+
1404
+ if (startLon .lt. 0.0) then
1405
+ startLon = startLon + 360.0
1406
+ endLon = endLon + 360.0
1407
+ end if
1408
+
1409
+ lats = fspan(startLat,endLat,npoints)
1410
+ lons = fspan(startLon,endLon,npoints)
1411
+ ; dont let the lons be greater than 360, because theses values will not be in
1412
+ ; the data. Otherwise an interpolation error will occur
1413
+ lons = where(lons.gt.360, lons-360.0, lons)
1414
+
1415
+ distRes = True
1416
+ distRes@lat = lats
1417
+ distRes@lon = lons
1418
+
1419
+ return distRes
1420
+ end
1421
+ ;---------------------------------------------------------------
1422
+ ; compute the distance between two points of great circle
1423
+ undef("getCirclePath")
1424
+ function getCirclePath(startCorner,endCorner,npoints)
1425
+ begin
1426
+ startLat = startCorner(1)
1427
+ endLat = endCorner(1)
1428
+
1429
+ startLon = startCorner(0)
1430
+ endLon = endCorner(0)
1431
+
1432
+ distRes = True
1433
+ dist = gc_latlon(startLat,startLon,endLat,endLon,npoints,2)
1434
+ distRes@lat = dist@gclat
1435
+ distRes@lon = dist@gclon
1436
+
1437
+ return distRes
1438
+ end
1439
+ ;---------------------------------------------------------------
1440
+ ; compute the path of the cross-section
1441
+ undef("getSectionPath")
1442
+ function getSectionPath(seclc,secrc,secpoints,secmode)
1443
+ begin
1444
+ if (secmode .eq. "straight") then
1445
+ pathRes = getStraightPath(seclc,secrc,secpoints)
1446
+ else
1447
+ pathRes = getCirclePath(seclc,secrc,secpoints)
1448
+ end if
1449
+ return pathRes
1450
+ end
1451
+ ;---------------------------------------------------------------
1452
+ ; compute the path of the cross-section but suitable for plotting in a separate Map
1453
+ undef("getSectionPathForMap")
1454
+ function getSectionPathForMap(seclc,secrc,secpoints,secmode)
1455
+ begin
1456
+ pathRes = getSectionPath(seclc,secrc,secpoints,secmode)
1457
+ pathRes@lon = where(pathRes@lon.lt.pathRes@lon(0),pathRes@lon + 360.0,pathRes@lon)
1458
+ return pathRes
1459
+ end
1460
+ ;---------------------------------------------------------------
1301
1461
  ; setting for vertical cross sections based on remapped icon data
1302
1462
  undef("setSection")
1303
- function setSection(secLC,secRC,npoints,var)
1463
+ function setSection(seclc,secrc,secpoints,var,secmode)
1304
1464
  begin
1305
- leftlat = secLC(1)
1306
- rightlat = secRC(1)
1465
+ pathRes = getSectionPath(seclc,secrc,secpoints,secmode)
1307
1466
 
1308
- leftlon = secLC(0)
1309
- rightlon = secRC(0)
1310
-
1311
- dist = gc_latlon(leftlat,leftlon,rightlat,rightlon,npoints,2)
1312
- trans = linint2_points(var&lon,var&lat,var,True,dist@gclon,dist@gclat,2)
1467
+ trans = linint2_points(var&lon,var&lat,var,True,pathRes@lon,pathRes@lat,2)
1313
1468
 
1314
1469
  return trans
1315
1470
  end
1316
1471
  ;---------------------------------------------------------------
1317
1472
  ; setting for vertical cross sections based on remapped icon data
1318
1473
  undef("setSectionFromHybridPress")
1319
- function setSectionFromHybridPress(secLC,secRC,npoints,var,filehandle,timestep)
1474
+ function setSectionFromHybridPress(seclc,secrc,npoints,var,filehandle,timestep)
1320
1475
  begin
1321
- leftlat = secLC(1)
1322
- rightlat = secRC(1)
1476
+ leftlat = seclc(1)
1477
+ rightlat = secrc(1)
1323
1478
 
1324
- leftlon = secLC(0)
1325
- rightlon = secRC(0)
1479
+ leftlon = seclc(0)
1480
+ rightlon = secrc(0)
1326
1481
 
1327
1482
  ;config
1328
1483
  pressName = "PS"
@@ -1557,8 +1712,8 @@ begin
1557
1712
  end
1558
1713
  ;---------------------------------------------------------------
1559
1714
  ; Create a resource for the grid plot
1560
- undef("setupGridResource")
1561
- function setupGridResource(var,levels,colors,boundslon,boundslat,wks,plot,debug)
1715
+ undef("performGridPlot")
1716
+ procedure performGridPlot(var,levels,colors,boundslon,boundslat,wks,plot,flags,debug)
1562
1717
  begin
1563
1718
  pres = True
1564
1719
  pres@gsEdgesOn = True ; Turn on edges
@@ -1571,7 +1726,9 @@ begin
1571
1726
  if (.not. ismissing(vlow(0))) then
1572
1727
  do j = 0, dimsizes(vlow)-1
1573
1728
  pres@gsFillColor = colors(i) ; first color
1729
+ if ( flags(vlow(i))) then
1574
1730
  gsn_polygon(wks,plot,boundslon(vlow(j),:),boundslat(vlow(j),:),pres)
1731
+ end if
1575
1732
  end do
1576
1733
  end if
1577
1734
  if (debug) then
@@ -1587,7 +1744,9 @@ begin
1587
1744
  if (.not. ismissing(vind(0))) then
1588
1745
  do j = 0, dimsizes(vind)-1
1589
1746
  pres@gsFillColor = colors(i+1)
1590
- gsn_polygon( wks,plot, boundslon(vind(j),:),boundslat(vind(j),:),pres)
1747
+ ;if ( flags(vind(i))) then
1748
+ gsn_polygon( wks,plot, boundslon(vind(j),:),boundslat(vind(j),:),pres)
1749
+ ;end if
1591
1750
  end do
1592
1751
  end if
1593
1752
  if (debug) then
@@ -1603,18 +1762,30 @@ begin
1603
1762
 
1604
1763
  ; if no index vhig is found with values larger levels(max-1), vhig is missing value:
1605
1764
  if (.not. ismissing(vhig(0))) then
1606
- do j = 0, dimsizes(vhig) -1
1607
- pres@gsFillColor = colors(i+1)
1608
- gsn_polygon( wks,plot, boundslon(vhig(j),:),boundslat(vhig(j),:),pres)
1609
- end do
1765
+ do j = 0, dimsizes(vhig) -1
1766
+ pres@gsFillColor = colors(i+1)
1767
+ if ( flags(vhig(i))) then
1768
+ gsn_polygon(wks,plot,boundslon(vhig(j),:),boundslat(vhig(j),:),pres)
1769
+ end if
1770
+ end do
1610
1771
  end if
1611
1772
  if (debug) then
1612
1773
  print ("i=" + i + ", Values larger than "+levels(i) +": " \
1613
1774
  + dimsizes(vhig) + " triangles considered, color= " + colors(i+1))
1614
1775
  end if
1615
1776
  delete(vhig)
1616
-
1617
- return pres
1777
+ end
1778
+ ;---------------------------------------------------------------
1779
+ ; mark the cell location
1780
+ undef("plotCellMarkers")
1781
+ procedure plotCellMarkers(cell_lons,cell_lats,wks,plot,debug)
1782
+ begin
1783
+ pres = True
1784
+ pres@gsMarkerIndex = 1
1785
+ pres@gsMarkerSizeF = 0.003
1786
+ do i = 0,dimsizes(cell_lons)-1
1787
+ gsn_polymarker(wks,plot,cell_lons(i),cell_lats(i),pres)
1788
+ end do
1618
1789
  end
1619
1790
  ;---------------------------------------------------------------
1620
1791
  ; Plot the ICON grid of a variable to the plot.
@@ -1637,8 +1808,7 @@ begin
1637
1808
  levels = getLevelsFromPlot(plot)
1638
1809
 
1639
1810
  if (debug) printGridPlotInfo(colors,levels,flags) end if
1640
-
1641
- pres = setupGridResource(variable,levels,colors,boundslon,boundslat,workstation,plot,debug)
1811
+ performGridPlot(variable,levels,colors,boundslon,boundslat,workstation,plot,flags,debug)
1642
1812
  end
1643
1813
  ;---------------------------------------------------------------
1644
1814
  ; read in mask variable
@@ -1651,6 +1821,11 @@ end
1651
1821
  undef("plotVecOrStream")
1652
1822
  function plotVecOrStream(useScalar,useStreamlines,uvar,vvar,scalarvar,resource,workstation,showMap)
1653
1823
  begin
1824
+ ; streamline setup
1825
+ resource@stArrowStride = 3; arrows start every third
1826
+ resource@stArrowLengthF = 0.002; default is dynamic
1827
+ resource@stMinDistanceF = 0.025; streamline dist
1828
+ resource@stLineThicknessF = 2.0; streamline thickness
1654
1829
  if (useScalar) then
1655
1830
  if (useStreamlines) then
1656
1831
  if (showMap)
@@ -1684,4 +1859,4 @@ begin
1684
1859
  end
1685
1860
 
1686
1861
  ;
1687
- ; vim:list
1862
+ ; vim:ft=ncl
@@ -20,15 +20,17 @@ class TestIconPlot < Test::Unit::TestCase
20
20
  if 'thingol' == `hostname`.chomp
21
21
  def test_simple
22
22
  ip = IconPlot.new(CALLER,PLOTTER,PLOTLIB,OFMT,PLOT_CMD,CDO,true)
23
+ ip.debug = true
23
24
  ofile = 'test_icon_plot'
24
- ip.show(ip.scalarPlot(OCE_PLOT_TEST_FILE, ofile,"T",:levIndex => 0))
25
- ip.show(ip.scalarPlot(OCE_PLOT_TEST_FILE, ofile,"T",:levIndex => 2))
26
- ip.show(ip.vectorPlot(OCE_PLOT_TEST_FILE, ofile,"u-veloc v-veloc",:levIndex => 2))
27
- ip.show(ip.scalarPlot(OCE_PLOT_TEST_FILE, ofile,"T",:vecVars => "u-veloc,v-veloc",:levIndex => 2,:mapType => "ortho"))
28
- ip.show(ip.scalarPlot(OCE_PLOT_TEST_FILE, ofile,"T",:vecVars => "u-veloc,v-veloc",:levIndex => 2,:secLC => "-20,-60", :secRC => "-20,60"))
29
- ip.show(ip.scalarPlot(OCELSM_PLOT_TEST_FILE,ofile,"T",:vecVars => "u-veloc,v-veloc",:levIndex => 2,:secLC => "-20,-60", :secRC => "-20,60",:maskName => 'wet_c'))
30
- ip.show(ip.scalarPlot(OCELSM_PLOT_TEST_FILE,ofile,"T",:vecVars => "u-veloc,v-veloc",:levIndex => 2,:maskName => 'wet_c'))
31
- ip.show(ip.scalarPlot(OCELSM_PLOT_TEST_FILE,ofile,"T",:levIndex => 2,:maskName => 'wet_c'))
25
+ ip.show(ip.scalarPlot(OCE_PLOT_TEST_FILE, ofile+'_00',"T",:levIndex => 0))
26
+ ip.show(ip.scalarPlot(OCE_PLOT_TEST_FILE, ofile+'_01',"T",:levIndex => 2))
27
+ ip.show(ip.vectorPlot(OCE_PLOT_TEST_FILE, ofile+'_02',"u-veloc v-veloc",:levIndex => 2))
28
+ ip.show(ip.scalarPlot(OCE_PLOT_TEST_FILE, ofile+'_03',"T",:vecVars => "u-veloc,v-veloc",:levIndex => 2,:mapType => "ortho"))
29
+ ip.show(ip.scalarPlot(OCE_PLOT_TEST_FILE, ofile+'_04',"T",:vecVars => "u-veloc,v-veloc",:levIndex => 2,:secLC => "-20,-60", :secRC => "-20,60"))
30
+ ip.show(ip.scalarPlot(OCELSM_PLOT_TEST_FILE,ofile+'_05',"T",:vecVars => "u-veloc,v-veloc",:levIndex => 2,:secLC => "-20,-60", :secRC => "-20,60",:maskName => 'wet_c'))
31
+ ip.show(ip.scalarPlot(OCELSM_PLOT_TEST_FILE,ofile+'_05',"T",:vecVars => "u-veloc,v-veloc",:levIndex => 2,:secLC => "-50,-60", :secRC => "0,60",:maskName => 'wet_c',:secMode => 'circle'))
32
+ ip.show(ip.scalarPlot(OCELSM_PLOT_TEST_FILE,ofile+'_06',"T",:vecVars => "u-veloc,v-veloc",:levIndex => 2,:maskName => 'wet_c'))
33
+ ip.show(ip.scalarPlot(OCELSM_PLOT_TEST_FILE,ofile+'_07',"T",:levIndex => 2,:maskName => 'wet_c'))
32
34
  ip.isIcon = false
33
35
  ip.show(ip.scalarPlot("remapnn_r90x45_oce.nc","reg_"+ofile,"T",:levIndex => 2,:mapType => "ortho"))
34
36
  ip.show(ip.scalarPlot("remapnn_r90x45_oce.nc","reg_"+ofile,"T",:vecVars => "u-veloc,v-veloc",:levIndex => 2,:mapType => "ortho"))
metadata CHANGED
@@ -1,100 +1,93 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iconPlot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
5
- prerelease:
4
+ version: 0.0.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ralf Mueller
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-09-21 00:00:00.000000000 Z
11
+ date: 2013-03-26 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: cdo
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: extcsv
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: gnuplot
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
- description: ! 'Plot with ncl via Ruby: requires NCL 6.* and CDO 1.5.*'
55
+ description: 'Plot with ncl via Ruby: requires NCL 6.* and CDO 1.5.*'
63
56
  email: stark.dreamdetective@gmail.com
64
- executables: []
57
+ executables:
58
+ - nclsh
65
59
  extensions: []
66
60
  extra_rdoc_files: []
67
61
  files:
68
62
  - lib/iconPlot.rb
69
63
  - gemspec
70
- - contrib/nclsh
64
+ - bin/nclsh
71
65
  - lib/icon_plot.ncl
72
66
  - lib/icon_plot_lib.ncl
73
67
  - test/test_iconPlot.rb
74
68
  homepage: https://github.com/Try2Code/iconPlot
75
69
  licenses:
76
70
  - GPLv2
71
+ metadata: {}
77
72
  post_install_message:
78
73
  rdoc_options: []
79
74
  require_paths:
80
75
  - lib
81
76
  required_ruby_version: !ruby/object:Gem::Requirement
82
- none: false
83
77
  requirements:
84
- - - ! '>='
78
+ - - '>='
85
79
  - !ruby/object:Gem::Version
86
80
  version: '1.8'
87
81
  required_rubygems_version: !ruby/object:Gem::Requirement
88
- none: false
89
82
  requirements:
90
- - - ! '>='
83
+ - - '>='
91
84
  - !ruby/object:Gem::Version
92
85
  version: '0'
93
86
  requirements: []
94
87
  rubyforge_project:
95
- rubygems_version: 1.8.23
88
+ rubygems_version: 2.0.0
96
89
  signing_key:
97
- specification_version: 3
90
+ specification_version: 4
98
91
  summary: Plot ICON output with ncl via Ruby
99
92
  test_files:
100
93
  - test/test_iconPlot.rb