-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGetReady.R
87 lines (72 loc) · 1.96 KB
/
GetReady.R
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
83
84
85
86
87
#!/usr/bin/env Rscript
# This file is used for pre-define the variables for the working environment.
# Important vars:
# 1. Path to Rawdata directory
# 2. Path to LDAS data directory
# 3. Path to landuse data raster file
# 4. Path to soil data directory
# 5. Project name
# 6. Years for simulation. startYear and endYear
# 7. Output path.
# Task:
# 1. Set the path to rawdata, output, project name
# 2. Load libraries.
# 3. Create the folders.
args = commandArgs(trailingOnly=TRUE)
if (length(args)==0) {
fn.prj='Example/9035800.autoshud.txt'
}else{
print(args)
fn.prj = args[1]
}
message('Reading project file ', fn.prj)
source('Rfunction/gdalwarp.R')
source('Rfunction/ReadProject.R')
xfg <- read.prj(fn.prj = fn.prj)
if( !is.null(xfg$fsp.lake) ){
LAKEON = TRUE
}else{
LAKEON = FALSE
}
pre.sp = list(
dem = 'dem.tif',
wbd = 'wbd.shp',
wbd.buf = 'wbd_buf.shp',
stm = 'stm.shp',
lake = 'lake.shp',
soil.r = 'soil.tif',
geol.r = 'geol.tif',
soil.v = 'soil.shp',
geol.v = 'geol.shp',
lu.r = 'landuse.tif',
lu.idx = 'landuse_idx.tif',
lu.v = 'landuse.shp',
meteo = 'meteo.shp',
meteoCov = 'meteoCov.shp',
meteoTif = 'meteoCov.tif'
)
dir.pd.pcs = file.path(xfg$dir$predata,'pcs')
dir.pd.gcs = file.path(xfg$dir$predata,'gcs')
dir.create(dir.pd.pcs, showWarnings = FALSE, recursive = TRUE)
dir.create(dir.pd.gcs, showWarnings = FALSE, recursive = TRUE)
pd.pcs = lapply(1:length(pre.sp), function(x){ file.path(dir.pd.pcs, pre.sp[[x]])} )
names(pd.pcs) = names(pre.sp)
pd.gcs = lapply(1:length(pre.sp), function(x){ file.path(dir.pd.gcs, pre.sp[[x]])} )
names(pd.gcs) = names(pre.sp)
pd.att <- list(
geol = file.path(xfg$dir$predata,'GEOL.csv'),
soil = file.path(xfg$dir$predata,'SOIL.csv'),
landuse = file.path(xfg$dir$predata,'LANDUSE.csv')
)
library(raster)
library(sp)
library(rgeos)
library(rgdal)
library(rSHUD)
library(lattice)
library(ggplot2)
# library(GGally)
library(hydroTSM)
library(hydroGOF)
library(xts)
fig.type='cairo'