Weather Data


In [1]:
using NetCDF

state_fips = ncread("../../data/cache/VIC_WB.nc", "state_fips")
months = round(ncread("../../data/cache/VIC_WB.nc", "month") * 12) % 12 + 1
precips = ncread("../../data/cache/VIC_WB.nc", "precip")[:, state_fips .== 8]


Out[1]:
735x63 Array{Float64,2}:
 80.9421   23.2225     49.7776   31.0619   …   46.8257    25.8622   13.4922 
  7.19915   0.397663    9.98583   1.33809      16.6845    25.9992   10.4059 
 43.337     3.07018    47.4247    2.98945      48.251     59.3302   25.427  
 48.5522    8.5639    108.946     5.12435      47.9639    75.1218   29.5475 
 13.5056    4.70976    38.2183    6.77846      39.2891    44.8227   18.3014 
 30.3067    6.45764    43.5227   11.7985   …   23.3097    28.372    15.6408 
 79.8451   35.8371    102.288    31.1096       25.245     28.3513    9.3598 
 34.8194   56.1155     67.0395   63.5881        6.44941    6.60298   3.11528
  3.64145  32.3701      6.54523  30.2011       23.6286    23.3887   26.9145 
 28.1697   52.5523     25.702    52.4673       48.8681    55.2244   42.2629 
  7.46783  10.7678     15.4505   48.9814   …   15.2583    13.7822   25.4263 
 57.1172   38.0723     76.4987   78.3945       85.009     64.9822   30.7055 
  6.42094   3.6941      9.23765   4.51532       7.07927   10.3954    6.22383
  ⋮                                        ⋱    ⋮                           
 12.3932    1.94321    23.6492    0.95867      97.8404    89.2237   44.4827 
 18.7032   12.9799     31.9083   15.6389       71.3631    52.1513   21.515  
 38.3992   23.5363     42.9483   25.5425   …   33.98      40.8687   27.46   
 61.1956   83.0964    105.662    68.3372       32.8899    46.633    27.373  
 36.9613   64.7583     86.6594   44.8885        3.62764    4.94862   4.38583
 32.7463   81.8857     47.2219   73.0667        3.7209     4.98819   2.64498
 21.8803   41.7827     35.1843   70.6321       62.0158    75.1243   50.7568 
 32.0988   38.3635     37.7202   66.2419   …   67.4909    70.0131   39.5582 
 11.985     0.550646    9.72163   2.65026      48.292     41.2662   20.022  
 44.595    22.0301    103.307    22.5949       59.8785    41.6178   19.6173 
 41.7536   14.6933     61.0696   17.6512       19.8509    16.1954    6.21322
 99.5385    6.65103    91.0438   12.4264      103.758    112.674    51.0261 

In [2]:
means = map(month -> mean(precips[months .== month, :]), 1:12)


Out[2]:
12-element Array{Float64,1}:
 31.7119
 29.2682
 42.6037
 49.764 
 54.6176
 40.5895
 55.5956
 53.6448
 39.1617
 36.1202
 32.5774
 32.2326

In [5]:
using DataFrames
using Gadfly

plot(DataFrame(month=1:12, mean=means), x="month", y="mean", Geom.bar)


Out[5]:
month -20 -15 -10 -5 0 5 10 15 20 25 30 35 -15.0 -14.5 -14.0 -13.5 -13.0 -12.5 -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5 -7.0 -6.5 -6.0 -5.5 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5 15.0 15.5 16.0 16.5 17.0 17.5 18.0 18.5 19.0 19.5 20.0 20.5 21.0 21.5 22.0 22.5 23.0 23.5 24.0 24.5 25.0 25.5 26.0 26.5 27.0 27.5 28.0 28.5 29.0 29.5 30.0 -20 0 20 40 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 mean

In [40]:
include("../../src/lib/readconfig.jl")
config = readconfig("../configs/complete.yml")
include("../../src/world.jl")
include("../../src/weather.jl")


Loading from saved region network...
Loading from saved water network...
Out[40]:
22559x735 Array{Float64,2}:
 168.311      37.1514     44.4302      …   14.9931    29.9789   211.896  
 163.959      39.7827     41.4199          17.5238    30.0023   194.012  
 190.818     108.967     122.75            50.7323   129.942    334.274  
 235.508     147.689     184.279           53.2637   178.776    389.112  
 151.524      68.1682     85.1841          13.2926    42.9184   102.997  
 151.524      68.1682     85.1841      …   13.2926    42.9184   102.997  
 298.93      306.301     347.366          222.786    272.575    353.904  
 302.105     335.032     380.873          256.153    290.027    409.078  
 104.391      85.4356    167.708           47.7566   158.387    249.194  
 104.391      85.4356    167.708           47.7566   158.387    249.194  
 221.438     188.661     249.85        …   63.5426   160.052    219.227  
 196.507     155.471     211.243           63.8892   161.184    240.363  
   0.797948    0.122984    0.00203041       1.91141    1.18491    3.07928
   ⋮                                   ⋱                                 
   0.0         0.0         0.0              0.0        0.0        0.0    
   0.0         0.0         0.0              0.0        0.0        0.0    
   0.0         0.0         0.0              0.0        0.0        0.0    
   0.0         0.0         0.0         …    0.0        0.0        0.0    
   0.0         0.0         0.0              0.0        0.0        0.0    
   0.0         0.0         0.0              0.0        0.0        0.0    
   0.0         0.0         0.0              0.0        0.0        0.0    
   0.0         0.0         0.0              0.0        0.0        0.0    
   0.0         0.0         0.0         …    0.0        0.0        0.0    
   0.0         0.0         0.0              0.0        0.0        0.0    
   0.0         0.0         0.0              0.0        0.0        0.0    
   0.0         0.0         0.0              0.0        0.0        0.0    

In [45]:
months2 = (parsemonth(config["startmonth"]):config["timestep"]:parsemonth(config["endmonth"])) % 12 + 1
getprecip2(month) = precip[map(fips -> fips[1:2], mastercounties[:fips]) .== "08", months2 .== month]
means2 = map(month -> mean(dropna(vec(getprecip2(month)))), 1:12)


Out[45]:
12-element Array{Float64,1}:
 32.2326
 31.7119
 29.2682
 42.6037
 49.764 
 54.6176
 40.5895
 55.5956
 53.6448
 39.1617
 36.1202
 32.5774

In [46]:
plot(DataFrame(month=1:12, mean=means2), x="month", y="mean", Geom.bar)


Out[46]:
month -20 -15 -10 -5 0 5 10 15 20 25 30 35 -15.0 -14.5 -14.0 -13.5 -13.0 -12.5 -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5 -7.0 -6.5 -6.0 -5.5 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5 15.0 15.5 16.0 16.5 17.0 17.5 18.0 18.5 19.0 19.5 20.0 20.5 21.0 21.5 22.0 22.5 23.0 23.5 24.0 24.5 25.0 25.5 26.0 26.5 27.0 27.5 28.0 28.5 29.0 29.5 30.0 -20 0 20 40 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 mean

In [ ]: