iconPlot 0.0.8 → 0.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81daefe787ba86d077804f2afbb20f24bb8625e0
4
- data.tar.gz: e2538b75ce60c906d8c90afd08654bc4a9f7a9f1
3
+ metadata.gz: df59cf8fcb883833c0355e39533c5da8e3075d25
4
+ data.tar.gz: 8346f47771d4ce6573732e64986e928a05eb9878
5
5
  SHA512:
6
- metadata.gz: b2a7478b62d8e95335816b006caeb81471f749cf1d014875647a9504a2efe03bca72c5a7db1036650407ff9c5e0a6d59a04865cef19b869de7163bf1213ae5aa
7
- data.tar.gz: c7da25dd5cd29dcc0232e049bf86da2192ab56cab2ff232a5b1a2f247d1158d8d1ace670f39c7a664607fe5382b6628a934867a4f0cb3ce9705b23558a2b5ef0
6
+ metadata.gz: 6b0086f6cb9c924a88b124b560298971805f810437da1bd3b0682f3339aca3bc7a36af54ae8d5f976df00710cc7aa951e50061b483de699b605dde68593187b9
7
+ data.tar.gz: 25de6154c6143f65914063ae23a1e4096e57fbae0e4c5636bed530f456c5f8e8206186e0b254de92a436d19feebcc16f30e6388232ae51a7f53cc0259a553c3f
data/gemspec CHANGED
@@ -3,7 +3,7 @@ $:.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.8'
6
+ s.version = '0.0.9'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.files = ["lib/iconPlot.rb"] + ["gemspec"] + ["bin/nclsh"] + Dir.glob("lib/*ncl")
9
9
  s.executables << 'nclsh'
data/lib/iconPlot.rb CHANGED
@@ -35,7 +35,7 @@ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug
35
35
  raise ArgumentError
36
36
  end
37
37
 
38
- opts[:tStrg] =ofile if opts[:tStrg].nil?
38
+ opts[:tStrg] = opts[:tStrg].nil? ? ofile : opts[:tStrg]
39
39
 
40
40
  cmd = [self.caller,self.plotter].join(' ')
41
41
  cmd << " -altLibDir=#{self.libdir} #{varIdent} -iFile=#{ifile} -oFile=#{ofile} -oType=#{self.otype}"
@@ -68,16 +68,16 @@ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug
68
68
  exit -1
69
69
  end
70
70
  Cdo.debug = true
71
- unit = Cdo.showunit(:in => "-selname,#{varname} #{ifile}").first
71
+ unit = Cdo.showunit(:input => "-selname,#{varname} #{ifile}").first
72
72
  ExtCsvDiagram.plot_xy(icon,"datetime",varname,
73
73
  "ICON: #{operation} on #{varname} (file:#{ifile})", # Change title here
74
- :label_position => 'below',:skipColumnCheck => true,
75
- :type => 'lines',:groupBy => ["depth"], :onlyGroupTitle => true,
74
+ :label_position => 'below',:skipColumnCheck => true,
75
+ :type => 'lines',:groupBy => ["depth"], :onlyGroupTitle => true,
76
76
  # :addSettings => ["logscale y"], # Commend theses out for large scale values like Vert_Mixing_V
77
77
  # :yrange => '[0.0001:10]', # Otherwise you'll see nothing reasonable
78
78
  :terminal => true ? 'png' : 'x11',
79
79
  :ylabel => "#{varname} [#{Shellwords.escape(unit)}]", # Correct the label if necessary
80
- :input_time_format => "'%Y%m%d %H:%M:%S'",
80
+ :input_time_format => "'%Y-%m-%d %H:%M:%S'",
81
81
  :filename => ofile,
82
82
  :output_time_format => '"%d.%m.%y \n %H:%M"',:size => "1600,600")
83
83
  return "#{ofile}.png"
@@ -85,7 +85,7 @@ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug
85
85
  def scatterPlot(ifile,ofile,xVarname,yVarname,opts={})
86
86
  # is there a variable which discribes different regions in the ocean
87
87
  regionVar = opts[:regionVar].nil? ? 'rregio_c' : opts[:regionVar]
88
- hasRegion = Cdo.showname(:in => ifile).join.split.include?(regionName)
88
+ hasRegion = Cdo.showname(:input => ifile).join.split.include?(regionName)
89
89
  unless hasRegion
90
90
  warn "Variable '#{regionName}' for showing regions is NOT found in the input '#{ifile}'!"
91
91
  warn "Going on without plotting regions!"
@@ -100,7 +100,7 @@ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug
100
100
  FileUtils.rm(file) if File.exists?(file)
101
101
  end
102
102
  def show(*files)
103
- files.flatten.each {|file| IO.popen("#{self.display} #{file} &") }
103
+ files.flatten.each {|file| out = IO.popen("#{self.display} #{file} &").read; puts out if self.debug }
104
104
  end
105
105
  def defaultPlot(ifile,ofile,opts={})
106
106
  show(scalarPlot(ifile,ofile,'T',opts))
@@ -117,13 +117,13 @@ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug
117
117
  IO.popen("echo 'date|time|depth|#{varname}' > #{dataFile}")
118
118
  Cdo.debug = true
119
119
  Cdo.outputkey('date,time,level,value',
120
- :in => "-#{operation} -selname,#{varname} #{ifile} >>#{dataFile} 2>&1")
120
+ :input => "-#{operation} -selname,#{varname} #{ifile} >>#{dataFile} 2>/dev/null")
121
121
 
122
122
  # postprocessing for correct time values
123
123
  data = []
124
124
  File.open(dataFile).each_with_index {|line,lineIndex|
125
125
  next if line.chomp.empty?
126
- _t = line.chomp.gsub(/ +/,'|').split('|')
126
+ _t = line.chomp.sub(/^ /,'').gsub(/ +/,'|').split('|')
127
127
  if 0 == lineIndex then
128
128
  data << _t
129
129
  next
@@ -131,14 +131,14 @@ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug
131
131
  if "0" == _t[1] then
132
132
  _t[1] = '00:00:00'
133
133
  else
134
- time = _t[1].reverse
135
- timeStr = ''
136
- while time.size > 2 do
137
- timeStr << time[0,2] << ':'
138
- time = time[2..-1]
139
- end
140
- timeStr << time.ljust(2,'0') unless time.size == 0
141
- _t[1] = timeStr.reverse
134
+ #time = _t[1].reverse
135
+ #timeStr = ''
136
+ #while time.size > 2 do
137
+ # timeStr << time[0,2] << ':'
138
+ # time = time[2..-1]
139
+ #end
140
+ #timeStr << time.ljust(2,'0') unless time.size == 0
141
+ #_t[1] = timeStr.reverse
142
142
  end
143
143
  data << _t
144
144
  }
