In [1]:
require 'nyaplot'
require 'mapnya'
Out[1]:
Out[1]:
Out[1]:
true

Case3: Plot wind vectors on the map

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]:
indexlatlonuwndvwnd
0-78.3750.1251.733504295349121-3.9492156505584717
10-78.3752.6252.0234389305114746-4.730513095855713
20-78.3755.1252.0112311840057373-5.069279193878174
30-78.3757.6251.748763918876648-5.585057735443115
40-78.37510.1251.1780503988265991-6.186290740966797
50-78.37512.6251.2970762252807617-5.874992370605469
60-78.37515.1250.9491546154022217-5.469083786010742
70-78.37517.6250.47915521264076233-5.066226959228516
80-78.37520.1250.21973997354507446-4.443630695343018
90-78.37522.625-0.5310382843017578-4.147592067718506
100-78.37525.125-0.9644143581390381-3.9125924110412598
110-78.37527.625-0.6531160473823547-3.5921382904052734
120-78.37530.125-1.0376609563827515-3.26252818107605
130-78.37532.625-1.287920355796814-2.7162301540374756
140-78.37535.125-1.0620765686035156-2.151620626449585
150-78.37537.625-0.4455838203430176-1.2024660110473633
...............
89423076.625357.6254.303241252899175.511810779571533
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]: