iconPlot 0.0.3 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/gemspec +1 -1
  2. data/lib/iconPlot.rb +20 -5
  3. data/test/test_iconPlot.rb +28 -15
  4. metadata +25 -10
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.3'
6
+ s.version = '0.0.6'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.files = ["lib/iconPlot.rb"] + ["gemspec"] + ["contrib/nclsh"] + Dir.glob("lib/*ncl")
9
9
  s.test_file = "test/test_iconPlot.rb"
data/lib/iconPlot.rb CHANGED
@@ -3,7 +3,9 @@ require 'cdo'
3
3
  require 'extcsv'
4
4
  require 'shellwords'
5
5
 
6
- class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug)
6
+ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug,:isIcon)
7
+ VERSION = '0.0.4'
8
+
7
9
  def IconPlot.gemPath
8
10
  gemSearcher = Gem::GemPathSearcher.new
9
11
  gemspec = gemSearcher.find('iconPlot')
@@ -20,6 +22,7 @@ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug
20
22
  :otype => 'png',
21
23
  :display => 'sxiv',
22
24
  :cdo => ENV['CDO'].nil? ? 'cdo' : ENV['CDO'],
25
+ :isIcon => true,
23
26
  :debug => false
24
27
  }
25
28
  self.each_pair {|k,v| self[k] = defaults[k] if v.nil? }
@@ -41,7 +44,9 @@ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug
41
44
  opts[:tStrg] =ofile
42
45
 
43
46
  cmd = [self.caller,self.plotter].join(' ')
44
- cmd << " -altLibDir=#{self.libdir} #{varIdent} -iFile=#{ifile} -oFile=#{ofile} -oType=#{self.otype} -isIcon -DEBUG"
47
+ cmd << " -altLibDir=#{self.libdir} #{varIdent} -iFile=#{ifile} -oFile=#{ofile} -oType=#{self.otype}"
48
+ cmd << " -isIcon" if self.isIcon
49
+ cmd << " -DEBUG" if self.debug
45
50
  opts.each {|k,v| cmd << " -"<< [k,v].join('=') }
46
51
  puts cmd if self.debug
47
52
  out = IO.popen(cmd).read
@@ -56,7 +61,6 @@ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug
56
61
  plot(ifile,ofile,varname,'vector',opts)
57
62
  end
58
63
  def levelPlot(ifile,ofile,varname,opts={})
59
- Cdo.setCdo('/home/ram/src/cdo/trunk/cdo/build/bin/cdo')
60
64
  operation = opts[:operation].nil? ? 'fldmin' : opts[:operation]
61
65
 
62
66
  data = createData(ifile,varname,operation)
@@ -83,7 +87,18 @@ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug
83
87
  :output_time_format => '"%d.%m.%y \n %H:%M"',:size => "1600,600")
84
88
  return "#{ofile}.png"
85
89
  end
86
- def scatterPlot(ifile,ofile,varname,opts={})
90
+ def scatterPlot(ifile,ofile,xVarname,yVarname,opts={})
91
+ # is there a variable which discribes different regions in the ocean
92
+ regionVar = opts[:regionVar].nil? ? 'rregio_c' : opts[:regionVar]
93
+ hasRegion = Cdo.showname(:in => ifile).join.split.include?(regionName)
94
+ unless hasRegion
95
+ warn "Variable '#{regionName}' for showing regions is NOT found in the input '#{ifile}'!"
96
+ warn "Going on without plotting regions!"
97
+ varnames = varnames[0,2]
98
+ groupBy = []
99
+ else
100
+ groupBy = [regionName]
101
+ end
87
102
  end
88
103
 
89
104
  def del(file)
