bczernecki / thundeR

thundeR - Rapid computation and visualisation of convective parameters from rawinsonde and NWP data
https://bczernecki.github.io/thundeR/
MIT License
44 stars 8 forks source link

Thunder crashed after five attempts to download a profile from Wyoming sever #47

Closed franciscoleoncrz closed 1 year ago

franciscoleoncrz commented 1 year ago

Hi, First of all, thank you so much for your work.

I have an issue and request for you guys. I'm trying to download a large number of profiles (with a simple iteration using "for" in R), but, in some stations and after five attempts, the program says something like:

Service not working or wmo_id or date not correct. Check URL:
http://weather.uwyo.edu/cgi-bin/sounding?TYPE=TEXT%3ALIST&YEAR=2000&MONTH=01&FROM=0312&TO=0312&STNM=76679
Problems with downloading. Re-trying in 5 seconds...

I know that this is because the sounding does not exist, but I'd like to know if there are any options that the program pass to the next date.

Thank you so much, Cheers.

bczernecki commented 1 year ago

Hi Francisco,

I think you should check documentation to tryCatch() statement that might be good solution for your use case.

If you're looking for rather "ready-to-use" snippet then I would strongly suggest installing the climate package (https://github.com/bczernecki/climate) and checking for example this kind of solution:

# install package
library(remotes)
install_github("bczernecki/climate")

my_results = list()
for (i in c(2021, 2023, 2020, 2010, 2100, 2011))  {
  element_in_list = length(my_results) + 1
  print(element_in_list)
  my_results[element_in_list] = sounding_wyoming(wmo_id = 45004, 
                                                 yy = i,
                                                 mm = 07, 
                                                 dd = 17,
                                                 hh = 12,
                                                 min = 00,
                                                 bufr = FALSE)
}

This is just an examplary pseudo-code, but I hope it will be running fine for most use-cases, so feel free to adjust it to your needs.

Best, Bartek