Skip to content
Prev 385259 / 398503 Next

Hot Air Balloon Weather Briefings

Hi Philip,
My fault for assuming that what worked for the sample data would work
for the entire data set. If you run the following code:

# read the file into a data frame
phdf<-read.csv("phdf.csv",stringsAsFactors=FALSE)
print(dim(phdf))
# create a logical variable for the subsetting step
keep<-rep(TRUE,length(phdf$Speed))
# this follows the conventional for(i in ...) syntax
# mini (minute index) is the name of the variable
# that is assigned the successive values of the
# unique values in the Minute column of phdf
# here I was lazy and only dealt with the sample data
# what I should have done was to create a column
# with minute values that don't repeat
phdf$hourmin<-phdf$Hour.Z * 60 + phdf$Minute
for(mini in unique(phdf$hourmin)) {
 # mark all minutes that are all zeros for deletion
 if(all(phdf$Speed[phdf$hourmin == mini] == 0))
  keep[phdf$hourmin == mini]<-FALSE
 # but now there is another condition
 # that I didn't notice (more laziness)
 # drop minutes containing ten consecutive zeros
 # I'll use a cheap trick for this
 # if the length of the run length encoding (rle)
 # of the Speed == 0 condition is less than three,
 # then there can't be a broken run of zeros
 if(length(rle(phdf$Speed[phdf$hourmin == mini])$length)<3)
  keep[phdf$hourmin == mini]<-FALSE
}
# now drop any rows for which has marked FALSE (note all caps!)
phdf<-phdf[keep,]
print(dim(phdf))

You will see that it has removed 67 rows. This is the same as if I had
only applied the first "all zeros"  condition, for there were no
unique minutes with 11 observations that contained a single non-zero
speed value. I can see that you are getting short runs of zero speeds
near the end. I assume that this is due to the balloon slowly bumping
along the ground. Often just looking at the data can suggest solutions
to problems like this.

Coincidentally I am about to email an old friend of mine whose sons
have dabbled in sending balloons high into the air and I will let them
know that they are not alone in performing this unusual practice. If I
haven't answered all your questions, feel free to let me know.

Jim
On Sun, Aug 16, 2020 at 4:39 AM Philip <herd_dog at cox.net> wrote:
Message-ID: <CA+8X3fV+a3Tm9tDbqoMZR8e3J6cxgkw=Ew7XnOCa8r2=wuomaQ-7322@mail.gmail.com>
In-Reply-To: <BF6CE6BC13F845C5B2AE8C90464D2527@OWNERPC>