data/lib/icon_plot.ncl CHANGED
@@ -55,7 +55,8 @@
55
55
  end if
56
56
  ;------------------------------------------------------------------------------
57
57
  ;==============================================================================
58
- VERSION = "0.0.6"
58
+ VERSION = "0.0.9"
59
+ ; setfileoption("nc", "filestructure", "advanced")
59
60
  ;----- MAIN PROGRAM -----------------------------------------------------------
60
61
  if (isvar("help")) then
61
62
  dq = str_get_dq()
@@ -63,7 +64,7 @@
63
64
  print("; Basic Usage:")
64
65
  print("; ncl icon_plot.ncl 'iFile=" + dq + "path/file.nc" + dq + "' 'varName=" + dq + "ELEV" + dq + "' 'oFile=" + dq + "test" + dq + "' timeStep=1 levIndex=1")
65
66
  print(";")
66
- print("; Select an special area of the globe with mapLLC (LowerLeftCorner) and mapURC (UpperRightCorner) ")
67
+ print("; Select a special area of the globe with mapLLC (LowerLeftCorner) and mapURC (UpperRightCorner) ")
67
68
  print("; ncl icon_plot.ncl 'iFile=" + dq + "path/file.nc" + dq + "' 'varName=" + dq + "W" + dq + "' 'mapLLC=(/35.0, -8/)' 'mapURC=(/55, 8/)'")
68
69
  print(";")
69
70
  print("; Masking:")
@@ -98,7 +99,9 @@
98
99
  print(";")
99
100
  print("; Optional Parameter:")
100
101
  print("; oType : output graphics format (ps, eps, png, default: eps)")
101
- print("; resolution : resolution string whish is used for remapping the icon data")
102
+ print("; xsize : width of plot (PNG only)")
103
+ print("; ysize : height of plot (PNG only)")
104
+ print("; resolution : resolution string which is used for remapping the icon data")
102
105
  print("; to regular grid (default: r90x45)")
103
106
  print("; vecRefLength : reference vector length (default: 8.0)")
104
107
  print("; vecColByLen : should vectors get coloured according to their lengths (default:False)")
@@ -112,15 +115,15 @@
112
115
  print("; mapLLC : (lon,lat) value array of the Lower Left Corner of the map")
113
116
  print("; mapURC : (lon,lat) ------- || ------- Upper Right Corner of the map")
114
117
  print("; use -180 to 180 for longitude !")
115
- print("; secLC, secRC : start and and point of a vertical section (no default value)")
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("; secLC, secRC : start and end point of a vertical section (no default value)")
119
+ print("; section is plotted if secLC and secRC are present")
120
+ print("; secMode : perform transection along a great cricle or on a straight line")
118
121
  print("; possible values: circle, straight (default)")
119
122
  print("; : ATTENTION: using 'circle' for sections with a small angle wrt the equator is NOT RECOMMENDED")
120
123
  print("; showSecMap : display the location of the vertical section in an additional map (default:true)")
121
124
  print("; centerLon : center longitute for satelite view (default:30.)")
122
125
  print("; centerLat : center latitude for satelite view (default:20.)")
123
- print("; satDist : satelite distance (default:20.0)")
126
+ print("; satDist : satellite distance (default:20.0)")
124
127
  print("; scaleFactor : optional scale factor")
125
128
  print("; fillMode : how to color contour plots,i.e. sets cnFillMode: CellFill or RasterFill (default:RasterFill)")
126
129
  print("; selMode : mode for level spacing of the plot:")
@@ -128,14 +131,17 @@
128
131
  print("; manual (automatic linear spacing with usage of minVar and maxVar)")
129
132
  print("; auto (default: let do ncl the spacing)")
130
133
  print("; scaleLimit : Limits the number of decades for levels in selMode-halflog")
131
- print("; minVar/maxVar : min/maximal Value to plot for selMode = 'manual' or 'halflog'")
134
+ print("; minVar/maxVar : min/maximal value to plot for selMode = 'manual' or 'halflog'")
132
135
  print("; numLevs : set a number of labels for manual selMode only. NumCol=numLevs+2")
133
136
  print("; (Not set directly, but used for computing the contour level spacing. default=10)")
134
137
  print("; plotLevs : set individual contour levels, selMode is set to 'manual' automatically")
135
138
  print("; mapType : projection type (default: lonlat), other: ortho (not compatible with showGrid), NHps")
136
139
  print("; and SHps (polar stereographic projections centered at the north and south pole respectively),")
137
140
  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)")
141
+ print("; hov[Depth] : plot hovmoeller diagram, expects variable with only two 'active' dimensions, i.e. time/depth")
142
+ print("; hovCut : plot hovmoeller diagram, input is 'levIndex' and 'hovLC' 'hovRC'")
143
+ print("; hovLC, hovRC : start and end point of a section for hovCut - currently same longitude allowed only,")
144
+ print("; the Northern and Southern values are used as plotting boundaries; switches to hovCut")
139
145
  print("; mapLine : (logical) draws continent lines on the plot (foreground/transparent)")
140
146
  print("; maskName : variable to mask with. maskName is expected NOT to have time dimension")
141
147
  print("; 'maskName=" + dq + "none" + dq + "' is same as default (no mask variable)")
@@ -146,17 +152,17 @@
146
152
  print("; lStrg : left string")
147
153
  print("; rStrg : right string")
148
154
  print("; tStrg : title string")
149
- print("; bStrg : base string - default is prgr name and time stamp only")
155
+ print("; bStrg : base string - default is program name and time stamp only")
150
156
  print("; maxView : (logical) maximize plot area on paper (not for buildbot -> convert to png)")
151
157
  print("; colormap : string for predefined colormaps of the plot (e.g. 'colormap=" + dq + "BlAqGrYeOrReVi200" + dq + "')")
152
158
  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)")
159
+ print("; withLineLabels: label the countour lines with their values (auto-enable withLines, default:False)")
154
160
  print("; showGrid : display polygon lines with filled colors instead of contour plot")
155
161
  print("; markCells : mark cell centers with dots")
156
162
  print("; showNcd : display NDC Grid to find Normalized Device Coordinates on the plot")
157
163
  print("; k2c : if True, perform Kelvin2Celsius shift (default:True)")
158
164
  print(";")
159
- print("; ATMOSPEHRE STUFF:")
165
+ print("; ATMOSPHERE STUFF:")
160
166
  print("; atmLev : chooses vertical plot levels for atmosphere input (h: height,p:pressure,m:modellevel,default:p)")
161
167
  print(";---------------------------------------------------------------")
162
168
  print("; altLibDir : Alternative directory for loading icon_plot_lib.ncl")
