#' read in data fram and bin based on meteorology
#'
#' @param data: data frame that has aermet column names
#
#' @return data
#'
#' @export mgstool.binbymet
#########################################################################
#function to read AERMET fortran surface file
mgstool.binbymet <- function(data){
#bin by wind direction
# North, East, South, West
data[which(data$wind_d <= 45 | data$wind_d >= 315),"direction90deg_bin"] <- "Winds from North"
data[which(data$wind_d > 45 & data$wind_d < 135),"direction90deg_bin"] <- "Winds from East"
data[which(data$wind_d >= 135 & data$wind_d < 225),"direction90deg_bin"] <- "Winds from South"
data[which(data$wind_d >= 225 & data$wind_d < 315),"direction90deg_bin"] <- "Winds from West"
# North, NorthEast, East, SouthEast, South, SouthWest, West, NorthWest
data[which(data$wind_d <= 22.5 | data$wind_d >= 337.5),"direction45deg_bin"] <- "Winds from North"
data[which(data$wind_d > 22.5 & data$wind_d <= 67.5),"direction45deg_bin"] <- "Winds from NorthEast"
data[which(data$wind_d > 67.5 & data$wind_d <= 112.5),"direction45deg_bin"] <- "Winds from East"
data[which(data$wind_d > 112.5 & data$wind_d <= 157.5),"direction45deg_bin"] <- "Winds from SouthEast"
data[which(data$wind_d > 157.5 & data$wind_d <= 202.5),"direction45deg_bin"] <- "Winds from South"
data[which(data$wind_d > 202.5 & data$wind_d <= 247.5),"direction45deg_bin"] <- "Winds from SouthWest"
data[which(data$wind_d > 247.5 & data$wind_d <= 292.5),"direction45deg_bin"] <- "Winds from West"
data[which(data$wind_d > 292.5 & data$wind_d < 337.5),"direction45deg_bin"] <- "Winds from NorthWest"
#bin by stability
data[which(data$MO_l > 0 & data$MO_l <=50),"stability_bin"] <- "Stable (0 < L <= 50)"
data[which(data$MO_l > 50 & data$MO_l <= 500),"stability_bin"] <- "Moderatly Stable (50 < L <= 500)"
data[which(abs(data$MO_l) > 500),"stability_bin"] <- "Neutral (|L| > 500)"
data[which(data$MO_l < -50 & data$MO_l >= -500),"stability_bin"] <- "Moderatly Convective (-50 > L >= -500)"
data[which(data$MO_l < 0 & data$MO_l >=-50),"stability_bin"] <- "Convective (0 > L >= -50)"
#bin by wind speed
data[which(data$wind_s <= 2),"speed_bin"] <- "Calm Winds [<= 2m/s]"
data[which(data$wind_s > 2 & data$wind_s <= 5),"speed_bin"] <- "Light Winds [2m/s - 5m/s]"
data[which(data$wind_s > 5 & data$wind_s <= 8),"speed_bin"] <- "Moderate Winds [5m/s - 8m/s]"
data[which(data$wind_s > 8),"speed_bin"] <- "High Winds [ > 8m/s]"
#bin by time-period
data[which(data$hour >= 7 & data$hour <= 8),"timeperiod_bin"] <- "AM rush peak [hours 7-8]"
data[which(data$hour >= 9 & data$hour <= 16),"timeperiod_bin"] <- "MID-day [hours 9-16]"
data[which(data$hour >= 17 & data$hour <= 19),"timeperiod_bin"] <- "PM rush peak [hours 17-19]"
data[which(data$hour > 19 | data$hour < 7),"timeperiod_bin"] <- "OFF peak [hours < 7 or > 19]"
return(data)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.