-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite_cli_gr.Rmd
82 lines (63 loc) · 2.12 KB
/
write_cli_gr.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
title: "Recording climatic data from the Excel spreadsheet program fortranovskoj format version 5"
output: html_notebook
---
####
```{r}
require(lubridate); require(openxlsx); require(readxl); require(imputeTS)
Sys.setenv(R_ZIPCMD = paste0("C:/Users/IVA/Dropbox/Apps", "/bin/zip.exe"))
cli.path <- "C:/Users/IVA/Dropbox/Apps/china/LZ"
cli.path.sdl <- "C:/Users/IVA/Dropbox/Apps/china/SDL"
file.cli.sdl <- "Meterorological data.xls"
file.cli <- "/LZ daily data.xlsx"
file.cli.perc <- "LZ daily data.xlsx - p.csv"; file.cli.temp <- "LZ daily data.xlsx - t.csv"
print("end.")
prec <- read_excel(paste0(cli.path, file.cli), sheet = "p")
#str(prec); summary(prec)
temp <- read_excel(paste0(cli.path, file.cli), sheet = "t")
#str(temp); summary(temp)
r <- c("Stationsname Lati.Long.Alti.",
"D Mo Year Min. Max. Mean Sunshine Daily Mean",
"* Temp. Temp. Cloud Abs. Rel. Prec. Trans Press Temp. Humid",
"* Cover",
"* /10 C /10 C /10 /10 h % /10mm /10mm/10hPa /10 C %",
"1969", #6
" 7062 14788 -9999", #7
"coku") #8
```
```{r}
# save(y50,y52, file = "C:/Users/IVA/Dropbox/Apps/china/LZ/y50y52.RData")
non.leap <-
```
####
```{r}
name.station <- "lz"
for(i in names(temp)){
fileConn<-file(paste0(cli.path, "/", name.station, i, ".cli"), open="w")
r[6] <- i
#r[7] <- ; r[8] <- ; r[9] <-
r[8] <- name.station
writeLines(r, fileConn)
if (leap_year(as.integer(i)))
num.days <- 366
else
num.days <- 365
day <- 1; month <- 1
for(k in 1:num.days){
cli.line <- rep("-9999",14); cli.line[14] <- "\n"
cli.line[3] <- as.integer(i)
if (leap_year(as.integer(i)) && month == 2){
if (day < 28) day <- day + 1
else day <- 1
}
if (!leap_year(as.integer(i)) && month == 2){
if (day < 27) day <- day + 1
else day <- 1
}
cli.line[1] <- as.integer(day)
cli.line <- paste0(cli.line)
writeLines(cli.line, con = fileConn, sep="")
}
close(fileConn)
}
```