@@ -374,30 +380,37 @@
374
380
  end if
375
381
  end if
376
382
 
377
- if ( (isvar("secLC").or.isvar("secRC")).ne.(isvar("secLC").and.isvar("secRC"))) then
378
- print("Please provide secLC AND secRC for generatin a section plot!")
383
+ if ((isvar("secLC").or.isvar("secRC")).ne.(isvar("secLC").and.isvar("secRC"))) then
384
+ print("Please provide secLC AND secRC for generating a section plot!")
379
385
  exit
380
386
  end if
381
387
  if (isvar("secLC").and.isvar("secRC")) plotMode = "section" end if
382
- if (isvar("hov")) plotMode = "hovmoeller" end if
388
+
389
+ if ((isvar("hovLC").or.isvar("hovRC")).ne.(isvar("hovLC").and.isvar("hovRC"))) then
390
+ print("Please provide hovLC AND hovRC for generating a Hovmoeller plot!")
391
+ exit
392
+ end if
393
+ if (isvar("hovLC").and.isvar("hovRC")) plotMode = "hovmoeller" end if
394
+ if (isvar("hovDepth").or.isvar("hovCut").or.(isvar("hov"))) plotMode = "hovmoeller" end if
383
395
 
384
396
  if (plotMode.eq."vector" .or. plotMode.eq."overlay" .or. plotMode.eq."section") then
385
397
  if (horizonalGridType .ne. "unstructured") then ; regular grid expected, i.e. remappgin is NOT required
386
398
  rFile = addfile(iFile+".nc","r")
387
399
  else
388
- ; performe some remapping to a regular grid because ncl cannot draw vector
400
+ ; perform some remapping to a regular grid because ncl cannot draw vector
389
401
  ; from unstructured grids
390
402
  ; TODO addVars=(/ "PS","PHIS"/)
391
- remapFilename = setRemapFilename(iFile,iType,resolution,atmLev)
403
+ operator = "remapnn"
404
+ remapFilename = setRemapFilename(iFile,iType,resolution,atmLev,operator)
392
405
  print("remapFilename:"+remapFilename)
393
406
  if (.not. checkRemappedFile(iFile,remapFilename,ivarname,iType,atmLev,atmPLevs,atmHLevs) ) then
394
407
  addVars=(/""/)
395
408
  print("PERFORM remapnn again!")
396
- remapForVecPlot(iFile,remapFilename,resolution,useMask,plotMode,DEBUG,addVars)
409
+ remapForVecPlot(iFile,remapFilename,resolution,useMask,plotMode,DEBUG,addVars,operator)
397
410
  end if
398
411
  rFile = addfile( remapFilename+".nc", "r" )
399
412
  end if
400
- ;if (plotMode .eq. "hoffmueller") then ; perform zonmean
413
+ ;if (plotMode .eq. "hovmoeller") then ; perform zonmean
401
414
  ; zonmeanFilename = setZonmeanFilename(remapFilename,ivarname,atmLev)
402
415
  ; zonmean4HoffmuellerPlot(remapFilename,ivarname,zonmeanFilename)
403
416
  ;end if
@@ -437,6 +450,7 @@
437
450
  print("oFile = "+oFile)
438
451
  print("Graphics format is " +oType)
439
452
  print("plotMode = "+plotMode)
453
+ print("showGrid = "+showGrid)
440
454
 
441
455
  if (plotMode.eq."scalar" .or. plotMode.eq."section" .or. plotMode.eq."hovmoeller") then
442
456
  print("varName = "+varName)
@@ -465,24 +479,6 @@
465
479
 
466
480
  var = selField(varName,File,timeStep,levIndex,horizonalGridType)
467
481
 
468
- if (horizonalGridType .eq. "unstructured") then
469
- if (isvar("gridFile")) then
470
- x = getCoordinateFromFile(lonCo,gridFile)
471
- y = getCoordinateFromFile(latCo,gridFile)
472
- if (showGrid) then
473
- bounds = getBoundsFromFile(lonCo,latCo,gridFile)
474
- end if
475
- else
476
- lonlatSizes = getCoordSizes(var,File)
477
- x = new(lonlatSizes(0),double)
478
- y = new(lonlatSizes(1),double)
479
- getLonLats(var,File,x,y)
480
- if (showGrid) then
481
- bounds = getBoundsOfCoordinates(var,File)
482
- end if
483
- end if
484
- end if
485
-
486
482
  scaleVar(var,scaleFactor)
487
483
 
488
484
  ; set minVar_maxVar for plotting
@@ -562,6 +558,10 @@
562
558
  ; make the plot
563
559
  ;---------------------------------------------------------------
564
560
  ; preparations
561
+ if (oType .eq. "png") then
562
+ if(isvar("xsize")) oType@wkWidth = xsize end if
563
+ if(isvar("ysize")) oType@wkHeight = ysize end if
564
+ end if
565
565
  wks = gsn_open_wks(oType,oFile)
566
566
 
567
567
  gsn_define_colormap(wks,colormap)
@@ -570,7 +570,7 @@
570
570
  drawNDCGrid(wks)
571
571
  end if
572
572
 
573
- ResC = setDefaultResource(True,withLines,withLineLabels,fillMode)
573
+ ResC = setDefaultResource(True,withLines,withLineLabels,fillMode,mapType)
574
574
 
575
575
  if (.not. userColors) setDefaultColors(ResC,minVar,maxVar,DEBUG) end if
576
576
 
@@ -578,10 +578,28 @@
578
578
 
579
579
  if (useMask) setMaskColor(wks,ResC) end if
580
580
 
581
-
582
- if (getHorizGridType(iFile,ivarname,isIcon) .eq. "unstructured") then
581
+ if (horizonalGridType .eq. "unstructured" .or. horizonalGridType .eq. "curvilinear") then
583
582
  if (plotMode.eq."scalar" .or. plotMode.eq."overlay")
584
- setCoordinates(ResC,x,y)
583
+ if (horizonalGridType .eq. "unstructured") then
584
+ if (isvar("gridFile")) then
585
+ ;TODO: fix x,y creation for external gridfile (plot restart data)
586
+ coords = setCoordinatesFromExtraFile(lonCo,latCo,gridFile,var,ResC)
587
+ if (showGrid) then
588
+ bounds = getBoundsFromFile(lonCo,latCo,gridFile)
589
+ end if
590
+ else
591
+ if (showGrid) then
592
+ bounds = getBoundsOfCoordinates(var,File)
593
+ end if
594
+ end if
595
+ end if
596
+ end if
597
+ if (.not.isvar("coords")) then
598
+ if (isvar("rFile")) then
599
+ coords = setCoordinates(ResC,rFile,var)
600
+ else
601
+ coords = setCoordinates(ResC,File,var)
602
+ end if
585
603
  end if
