
R version 4.4.0 (2024-04-24) -- "Puppy Cup"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(data.table)
> library(lubridate)

Attaching package: ‘lubridate’

The following objects are masked from ‘package:data.table’:

    hour, isoweek, mday, minute, month, quarter, second, wday, week,
    yday, year

The following objects are masked from ‘package:base’:

    date, intersect, setdiff, union

> Sys.setenv(TZ = "UTC") 
> 
> PYEAR <- "2024"
> PMON <- "11"
> 
> 
> ###################################################################
> # SELECT TIME PERIOD
> # seconds for  2 days
> daystep <- 60*60*24
> step <- daystep*7
> args <- commandArgs(trailingOnly = TRUE)
> message("ARGUMENTS = ",length(args))
ARGUMENTS = 0
> if (length(args)==0) {
+   t2 <- as.POSIXlt(Sys.time(),tz="UTC")
+   t2 <- t2 + 60*60
+   t2 <- round_date(as.POSIXct(t2),"5 minutes")
+   #t2 <- Sys.time()
+   t1 <- t2 - step
+   #"args:" length(args)
+ } else {
+   t1 <- as.POSIXlt(args[1])
+   t2 <- as.POSIXlt(args[2])
+ }
> 
> MON <- PMON
> MON1 <- as.integer(MON) + 1
> 
> # SET TIME PERIOD HERE:
> t1 <- as.POSIXct(paste0(PYEAR,"-",MON,"-01 00:00:00 CET"))
> t2 <- as.POSIXct(paste0(PYEAR,"-",MON1,"-01 00:00:00 CET"))
> 
> t1 <- as.POSIXlt(format(t1,"%Y-%m-%d %H:%M:00"))
> t2 <- as.POSIXlt(format(t2,"%Y-%m-%d %H:%M:00"))
> #t2 <- t2 + 60*60
> message("PERIOD = ",t1," ",t2)
PERIOD = 2024-11-01 2024-12-01
> runningdate <- seq.Date( from=as.Date(t1), to=as.Date(t2), by="day")
> aggregation <- "5 min"
> 
> 
> header <- c("timetext","TE","FE","TD","DR","WR","WV","WG","WS","WD","RE","RD","SO","UB","DB","TP","WC","FS","RH","HU")
> uni03 <- data.frame(
+   timetext=character(),TE=double(),FE=double(),TD=double(),DR=double(),WR=double(),WV=double(),WG=double(),WS=double(),
+   WD=double(),RE=double(),RD=double(),SO=double(),UB=double(),DB=double(),TP=double(),WC=double(),FS=double(),RH=double(),HU=double(),
+   stringsAsFactors=FALSE)
> 
> 
> for (i in seq_along(runningdate)) {
+ 
+    date <- runningdate[i]
+    message(paste0("reading ",date))
+    datedot <- paste0(substring(date,1,4),".",substring(date,6,7),".",substring(date,9,10))
+    file <- paste0("/zugspitze/lappwald/saqn/meteo/uni03/",substring(date,1,7),"/mws10_",datedot,"_dat.txt")
+    message(paste0("reading ",file))
+ 
+    x <- try(fread(file,header=FALSE,stringsAsFactors=FALSE,sep=" ",dec=".",skip=0,col.names=header,fill=T))
+    if(inherits(x, "try-error")){
+     message("file read error!")
+   }else{
+ 
+   uni03 <- rbind(uni03,x)   
+ 
+   }
+ }
reading 2024-11-01
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.01_dat.txt
reading 2024-11-02
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.02_dat.txt
reading 2024-11-03
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.03_dat.txt
reading 2024-11-04
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.04_dat.txt
reading 2024-11-05
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.05_dat.txt
reading 2024-11-06
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.06_dat.txt
reading 2024-11-07
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.07_dat.txt
reading 2024-11-08
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.08_dat.txt
reading 2024-11-09
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.09_dat.txt
reading 2024-11-10
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.10_dat.txt
reading 2024-11-11
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.11_dat.txt
reading 2024-11-12
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.12_dat.txt
reading 2024-11-13
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.13_dat.txt
reading 2024-11-14
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.14_dat.txt
reading 2024-11-15
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.15_dat.txt
reading 2024-11-16
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.16_dat.txt
reading 2024-11-17
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.17_dat.txt
reading 2024-11-18
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.18_dat.txt
reading 2024-11-19
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.19_dat.txt
reading 2024-11-20
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.20_dat.txt
reading 2024-11-21
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.21_dat.txt
reading 2024-11-22
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.22_dat.txt
reading 2024-11-23
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.23_dat.txt
reading 2024-11-24
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.24_dat.txt
reading 2024-11-25
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.25_dat.txt
reading 2024-11-26
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.26_dat.txt
Error in fread(file, header = FALSE, stringsAsFactors = FALSE, sep = " ",  : 
  File '/zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.26_dat.txt' does not exist or is non-readable. getwd()=='/zugspitze/lappwald/saqn/recent'
file read error!
reading 2024-11-27
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.27_dat.txt
reading 2024-11-28
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.28_dat.txt
reading 2024-11-29
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.29_dat.txt
Error in fread(file, header = FALSE, stringsAsFactors = FALSE, sep = " ",  : 
  File '/zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.29_dat.txt' does not exist or is non-readable. getwd()=='/zugspitze/lappwald/saqn/recent'
file read error!
reading 2024-11-30
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.30_dat.txt
Error in fread(file, header = FALSE, stringsAsFactors = FALSE, sep = " ",  : 
  File '/zugspitze/lappwald/saqn/meteo/uni03/2024-11/mws10_2024.11.30_dat.txt' does not exist or is non-readable. getwd()=='/zugspitze/lappwald/saqn/recent'
file read error!
reading 2024-12-01
reading /zugspitze/lappwald/saqn/meteo/uni03/2024-12/mws10_2024.12.01_dat.txt
Error in fread(file, header = FALSE, stringsAsFactors = FALSE, sep = " ",  : 
  File '/zugspitze/lappwald/saqn/meteo/uni03/2024-12/mws10_2024.12.01_dat.txt' does not exist or is non-readable. getwd()=='/zugspitze/lappwald/saqn/recent'
file read error!
> 
> uni03 <- as.data.frame(uni03)
> time <- as.POSIXlt(uni03$timetext,format="%Y:%m:%d:%H:%M:%S",tz="UTC")
> uni03$time <- time
> uni03[uni03 == -99999.90] <- NA
> 
> 
> ##############################################################################
> png(paste0("uni03_temp_",PYEAR,"-",MON,".png"),width=1900, height=400, units="px", res=300, pointsize=3)
> tmin <- min(uni03$time)
> tmax <- max(uni03$time)
> #message("tmin =",tmin)
> #message("tmax =",tmax)
> tstart <- min(seq(tmin, tmax, by = "hour"))
> tstop <- max(seq(tmin, tmax, by = "hour"))
> vmax <- max(uni03$TE)
> vmin <- min(uni03$TE)
> vmin <- floor(vmin)
> vmax <- ceiling(vmax)
> plot(uni03$time,uni03$TE,xlab=paste("time UTC"),ylab="temperature (°C)",
+ xlim=c(as.POSIXct(tstart),as.POSIXct(tstop)),ylim=c(vmin,vmax),type="n",xaxs="i",yaxs="i",xaxt="n",
+ main=paste("Temperature roof station (",tmin," - ",tmax," UTC)" ))
> ihours <- round( seq( as.POSIXct(tstart), as.POSIXct(tstop),by=3600) , units="hours")
> axis.POSIXct(1, x=uni03$time, at = ihours, format = "%a %m-%d %H:%M")
> abline(v= as.POSIXct(ihours) ,lwd=0.2,col="gray")
> abline(h=seq(vmin,vmax,by=1),lwd=0.2,col="gray")
> lines(uni03$time,uni03$TE,col="black",t="l",lwd=1.0)
> dev.off()
null device 
          1 
> 
> ##############################################################################
> png(paste0("uni03_rhum_",PYEAR,"-",MON,".png"),width=1900, height=400, units="px", res=300, pointsize=3)
> tmin <- min(uni03$time)
> tmax <- max(uni03$time)
> #message("tmin =",tmin)
> #message("tmax =",tmax)
> tstart <- min(seq(tmin, tmax, by = "hour"))
> tstop <- max(seq(tmin, tmax, by = "hour"))
> #vmax <- max(uni03$FE)
> #vmax <- ceiling(vmax)
> vmax <- 100
> #vmin <- min(uni03$FE)
> #vmin <- floor(vmin)
> vmin <- 0
> plot(uni03$time,uni03$FE,xlab=paste("time UTC"),ylab="relative humidity (%)",
+ xlim=c(as.POSIXct(tstart),as.POSIXct(tstop)),ylim=c(vmin,vmax),type="n",xaxs="i",yaxs="i",xaxt="n",
+ main=paste("Relative Humidty roof station (",tmin," - ",tmax," UTC)" ))
> ihours <- round( seq( as.POSIXct(tstart), as.POSIXct(tstop),by=3600) , units="hours")
> axis.POSIXct(1, x=uni03$time, at = ihours, format = "%a %m-%d %H:%M")
> abline(v= as.POSIXct(ihours) ,lwd=0.2,col="gray")
> abline(h=seq(vmin,vmax,by=10),lwd=0.2,col="gray")
> lines(uni03$time,uni03$FE,col="black",t="l",lwd=1.0)
> dev.off()
null device 
          1 
> 
> ##############################################################################
> png(paste0("uni03_wspd_",PYEAR,"-",MON,".png"),width=1900, height=400, units="px", res=300, pointsize=3)
> tmin <- min(uni03$time)
> tmax <- max(uni03$time)
> #message("tmin =",tmin)
> #message("tmax =",tmax)
> tstart <- min(seq(tmin, tmax, by = "hour"))
> tstop <- max(seq(tmin, tmax, by = "hour"))
> vmax <- max(uni03$WG)
> vmin <- min(uni03$WG)
> vmin <- 0 #floor(vmin)
> vmax <- ceiling(vmax)
> plot(uni03$time,uni03$WG,xlab=paste("time UTC"),ylab="wind speed (m/s)",
+ xlim=c(as.POSIXct(tstart),as.POSIXct(tstop)),ylim=c(vmin,vmax),type="n",xaxs="i",yaxs="i",xaxt="n",
+ main=paste("Wind Speed 2m roof station (",tmin," - ",tmax," UTC)" ))
> ihours <- round( seq( as.POSIXct(tstart), as.POSIXct(tstop),by=3600) , units="hours")
> axis.POSIXct(1, x=uni03$time, at = ihours, format = "%a %m-%d %H:%M")
> abline(v= as.POSIXct(ihours) ,lwd=0.2,col="gray")
> abline(h=seq(vmin,vmax,by=1),lwd=0.2,col="gray")
> lines(uni03$time,uni03$WG,col="black",t="l",lwd=1.0)
> dev.off()
null device 
          1 
> 
> ##############################################################################
> png(paste0("uni03_wdir_",PYEAR,"-",MON,".png"),width=1900, height=400, units="px", res=300, pointsize=3)
> tmin <- min(uni03$time)
> tmax <- max(uni03$time)
> #message("tmin =",tmin)
> #message("tmax =",tmax)
> tstart <- min(seq(tmin, tmax, by = "hour"))
> tstop <- max(seq(tmin, tmax, by = "hour"))
> #vmax <- max(uni03$WR)
> #vmin <- min(uni03$WR)
> vmin <- 0 #floor(vmin)
> vmax <- 360 #ceiling(vmax)
> plot(uni03$time,uni03$WR,xlab=paste("time UTC"),ylab="wind direction (°)",
+ xlim=c(as.POSIXct(tstart),as.POSIXct(tstop)),ylim=c(vmin,vmax),type="n",xaxs="i",yaxs="i",xaxt="n",
+ main=paste("Wind Direction 2m roof station (",tmin," - ",tmax," UTC)" ))
> ihours <- round( seq( as.POSIXct(tstart), as.POSIXct(tstop),by=3600) , units="hours")
> axis.POSIXct(1, x=uni03$time, at = ihours, format = "%a %m-%d %H:%M")
> abline(v= as.POSIXct(ihours) ,lwd=0.2,col="gray")
> abline(h=seq(vmin,vmax,by=90),lwd=1.0,col="darkgray")
> lines(uni03$time,uni03$WR,col="black",t="l",lwd=1.0)
> dev.off()
null device 
          1 
> 
> ##############################################################################
> png(paste0("uni03_prec_",PYEAR,"-",MON,".png"),width=1900, height=400, units="px", res=300, pointsize=3)
> tmin <- min(uni03$time)
> tmax <- max(uni03$time)
> #message("tmin =",tmin)
> #message("tmax =",tmax)
> tstart <- min(seq(tmin, tmax, by = "hour"))
> tstop <- max(seq(tmin, tmax, by = "hour"))
> vmax <- max(uni03$RE)
> vmax <- ceiling(vmax)
> #vmin <- min(uni03$RE)
> vmin <- 0 #floor(vmin)
> if(vmax < 3){vmax <- 3}
> plot(uni03$time,uni03$RE,xlab=paste("time UTC"),ylab="precipitation (mm)",
+ xlim=c(as.POSIXct(tstart),as.POSIXct(tstop)),ylim=c(vmin,vmax),type="n",xaxs="i",yaxs="i",xaxt="n",
+ main=paste("Precipitation 2m roof station (",tmin," - ",tmax," UTC)" ))
> ihours <- round( seq( as.POSIXct(tstart), as.POSIXct(tstop),by=3600) , units="hours")
> axis.POSIXct(1, x=uni03$time, at = ihours, format = "%a %m-%d %H:%M")
> abline(v= as.POSIXct(ihours) ,lwd=0.2,col="gray")
> abline(h=seq(vmin,vmax,by=1),lwd=0.5,col="darkgray")
> lines(uni03$time,uni03$RE,col="black",t="l",lwd=1.0)
> dev.off()
null device 
          1 
> 
> ##############################################################################
> png(paste0("uni03_glob_",PYEAR,"-",MON,".png"),width=1900, height=400, units="px", res=300, pointsize=3)
> tmin <- min(uni03$time)
> tmax <- max(uni03$time)
> #message("tmin =",tmin)
> #message("tmax =",tmax)
> tstart <- min(seq(tmin, tmax, by = "hour"))
> tstop <- max(seq(tmin, tmax, by = "hour"))
> vmax <- max(uni03$SO)
> #vmin <- min(uni03$SO)
> vmin <- 0 #floor(vmin)
> vmax <- ceiling(vmax)
> if(vmax < 10){vmax <- 3}
> plot(uni03$time,uni03$SO,xlab=paste("time UTC"),ylab="global radiation (W/m²)",
+ xlim=c(as.POSIXct(tstart),as.POSIXct(tstop)),ylim=c(vmin,vmax),type="n",xaxs="i",yaxs="i",xaxt="n",
+ main=paste("Global Radiation 2m roof station (",tmin," - ",tmax," UTC)" ))
> ihours <- round( seq( as.POSIXct(tstart), as.POSIXct(tstop),by=3600) , units="hours")
> axis.POSIXct(1, x=uni03$time, at = ihours, format = "%a %m-%d %H:%M")
> abline(v= as.POSIXct(ihours) ,lwd=0.2,col="gray")
> abline(h=seq(vmin,vmax,by=100),lwd=0.5,col="darkgray")
> lines(uni03$time,uni03$SO,col="black",t="l",lwd=1.0)
> dev.off()
null device 
          1 
> 
> ##############################################################################
> png(paste0("uni03_pres_",PYEAR,"-",MON,".png"),width=1900, height=400, units="px", res=300, pointsize=3)
> tmin <- min(uni03$time)
> tmax <- max(uni03$time)
> #message("tmin =",tmin)
> #message("tmax =",tmax)
> tstart <- min(seq(tmin, tmax, by = "hour"))
> tstop <- max(seq(tmin, tmax, by = "hour"))
> vmax <- max(uni03$DR)
> vmin <- min(uni03$DR)
> vmax <- ceiling(vmax)
> if(vmax < 10){vmax <- 3}
> plot(uni03$time,uni03$DR,xlab=paste("time UTC"),ylab="pressure (hPa)",
+ xlim=c(as.POSIXct(tstart),as.POSIXct(tstop)),ylim=c(vmin,vmax),type="n",xaxs="i",yaxs="i",xaxt="n",
+ main=paste("Pressure 2m roof station (",tmin," - ",tmax," UTC)" ))
> ihours <- round( seq( as.POSIXct(tstart), as.POSIXct(tstop),by=3600) , units="hours")
> axis.POSIXct(1, x=uni03$time, at = ihours, format = "%a %m-%d %H:%M")
> abline(v= as.POSIXct(ihours) ,lwd=0.2,col="gray")
> abline(h=seq(vmin,vmax,by=1),lwd=0.5,col="darkgray")
> lines(uni03$time,uni03$DR,col="black",t="l",lwd=1.0)
> dev.off()
null device 
          1 
> 
> proc.time()
   user  system elapsed 
  2.428   2.002   2.319 
