-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecdf-density.Rmd
executable file
·84 lines (66 loc) · 2.16 KB
/
ecdf-density.Rmd
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
title: "R Notebook"
output:
html_notebook: default
pdf_document: default
---
```{r include=FALSE}
knitr::opts_chunk$set(fig.width = 7, fig.height = 4, fig.align = "center", out.width = '80%')
```
# Preamble
First we load the dataset
```{r message=FALSE}
# Source base code -----------------------------------------
source("hadisst_base.R")
source("hurdat2_pdi_base.R")
source("analysis_base.R")
# Create PDI data frame ------------------------------------
# Get hurricanes data frames
hurr.natl.obs <- get_hurr_obs("hurdat2-1851-2016-apr2017.txt")
hurr.epac.obs <- get_hurr_obs("hurdat2-nepac-1949-2016-apr2017.txt")
hurr.all.obs <- rbind(hurr.natl.obs, hurr.epac.obs)
# Create data frame with PDI and year of the storm
hurr.natl.pdi <- get_pdis(hurr.natl.obs) %>%
filter(storm.id != "AL171988")
attr(hurr.natl.pdi, "title") <- "N. Atl."
hurr.epac.pdi <- get_pdis(hurr.epac.obs) %>%
filter(storm.id != "EP231989")
attr(hurr.epac.pdi, "title") <- "E. Pac."
hurr.all.pdi <- get_pdis(hurr.all.obs)
# Create SST data frames -----------------------------------
hadsst.raster <- load_hadsst(file = "data/HadISST_sst.nc")
# Windows of activity
years.natl <- 1966:2016
coords.natl <- c("90W", "20E", "5N", "25N")
coords.natl.map <- c("100W", "20E", "0N", "60N")
years.epac <- 1966:2016
coords.epac <- c("120W", "90W", "5N", "20N")
coords.epac.map <- c("160W", "90W", "5N", "35N")
# Construct SST data frames
ssts.natl <- get_mean_ssts(years = years.natl, coords = coords.natl)
attr(ssts.natl, "title") <- "N. Atl."
ssts.epac <- get_mean_ssts(years = years.epac, coords = coords.epac)
attr(ssts.epac, "title") <- "E. Pac."
```
# ECDF & Density functions (PDI / energy)
```{r}
plot(density(hurr.natl.pdi$storm.pdi))
ggplot(hurr.natl.pdi, aes(storm.pdi)) +
stat_density(geom = "line")
```
```{r}
plot(ecdf(hurr.all.pdi$storm.pdi))
ggplot(hurr.natl.pdi, aes(storm.pdi)) +
stat_ecdf(geom = "line")
```
# ECDF & Density functions (duration)
```{r}
plot(density(hurr.natl.pdi$storm.duration))
ggplot(hurr.natl.pdi, aes(storm.duration)) +
stat_density(geom = "line")
```
```{r}
plot(ecdf(hurr.natl.pdi$storm.duration))
ggplot(hurr.natl.pdi, aes(storm.duration)) +
stat_ecdf(geom = "line")
```