586
604
  end if
587
605
 
@@ -608,7 +626,11 @@
608
626
 
609
627
  setMapType(ResC,mapType,centerLon,centerLat,satDist)
610
628
 
611
- selMapCut(ResC,mapLLC,mapURC)
629
+ if (isvar("limitMap")) then
630
+ limitMap2Coords(ResC)
631
+ else
632
+ selMapCut(ResC,mapLLC,mapURC)
633
+ end if
612
634
 
613
635
  setMapVisibility(ResC,mapLine)
614
636
 
@@ -654,29 +676,67 @@
654
676
  draw(plot)
655
677
  end if
656
678
  if (plotMode.eq."scalar") then
657
- if (DEBUG .and. horizonalGridType.eq."unstructured") print("Gridtype is "+getGridType(var)) end if
679
+ ;if (DEBUG .and. horizonalGridType.eq."unstructured") print("Gridtype is "+getGridType(var)) end if
680
+ if ( horizonalGridType .eq. "curvilinear") then
681
+ ResC@cnFillMode = "CellFill"
682
+ end if
683
+ if (showGrid ) then
684
+ if ( horizonalGridType .eq. "curvilinear") then
685
+ ResC@cnLinesOn = False
686
+ ResC@cnFillMode = "CellFill"
687
+ ResC@cnCellFillEdgeColor = "black" ;-- set edge color (default: -1 transparent)
688
+ ResC@cnCellFillMissingValEdgeColor = "grey" ;-- set miss val edge color (default: -1 transparent)
689
+ end if
690
+ end if
658
691
  plot = gsn_csm_contour_map(wks,var,ResC)
659
-
660
692
  if (showGrid) then
661
- if ( horizonalGridType .ne. "unstructured") then
693
+ if (horizonalGridType .eq. "unstructured") then
694
+ ;=======================================================================================
695
+ ;plotGrid(wks,plot,var,coords(1,:),bounds,File,ResC,DEBUG)
696
+ boundslon = bounds(0,:,:)
697
+ boundslat = bounds(1,:,:)
698
+ pres = plotGrid_62(wks,plot,var,boundslon,boundslat)
699
+ gsid = gsn_add_polygon(wks,plot,ndtooned(boundslon),ndtooned(boundslat),pres)
700
+ ; }}}
701
+ ;=======================================================================================
702
+ end if
703
+ if ( horizonalGridType .ne. "curvilinear" .and. horizonalGridType .ne. "unstructured") then
662
704
  print("#=====================================================================")
663
705
  print("Grid representation is only implemented for the unstructured ICON grid")
664
706
  exit
665
707
  end if
666
- plotGrid(wks,plot,var,x,bounds,File,ResC,DEBUG)
667
708
  end if
668
709
  if ( markCells ) then
710
+ x = coords(0,:)
711
+ y = coords(1,:)
669
712
  plotCellMarkers(x,y,wks,plot,True)
670
713
  end if
714
+ draw(plot)
671
715
  end if
672
716
  if (plotMode.eq."scatter") then
673
717
  plot = gsn_csm_xy(wks,xvar,yvar,ResC)
674
718
  end if
675
719
  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)
720
+ if (isvar("hovDepth").or.(isvar("hov"))) then
721
+ ; select the whole time series
722
+ ; and plot it with
723
+ ResC@trYReverse = True
724
+ plot = gsn_csm_hov(wks, var(depth|:,time|:,lat|0,lon|0), ResC)
725
+ end if
726
+ if (isvar("hovRC")) then
727
+ startLon = hovRC(0)
728
+ northLat = hovRC(1)
729
+ endLon = hovLC(0)
730
+ southLat = hovLC(1)
731
+ hovCut = True
732
+ end if
733
+ if (isvar("hovCut")) then
734
+ ;plot = gsn_csm_hov(wks, var(depth|0,time|:,lat|:,lon|0), ResC)
735
+ ;plot = gsn_csm_lat_time(wks, var(depth|0,time|:,lat|:,lon|0), ResC)
736
+ ;plot = gsn_csm_lat_time(wks, var(depth|0,lat|:,lon|165,time|:), ResC)
737
+ ;plot = gsn_csm_hov(wks, var({depth|150},{lat|70:-80},{lon|330},time|:), ResC)
738
+ plot = gsn_csm_hov(wks, var(depth|levIndex,{lat|northLat:southLat},{lon|startLon},time|:), ResC)
739
+ end if
680
740
  end if
681
741
  if (plotMode.eq."section") then
682
742
 
@@ -687,7 +747,7 @@
687
747
  end if
688
748
  points = ispan(0,secPoints-1,1)*1.0
689
749
 
690
- res = setDefaultSectionResource(points,secPoints,secLC,secRC)
750
+ res = setDefaultSectionResource(points,secPoints,secLC,secRC,withLines,withLineLabels)
691
751
  setAutomaticPlotCaptions(res,plotMode,varName,File,iFile,timeStep,levIndex,iType,atmLev,k2c)
692
752
  setLevels(selMode,res,minVar,maxVar,scaleLimit,numLevs,DEBUG)
693
753
  setSectionVertLabel(res,iType,atmLev)
@@ -1,22 +1,22 @@
1
1
  ;---------------------------------------------------------------
2
2
  ; ICON PLOT LIB
3
3
  ; This library aimes to provide an abstract way to access and plot ICON data
4
- ; fields from NetCDF files. It should obay some general requirements:
5
- ; * Don-Repeat-Yourself-principle: Every method has one responsebility, which no
4
+ ; fields from NetCDF files. It should obey some general requirements:
5
+ ; * Dont-Repeat-Yourself-Principle: Every method has one responsibility, which no
6
6
  ; other method has. Or in other words: Don't just CopyAndPaste.
7
7
  ; * Use as much information from the input files as possible. If something is
8
- ; missing, create a better file or let the user input this peace of
9
- ; information. Examples are coordinates of data variabels and bounds of them.
8
+ ; missing, create a better file or let the user input this piece of
9
+ ; information. Examples are coordinates of data variables and bounds of them.
10
10
  ; There are attributes for this.
11
11
  ; * naming conventions:
12
12
  ; # check* methods are procedure which can exit the whole program
13
- ; # get* methods are functions with return, what they descibe with their
13
+ ; # get* methods are functions with return, what they describe with their
14
14
  ; name. This is similar to NCL itself, e.g. getfilevardims()
15
15
  ; # set* methods are procedures
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
+ ; VERSION = "0.0.9"
20
20
  ;-------------------------------------------------------------------------------
21
21
  ; some global defaults
22
22
  DEFAULTLON = "clon"