@@ -93,7 +108,7 @@ class IconPlot < Struct.new(:caller,:plotter,:libdir,:otype,:display,:cdo,:debug
93
108
  files.flatten.each {|file| IO.popen("#{self.display} #{file} &") }
94
109
  end
95
110
  def defaultPlot(ifile,ofile,opts={})
96
- show(scalarPlot(ifile,ofile,DEFAULT_VARNAME,opts))
111
+ show(scalarPlot(ifile,ofile,'T',opts))
97
112
  end
98
113
  def showVector(ifile,ofile,vars,opts={})
99
114
  show(vectorPlot(ifile,ofile,vars,opts))
@@ -4,25 +4,38 @@ require "iconPlot"
4
4
 
5
5
  class TestIconPlot < Test::Unit::TestCase
6
6
 
7
- CALLER = "/home/ram/src/git/icon/scripts/postprocessing/tools/contrib/nclsh"
8
- PLOTTER= "/home/ram/src/git/icon/scripts/postprocessing/tools/icon_plot.ncl"
9
- PLOTLIB = "/home/ram/src/git/icon/scripts/postprocessing/tools"
10
- LS = 'ls -crtlh'
11
- OCE_PLOT_TEST_FILE = ENV['HOME']+'/data/icon/oce.nc'
12
- OCELONG_PLOT_TEST_FILE = ENV['HOME']+'/data/icon/oceLong.nc'
13
- ATM_PLOT_TEST_FILE = ENV['HOME']+'/data/icon/atm.nc'
14
- OCE_REGPLOT_TEST_FILE = ENV['HOME']+'/data/icon/regular_oce.nc' #remapnn,r180x90
15
- ATM_REGPLOT_TEST_FILE = ENV['HOME']+'/data/icon/regular_atm.nc' #remapnn,n63 (no sections), r180x90 (with sections)
16
- OFMT = 'png'
17
- PLOT_CMD = 'sxiv'
18
- CDO = ENV['CDO'].nil? ? 'cdo' : ENV['CDO']
7
+ CALLER = "/home/ram/src/git/icon/scripts/postprocessing/tools/contrib/nclsh"
8
+ PLOTTER = "/home/ram/src/git/icon/scripts/postprocessing/tools/icon_plot.ncl"
9
+ PLOTLIB = "/home/ram/src/git/icon/scripts/postprocessing/tools"
10
+ LS = 'ls -crtlh'
11
+ OCE_PLOT_TEST_FILE = ENV['HOME']+'/data/icon/oce.nc'
12
+ OCELSM_PLOT_TEST_FILE = ENV['HOME']+'/data/icon/oce_lsm.nc'
13
+ OCELONG_PLOT_TEST_FILE = ENV['HOME']+'/data/icon/oceLong.nc'
14
+ ATM_PLOT_TEST_FILE = ENV['HOME']+'/data/icon/atm.nc'
15
+ OCE_REGPLOT_TEST_FILE = ENV['HOME']+'/data/icon/regular_oce.nc' #remapnn,r180x90
16
+ ATM_REGPLOT_TEST_FILE = ENV['HOME']+'/data/icon/regular_atm.nc' #remapnn,n63 (no sections), r180x90 (with sections)
17
+ OFMT = 'png'
18
+ PLOT_CMD = 'sxiv'
19
+ CDO = ENV['CDO'].nil? ? 'cdo' : ENV['CDO']
19
20
  if 'thingol' == `hostname`.chomp
20
21
  def test_simple
21
22
  ip = IconPlot.new(CALLER,PLOTTER,PLOTLIB,OFMT,PLOT_CMD,CDO,true)
22
23
  ofile = 'test_icon_plot'
23
- ip.show(ip.scalarPlot(OCE_PLOT_TEST_FILE,ofile,"T",:levIndex => 0))
24
- ip.show(ip.scalarPlot(OCE_PLOT_TEST_FILE,ofile,"T",:levIndex => 2))
25
- ip.show(ip.vectorPlot(OCE_PLOT_TEST_FILE,ofile,"u-veloc v-veloc",:levIndex => 2))
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'))
32
+ ip.isIcon = false
33
+ ip.show(ip.scalarPlot("remapnn_r90x45_oce.nc","reg_"+ofile,"T",:levIndex => 2,:mapType => "ortho"))
34
+ ip.show(ip.scalarPlot("remapnn_r90x45_oce.nc","reg_"+ofile,"T",:vecVars => "u-veloc,v-veloc",:levIndex => 2,:mapType => "ortho"))
35
+ ip.show(ip.scalarPlot("remapnn_r90x45_oce_lsm.nc","reg_lsm_"+ofile,"T",:levIndex => 2,:mapType => "ortho",:maskName => 'wet_c'))
36
+ ip.show(ip.scalarPlot("remapnn_r90x45_oce_lsm.nc","reg_lsm_"+ofile,"wet_c",:mapType => "ortho"))
37
+ ip.show(ip.scalarPlot("remapnn_r90x45_oce_lsm.nc","reg_lsm_"+ofile,"T",:vecVars => "u-veloc,v-veloc",:levIndex => 2,:mapType => "ortho",:maskName => 'wet_c'))
38
+ ip.show(ip.scalarPlot("remapnn_r90x45_oce_lsm.nc","reg_lsm_"+ofile,"wet_c",:vecVars => "u-veloc,v-veloc",:levIndex => 2,:mapType => "ortho",:maskName => 'wet_c'))
26
39
  end
27
40
  end
28
41
  def test_defaults
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iconPlot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-07 00:00:00.000000000 Z
12
+ date: 2012-09-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cdo
16
- requirement: &16945020 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *16945020
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: extcsv
27
- requirement: &16944200 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *16944200
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: gnuplot
38
- requirement: &16943700 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,7 +53,12 @@ dependencies:
43
53
  version: '0'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *16943700
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  description: ! 'Plot with ncl via Ruby: requires NCL 6.* and CDO 1.5.*'
48
63
  email: stark.dreamdetective@gmail.com
49
64
  executables: []
@@ -53,8 +68,8 @@ files:
53
68
  - lib/iconPlot.rb
54
69
  - gemspec
55
70
  - contrib/nclsh
56
- - lib/icon_plot_lib.ncl
57
71
  - lib/icon_plot.ncl
72
+ - lib/icon_plot_lib.ncl
58
73
  - test/test_iconPlot.rb
59
74
  homepage: https://github.com/Try2Code/iconPlot
60
75
  licenses:
@@ -77,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
92
  version: '0'
78
93
  requirements: []
79
94
  rubyforge_project:
80
- rubygems_version: 1.8.17
95
+ rubygems_version: 1.8.23
81
96
  signing_key:
82
97
  specification_version: 3
83
98
  summary: Plot ICON output with ncl via Ruby