-
Notifications
You must be signed in to change notification settings - Fork 0
/
7_Kedich.R
109 lines (91 loc) · 5.35 KB
/
7_Kedich.R
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
library(tidyverse)
library(googlesheets4)
library(rlang)
library(lubridate)
catalog <- read_sheet('1Q6HCY4jxiYefjPdWrN5erwgEee-Gz_BywqZW2mQcftw')
meteo_data <- lapply(as.character(catalog$ID), function(X) read_sheet('1FWC_YBrlINnjR5POC2kxa_LnLC7n5fFA90oNA7dLTP0', sheet = X, col_types = 'ccncccnninncnnnnncc')) %>%
set_names(catalog$ID) %>%
bind_rows(.id = 'id') %>%
mutate(id = as.numeric(id)) %>%
full_join(catalog, by = c('id' = 'ID')) %>%
mutate(Datetime = as.POSIXct(Datetime)) %>%
relocate(id, .before = NAME) %>%
set_names(c('Datetime', 'Wdir', 'Wspd', 'Vis', 'Phen', 'Cloud', 'T', 'Td', 'F', 'Te', 'Tes', 'Comf', 'P', "Po", 'Tmin', 'Tmax', 'R', 'R24', 'S', 'ID', 'NAME', 'LON', 'LAT', 'H'))
filter_data <- meteo_data %>%
filter(str_detect(NAME, 'Балчуг') | str_detect(NAME, 'Сареево'))
filter_data_night <- filter_data %>%
filter(hour(Datetime) == 0 | hour(Datetime) == 3)
ggplot(filter_data, mapping = aes(Datetime, `T`, color = NAME)) +
geom_point(alpha = 0.1) +
geom_density_2d() +
ggtitle('Плотности распределения температур на станциях "Малое Сараево", "Балчуг"') +
ylab('C°') +
xlab('Месяц') +
labs(color = 'Метеостанция')
ggplot(filter_data_night, mapping = aes(Datetime, `T`, color = NAME)) +
geom_point(alpha = 0.5) +
geom_density_2d() +
ggtitle('Плотности распределения ночных температур на станциях "Малое Сараево", "Балчуг"') +
ylab('C°') +
xlab('Месяц') +
labs(color = 'Метеостанция')
ggplot(filter_data, mapping = aes(NAME, `T`, fill = NAME)) +
geom_boxplot(alpha = 0.4, width = 0.6) +
ylab('C°') +
theme(axis.title.x = element_blank()) +
ggtitle('Диаграммы размаха температур на метеостанциях') +
theme(legend.position="none")
ggplot(filter_data_night, mapping = aes(NAME, `T`, fill = NAME)) +
geom_boxplot(alpha = 0.4, width = 0.6) +
ylab('C°') +
theme(axis.title.x = element_blank()) +
ggtitle('Диаграммы размаха температур на метеостанциях') +
theme(legend.position="none")
t.test(filter_data %>% filter(ID == 27605) %>% pull(`T`),
filter_data %>% filter(ID == 27518) %>% pull(`T`))
var.test(filter_data %>% filter(ID == 27605) %>% pull(`T`),
filter_data %>% filter(ID == 27518) %>% pull(`T`))
t.test(filter_data_night %>% filter(ID == 27605) %>% pull(`T`),
filter_data_night %>% filter(ID == 27518) %>% pull(`T`))
var.test(filter_data_night %>% filter(ID == 27605) %>% pull(`T`),
filter_data_night %>% filter(ID == 27518) %>% pull(`T`))
dif_df = inner_join(filter_data %>%
select(Datetime, `T`, ID, NAME) %>%
filter(ID == 27605),
filter_data %>%
select(Datetime, `T`, ID, NAME) %>%
filter(ID == 27518),
by = 'Datetime') %>%
mutate(temp_dif = `T.x` - `T.y`) %>%
select(Datetime, temp_dif) %>%
inner_join(meteo_data %>% group_by(Datetime) %>% summarise(mean_wind_spd = round(mean(Wspd, na.rm = T), 2)))
dif_df_night <- dif_df %>%
filter(hour(Datetime) == 0 | hour(Datetime) == 3)
ggplot(dif_df, mapping = aes(mean_wind_spd, temp_dif)) +
geom_point(shape = 1, size = 0.8, color = 'red') +
geom_smooth(method = 'loess', color = 'blue', size = 0.8, span = 0.5) +
ggtitle('Диаграмма рассеяния между скоростью ветра\nи разницей температур (Малое Сареево и Балчуг)') +
xlab('Скорость ветра, м/с') +
ylab('Разница температур, C°')
ggplot(dif_df_night, mapping = aes(mean_wind_spd, temp_dif)) +
geom_point(shape = 1, size = 0.8, color = 'red') +
geom_smooth(method = 'loess', color = 'blue', size = 0.8, span = 0.9) +
ggtitle('Диаграмма рассеяния между скоростью ветра\nи разницей ночных температур (Малое Сареево и Балчуг)') +
xlab('Скорость ветра, м/с') +
ylab('Разница температур, C°')
ggplot(dif_df, mapping = aes(log10(mean_wind_spd), temp_dif)) +
geom_point(shape = 1, size = 0.8, color = 'red') +
geom_smooth(method = 'lm', color = 'blue', size = 0.8) +
ggtitle('Диаграмма рассеяния между скоростью ветра\nи разницей температур (Малое Сареево и Балчуг)') +
xlab(expression('log'[10]*'(Скорость ветра), м/с')) +
ylab('Разница температур, C°')
ggplot(dif_df_night, mapping = aes(log10(mean_wind_spd), temp_dif)) +
geom_point(shape = 1, size = 0.8, color = 'red') +
geom_smooth(method = 'lm', color = 'blue', size = 0.8) +
ggtitle('Диаграмма рассеяния между скоростью ветра\nи разницей температур (Малое Сареево и Балчуг)') +
xlab(expression('log'[10]*'(Скорость ветра), м/с')) +
ylab('Разница температур, C°')
cor.test(log10(dif_df2$mean_wind_spd), dif_df2$temp_dif)
cor.test(log10(dif_df_night$mean_wind_spd), dif_df_night$temp_dif)
linear_model = lm(log10(dif_df$mean_wind_spd) ~ dif_df$temp_dif)
summary(linear_model)