@@ -29,9 +29,10 @@
29
29
  DEFAULTCOLOR = "BlueDarkRed18" ; ncolors = 256
30
30
  DEFAULTCOLOR = "BlueWhiteOrangeRed" ; ncolors = 256
31
31
  ;-------------------------------------------------------------------------------
32
- procedure setCDO(path)
32
+ undef("setCDO")
33
+ procedure setCDO(path2Cdo)
33
34
  begin
34
- CDO=path
35
+ CDO=path2Cdo
35
36
  end
36
37
  ;-------------------------------------------------------------------------------
37
38
  ; signum function
@@ -44,16 +45,62 @@ begin
44
45
  return(val/abs(val))
45
46
  end if
46
47
  end
48
+ ;---------------------------------------------------------------
49
+ ; return ncl version string
50
+ undef("getNclVersion")
51
+ function getNclVersion()
52
+ begin
53
+ version_string = systemfunc("ncl -V")
54
+ version_array = str_split(version_string, ".")
55
+ ; use integers instead
56
+ return stringtointeger(version_array)
57
+ end
58
+ ;---------------------------------------------------------------
59
+ ; return true if ncl uses groups for netcdf4 input (release 6.1.1 with netcdf4 input)
60
+ undef("versionWithNC4GroupNotationSupport")
61
+ function versionWithNC4GroupNotationSupport()
62
+ begin
63
+ return (/6,1,1/)
64
+ end
65
+ undef("versionIsGE")
66
+ function versionIsGE(otherVersion)
67
+ begin
68
+ return True
69
+ diff = otherVersion .gt. getNclVersion()
70
+ print(""+diff)
71
+ do i=0,dimsizes(diff)
72
+ if (.not. diff(i)) then
73
+ return False
74
+ end if
75
+ end do
76
+ return True
77
+ end
78
+ ;-------------------------------------------------------------------------------
79
+ ; return a filehandle that can access variables names without leading '/' even
80
+ ; if the input it nc4 and ncl has version 6.1.1 or above
81
+ undef("nc4Aware_addfile")
82
+ function nc4Aware_addfile(filename,debug)
83
+ begin
84
+ filehandle = addfile( filename, "r" )
85
+ filetype = get_file_version(filehandle)
86
+ if debug then
87
+ print("[nc4Aware_addfile]Read in file:'" + filename +"'")
88
+ print("[nc4Aware_addfile] Filetype:'" + filetype +"'")
89
+ print("[nc4Aware_addfile]NCL version:'" + str_join(getNclVersion(),".") +"'")
90
+ print("[nc4Aware_addfile]version > 611'" + versionIsGE((/6,1,1/)) )
91
+ end if
92
+ if ((get_file_version(filehandle) .eq. "NETCDF4") .and. versionIsGE((/6,1,1/))) then
93
+ print("[nc4Aware_addfile]switch to root group '/'")
94
+ ;filehandle = filehandle=>/
95
+ end if
96
+ return filehandle
97
+ end
47
98
  ;-------------------------------------------------------------------------------
48
99
  ; Is the 'time' variable a dimesions in the input dimensions array?
49
100
  undef("has_time")
50
101
  function has_time(dims)
51
102
  begin
52
- if (any(dims.eq."time")) then
53
- return(True)
54
- else
55
- return(False)
56
- end if
103
+ return any(dims.eq."time")
57
104
  end
58
105
  ;-------------------------------------------------------------------------------
59
106
  ; Has the input variable the dimension 'time'?
@@ -74,7 +121,7 @@ function has_var(filehandle,varname)
74
121
  begin
75
122
  vNames = getfilevarnames(filehandle)
76
123
  n = dimsizes (vNames)
77
- do i=0,n-1 ; loop thru each variable
124
+ do i=0,n-1 ; loop through each variable
78
125
  if (vNames(i).eq.varname) return True end if
79
126
  end do
80
127
  return False
@@ -103,7 +150,7 @@ begin
103
150
  end
104
151
  ;-------------------------------------------------------------------------------
105
152
  ; Read a horizontal field of the variable 'varname' from the given filehandle.
106
- ; If it is time dependend or has a vertival axis, use the given values for
153
+ ; If it is time dependant or has a vertical axis, use the given values for
107
154
  ; timstep and levelindex for selecting the field.
108
155
  ;
109
156
  ; Currently this limited to 3 dimensions, so that 4D tracer variables are ignored
@@ -368,15 +415,17 @@ end
368
415
  ;-------------------------------------------------------------------------------
369
416
  ; Return the coordinates of a given variable in degrees
370
417
  undef("getLonLats")
371
- procedure getLonLats(variable,filehandle,x,y)
418
+ procedure getLonLats(variable,filehandle,x,y,isicon)
372
419
  begin
373
420
  lonlat = str_split(variable@coordinates," ")
374
421
  lon = lonlat(0)
375
422
  lat = lonlat(1)
376
423
  x = filehandle->$lon$
377
424
  y = filehandle->$lat$
378
- x = x * RAD2DEG
379
- y = y * RAD2DEG
425
+ if (isicon) then
426
+ x = x * RAD2DEG
427
+ y = y * RAD2DEG
428
+ end if
380
429
  end
381
430
  ;-------------------------------------------------------------------------------
382
431
  ; get variable from a certain file
@@ -401,7 +450,7 @@ end
401
450
  ; Examples:
402
451
  ; (/1,2,5,10,20,50,100,200,500/) or
403
452
  ; (/-1,-5e-1,-2e-1,-1e-1,-5e-2,-2e-2,-1e-2,0,1e-2,2e-2,5e-2,1e-1,2e-1,5e-1,1/)
404
- ; scaleLimit determines the numer of decades on the positive or negtive axis of the output array
453
+ ; scaleLimit determines the number of decades on the positive or negative axis of the output array
405
454
  undef("createLevels")
406
455
  function createLevels(minVar, maxVar, scaleLimit)
407
456
  begin
@@ -486,6 +535,7 @@ begin
486
535
  end
487
536
  ;---------------------------------------------------------------
488
537
  ; Print information about dimensions and attributes of a given varaiable
538
+ undef("printVar")
489
539
  procedure printVar(varname, filehandle)
490
540
  begin
491
541
  dims = getfilevardims(filehandle,varname)
@@ -590,9 +640,9 @@ end
590
640
  ;---------------------------------------------------------------
591
641
  ; set filename for the automatically remapped file
592
642
  undef("setRemapFilename")
593
- function setRemapFilename(filename,itype,resolution,atmlev)
643
+ function setRemapFilename(filename,itype,resolution,atmlev,operator)
594
644
  begin
595
- return setNewFilename(filename,"remapnn_"+resolution,itype,atmlev)
645
+ return setNewFilename(filename,operator+"_"+resolution,itype,atmlev)
596
646
  end
