midraed / water

R package to calculate surface energy balance models
24 stars 20 forks source link

problem in read.WSdata #32

Closed IFuentesSR closed 7 years ago

IFuentesSR commented 7 years ago

I'm having problems trying to run the function to read the weather station data. Not even the examples of the package are working in the last actualization v0.6. When trying to execute these lines of code, which depicts the example of the function in the documentation, there is an error: csvfile <- system.file("extdata", "apples.csv", package="water") MTLfile <- system.file("extdata", "L7.MTL.txt", package="water") WS <- read.WSdata(WSdata = csvfile, date.format = "%d/%m/%Y",lat=-35.42222, long= -71.38639, elev=201, height= 2.2,MTL = MTLfile)

"Error in Ops.data.frame(WS.after, WS.prev) : ‘-’ only defined for equally-sized data frames"

midraed commented 7 years ago

is working on my computer and other test machines!

But you should receive a warning because I just changed the parameter "columns"... but is only a warning, the object WS shouyld exists after running your third line!

Best,

2017-07-26 5:25 GMT-03:00 IFuentesSR notifications@github.com:

I'm having problems trying to run the function to read the weather station data. Not even the examples of the package are working in the last actualization v0.6. When trying to execute these lines of code, which depicts the example of the function in the documentation, there is an error: csvfile <- system.file("extdata", "apples.csv", package="water") MTLfile <- system.file("extdata", "L7.MTL.txt", package="water") WS <- read.WSdata(WSdata = csvfile, date.format = "%d/%m/%Y",lat=-35.42222, long= -71.38639, elev=201, height= 2.2,MTL = MTLfile)

"Error in Ops.data.frame(WS.after, WS.prev) : ‘-’ only defined for equally-sized data frames"

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/midraed/water/issues/32, or mute the thread https://github.com/notifications/unsubscribe-auth/ACIcZlUpCRDfs-KOyFu2bODpqEakjpByks5sRvfigaJpZM4OjlsE .

IFuentesSR commented 7 years ago

Hi, Decomposing the function I found the problem. As I'm in Australia, and I'm not setting tz (tz=''), it assumes the tz of my pc (GMT +10). The datetime of the satellite is "2013-02-15 14:30:40 GMT" and the higher threshold of the WSdata csv is "2013-02-15 23:45:00 AEDT", therefore an exception occurs when trying to find the time after the satellite pass time... which doesn't exist. If an error occurs after that line of code (I copied that after the paragraph), maybe a message could pop up, explaining that the length of the weather satellite time series is too short, or that the tz parameter should be carefully considered as well.
WS.after <- WSdata[WSdata$datetime == datetime[datetime > sat.datetime][1],]

Regards

midraed commented 7 years ago

Thank you very much IFuentesSR! And thank you also for your suggestion! I added a warning() when tz='' reporting the assumed timezone for the weather station data!

The fix in on the development version.

Kind regards!