bczernecki / climate

The R climate package: an interface for downloading in-situ meteorological (and hydrological) dataset
https://bczernecki.github.io/climate/
Other
77 stars 20 forks source link

sounding_wyoming - better error message #10

Closed Nowosad closed 4 years ago

Nowosad commented 5 years ago

Kolejne dwa przypadki podobne do #9.

W pierwszym podany jest błędny numer stacji. Error powinien to powiedzieć + podpowiedzieć skąd wziąć kod.

library(climate)

profile <- sounding_wyoming(wmo_id = 12220, yy = 2019, mm = 4, dd = 4, hh = 0)
#> Error in if (skip) readLines(file, n = skip): argument is not interpretable as logical

W drugim podałem dwa argumenty do wmo_id. Dla tej funkcji powinny być sprawdzenia (defensive programming), że wszystkie argumenty mają długość 1, a następnie informacyjny error, co ma użytkownik naprawić.

profile <- sounding_wyoming(wmo_id = c(12120, 12375), yy = 2019, mm = 4, dd = 4, hh = 0)
#> Error in download.file(url, temp): 'url' must be a length-one character vector
aglogowski commented 4 years ago

zrobione

Nowosad commented 4 years ago

@aglogowski myślę, że ten błąd poniżej powinien być wyłapany w kodzie i użytkownik powinien dostać error w stylu HTTP status was '503 Service Unavailable'. Have you provided a correct station id? i może info jak znaleźć to id...

profile <- sounding_wyoming(wmo_id = 12220, yy = 2019, mm = 4, dd = 4, hh = 0)
#> trying URL 'http://weather.uwyo.edu/cgi-bin/sounding?region=europe&TYPE=TEXT%3ALIST&YEAR=2019&MONTH#> =04&FROM=0400&TO=0400&STNM=12220'
#> Error in download.file(url, temp) : 
#>   cannot open URL 'http://weather.uwyo.edu/cgi-bin/sounding?region=europe&TYPE=TEXT%3ALIST&YEAR=2019&MONTH#> =04&FROM=0400&TO=0400&STNM=12220'
#> In addition: Warning message:
#>   In download.file(url, temp) :
#>   cannot open URL 'http://weather.uwyo.edu/cgi-bin/sounding?region=europe&TYPE=TEXT%3ALIST&YEAR=2019&MONTH#> =04&FROM=0400&TO=0400&STNM=12220': HTTP status was '503 Service Unavailable'
aglogowski commented 4 years ago

Ej ale ja mam inny error do tego kodu

> profile <- sounding_wyoming(wmo_id = 12220, yy = 2019, mm = 4, dd = 4, hh = 0) trying URL 'http://weather.uwyo.edu/cgi-bin/sounding?region=europe&TYPE=TEXT%3ALIST&YEAR=2019&MONTH=04&FROM=0400&TO=0400&STNM=12220' Content type 'text/html; charset=UTF-8' length unknown downloaded 752 bytes

Wrong wmo_id number. Please check wmo_id numbers at https://ogimet.com/display_stations.php?lang=en&tipo=AND&isyn=&oaci=&nombre=&estado=&Send=Send Error incolnames<-(tmp, value = c("PRES", "HGHT", "TEMP", "DWPT", : attempt to set 'colnames' on an object with less than two dimensions