597
647
  undef("setZonmeanFilename")
598
648
  function setZonmeanFilename(filename,itype,atmlev)
@@ -600,7 +650,7 @@ begin
600
650
  return setNewFilename(filename,"zonmean",itype,atmlev)
601
651
  end
602
652
  ;---------------------------------------------------------------
603
- ; Check, if two files have the same number of timestemps. Exit otherwise
653
+ ; Check, if two files have the same number of time steps. Exit otherwise
604
654
  undef("checkRemappedFile")
605
655
  function checkRemappedFile(infilename,remapfilename,varname,itype,atmlev,atmplevs,atmhlevs)
606
656
  begin
@@ -676,13 +726,13 @@ end
676
726
  ; Perform a remapping (wich CDO) to a regular grid with a given resolution and return the
677
727
  ; filename of the remapped file. If the file is already present, the name is returned only
678
728
  undef("remapForVecPlot")
679
- procedure remapForVecPlot(iFile,remapFilename,resolution,useMask,plotMode,debug,addvars)
729
+ procedure remapForVecPlot(iFile,remapFilename,resolution,useMask,plotMode,debug,addvars,operator)
680
730
  begin
681
731
  if (plotMode.eq."section") then vecVars=(/varName/) end if
682
732
  print("#=====================================================================================")
683
733
  print("Looking for remapped file: "+remapFilename)
684
734
  print("Use CDO to perform remapping: Create intermediate file: "+remapFilename)
685
- print("Remove this intermediate file, if it was NOT automatically created from your inpur file "+iFile+"!")
735
+ print("Remove this intermediate file, if it was NOT automatically created from your input file "+iFile+"!")
686
736
  variables = str_join(vecVars,",")
687
737
  if ( addvars(0) .ne. "")
688
738
  variables = str_concat((/variables,",",str_join(addvars,",")/))
@@ -694,7 +744,7 @@ begin
694
744
  end if
695
745
  if (plotMode.eq."overlay") variables = variables+","+varName end if
696
746
 
697
- cmd = CDO+" -P 8 -remapnn,"+resolution+" -selname,"+variables+" "+iFile+" "+remapFilename
747
+ cmd = CDO+" -P 8 -"+operator+","+resolution+" -selname,"+variables+" "+iFile+" "+remapFilename
698
748
  if debug then
699
749
  print(cmd)
700
750
  end if
@@ -712,7 +762,7 @@ begin
712
762
  system(cmd)
713
763
  end
714
764
  ;---------------------------------------------------------------
715
- ; Return the bounds of the coordinates of agiven variable
765
+ ; Return the bounds of the coordinates of a given variable
716
766
  undef("getBoundsOfCoordinates")
717
767
  function getBoundsOfCoordinates(variable,filehandle)
718
768
  begin
@@ -729,7 +779,7 @@ begin
729
779
  return (/boundslon, boundslat/)
730
780
  end
731
781
  ;---------------------------------------------------------------
732
- ; Return the bounds of the coordinates of agiven variable
782
+ ; Return the bounds of the coordinates of a given variable
733
783
  undef("getBoundsFromFile")
734
784
  function getBoundsFromFile(lonname,latname,filename)
735
785
  begin
@@ -839,23 +889,12 @@ begin
839
889
  end if
840
890
  end
841
891
  ;---------------------------------------------------------------
842
- ; Create a default NCL resource
843
- undef("setDefaultResource")
844
- function setDefaultResource(verticallabelbar,withLines,withLineLabels,fillmode)
892
+ ; set the lines and their labels
893
+ undef("setLineAndLineLabels")
894
+ procedure setLineAndLineLabels(resource,withLines,withLineLabels)
845
895
  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
896
  ; lines/labels inside the plot ================================================
854
- if (withLines) then
855
- resource@cnLinesOn = True
856
- else
857
- resource@cnLinesOn = False
858
- end if
897
+ resource@cnLinesOn = False
859
898
  resource@cnLineLabelsOn = False
860
899
  if (withLineLabels ) then
861
900
  withLines = True
@@ -864,7 +903,23 @@ begin
864
903
  resource@cnLineLabelFontThicknessF = 0.006
865
904
  end if
866
905
  if (withLines) resource@cnLinesOn = True end if
906
+ end
907
+ ;---------------------------------------------------------------
908
+ ; Create a default NCL resource
909
+ undef("setDefaultResource")
910
+ function setDefaultResource(verticallabelbar,withLines,withLineLabels,fillmode,maptype)
911
+ begin
912
+ resource = True
913
+ resource@gsnMaximize = False
914
+ resource@gsnFrame = False
915
+ resource@gsnDraw = True
916
+ resource@gsnSpreadColors = True
917
+ resource@cnFillOn = True
918
+
919
+ resource@mapType = maptype
867
920
 
921
+ ; lines/labels inside the plot ================================================
922
+ setLineAndLineLabels(resource,withLines,withLineLabels)
868
923
  ; representation of missing values ===========================================
869
924
  delete(resource@cnMissingValFillPattern); no longer filling missing value areas
870
925
  delete(resource@cnMissingValFillColor); no longer filling missing value areas
@@ -909,7 +964,7 @@ begin
909
964
  end
910
965
  ;---------------------------------------------------------------
911
966
  undef("setDefaultSectionResource")
912
- function setDefaultSectionResource(points,secpoints,seclc,secrc)
967
+ function setDefaultSectionResource(points,secpoints,seclc,secrc,withLines,withLineLabels)
913
968
  begin
914
969
  resource = True; plot mods desired
915
970
  resource@gsnFrame = False; don't turn page yet
@@ -930,10 +985,6 @@ begin
930
985
  resource@cnFillOn = True; turn on color
931
986
  resource@lbLabelAutoStride = True; nice label bar label stride
932
987
  resource@gsnSpreadColors = True; use full range of colormap
933
- resource@cnLinesOn = False; turn off countour lines
934
- ; if (useContourLines)
935
- resource@cnLinesOn = False
936
- resource@cnLineLabelsOn = False
937
988
  resource@lbOrientation = "vertical"; vertical label bar
938
989
  resource@pmLabelBarOrthogonalPosF = -0.05; move label bar closer to plot
939
990
  resource@lbTitlePosition = "Bottom"
@@ -953,6 +1004,9 @@ begin
953
1004
  ;resource@gsnYAxisIrregular2Log = True
954
1005
  resource@cnFillMode = "RasterFill"
955
1006
  resource@cnRasterSmoothingOn = False
1007
+
1008
+ ; lines/labels inside the plot ================================================
1009
+ setLineAndLineLabels(resource,withLines,withLineLabels)
956
1010
  return resource
957
1011
  end
958
1012
  ;---------------------------------------------------------------
