In [1]:
require 'nyaplot'
require 'mapnya'
Out[1]:
Out[1]:
Out[1]:
Next, let's generate plot vectors on the map. I prepared the data of wind vectors on 2011/01/01, from the website of NASA poddac. I converted NetCDF distributed in the database to CSV file with ruby-netcdf.
In [2]:
path = File.expand_path("../data/wind.csv", __FILE__)
df = Nyaplot::DataFrame.from_csv(path)
Out[2]:
In [3]:
# Evil pre-processing of data
df.filter!{|row| !(row[:lon] < 200 && row[:lon] > 175)}
df.each_row{|row| row[:uwnd] = row[:uwnd]/3; row[:vwnd] = row[:vwnd]/3}
""
Out[3]:
In [4]:
plot = Nyaplot::MapPlot.new
vectors = plot.add_with_df(df, :vectors, :lon, :lat)
vectors.dx(:uwnd)
vectors.dy(:vwnd)
plot.show
Out[4]:
That generally looks good, but I'd like to fill each vector in different color according to its length.
In [5]:
abs = []
df.each_row{|row| abs.push(Math.sqrt(row[:uwnd]*row[:uwnd]+row[:vwnd]*row[:vwnd]))}
df.abs = abs
df
Out[5]:
In [6]:
vectors.fill_by(:abs)
plot.show
Out[6]:
In [7]:
color = Nyaplot::Colors.OrRd(3)
Out[7]:
In [8]:
vectors.color(color)
plot.show
Out[8]:
This notebook was created as the demonstration of Nyaplot.