Skip to content

Commit

Permalink
Merge pull request #26 from bczernecki/devel
Browse files Browse the repository at this point in the history
get_sounding re-tries
  • Loading branch information
bczernecki authored Apr 5, 2021
2 parents b426819 + 0869cc0 commit 9505680
Show file tree
Hide file tree
Showing 45 changed files with 145 additions and 112 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: thunder
Type: Package
Title: Computation and Visualisation of Atmospheric Convective Parameters
Version: 0.0.13
Version: 0.0.14
Authors@R: c(person("Bartosz", "Czernecki", email = "nwp@amu.edu.pl", role = c("aut", "cre"),comment = c(ORCID = "0000-0001-6496-1386")),
person("Mateusz", "Taszarek", email = "mateusz.taszarek@noaa.gov", role = c("aut"),comment = c(ORCID = "0000-0001-9578-5872")),
person("Piotr", "Szuster", email = "retsuz@gmail.com", role = c("aut"), comment = c(ORCID = "0000-0001-7937-8046")),
Expand Down
33 changes: 20 additions & 13 deletions R/get_sounding.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Download rawinsonde measurement
#'
#' Download rawinsonde measurement from sounding database of the University of Wyoming in a form convenient to use with thundeR package.
#' In case of problems with downloading the chosen dataset the url is checked 5 times in 5-second intervals.
#'
#' @param wmo_id international WMO station code (e.g. 11035 for Vienna)
#' @param yy year - single number (e.g. 2010)
Expand Down Expand Up @@ -39,22 +40,28 @@

get_sounding = function(wmo_id, yy, mm, dd, hh, metadata = FALSE){

# clipping to define max_hght
sounding_data = climate::sounding_wyoming(wmo_id, yy, mm, dd, hh)

colnames(sounding_data[[1]]) = c("pressure", "altitude", "temp", "dpt",
"rh", "mixr", "wd", "ws", "thta", "thte", "thtv")
# take another attempt if object empty
i = 1
while(is.null(sounding_data) & i < 5){
message("\nProblems with downloading. Re-trying in 5 seconds...")
Sys.sleep(5)
sounding_data = climate::sounding_wyoming(wmo_id, yy, mm, dd, hh)
i = i + 1
}

if((!is.null(sounding_data)) & (ncol(sounding_data[[1]]) > 0)){

sounding_data[[1]] = sounding_data[[1]][,c("pressure", "altitude", "temp", "dpt","wd", "ws")]

sounding_data[[1]] = na.omit(sounding_data[[1]])

if(!metadata){
sounding_data = sounding_data[[1]]
colnames(sounding_data[[1]]) = c("pressure", "altitude", "temp", "dpt",
"rh", "mixr", "wd", "ws", "thta", "thte", "thtv")
sounding_data[[1]] = sounding_data[[1]][,c("pressure", "altitude", "temp", "dpt","wd", "ws")]

sounding_data[[1]] = na.omit(sounding_data[[1]])

if(!metadata){
sounding_data = sounding_data[[1]]
}
}
return(sounding_data)
}




2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions docs/articles/getstarted.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified docs/articles/getstarted_files/figure-html/example4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/articles/getstarted_files/figure-html/example5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/articles/getstarted_files/figure-html/example6-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9505680

Please sign in to comment.