@@ -1026,7 +1080,8 @@ end
1026
1080
  undef("setBaseString")
1027
1081
  procedure setBaseString(workstation,plot,resource,basestring)
1028
1082
  begin
1029
- resource@txFontHeightF = 0.01 ; if this is changed, please adjust the implementation of getLshiftForNDCString()
1083
+ resource@txFontHeightF = 0.01 ; if this is changed, please adjust
1084
+ ; the implementation of getLshiftForNDCString()
1030
1085
  gsn_text_ndc(workstation,basestring,getLshiftForNDCString(basestring),.01,resource)
1031
1086
  end
1032
1087
  ;---------------------------------------------------------------
@@ -1268,10 +1323,12 @@ end
1268
1323
  undef("checkMinMaxVar")
1269
1324
  procedure checkMinMaxVar(minvar,maxvar)
1270
1325
  begin
1326
+ if ( (.not. ismissing(minvar)) .and. (.not. ismissing(maxvar)) ) then
1271
1327
  if ( minvar .gt. maxvar ) then
1272
1328
  print("minVar has to be larger than maxVar")
1273
1329
  exit
1274
1330
  end if
1331
+ end if
1275
1332
  end
1276
1333
  ;---------------------------------------------------------------
1277
1334
  ; set the color of masked locations
@@ -1282,13 +1339,53 @@ begin
1282
1339
  resource@cnMissingValPerimOn = True; turn on missing value outlines
1283
1340
  resource@cnMissingValPerimThicknessF = 2.5; set the missing value outline thickness
1284
1341
  end
1342
+ undef("setCoordsForResouce")
1343
+ procedure setCoordsForResouce(x,y,variable,resource)
1344
+ begin
1345
+ if (dimsizes(dimsizes(x)).ne.1) then
1346
+ variable@lon2d = x
1347
+ variable@lat2d = y
1348
+ end if
1349
+ resource@sfXArray = x
1350
+ resource@sfYArray = y
1351
+ end
1285
1352
  ;---------------------------------------------------------------
1286
1353
  ; set the coordinates for an ICON data field
1287
1354
  undef("setCoordinates")
1288
- procedure setCoordinates(resource,lons,lats)
1355
+ function setCoordinates(resource,filehandle,variable)
1289
1356
  begin
1290
- resource@sfXArray = lons
1291
- resource@sfYArray = lats
1357
+ ret = True
1358
+ if (isatt(variable,"coordinates")) then
1359
+ lonlat = str_split(variable@coordinates," ")
1360
+ lon = lonlat(0)
1361
+ lat = lonlat(1)
1362
+ else
1363
+ lon = "lon"
1364
+ lat = "lat"
1365
+ ret = False
1366
+ end if
1367
+ x = filehandle->$lon$
1368
+ y = filehandle->$lat$
1369
+ if ("radian" .eq. x@units) x = x * RAD2DEG end if
1370
+ if ("radian" .eq. y@units) y = y * RAD2DEG end if
1371
+
1372
+ setCoordsForResouce(x,y,variable,resource)
1373
+
1374
+ if (ret) then
1375
+ return (/x,y/)
1376
+ else
1377
+ return (/1,1/)
1378
+ end if
1379
+ end
1380
+ undef("setCoordinatesFromExtraFile")
1381
+ function setCoordinatesFromExtraFile(lon_name,lat_name,filename,variable,resource)
1382
+ begin
1383
+ x = getCoordinateFromFile(lon_name,filename)
1384
+ y = getCoordinateFromFile(lat_name,filename)
1385
+
1386
+ setCoordsForResouce(x,y,variable,resource)
1387
+
1388
+ return (/x,y/)
1292
1389
  end
1293
1390
  ;---------------------------------------------------------------
1294
1391
  ; set the coordinates bounds for an ICON data field
@@ -1361,7 +1458,7 @@ end
1361
1458
  undef("getVarLevelType")
1362
1459
  function getVarLevelType(filename,varname)
1363
1460
  begin
1364
- f = addfile(filename+".nc","r")
1461
+ f = addfile(filename,"r")
1365
1462
  vertdim = getVertDim(f,f->$varname$)
1366
1463
  if (ismissing(vertdim)) then
1367
1464
  delete(f)
@@ -1385,7 +1482,7 @@ begin
1385
1482
  gridtype = "unstructured"
1386
1483
  else
1387
1484
  print("CDO:"+CDO)
1388
- print("Call cdo griddes for determine the horizontal gridtype")
1485
+ print("Call cdo griddes to determine the horizontal gridtype")
1389
1486
  gridtype = systemfunc(CDO+" -griddes -selname,"+varname+" -seltimestep,1 "+filename+" | grep gridtype | cut -d ' ' -f 4")
1390
1487
  end if
1391
1488
  print("Found horizontal grid of type: "+gridtype)
@@ -1408,7 +1505,7 @@ begin
1408
1505
 
1409
1506
  lats = fspan(startLat,endLat,npoints)
1410
1507
  lons = fspan(startLon,endLon,npoints)
1411
- ; dont let the lons be greater than 360, because theses values will not be in
1508
+ ; don't let the lons be greater than 360, because these values will not be in
1412
1509
  ; the data. Otherwise an interpolation error will occur
1413
1510
  lons = where(lons.gt.360, lons-360.0, lons)
1414
1511
 
@@ -1531,7 +1628,7 @@ begin
1531
1628
  var_at_p@units = var@units
1532
1629
  var_at_p@long_name = var@long_name
1533
1630
 
1534
- extrapolate = True ; switch for doing extrapolation below the ground:
1631
+ extrapolate = True ; switch to do extrapolation below the ground:
1535
1632
  intmethod = 1 ; 1: method for temperature, -1: method for geopotential, 0: other vars
1536
1633
  tlow = var(nlevels-1,:,:) ; temperature at lowest model level
1537
1634
  ; (use ground temperature if available)
@@ -1641,7 +1738,7 @@ begin
1641
1738
  var_at_p@units = theta3d@units
1642
1739
  var_at_p@long_name = theta3d@long_name
1643
1740
 
1644
- extrapolate = True ; switch for doing extrapolation below the ground:
1741
+ extrapolate = True ; switch to do extrapolation below the ground:
1645
1742
  intmethod = 1 ; 1: method for temperature, -1: method for geopotential, 0: other vars
1646
1743
  tlow = theta3dll(nlevels-1,:,:) ; temperature at lowest model level
1647
1744
  ; (use ground temperature if available)
@@ -1661,6 +1758,11 @@ undef("getFlags")
1661
1758
  function getFlags(var,boundslon,boundslat,resource)
1662
1759
  begin
1663
1760
  flags = new(dimsizes(var),logical,"No_FillValue")
