Información del Automated Surface Observing System (ASOS)
#install.packages("riem")
library(riem)
#install.packages("tidyverse")
library("tidyverse")## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.0 ✔ stringr 1.4.1
## ✔ readr 2.1.2 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
#install.packages("lubridate")
library("lubridate")##
## Attaching package: 'lubridate'
##
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
#install.packages("ggplot2")
library("ggplot2")
#install.packages("plotly")
library("plotly")##
## Attaching package: 'plotly'
##
## The following object is masked from 'package:ggplot2':
##
## last_plot
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following object is masked from 'package:graphics':
##
## layout
#install.packages("riem_networks")view(riem_networks())view(riem_stations("MX__ASOS"))monterrey <- riem_measures("MMMY")str(monterrey)## tibble [77,985 × 32] (S3: tbl_df/tbl/data.frame)
## $ station : chr [1:77985] "MMMY" "MMMY" "MMMY" "MMMY" ...
## $ valid : POSIXct[1:77985], format: "2014-01-01 00:16:00" "2014-01-01 00:49:00" ...
## $ lon : num [1:77985] -100 -100 -100 -100 -100 ...
## $ lat : num [1:77985] 25.8 25.8 25.8 25.8 25.8 ...
## $ tmpf : num [1:77985] 48.2 48.2 48.2 46.4 46.4 46.4 46.4 46.4 46.4 46.4 ...
## $ dwpf : num [1:77985] 46.4 46.4 46.4 46.4 46.4 44.6 44.6 44.6 44.6 44.6 ...
## $ relh : num [1:77985] 93.5 93.5 93.5 100 100 ...
## $ drct : num [1:77985] 0 120 120 120 110 100 110 130 60 0 ...
## $ sknt : num [1:77985] 0 3 5 6 5 5 4 3 3 0 ...
## $ p01i : num [1:77985] 0 0 0 0 0 0 0 0 0 0 ...
## $ alti : num [1:77985] 30.3 30.3 30.3 30.3 30.3 ...
## $ mslp : num [1:77985] NA NA NA NA NA ...
## $ vsby : num [1:77985] 4 3 1 0.25 0.12 0.12 0.06 0.06 0.06 0.12 ...
## $ gust : num [1:77985] NA NA NA NA NA NA NA NA NA NA ...
## $ skyc1 : chr [1:77985] "SCT" "SCT" "SCT" "VV " ...
## $ skyc2 : chr [1:77985] "BKN" "BKN" "BKN" NA ...
## $ skyc3 : chr [1:77985] "OVC" "OVC" "OVC" NA ...
## $ skyc4 : chr [1:77985] NA NA NA NA ...
## $ skyl1 : num [1:77985] 700 300 200 200 100 100 100 100 100 100 ...
## $ skyl2 : num [1:77985] 1200 400 300 NA NA NA NA NA NA NA ...
## $ skyl3 : num [1:77985] 4000 900 500 NA NA NA NA NA NA NA ...
## $ skyl4 : num [1:77985] NA NA NA NA NA NA NA NA NA NA ...
## $ wxcodes : chr [1:77985] NA "BR" "BR" "FG" ...
## $ ice_accretion_1hr: logi [1:77985] NA NA NA NA NA NA ...
## $ ice_accretion_3hr: logi [1:77985] NA NA NA NA NA NA ...
## $ ice_accretion_6hr: logi [1:77985] NA NA NA NA NA NA ...
## $ peak_wind_gust : logi [1:77985] NA NA NA NA NA NA ...
## $ peak_wind_drct : logi [1:77985] NA NA NA NA NA NA ...
## $ peak_wind_time : logi [1:77985] NA NA NA NA NA NA ...
## $ feel : num [1:77985] 48.2 47.2 45.6 42.9 43.5 ...
## $ metar : chr [1:77985] "MMMY 010016Z 00000KT 4SM SCT007 BKN012 OVC040 09/08 A3028 RMK 8/5// BR" "MMMY 010049Z 12003KT 3SM BR SCT003 BKN004 OVC009 09/08 A3028 RMK 8/5// -DZ OCNL" "MMMY 010116Z 12005KT 1SM BR SCT002 BKN003 OVC005 09/08 A3028 RMK 8/6// -DZ OCNL" "MMMY 010120Z 12006KT 1/4SM FG VV002 08/08 A3029 RMK 8//// BC FG MOV SE/NW" ...
## $ snowdepth : logi [1:77985] NA NA NA NA NA NA ...
summary(monterrey)## station valid lon
## Length:77985 Min. :2014-01-01 00:16:00.00 Min. :-100.1
## Class :character 1st Qu.:2016-03-11 13:42:00.00 1st Qu.:-100.1
## Mode :character Median :2018-05-07 05:43:00.00 Median :-100.1
## Mean :2018-05-11 23:07:02.83 Mean :-100.1
## 3rd Qu.:2020-07-04 10:40:00.00 3rd Qu.:-100.1
## Max. :2022-09-20 23:40:00.00 Max. :-100.1
##
## lat tmpf dwpf relh
## Min. :25.78 Min. : 23.00 Min. :-5.80 Min. : 2.32
## 1st Qu.:25.78 1st Qu.: 64.40 1st Qu.:51.80 1st Qu.: 48.05
## Median :25.78 Median : 73.40 Median :62.60 Median : 69.14
## Mean :25.78 Mean : 72.49 Mean :57.98 Mean : 65.07
## 3rd Qu.:25.78 3rd Qu.: 80.60 3rd Qu.:68.00 3rd Qu.: 83.32
## Max. :25.78 Max. :111.20 Max. :86.00 Max. :163.20
## NA's :89 NA's :1686 NA's :1741
## drct sknt p01i alti mslp
## Min. : 0.0 Min. : 0.000 Min. :0 Min. : 0.04 Min. : 913.2
## 1st Qu.: 70.0 1st Qu.: 4.000 1st Qu.:0 1st Qu.:29.88 1st Qu.:1011.4
## Median :110.0 Median : 5.000 Median :0 Median :29.97 Median :1014.5
## Mean :130.7 Mean : 5.819 Mean :0 Mean :29.98 Mean :1015.3
## 3rd Qu.:160.0 3rd Qu.: 8.000 3rd Qu.:0 3rd Qu.:30.07 3rd Qu.:1018.4
## Max. :360.0 Max. :98.000 Max. :0 Max. :30.81 Max. :1103.4
## NA's :72 NA's :72 NA's :26 NA's :66986
## vsby gust skyc1 skyc2
## Min. : 0.000 Min. : 13.00 Length:77985 Length:77985
## 1st Qu.: 6.000 1st Qu.: 20.00 Class :character Class :character
## Median :10.000 Median : 24.00 Mode :character Mode :character
## Mean : 9.124 Mean : 24.65
## 3rd Qu.:12.000 3rd Qu.: 28.00
## Max. :40.000 Max. :210.00
## NA's :31 NA's :75529
## skyc3 skyc4 skyl1 skyl2
## Length:77985 Length:77985 Min. : 0 Min. : 0
## Class :character Class :character 1st Qu.: 1500 1st Qu.: 2000
## Mode :character Mode :character Median : 3000 Median : 6000
## Mean : 5387 Mean : 8016
## 3rd Qu.: 7000 3rd Qu.:10000
## Max. :37000 Max. :30000
## NA's :23057 NA's :51718
## skyl3 skyl4 wxcodes ice_accretion_1hr
## Min. : 400 Min. : 3000 Length:77985 Mode:logical
## 1st Qu.: 8000 1st Qu.:20000 Class :character NA's:77985
## Median :16000 Median :20000 Mode :character
## Mean :14779 Mean :20656
## 3rd Qu.:20000 3rd Qu.:25000
## Max. :30000 Max. :25000
## NA's :73252 NA's :77790
## ice_accretion_3hr ice_accretion_6hr peak_wind_gust peak_wind_drct
## Mode:logical Mode:logical Mode:logical Mode:logical
## NA's:77985 NA's:77985 NA's:77985 NA's:77985
##
##
##
##
##
## peak_wind_time feel metar snowdepth
## Mode:logical Min. : 9.11 Length:77985 Mode:logical
## NA's:77985 1st Qu.: 64.40 Class :character NA's:77985
## Median : 73.40 Mode :character
## Mean : 73.17
## 3rd Qu.: 83.29
## Max. :131.06
## NA's :1744
este_mes<-subset(monterrey, valid >= as.POSIXct("2022-09-01 00:00") & valid <=as.POSIXct("2022-09-07 23:59"))
este_mes## # A tibble: 191 × 32
## station valid lon lat tmpf dwpf relh drct sknt p01i
## <chr> <dttm> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 MMMY 2022-09-01 05:40:00 -100. 25.8 75.2 73.4 94.1 60 8 0
## 2 MMMY 2022-09-01 06:40:00 -100. 25.8 75.2 75.2 100 110 7 0
## 3 MMMY 2022-09-01 07:40:00 -100. 25.8 75.2 75.2 100 0 0 0
## 4 MMMY 2022-09-01 08:25:00 -100. 25.8 75.2 75.2 100 130 12 0
## 5 MMMY 2022-09-01 08:40:00 -100. 25.8 73.4 73.4 100 130 8 0
## 6 MMMY 2022-09-01 09:40:00 -100. 25.8 71.6 71.6 100 80 3 0
## 7 MMMY 2022-09-01 10:40:00 -100. 25.8 71.6 71.6 100 70 3 0
## 8 MMMY 2022-09-01 11:40:00 -100. 25.8 71.6 71.6 100 80 5 0
## 9 MMMY 2022-09-01 12:40:00 -100. 25.8 71.6 71.6 100 0 0 0
## 10 MMMY 2022-09-01 13:40:00 -100. 25.8 75.2 71.6 88.6 0 0 0
## # … with 181 more rows, and 22 more variables: alti <dbl>, mslp <dbl>,
## # vsby <dbl>, gust <dbl>, skyc1 <chr>, skyc2 <chr>, skyc3 <chr>, skyc4 <chr>,
## # skyl1 <dbl>, skyl2 <dbl>, skyl3 <dbl>, skyl4 <dbl>, wxcodes <chr>,
## # ice_accretion_1hr <lgl>, ice_accretion_3hr <lgl>, ice_accretion_6hr <lgl>,
## # peak_wind_gust <lgl>, peak_wind_drct <lgl>, peak_wind_time <lgl>,
## # feel <dbl>, metar <chr>, snowdepth <lgl>
plot(este_mes$valid, este_mes$relh)promedio<-monterrey %>%
mutate (date = ymd_hms(valid), date = as.Date(date)) %>%
group_by(date) %>%
summarize_if(is.numeric, ~mean(.,na.rm=TRUE))
tibble(promedio) ## # A tibble: 3,152 × 18
## date lon lat tmpf dwpf relh drct sknt p01i alti mslp vsby
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2014-01-01 -100. 25.8 50.7 47.5 90.2 90.3 2.42 0 30.2 1023. 2.29
## 2 2014-01-02 -100. 25.8 53.9 47.4 81.3 238. 8.13 0 30.2 1024. 8.48
## 3 2014-01-03 -100. 25.8 45.5 34.4 69.0 97.2 4.16 0 30.4 1030. 15
## 4 2014-01-04 -100. 25.8 44.8 36 71.7 78.9 2.22 0 30.1 1022. 15
## 5 2014-02-07 -100. 25.8 37.6 36.3 95.3 82.6 2.96 0 30.2 1026. 1.78
## 6 2014-02-08 -100. 25.8 44.8 41.5 90.0 100 2.74 0 30.2 1023. 1.81
## 7 2014-02-09 -100. 25.8 53.8 44.7 77.1 212. 5.38 0 30.1 1019. 6.46
## 8 2014-02-10 -100. 25.8 62.5 54.0 77.8 158. 7.68 0 29.9 1014. 7.27
## 9 2014-02-11 -100. 25.8 50.5 45.6 83.9 228. 7.58 0 30.0 1019. 6.81
## 10 2014-02-12 -100. 25.8 45.5 35.1 69.0 229. 8.85 0 30.2 1023. 9.56
## # … with 3,142 more rows, and 6 more variables: gust <dbl>, skyl1 <dbl>,
## # skyl2 <dbl>, skyl3 <dbl>, skyl4 <dbl>, feel <dbl>
centigrados<-promedio
centigrados$tmpc<- (centigrados$tmpf-32)/1.8
str(centigrados)## tibble [3,152 × 19] (S3: tbl_df/tbl/data.frame)
## $ date : Date[1:3152], format: "2014-01-01" "2014-01-02" ...
## $ lon : num [1:3152] -100 -100 -100 -100 -100 ...
## $ lat : num [1:3152] 25.8 25.8 25.8 25.8 25.8 ...
## $ tmpf : num [1:3152] 50.7 53.9 45.5 44.8 37.6 ...
## $ dwpf : num [1:3152] 47.5 47.4 34.4 36 36.3 ...
## $ relh : num [1:3152] 90.2 81.3 69 71.7 95.3 ...
## $ drct : num [1:3152] 90.3 238.3 97.2 78.9 82.6 ...
## $ sknt : num [1:3152] 2.42 8.13 4.16 2.22 2.96 ...
## $ p01i : num [1:3152] 0 0 0 0 0 0 0 0 0 0 ...
## $ alti : num [1:3152] 30.2 30.2 30.4 30.1 30.2 ...
## $ mslp : num [1:3152] 1023 1024 1030 1022 1026 ...
## $ vsby : num [1:3152] 2.29 8.48 15 15 1.78 ...
## $ gust : num [1:3152] NaN 27.1 NaN NaN NaN ...
## $ skyl1: num [1:3152] 1527 7150 12000 1700 348 ...
## $ skyl2: num [1:3152] 8400 10812 NaN NaN 580 ...
## $ skyl3: num [1:3152] 9080 20000 NaN NaN NaN ...
## $ skyl4: num [1:3152] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ...
## $ feel : num [1:3152] 49.8 53.6 44.1 43.4 34.9 ...
## $ tmpc : num [1:3152] 10.36 12.17 7.52 7.11 3.09 ...
centigrados$feelc <- (centigrados$feel-32)/1.8
str(centigrados)## tibble [3,152 × 20] (S3: tbl_df/tbl/data.frame)
## $ date : Date[1:3152], format: "2014-01-01" "2014-01-02" ...
## $ lon : num [1:3152] -100 -100 -100 -100 -100 ...
## $ lat : num [1:3152] 25.8 25.8 25.8 25.8 25.8 ...
## $ tmpf : num [1:3152] 50.7 53.9 45.5 44.8 37.6 ...
## $ dwpf : num [1:3152] 47.5 47.4 34.4 36 36.3 ...
## $ relh : num [1:3152] 90.2 81.3 69 71.7 95.3 ...
## $ drct : num [1:3152] 90.3 238.3 97.2 78.9 82.6 ...
## $ sknt : num [1:3152] 2.42 8.13 4.16 2.22 2.96 ...
## $ p01i : num [1:3152] 0 0 0 0 0 0 0 0 0 0 ...
## $ alti : num [1:3152] 30.2 30.2 30.4 30.1 30.2 ...
## $ mslp : num [1:3152] 1023 1024 1030 1022 1026 ...
## $ vsby : num [1:3152] 2.29 8.48 15 15 1.78 ...
## $ gust : num [1:3152] NaN 27.1 NaN NaN NaN ...
## $ skyl1: num [1:3152] 1527 7150 12000 1700 348 ...
## $ skyl2: num [1:3152] 8400 10812 NaN NaN 580 ...
## $ skyl3: num [1:3152] 9080 20000 NaN NaN NaN ...
## $ skyl4: num [1:3152] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ...
## $ feel : num [1:3152] 49.8 53.6 44.1 43.4 34.9 ...
## $ tmpc : num [1:3152] 10.36 12.17 7.52 7.11 3.09 ...
## $ feelc: num [1:3152] 9.87 12.01 6.71 6.36 1.6 ...
este_mes<-subset(monterrey, valid >= as.POSIXct("2022-09-01 00:00") & valid <=as.POSIXct("2022-09-07 23:59"))#plot(este_año$date, este_año$tmpc, type="l", main="Temperatura Promedio en Monterrey durante 2022",xlab="Fecha", ylab="c")En esta actividad nos damos cuenta como R studio tiene la capacidad de predecir el clima y la temperatura unicamente con comandos y sin necesidad de una base de datos personal. El ASOS sirve como una red de observación meterológica del paÃs y en este caso se utilizó para conocer el clima de Monterrey. Primero se buscó el paÃs y la ciudad, se obtuvo información y se analizo con la finalidad de graficarla y entender diferentes variables, promediar y predecir el clima y las temperaturas, para ello se cambiaron los grados a centigrados, ya que estos se encontraban en Farenheits.
En este caso la información que se extrajo fue de Monterrey, Mexico y en los gráficos que obtuvimos podemos darnos cuenta como la temperatura cambia seegún los meses del año, por ejemplo los meses entre enero y marzo muestran tener las temperaturas más bajar alcanzando los 3 grados centigrados y en los meses entre junio y agosto los meses más calientes llegando a temperaturas de arriba de los 30 grados centigrados.