midraed / water

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

Import weather station #41

Open nrfsilva opened 5 years ago

nrfsilva commented 5 years ago

Hi Guilhermo,

I am trying to import my weather station, but it is showing the error:

Error in data.frame(date = unique(WSdata$date), radiation_sum = tapply(WSdata$radiation, : arguments imply differing number of rows: 1, 0 In addition: Warning message: In read.WSdata(CSVFILE, date.format = "%d/%m/%Y", lat = -35.42222, : As tz = "", assuming the weather station time zone is America/Sao_Paulo

Do you know, what is going on? I imported your apple.csv, and works but mine file not.

Thank you,

midraed commented 5 years ago

Please check date.format, datetime.format, time.format parameters. They should be correct for your csv. Also check columns parameter. And the "warning" is because you not specifying the time zone with the tz parameter. If the weather station is located in the same timezone than you, should work ok.

Best,

GF

On Thu, Nov 1, 2018 at 2:32 PM nildsonsilva notifications@github.com wrote:

Hi Gonzalo,

I am trying to import my weather station, but it is showing the error:

Error in data.frame(date = unique(WSdata$date), radiation_sum = tapply(WSdata$radiation, : arguments imply differing number of rows: 1, 0 In addition: Warning message: In read.WSdata(CSVFILE, date.format = "%d/%m/%Y", lat = -35.42222, : As tz = "", assuming the weather station time zone is America/Sao_Paulo

Do you know, what is going on? I imported your apple.csv, and works but mine file not.

Thank you,

— 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/41, or mute the thread https://github.com/notifications/unsubscribe-auth/ACIcZskrcmLPJDAGQwEZMw0bo8SjZqSwks5uqzBFgaJpZM4YHqY4 .

nrfsilva commented 5 years ago

Thank you Guilhermo,

I ordered everything, but it is not working yet.

Follow my code:

library(water) csvfile <- "C:/Users/ZZZZ/ZZZZZ/ZZZZZ/PAPERS/WeatherStation2.csv" WeatherStation <- read.WSdata(WSdata = csvfile, date.format = "%d/%m/%Y", time.format = "%H:%M", lat= -9.324425, long= -40.559563, elev=322, height= 2, columns=c("date" = 1, "time" = 2, "radiation" = 3, "wind" = 4, "RH" = 5, "temp" = 6, "rain" = 7), cf = c(1,1,1), tz = "")

I am not using MTL, because I am using MODIS images.

My WS:

WeatherStation2.zip

Best regards and thank you,

Nildson

midraed commented 5 years ago

Can you show me the first 5 lines of your csv? An image is enough.

BR,

GF

On Fri, Nov 2, 2018 at 11:17 AM nildsonsilva notifications@github.com wrote:

Thank you Gonzalo,

I ordered everything, but it is not working yet.

Follow my code:

library(water) csvfile <- "C:/Users/ZZZZ/ZZZZZ/ZZZZZ/PAPERS/WeatherStation2.csv" WeatherStation <- read.WSdata(WSdata = csvfile, date.format = "%d/%m/%Y", time.format = "%H:%M", lat= -9.324425, long= -40.559563, elev=322, height= 2, columns=c("date" = 1, "time" = 2, "radiation" = 3, "wind" = 4, "RH" = 5, "temp" = 6, "rain" = 7), cf = c(1,1,1), tz = "")

Best regards,

Nildson

On Fri, 2 Nov 2018 at 10:03, Guillermo Federico Olmedo < notifications@github.com> wrote:

Please check date.format, datetime.format, time.format parameters. They should be correct for your csv. Also check columns parameter. And the "warning" is because you not specifying the time zone with the tz parameter. If the weather station is located in the same timezone than you, should work ok.

Best,

GF

On Thu, Nov 1, 2018 at 2:32 PM nildsonsilva notifications@github.com wrote:

Hi Gonzalo,

I am trying to import my weather station, but it is showing the error:

Error in data.frame(date = unique(WSdata$date), radiation_sum = tapply(WSdata$radiation, : arguments imply differing number of rows: 1, 0 In addition: Warning message: In read.WSdata(CSVFILE, date.format = "%d/%m/%Y", lat = -35.42222, : As tz = "", assuming the weather station time zone is America/Sao_Paulo

Do you know, what is going on? I imported your apple.csv, and works but mine file not.

Thank you,

— 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/41, or mute the thread <

https://github.com/notifications/unsubscribe-auth/ACIcZskrcmLPJDAGQwEZMw0bo8SjZqSwks5uqzBFgaJpZM4YHqY4

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/midraed/water/issues/41#issuecomment-435372578, or mute the thread < https://github.com/notifications/unsubscribe-auth/Aqm_vwuNTLZ6_5ZLdzngsv4l74TgkyUPks5urEK5gaJpZM4YHqY4

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/midraed/water/issues/41#issuecomment-435394378, or mute the thread https://github.com/notifications/unsubscribe-auth/ACIcZhv_UmIeH5dz9GR9WKZyUeDnlHZ8ks5urFPugaJpZM4YHqY4 .

masaba79 commented 5 years ago

Hello, we are new to water package and trying our own data. Also encountered problems importing our own weather station data.

I get the following error with my code:

WeatherStation <- read.WSdata(WSdata = csvfile, date.format = "%d/%m/%Y", lat=18.094, long= -89.462, elev=279, height=2,tz="GTM-6", columns=c("date" = 1, "time" = 2, "radiation" = 3, "wind" = 4, "RH" = 5, "temp" = 6, "rain" = 7), MTL = MTLfile) Error in Ops.data.frame(WS.after, WS.prev) : ‘-’ only defined for equally-sized data frames In addition: There were 14 warnings (use warnings() to see them)

warnings() Warning messages: 1: In strptime(datetime, format = paste(date.format, time.format), ... : unknown timezone 'GTM-6' 2: In as.POSIXct.POSIXlt(x) : unknown timezone 'GTM-6' 3: In as.POSIXlt.POSIXct(x, tz = tz) : unknown timezone 'GTM-6' 4: In as.POSIXlt.POSIXct(WSdata$datetime) : unknown timezone 'GTM-6' 5: In as.POSIXct.POSIXlt(from) : unknown timezone 'GTM-6' 6: In as.POSIXct.POSIXlt(to) : unknown timezone 'GTM-6' 7: In as.POSIXct.POSIXlt(from) : unknown timezone 'GTM-6' 8: In as.POSIXct.POSIXlt(to) : unknown timezone 'GTM-6' 9: In as.POSIXct.POSIXlt(e1) : unknown timezone 'GTM-6' 10: In check_tzones(e1, e2) : 'tzone' attributes are inconsistent 11: In as.POSIXct.POSIXlt(e2) : unknown timezone 'GTM-6' 12: In as.POSIXct.POSIXlt(e1) : unknown timezone 'GTM-6' 13: In check_tzones(e1, e2) : 'tzone' attributes are inconsistent 14: In as.POSIXct.POSIXlt(e2) : unknown timezone 'GTM-6'

Any ideas? Also, how do I define a different time zone than the one of the computer?

I think I have correctly captured the data formats...

image

Thank you in advance,

Susana.

midraed commented 5 years ago

To define a gmt zone only use "-6". And if you want to use gmt+6, it has to be "-6". Check strptime()

BEST

On Tue, Apr 9, 2019, 6:52 PM masaba79 notifications@github.com wrote:

Hello, also have problems importing weather station data.

I get the following error with my code:

WeatherStation <- read.WSdata(WSdata = csvfile, date.format = "%d/%m/%Y", lat=18.094, long= -89.462, elev=279, height=2,tz="GTM-6", columns=c("date" = 1, "time" = 2, "radiation" = 3, "wind" = 4, "RH" = 5, "temp" = 6, "rain" = 7), MTL = MTLfile)

Error in Ops.data.frame(WS.after, WS.prev) : ‘-’ only defined for equally-sized data frames In addition: There were 14 warnings (use warnings() to see them)

warnings() Warning messages: 1: In strptime(datetime, format = paste(date.format, time.format), ... : unknown timezone 'GTM-6' 2: In as.POSIXct.POSIXlt(x) : unknown timezone 'GTM-6' 3: In as.POSIXlt.POSIXct(x, tz = tz) : unknown timezone 'GTM-6' 4: In as.POSIXlt.POSIXct(WSdata$datetime) : unknown timezone 'GTM-6' 5: In as.POSIXct.POSIXlt(from) : unknown timezone 'GTM-6' 6: In as.POSIXct.POSIXlt(to) : unknown timezone 'GTM-6' 7: In as.POSIXct.POSIXlt(from) : unknown timezone 'GTM-6' 8: In as.POSIXct.POSIXlt(to) : unknown timezone 'GTM-6' 9: In as.POSIXct.POSIXlt(e1) : unknown timezone 'GTM-6' 10: In check_tzones(e1, e2) : 'tzone' attributes are inconsistent 11: In as.POSIXct.POSIXlt(e2) : unknown timezone 'GTM-6' 12: In as.POSIXct.POSIXlt(e1) : unknown timezone 'GTM-6' 13: In check_tzones(e1, e2) : 'tzone' attributes are inconsistent 14: In as.POSIXct.POSIXlt(e2) : unknown timezone 'GTM-6'

Any ideas? Also, how do I define a different time zone than the one of the computer?

I think I have correctly captured the data formats...

[image: image] https://user-images.githubusercontent.com/49459091/55837747-e2c4bc00-5ae7-11e9-9ad8-b6a0eed26e35.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/midraed/water/issues/41#issuecomment-481454072, or mute the thread https://github.com/notifications/unsubscribe-auth/ACIcZmcdYdGErOlbg0KoXVZf29lF_4o7ks5vfQuzgaJpZM4YHqY4 .

masaba79 commented 5 years ago

Ok thanks, but I still get this error:

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

what to do about it?

masaba79 commented 5 years ago

RESOLVED! The error was due to using "-6". It was resolved by loading library(lubridate), and using tz="America/Merida". Also, we had a wrong date in the weatherstation file...not sure if it had anything to do with the error, but also found out that to be wrong.

Thanks!!

csryan1 commented 5 years ago

Hello,

I am having an issue reading in the Wx station data. I know that a previous comment already addressed this error message, but I do not know what else to do. Here it is:

Error in data.frame(date = unique(WSdata$date), radiation_sum = tapply(WSdata$radiation, : arguments imply differing number of rows: 1, 0

My format for date is %d/%m%Y, and the actual date is 6/28/2017. The excel doc. is in csv format. Should date and time be in a different class besides 'factor'?

Thank you.

metrichelp

midraed commented 5 years ago

Your date format looks more like %m/%d/%Y, and you have an empty column in the middle

On Mon, Apr 15, 2019 at 12:42 PM csryan1 notifications@github.com wrote:

Hello,

I am having an issue reading in the Wx station data. I know that a previous comment already addressed this error message, but I do not know what else to do. Here it is:

Error in data.frame(date = unique(WSdata$date), radiation_sum = tapply(WSdata$radiation, : arguments imply differing number of rows: 1, 0

My format for date is %d/%m%Y, and the actual date is 6/28/2017. The excel doc. is in csv format. Should date and time be in a different class besides 'factor'?

Thank you.

[image: metrichelp] https://user-images.githubusercontent.com/49650140/56145995-6ca2d800-5f73-11e9-8eb4-15ca643eae68.JPG

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/midraed/water/issues/41#issuecomment-483306288, or mute the thread https://github.com/notifications/unsubscribe-auth/ACIcZq9UP2tjh4HWYqoG9R-_WfgrxStXks5vhJ31gaJpZM4YHqY4 .

csryan1 commented 5 years ago

Okay I see now... Thank you. Somewhat new to R Studio.

engrblair30 commented 5 years ago

Hi,

Please I am new to water package. I'm trying to import my weather station, but it is showing error. Below is my code and the error:

WeatherStation <- read.WSdata(WSdata =csvfile, date.format= "%d/%m/%Y", time.format= "%H:%M", lat=42.04306, long=-82.67389, elev=200, height=2.2, columns=c("date" = 1, "time" = 2, "radiation" = 3, "wind" = 4, "RH" = 5, "temp" = 6, "rain" = 7), MTL = MTLfile) Error in data.frame(date = unique(WSdata$date), radiation_sum = tapply(WSdata$radiation, : arguments imply differing number of rows: 1, 0 In addition: Warning message: In read.WSdata(WSdata = csvfile, date.format = "%d/%m/%Y", time.format = "%H:%M", : As tz = "", assuming the weather station time zone is America/New_York

Note: I have read the comments above and I have checked to ensure that my columns are correct and in order. Please what could possibly cause this and what's the possible solution?

Thanks kindly for helping,

Onyeka

csryan1 commented 5 years ago

Onyeka,

I got the same error and this worked for me: I read the weather station data within the read.WSdata function. So for me it was a read.csv function within the read.WSdata function. I also let the function find the MTL file in the working directory instead of reading it in beforehand. This may not solve your own issue, but it worked for me.

Hope that helps.

engin82 commented 4 years ago

Hi Trying to calculate the actual evapotranspiration using water pack. I've uploaded L8 images, but I'm constantly getting an error while loading the WeatherStation file. I think my csv file is correct because I checked it too. Below is the error message I received from the code and post. I would also appreciate it if you can help drop down the screenshot of my csv file csvfile <- "C: /Users/HP/Desktop/water/INTA_1.csv" MTLfile <- "C: /Users/HP/Desktop/water/LC08_L1TP_175034_20150122_20170413_01_T1_MTL.txt" WeatherStation <- read.WSdata (WSdata = csvfile,                               datetime.format = "% Y /% d /% m% H:% M",                               columns = c ("date" = 1, "radiation" = 5,                                         "wind" = 6, "RH" = 3, "temp" = 2, "rain" = 4),                               lat = 37.0005, long = 35.4183, elev = 65, height = 2,                               MTL = MTLfile)

Error in data.frame (date = unique (WSdata $ date), radiation_sum = tapply (WSdata $ radiation,: arguments imply differing number of rows: 1, 0 ekran alıntısı

zaib19 commented 4 years ago

code error I am unable to understand the error received in read.WSdata, can anyone help, i tried all means mentioned above,

error is Error in data.frame(date = unique(WSdata$date), radiation_sum = tapply(WSdata$radiation, : arguments imply differing number of rows: 1, 0 ws read error

eelsaf commented 2 years ago

Hi Guilhermo

I also have an error to import the weather data : Error in read.table(file = file, header = header, sep = sep, quote = quote, : 'file' must be a character string or connection

I've checked my csvfile as below image image

and I used this code :

MTLfile <- c("LC08_L1TP_126060_20191110_20191115_01_T1_MTL.txt") csvfile <- c('WSSiak2019.csv') c2 = read.csv(csvfile) m2 = read.delim(MTLfile) head(c2) head(m2) WS <- read.WSdata(WSdata = csvfile, date.format = "%d/%m/%Y", cf= c(1,1,1), lat=0.65222, long= 101.686389, elev=30, height= 2.2, columns=c("date" = 1, "time" = 2, "radiation" = 3, "wind" = 4, "RH" = 5, "temp" = 6, "rain" = 7), MTL = MTLfile)

Please, uploading the CSVfile into the WS function is always a trouble for me.

Thank you

agronomofiorentini commented 1 year ago

I have the same issue as @zaib19 and @eelsaf in order to run the read.WSdata function.

i will report here below the output of the console by using the str() function of the csv file used as an example by the water R package.

'data.frame':   96 obs. of  8 variables:
 $ Date      : chr  "15/02/2013" "15/02/2013" "15/02/2013" "15/02/2013" ...
 $ Time      : chr  "00:00:00" "00:15:00" "00:30:00" "00:45:00" ...
 $ Rad       : num  0 0 0 0 0 0 0 0 0 0 ...
 $ wind_speed: num  0.44 1.17 2.1 3.57 3.52 3.13 0.63 0.39 0.39 0.63 ...
 $ wind_dir  : num  221 227 235 233 210 ...
 $ RH        : num  63.7 63.4 63.7 64.9 65.5 ...
 $ temp      : num  21.5 21.6 21.7 21.4 21.2 ...
 $ pp        : int  0 0 0 0 0 0 0 0 0 0 ...

while this one is the one that i have created, and i cannot see any different

'data.frame':   95 obs. of  8 variables:
 $ Date      : chr  "04/09/2020" "04/09/2020" "04/09/2020" "04/09/2020" ...
 $ Time      : chr  "00:00:00" "00:00:15" "00:00:30" "00:00:45" ...
 $ Rad       : num  0 0 0 0 0 0 0 0 0 0 ...
 $ wind_speed: num  7.6 7.6 7.6 7.6 5.4 5.4 5.4 5.4 7.6 7.6 ...
 $ wind_dir  : num  190 190 190 190 190 190 190 190 190 190 ...
 $ RH        : num  93.8 93.8 93.8 93.8 93.8 ...
 $ temp      : num  18 18 18 18 17 17 17 17 17 17 ...
 $ pp        : int  0 0 0 0 0 0 0 0 0 0 ...

But when i am running the following code

WeatherStation <- read.WSdata(WSdata=weather_data,
                              lat = 43.6321,
                              long = 13.3924,
                              elev = 113,
                              height = 2,
                              MTL = metadata,
                              tz="Europe/Berlin")

I have this output

Error in data.frame(date = unique(WSdata$date), radiation_sum = tapply(WSdata$radiation,  : arguments imply a different number of rows: 1, 0