Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Franssen, Wietse
WFRTools
Commits
6a898d91
Commit
6a898d91
authored
Feb 16, 2015
by
Franssen, Wietse
Browse files
Some small improvements
parent
6428476b
Changes
1
Hide whitespace changes
Inline
Side-by-side
R/WFRTools.R
View file @
6a898d91
#' @keywords internal
.PRINT_INFO
<-
TRUE
#' blabla a test primt message
#'
#' @param none (yet)
...
...
@@ -20,10 +23,10 @@ plotje <-function(data, title = " ") {
#' @author Wietse Franssen \email{wietse.franssen@wur.nl}
#' @export
#' @keywords internal
ncPlot
<-
function
(
file
)
{
data
<-
ncLoad
(
file
)
ncPlot
<-
function
(
file
,
varName
=
"pr"
)
{
data
<-
ncLoad
(
file
,
varName
)
plotje
(
data
,
title
=
paste0
(
data
$
Variable
$
varName
,
" ("
,
data
$
Dates
$
start
[
1
],
")"
))
return
(
data
)
#
return(data)
}
#' Shows a test primt message
...
...
@@ -45,15 +48,58 @@ rDataStructure <-function() {
return
(
rData
)
}
ncCheck
<-
function
(
ncFile
,
variable
)
{
result
<-
NULL
result
$
xFlip
<-
FALSE
result
$
yFlip
<-
FALSE
result
$
dims
<-
FALSE
result
$
dimids
<-
FALSE
result
$
tArray
<-
FALSE
lons
<-
ncFile
$
dim
$
lon
$
vals
lats
<-
ncFile
$
dim
$
lat
$
vals
times
<-
ncFile
$
dim
$
time
$
vals
# what is the order of the variable dimensions:
for
(
i
in
1
:
length
(
ncFile
$
var
[[
variable
]]
$
dimids
))
{
result
$
dims
[
i
]
<-
ncFile
$
dim
[[
i
]]
$
name
result
$
dimids
[
i
]
<-
ncFile
$
dim
[[
i
]]
$
id
}
if
(
length
(
times
)
>
1
)
{
result
$
tArray
<-
TRUE
}
if
((
lons
[
2
]
-
lons
[
1
])
<
0
)
{
result
$
xFlip
<-
TRUE
}
if
((
lats
[
2
]
-
lats
[
1
])
<
0
)
{
result
$
yFlip
<-
TRUE
}
return
(
result
)
}
#' blabla a test primt message
#'
#' @param none (yet)
#' @details The function
#' @return blabla
#' @author Wietse Franssen \email{wietse.franssen@@wur.nl}
#' @export
#' @argument title
#' @keywords internal
ncLoad
<-
function
(
file
,
varName
=
"pr"
)
{
#dat<-ncLoad(file = "~/Desktop/gg/wfd_pr_1974.nc" )
#dat
a
<-ncLoad(file = "~/Desktop/gg/wfd_pr_1974.nc" )
data
<-
rDataStructure
()
ncFile
<-
nc_open
(
file
)
ncCheckResult
<-
ncCheck
(
ncFile
=
ncFile
,
variable
=
varName
)
data
$
xyCoords
$
x
<-
ncFile
$
dim
$
lon
$
vals
data
$
xyCoords
$
y
<-
ncFile
$
dim
$
lat
$
vals
if
(
.PRINT_INFO
==
TRUE
)
{
cat
(
"Variables:\n"
)
print
(
names
(
ncFile
$
var
))
cat
(
"yeah!\n"
)
print
(
ncCheckResult
)
#print(ncFile)
}
NCtime
<-
ncvar_get
(
ncFile
,
"time"
)
NCtimeAtt
<-
ncatt_get
(
ncFile
,
"time"
,
"units"
)
$
value
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment