October 4 Open House

Harold Nelson

10/4/2018

How’s the Weather?

This little presentation looks at weather for the Olympia area. If you’re new, what should you expect over the next few months?

I thought that last July was unusually hot. Was it different?

olyw1018 <- read_csv("~/Dropbox/RProjects/Oly Weather/olyw100118.csv", col_types = cols(DATE = col_character(),SNOW = col_double(), TMAX =col_double(),TMIN = col_double()))

Look at the data and see what we have.

str(olyw1018)
## Classes 'tbl_df', 'tbl' and 'data.frame':    53034 obs. of  6 variables:
##  $ STATION_NAME: chr  "OLYMPIA PRIEST PT PA WA US" "OLYMPIA PRIEST PT PA WA US" "OLYMPIA PRIEST PT PA WA US" "OLYMPIA PRIEST PT PA WA US" ...
##  $ DATE        : chr  "18770701" "18770702" "18770703" "18770704" ...
##  $ PRCP        : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ SNOW        : num  -9999 -9999 -9999 -9999 -9999 ...
##  $ TMAX        : num  63 63 67 67 71 74 80 88 81 70 ...
##  $ TMIN        : num  48 53 45 45 43 49 49 50 57 57 ...
##  - attr(*, "spec")=List of 2
##   ..$ cols   :List of 6
##   .. ..$ STATION_NAME: list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ DATE        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_character" "collector"
##   .. ..$ PRCP        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_double" "collector"
##   .. ..$ SNOW        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_double" "collector"
##   .. ..$ TMAX        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_double" "collector"
##   .. ..$ TMIN        : list()
##   .. .. ..- attr(*, "class")= chr  "collector_double" "collector"
##   ..$ default: list()
##   .. ..- attr(*, "class")= chr  "collector_guess" "collector"
##   ..- attr(*, "class")= chr "col_spec"
summary(olyw1018)
##  STATION_NAME           DATE                PRCP         
##  Length:53034       Length:53034       Min.   :-9999.00  
##  Class :character   Class :character   1st Qu.:    0.00  
##  Mode  :character   Mode  :character   Median :    0.00  
##                                        Mean   : -126.37  
##                                        3rd Qu.:    0.14  
##                                        Max.   :    4.82  
##                                                          
##       SNOW              TMAX                TMIN          
##  Min.   :-9999.0   Min.   :-9999.000   Min.   :-9999.000  
##  1st Qu.:-9999.0   1st Qu.:   50.000   1st Qu.:   34.000  
##  Median :    0.0   Median :   59.000   Median :   41.000  
##  Mean   :-4119.4   Mean   :    6.775   Mean   :   -6.512  
##  3rd Qu.:    0.0   3rd Qu.:   71.000   3rd Qu.:   47.000  
##  Max.   :   14.2   Max.   :  104.000   Max.   :   76.000  
##  NA's   :7

Fix the dates

olyw1018$DATE = gsub('-','',olyw1018$DATE) 
olyw1018$DATE = ymd(olyw1018$DATE)

Fix the rest of the problems.

olyw1018 %>% mutate(TMAX = ifelse(TMAX == -9999,NA,TMAX),
       TMIN = ifelse(TMIN == -9999,NA,TMIN),
SNOW = ifelse(SNOW == -9999,0,SNOW), 
PRCP = ifelse(PRCP == -9999,0,PRCP), 
       yr = year(DATE),
       mo = month(DATE),
       dy = day(DATE)) %>% 
filter(complete.cases(olyw1018)) %>% 
filter(yr >= 1948) -> olyw1018

save(olyw1018,file="olyw1018.rdata")

The Data

The dataset contains daily observations of weather from July 1948 forward.

summary(olyw1018)
##  STATION_NAME            DATE                 PRCP       
##  Length:28705       Min.   :1948-01-01   Min.   :0.0000  
##  Class :character   1st Qu.:1959-10-04   1st Qu.:0.0000  
##  Mode  :character   Median :1979-05-28   Median :0.0000  
##                     Mean   :1980-03-14   Mean   :0.1404  
##                     3rd Qu.:1999-01-21   3rd Qu.:0.1400  
##                     Max.   :2018-09-21   Max.   :4.8200  
##                                                          
##       SNOW               TMAX             TMIN             yr      
##  Min.   : 0.00000   Min.   : 18.00   Min.   :-8.00   Min.   :1948  
##  1st Qu.: 0.00000   1st Qu.: 50.00   1st Qu.:33.00   1st Qu.:1959  
##  Median : 0.00000   Median : 59.00   Median :40.00   Median :1979  
##  Mean   : 0.03357   Mean   : 60.45   Mean   :39.85   Mean   :1980  
##  3rd Qu.: 0.00000   3rd Qu.: 71.00   3rd Qu.:47.00   3rd Qu.:1999  
##  Max.   :14.20000   Max.   :104.00   Max.   :69.00   Max.   :2018  
##                     NA's   :13       NA's   :14                    
##        mo               dy       
##  Min.   : 1.000   Min.   : 1.00  
##  1st Qu.: 4.000   1st Qu.: 8.00  
##  Median : 7.000   Median :16.00  
##  Mean   : 6.501   Mean   :15.72  
##  3rd Qu.: 9.000   3rd Qu.:23.00  
##  Max.   :12.000   Max.   :31.00  
## 

Prediction

Let’s create a permanent weather prediction for any future year based on average historical values for each day.

All of the Data

Here’s a graph showing all of the historical values.

2018 Enhanced

Here’s the same graph with 2018 values enhanced.

Replace the cloud with a smoother.

Median Maximum Temperature

Rain?