1761
+
1762
+ if (resource@mapType .EQ. "NHps" .OR. resource@mapType .EQ. "SHps") then
1763
+ flags = True
1764
+ return flags
1765
+ end if
1664
1766
  do i = 0,dimsizes(var) - 1
1665
1767
  flags(i) = where(all(boundslon(i,:) .gt. resource@mpMaxLonF) .or. \
1666
1768
  all(boundslon(i,:) .lt. resource@mpMinLonF) .or. \
@@ -1764,7 +1866,7 @@ begin
1764
1866
  if (.not. ismissing(vhig(0))) then
1765
1867
  do j = 0, dimsizes(vhig) -1
1766
1868
  pres@gsFillColor = colors(i+1)
1767
- if ( flags(vhig(i))) then
1869
+ if ( flags(vhig(j))) then
1768
1870
  gsn_polygon(wks,plot,boundslon(vhig(j),:),boundslat(vhig(j),:),pres)
1769
1871
  end if
1770
1872
  end do
@@ -1811,6 +1913,50 @@ begin
1811
1913
  performGridPlot(variable,levels,colors,boundslon,boundslat,workstation,plot,flags,debug)
1812
1914
  end
1813
1915
  ;---------------------------------------------------------------
1916
+ ; Plot the ICON grid: New version, req. ncl 6.2
1917
+ undef("plotGrid_62")
1918
+ function plotGrid_62(wks,plot,var,boundslon,boundslat)
1919
+ begin
1920
+ pres = True
1921
+ pres@gsEdgesOn = True ; Turn on edges
1922
+ pres@gsFillIndex = 0 ; Solid fill, the default
1923
+ ;---Create color array for triangles
1924
+ ntri = dimsizes(var) ;-- Number of triangles
1925
+ gscolors = new(ntri,integer)
1926
+ gscolors = -1 ;-- Initialize to transparent
1927
+
1928
+ getvalues plot@contour
1929
+ "cnLevels" : levels
1930
+ "cnFillColors" : colors
1931
+ end getvalues
1932
+ ;---All triangles less than lowest level
1933
+ vind = ind(var .lt. levels(0))
1934
+ if(.not.all(ismissing(vind))) then
1935
+ gscolors(vind) = colors(0)
1936
+ end if
1937
+
1938
+ ;---All triangles inbetween levels
1939
+ do i = 1, dimsizes(levels) - 1
1940
+ vind := ind(var .ge. levels(i-1) .and. var .lt. levels(i))
1941
+ if(.not.all(ismissing(vind))) then
1942
+ gscolors(vind) = colors(i)
1943
+ end if
1944
+ end do
1945
+
1946
+ ;---All triangles higher than highest level
1947
+ delete(vind)
1948
+ vind = ind(var .ge. levels(dimsizes(levels)-1))
1949
+ if(.not.all(ismissing(vind))) then
1950
+ gscolors(vind) = colors(dimsizes(levels)-1)
1951
+ end if
1952
+
1953
+ pres@gsColors = gscolors
1954
+ pres@gsSegments = ispan(0,dimsizes(var) * 3,3)
1955
+
1956
+ return pres
1957
+ ; }}}
1958
+ end
1959
+ ;---------------------------------------------------------------
1814
1960
  ; read in mask variable
1815
1961
  undef("readMaskVar")
1816
1962
  function readMaskVar()
@@ -1822,10 +1968,11 @@ undef("plotVecOrStream")
1822
1968
  function plotVecOrStream(useScalar,useStreamlines,uvar,vvar,scalarvar,resource,workstation,showMap)
1823
1969
  begin
1824
1970
  ; 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
1971
+ resource@stArrowStride = 4; arrows start every third
1972
+ resource@stArrowLengthF = 0.0015; default is dynamic
1973
+ resource@stMinDistanceF = 0.008; streamline dist
1974
+ resource@stLineThicknessF = 1.0; streamline thickness
1975
+ ; resource@stCrossoverCheckCount = 100;
1829
1976
  if (useScalar) then
1830
1977
  if (useStreamlines) then
1831
1978
  if (showMap)
@@ -1857,6 +2004,25 @@ begin
1857
2004
  end if
1858
2005
  return vc
1859
2006
  end
2007
+ ;---------------------------------------------------------------
2008
+ ; limit the map to given coords
2009
+ undef("limitMap2Coords")
2010
+ procedure limitMap2Coords(resource)
2011
+ begin
2012
+ lons = resource@sfXArray
2013
+ lats = resource@sfYArray
2014
+ resource@mpMinLatF = floor(min(lats))
2015
+ resource@mpMaxLatF = ceil(max(lats))
2016
+ resource@mpMinLonF = floor(min(lons))
2017
+ resource@mpMaxLonF = ceil(max(lons))
2018
+
2019
+
2020
+ ; bounds of plotting area for stereographic plots
2021
+ resource@mpLeftCornerLonF = floor(min(lons))
2022
+ resource@mpLeftCornerLatF = floor(min(lats))
2023
+ resource@mpRightCornerLonF = ceil(max(lons))
2024
+ resource@mpRightCornerLatF = ceil(max(lats))
2025
+ end
1860
2026
 
1861
2027
  ;
1862
2028
  ; vim:ft=ncl
@@ -1,8 +1,8 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
- require "test/unit"
2
+ require "minitest/autorun"
3
3
  require "iconPlot"
4
4
 
5
- class TestIconPlot < Test::Unit::TestCase
5
+ class TestIconPlot < Minitest::Test
6
6
 
7
7
  CALLER = "/home/ram/src/git/icon/scripts/postprocessing/tools/contrib/nclsh"
8
8
  PLOTTER = "/home/ram/src/git/icon/scripts/postprocessing/tools/icon_plot.ncl"
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iconPlot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ralf Mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-26 00:00:00.000000000 Z
11
+ date: 2014-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cdo
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: extcsv
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: gnuplot
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: 'Plot with ncl via Ruby: requires NCL 6.* and CDO 1.5.*'
@@ -59,9 +59,9 @@ executables:
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - lib/iconPlot.rb
63
- - gemspec
64
62
  - bin/nclsh
63
+ - gemspec
64
+ - lib/iconPlot.rb
65
65
  - lib/icon_plot.ncl
66
66
  - lib/icon_plot_lib.ncl
67
67
  - test/test_iconPlot.rb
@@ -75,17 +75,17 @@ require_paths:
75
75
  - lib
76
76
  required_ruby_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - '>='
78
+ - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: '1.8'
81
81
  required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - '>='
83
+ - - ">="
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
87
  rubyforge_project:
88
- rubygems_version: 2.0.0
88
+ rubygems_version: 2.2.2
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: Plot ICON output with ncl via Ruby