Commit 008f7eea authored by Burkhardt Rockel's avatar Burkhardt Rockel

ncdf4Utils version 2.0

-------------------------

**Changed functions:**

`plotmap`

* Has been rewritten in large parts. It should work now not just for geographical and rotated model coordinates, by for most structured grids, if additional geographic lat/lon data are provided for the model grid.
* An additional small model area can no longer be plotted. For this plot a rectangle of the small model area over the plot or use the old version `plotmap.old`

*New Options*

* units - default=NULL (overwrites the units from the netCDF file)
* longname - default=NULL (overwrites the longname from the netCDF file)
* add.offset - default=0
* scale.factor - default=1
* geo.coordinate.names - default=c("lon,"lat") 2D fields of the geographical longitude and latitude at the model grid points

*Removed Options*

* file.small
* sponge.small
* lsm.file.small

**New functions:**

`windvec`

* plots wind vectors over a given plot

`geo2mod`

* converts geographical coordinates to model coordinates

`get.ethz.palette`

* gets a palette from the web page https://wiki.c2sm.ethz.ch/Data/VisNCLCosmoLibraryColorTables

`get.ncar.palette`

* gets a palette from the web page http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml

**Depecreated functions:**

The old version of the function `plotmap` is now called `plotmap.old`. This function will stay as is and will not be further developped.
parent 827a5321
ncdf4Utils version 2.0
-------------------------
**Changed functions:**
`plotmap`
* Has been rewritten in large parts. It should work now not just for geographical and rotated model coordinates, by for most structured grids, if additional geographic lat/lon data are provided for the model grid.
* An additional small model area can no longer be plotted. For this plot a rectangle of the small model area over the plot or use the old version `plotmap.old`
*New Options*
* units - default=NULL (overwrites the units from the netCDF file)
* longname - default=NULL (overwrites the longname from the netCDF file)
* add.offset - default=0
* scale.factor - default=1
* geo.coordinate.names - default=c("lon,"lat") 2D fields of the geographical longitude and latitude at the model grid points
*Removed Options*
* file.small
* sponge.small
* lsm.file.small
**New functions:**
`windvec`
* plots wind vectors over a given plot
`geo2mod`
* converts geographical coordinates to model coordinates
`get.ethz.palette`
* gets a palette from the web page https://wiki.c2sm.ethz.ch/Data/VisNCLCosmoLibraryColorTables
`get.ncar.palette`
* gets a palette from the web page http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml
**Depecreated functions:**
The old version of the function `plotmap` is now called `plotmap.old`. This function will stay as is and will not be further developped.
ncdf4Utils version 1.1
-------------------------
**Changed functions:**
`plotmap`
* corrected a bug preventing sea color to be blue by default
* new parameter "smoothed". If set to "T" the plot will be smoothed.
ncdf4Utils version 1.0
-------------------------
*Changed functions:*
**Changed functions:**
@plotmap.R@ -- corrected bug in case of grid.txt=T,
eliminated artificial straight lines across the plot showing up under some circumstances
eliminated errors plotting grid and writing grid labels in some cases when the date line
or/and a pole lies in the plotting area
`plotmap`
*New functions:*
* corrected bug in case of grid.txt=T
* eliminated artificial straight lines across the plot showing up under some circumstances
* eliminated errors plotting grid and writing grid labels in some cases when the date line or/and a pole lies in the plotting area
@plotmask.R@ -- creates a mask file from a given polygon
**New functions:**
`polymask`
* creates a mask file from a given polygon
ncdf4Utils version 0.5-3
-------------------------
*Changed functions:*
**Changed functions:**
`plotmap`
@plotmap.R@ -- Introduced new paramenter "pollonshift" to account for pollat=90, pollon=180 (TRUE, default)
and pollat=90, pollon=0 (FALSE) representing rotated == geographical grid
* Introduced new paramenter "pollonshift" to account for pollat=90, pollon=180 (TRUE, default) and pollat=90, pollon=0 (FALSE) representing rotated == geographical grid
@geo2rot.R@ —- Introduced new paramenter "pollonshift" to account for pollat=90, pollon=180 (TRUE, default)
and pollat=90, pollon=0 (FALSE) representing rotated == geographical grid.
Corrected error in case pollat=90, pollon /= 0., pollonshift=FALSE
`geo2rot`
* Introduced new paramenter "pollonshift" to account for pollat=90, pollon=180 (TRUE, default)and pollat=90, pollon=0 (FALSE) representing rotated == geographical grid
* Corrected error in case pollat=90, pollon /= 0., pollonshift=FALSE
ncdf4Utils version 0.5-2
-------------------------
*Changed functions:*
**Changed functions:**
`ncdf_times`
* changed default time from CET to UTC
* changed input format of reference time to %Y-%m-%d %H:%M:%
@ncdf_times.R@ -- changed default time from CET to UTC
changed input format of reference time to %Y-%m-%d %H:%M:%
`plot_colourbar`
@plot_colourbar.R@ -- changed label "sea" to "water".
Direction of the axis description now depends on which side the
axis is plotted.
* changed label "sea" to "water"
* Direction of the axis description now depends on which side the axis is plotted.
@plotmap.R@ -- grid labels can be set on and of for each axis separately.
New parameter grid.lwd for the line width of the grid.
Missing reading of attribute earth_radius for multiple_rotated_pole transformation added.
Distinguish for 3D variables whether the third dimension is time or level
`plotmap`
* Grid labels can be set on and of for each axis separately
* New parameter grid.lwd for the line width of the grid
* Missing reading of attribute earth_radius for multiple_rotated_pole transformation added
* Distinguish for 3D variables whether the third dimension is time or level
ncdf4Utils version 0.5-1
-------------------------
*Removed functions:*
@nc_open.R@ -- is no longer necessary since ncdf4 package (version >= 1.6.1) considers
_FillValue as attribute holding missing values
**Removed functions:**
`nc_open`
* is no longer necessary since ncdf4 package (version >= 1.6.1)
@plotmap_rot.R@ -- the new plotmap.R function includes rotated coordinates
*Changed functions:*
@geo2rot.R@ -- calculates the special case pollat=90.,pollon=0.,polgam=0. (i.e. same geographical coordinates)
now logically (no longer pollat=90.,pollon=180.,polgam=0. or pollat=90.,pollon=0.,polgam=180.
for geographical coordinates)
@plotmap.R@ -- this function has been re-written and includes (and thus replaces) the former
plotmap.R and plotmap_rot.R functions. The new function now decides on the
existance and value of the grid mapping parameter in the netCDF file .
A new grid mapping for multiple rotated pole has been added.
A new option is available: "na.col". The colour of undefined grid pixels is defined
by this option. By default it is transparent.
*New functions:*
@geo2multirot.R@ -- transforms geographical to multiple rotated pole coordinates (usage: geo2multirot)
or multiple rotated pole to geographical coordinates (usage: multirot2geo)
`plotmap_rot`
* the new plotmap.R function includes rotated coordinates
**Changed functions:**
`geo2rot`
* calculates the special case pollat=90.,pollon=0.,polgam=0. (i.e. same geographical coordinates) now logically (no longer pollat=90.,pollon=180.,polgam=0. or pollat=90.,pollon=0.,polgam=180.for geographical coordinates)
`plotmap`
* This function has been re-written and includes (and thus replaces) the former plotmap.R and plotmap_rot.R functions. The new function now decides on the existance and value of the grid mapping parameter in the netCDF file
* A new grid mapping for multiple rotated pole has been added.
* A new option is available: "na.col". The colour of undefined grid pixels is defined by this option. By default it is transparent.
**New functions:**
`geo2multirot`
* Transforms geographical to multiple rotated pole coordinates (usage: geo2multirot) or multiple rotated pole to geographical coordinates (usage: multirot2geo)
ncdf4Utils version 0.4-10
......
Package: ncdf4Utils
Type: Package
Title: provides plot functions to use with NetCDF data
Version: 1.0
Date: 2015-04-30
Version: 2.0
Date: 2017-06-29
Author: Jonas Bhend, with contributions
from Burkhardt Rockel <burkhardt.rockel@hzg.de>
Maintainer: Burkhardt Rockel <burkhardt.rockel@hzg.de>
......@@ -15,4 +15,4 @@ Description: This package contains numerous functions to plot
License: GPL
LazyLoad: yes
LazyData: true
Packaged: Thu April 30 16:10:000 2015; rockel
Packaged: Thu Jun 29 12:45:52 CEST 2017; rockel
exportPattern("^[^\\.]")
useDynLib(ncdf4Utils)
......@@ -156,3 +156,34 @@ gbfun <- function(x, start=0.4, log=F){
.soil <- c("#E6FAFF","white", "grey", gbfun(6)[c(3:1,4:6)], .water)
get.ethz.palette <-
function(palette.name, url="https://wiki.c2sm.ethz.ch/pub/Data/VisNCLCosmoLibraryColorTables/")
{
file<-paste(url,palette.name,".ct",sep="")
urlcolors<-readLines(file)
n.levels<-as.numeric(urlcolors[3])
#levels<-as.numeric(strsplit(x = urlcolors[4], split = " ", fixed = T)[[1]][])
levels<-as.numeric(scan(text=urlcolors[4], what="",quiet=TRUE))
colors<-c(1:(n.levels+1))
for (i in 1:(n.levels+1)) {
colors.rgb <- as.numeric(scan(text=urlcolors[i+4], what="",quiet=TRUE))
colors[i] <- rgb(colors.rgb[1],colors.rgb[2],colors.rgb[3], maxColorValue=255)
}
out<-list(colors=colors, levels=levels)
}
get.ncar.palette <-
function(palette.name, url="http://www.ncl.ucar.edu/Document/Graphics/ColorTables/Files/")
{
file<-paste(url,palette.name,".rgb",sep="")
urlcolors<-readLines(file)
n.colors<-as.numeric(strsplit(x = urlcolors[1], split = "=", fixed = T)[[1]][2])
colors<-c(1:n.colors)
for (i in 1:(n.colors)) {
colors.rgb <- as.numeric(scan(text=urlcolors[i+2], what="",quiet=TRUE))
# print(c(i,colors.rgb))
colors[i] <- rgb(colors.rgb[1],colors.rgb[2],colors.rgb[3], maxColorValue=255)
}
out<-list(colors=colors)
}
geo2mod <- function(lon,lat,ptlon,ptlat, gridmapping=list(attribute1=NULL)) {
npt = length(ptlon)
# if (is.null(gridmapping)) gridmapping<-list(attribute1=NULL)
if ((is.null(ncol(lon)) || is.na(ncol(lon))) && is.null(gridmapping$attribute1) ) {
#... lat/lon are 1D. Therefore assuming geographical lat/lon. No conversion necessary in this case.
out <- list(x=ptlon, y=ptlat)
} else if ( !is.null(gridmapping$attribute1) ) {
#... data are in rotated coordinates
out <- geo2rot(gridmapping$attribute1,gridmapping$attribute2,ptlon, ptlat, gridmapping$attribute3, gridmapping$attribute4)
} else {
#... lon/lat are 2D. Grid mapping is assumed in this case.
if (!is.loaded('find_closest')) {
dyn.load('/Volumes/Moritz/R/new_plotmap/find_closest.so')
}
nx = dim(lon)[1]
ny = dim(lon)[2]
ptlon[is.na(ptlon)] <- -999
ptlat[is.na(ptlat)] <- -999
undef <- -999
retdata <- .Fortran("find_closest",
undef = as.double(undef),
ptlon = as.double(ptlon),
ptlat = as.double(ptlat),
lon = as.double(lon),
lat = as.double(lat),
npt = as.integer(npt),
nx = as.integer(nx),
ny = as.integer(ny),
xindex = double(npt),
yindex = double(npt))
out <- list(x=retdata$xindex-1, y=retdata$yindex-1)
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
windvec <- function(u, v, x, y, scale=2., length=0.05, units=NA, lwd=1, colvar=NA, col=par("fg"), levels=1, n=5){
x1 <- x[c(n*1:(length(x)/n))]
y1 <- y[c(n*1:(length(y)/n))]
u1 <- u[c(n*1:(length(x)/n)),c(n*1:(length(y)/n))]
v1 <- v[c(n*1:(length(x)/n)),c(n*1:(length(y)/n))]
lo <- rep(x1, length(u1))
la <- rep(y1, each=length(u1)/length(y1))
w <- sqrt(u1**2 + v1**2)
wmax <- max(w)
if (missing(scale)) scale <- 3*median(abs(c(diff(x1), diff(y1))))
uu <- as.vector(u1)/wmax*scale
vv <- as.vector(v1)/wmax*scale
if (length(levels) == 1) {
arrows(lo, la, lo+uu, la+vv, length=length,lwd=lwd,col=col)
} else {
arrows(lo, la, lo+uu, la+vv, length=length,lwd=lwd,col=col[findInterval(colvar,levels)])
}
# legend
if (!is.na(units)) {
usr <- par( "usr" )
par(xpd=NA)
arrows(usr[ 2 ]-(10./wmax*scale),usr[ 4 ]+xinch(0.1),usr[ 2 ],usr[ 4 ]+xinch(0.1), length=length,lwd=lwd)
text(usr[ 2 ], usr[ 4 ]+xinch(0.3),units, adj = c( 1, 1 ))
par(xpd=FALSE)
}
}
\name{geo2mod}
\alias{geo2mod}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Function to convert geographical into model coordinates}
\description{
Functions to converts geographical latitudes and longitudes to positions on a regular model grid.
}
\usage{
geo2mod(lon,lat,ptlon,ptlat,gridmapping=list(attribute1=NULL))
}
\arguments{
\item{lon}{geographical longitudes of the model grid points, a vector or a matrix}
\item{lat}{geographical latitudes of the model grid points, a vector or a matrix}
\item{ptlon}{geographical longitude values to be converted, a vector with the same length as ptlat}
\item{ptlat}{geographical longitude values to be converted, a vector with the same length as ptlon}
\item{gridmapping}{A list of attributes for the grid mapping as it is returned by the plotmap function}
}
\value{
Returns a list with two vectors:
\item{x}{Processed longitudes}
\item{y}{Processed latitudes}
}
\note{
This function does not work for unstructured grids.
}
\author{Burkhardt Rockel: burkhardt.rockel@hzg.de}
\examples{
for geographical and rotated coordinates
tmp <- plotmap(...)
point<- geo2mod(lon, lat, c(10.,30.,-40.), c(50.,60.,60.),gridmapping=tmp$gridmapping)
for all other coordinates
tmp <- plotmap(...)
point<- geo2mod(lon, lat, c(10.,30.,-40.), c(50.,60.,60.),shift=c(-1,-1),gridmapping=tmp$gridmapping)
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ manip }
\keyword{ utilities }% __ONLY ONE__ keyword per line
\name{get.ethz.palette}
\alias{get.ethz.palette}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{ Function to get a palette from the ETHZ web site}
\description{
The functions retrieves a palette from the ETHZ web site
https://wiki.c2sm.ethz.ch/Data/VisNCLCosmoLibraryColorTables
}
\usage{
get.ethz.palette (palette.name,
url="https://wiki.c2sm.ethz.ch/pub/Data/VisNCLCosmoLibraryColorTables/")
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{palette.name}{Name of the palette as listed on the ETHZ web site}
\item{url}{url of the ETHZ palette web site}
}
\value{
Returns a list with two vectors:
\item{colors}{the colors of the palette in hex}
\item{levels}{the levels of the palette}
}
\note{
This function is part of colfun.R
}
\author{Burkhardt Rockel: burkhardt.rockel@hzg.de}
\examples{
tmp<-get.ethz.palette("kd_temp_1m")
col<-tmp$colors
levs<-tmp$levels
out <- plotmap(...,col=col,levels=levs, ...)
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{color}
\name{get.ncar.palette}
\alias{get.ncar.palette}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{ Function to get a palette from the NCAR web site}
\description{
The functions retrieves a palette from the NCAR web site
http://www.ncl.ucar.edu/Document/Graphics/ColorTables/Files/
}
\usage{
get.ncar.palette (palette.name,
url="http://www.ncl.ucar.edu/Document/Graphics/ColorTables/Files/")
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{palette.name}{Name of the palette as listed on the NCAR web site}
\item{url}{url of the NCAR palette web site}
}
\value{
Returns a list with one vector:
\item{colors}{the colors of the palette in hex}
}
\note{
This function is part of colfun.R
}
\author{Burkhardt Rockel: burkhardt.rockel@hzg.de}
\examples{
tmp<-get.ncar.palette("BlueDarkRed18")
col<-tmp$colors
out <- plotmap(...,col=col, ...)
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{color}
......@@ -4,31 +4,33 @@
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Plot NetCDF data on rotated, multiple rotated or regular lonlat grids}
\description{
This function reads in NetCDF data and produces a lon-lat plot of the specified variable.
This function reads in NetCDF data and produces a plot of the specified variable.
}
\usage{
plotmap(file, file.small = NULL, sponge = 8,
sponge.small = 15, varname = NULL,
lsm.file = NULL, lsm.file.small = NULL, col = NULL,
levels = NULL, sea.col = NULL, na.col = NULL, rivers = T, cities = T,
label = TRUE, minpop = NULL, ncities = 10, city.pch = 19,
alt.contour = F, alt.lev = NULL, grid = TRUE,
grid.txt = TRUE, grid.lty = 2, i.time = 1, i.lev = 1,
map.lwd = 2, map.lty = 1, cex.axis = 1, cex.lab = 1, cex.main = 1,
cex.txt = 1, main = "", xlab = "", ylab = "",
colourplot = TRUE, hires = FALSE, interior = FALSE,
alt.poli=TRUE, add=TRUE, nlongrid=10, nlatgrid=5,
lon.ind, lat.ind, pollonshift = TRUE)
plotmap(file, sponge=8,
varname = NULL, lsm.file=NULL,
units=NULL, longname=NULL, add.offset=0, scale.factor=1,
col=NULL, levels=NULL, sea.col=NULL, na.col=NULL, rivers=T,
cities=T, label=TRUE, minpop=NULL, ncities=10, city.pch=19,
alt.contour=F, alt.lev=NULL,
grid=TRUE, grid.txt=c(T,T,T,T), grid.lty=2, grid.lwd=1,
i.time=1, i.lev=1, map.lwd=2, map.lty=1,
cex.axis=1, cex.txt=1,
main="", xlab="", ylab="", add=FALSE,
colourplot=TRUE, hires=FALSE, interior=FALSE, alt.poli=TRUE,
nlongrid=10, nlatgrid=5, lon.ind, lat.ind, pollonshift=TRUE,smoothed=FALSE,
geo.coordinate.names=c("lon","lat"))
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{file}{Path to the NetCDF file containing the data to plot}
\item{file.small}{... for the nest in the large region}
\item{sponge}{Number of grid cells to mask out at boundary}
\item{sponge.small}{... for the nest in the large region}
\item{varname}{Variable to plot (defaults to \code{HSURF} for orography or any variable with at least lon and lat dimensions)}
\item{lsm.file}{Additional file containing land-sea mask and/or altitude information in \code{FR_LAND} and \code{HSURF}}
\item{lsm.file.small}{... for the nest in the large region}
\item{lsm.file}{Additional file containing land-sea mask and/or altitude information in quantities with the \code{standard_names}: \code{land_area_fraction} and \code{surface_altitude}}
\item{units}{overwrites the units from the netCDF file}
\item{longname}{overwrites the longname from the netCDF file}
\item{add_offset}{adds a constant to the quantity to be plotted}
\item{scale_factor}{multiplies the quantity to be plotted with a constant}
\item{col}{Colours to use}
\item{levels}{Levels to use}
\item{sea.col}{Colour for masked out water grid points}
......@@ -39,7 +41,6 @@ plotmap(file, file.small = NULL, sponge = 8,
\item{minpop}{Minimal population for cities to get drawn}
\item{ncities}{Number of cities to draw}
\item{city.pch}{Symbol for city points}
\item{cex.txt}{Character expansion for city labels}
\item{alt.contour}{Switch for usage of the coastline as in file or lsm.file}
\item{alt.lev}{Level at which to draw coastline (if alt.contour == TRUE) in units of "\code{FR_LAND}"}
\item{grid}{Switch for inclusion of grid lines}
......@@ -50,40 +51,33 @@ plotmap(file, file.small = NULL, sponge = 8,
\item{i.lev}{Level to plot}
\item{map.lwd}{Line width for the coastline/ country border}
\item{map.lty}{Line type for the coastline/ country border}
\item{cex.axis}{Character expansion for axis lat/lon labels}
\item{cex.txt}{Character expansion for city labels}
\item{add}{Should plot be added to existing plot}
\item{colourplot}{Switch for colour or grayscale plot}
\item{hires}{Use hi-resolution coastline}
\item{interior}{Draw political boundaries}
\item{colourplot}{Switch for colour or grayscale plot}
\item{alt.poli}{Switch to use alternative political boundaries}
\item{add}{Should plot be added to existing plot}
\item{nlongrid, nlatgrid}{Approximate number of longitude and latitude grid lines}
\item{lon.ind, lat.ind}{Sequence of longitudes (latitudes) at which to draw grid lines. Has to be increasing. Longitudes greater than 180 are converted.}
\item{pollonshift}{Effects only special cases where pollat=90. in rotated coordinates. For example for rotated==geographic coordinate system pollon=0., pollat=90.. However, due to a bug in nearly all existing conversion routines, this is mostly defined as pollon=180., pollat=90. or pollon=0., pollat=90., polgam=180.. In the latter case set pollonshift=T}
\item{smoothed}{Smooth the plot. Internally use of \code{filled.contour} instead of \code{image}}
\item{geo.coordinate.names}{names fo the 2D fields of the geographical longitude and latitude at the model grid points}
}
\value{
A List of class "plotmap" containing the following objects:
For rotated pole grid mapping:
\item{pollon}{Longitude of the rotated pole}
\item{pollat}{Latitude of the rotated pole}
\item{polgam}{Rotation angle about the North-South-Pole axis in the rotated system}
For multiple rotated pole grid mapping:
\item{loncent}{center longitude of the transformed system in degrees}
\item{latcent}{center latitude of the transformed system in degrees}
\item{false_easting}{false easting of x, i.e. shift of x-coordinate}
\item{false_northing}{false northing of y, i.e. shift of y-coordinate}
\item{earth_radius}{earth radius in meter}
For all grid mappings:
\item{levs}{The levels used}
\item{col}{The colours used}
\item{sea.col}{The colour used for water grid points}
\item{longname}{The longname attribute of the variable plotted}
\item{units}{The units of the variable plotted}
\item{gridmapping}{A list containing the grid mapping attributes and additionals. For example rotated pole coodinates: gridmapping=list(attribute1=pollon, attribute2=pollat, attribute3=polgam, attribute4=pollonshift) }
}
\note{
This function chooses the grid mapping dependent on the existance of the parameter "rotated_pole" or "multiple_rotated_pole".
If none of them exists geographical coordinates are assumed.
This function should work now not just for geographical and rotated model coordinates, by for most structured grids, if additional geographic lat/lon data are provided for the model grid.
}
\author{Jonas Bhend / Burkhardt Rockel: Burkhardt.Rockel@hzg.de}
\author{Burkhardt Rockel: Burkhardt.Rockel@hzg.de}
\seealso{\code{\link{plot_colourbar.plotmap}}}
\examples{
print("Sorry no examples, too complex...")
......
\name{plotmap_rot}
\alias{plotmap_rot}
\alias{plotmap}
\name{plotmap.old}
\alias{plotmap.old}
\alias{plotmap.old}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Plot NetCDF data on rotated or regular lonlat grids}
\title{Plot NetCDF data on rotated, multiple rotated or regular lonlat grids}
\description{
This function reads in NetCDF data and produces a lon-lat plot of the specified variable.
Depecriated, you may use the new plotmap version instead.
This function reads in NetCDF data and produces a plot of the specified variable.
}
\usage{
plotmap_rot(file, file.small = NULL, sponge = 8,
plotmap.old(file, file.small = NULL, sponge = 8,
sponge.small = 15, varname = NULL,
lsm.file = NULL, lsm.file.small = NULL, col = NULL,
levels = NULL, sea.col = NULL, rivers = T, cities = T,
levels = NULL, sea.col = NULL, na.col = NULL, rivers = T, cities = T,
label = TRUE, minpop = NULL, ncities = 10, city.pch = 19,
alt.contour = F, alt.lev = NULL, grid = TRUE,
grid.txt = TRUE, grid.lty = 2, i.time = 1, i.lev = 1,
map.lwd = 2, cex.axis = 1, cex.lab = 1, cex.main = 1,
map.lwd = 2, map.lty = 1, cex.axis = 1, cex.lab = 1, cex.main = 1,
cex.txt = 1, main = "", xlab = "", ylab = "",
colourplot = TRUE, hires = FALSE, interior = FALSE,
alt.poli=TRUE, add=TRUE, nlongrid=10, nlatgrid=5,
lon.ind, lat.ind)
plotmap(file, file.small = NULL, sponge = 8,
sponge.small = 15, varname = NULL, lsm.file = NULL,
lsm.file.small = NULL, col = NULL, levels = NULL,
sea.col = NULL, alt.contour = F, alt.lev = NULL,
grid = TRUE, grid.txt = TRUE, grid.lty = 2, i.time = 1,
i.lev = 1, map.lwd = 2, cex.axis = 1, cex.lab = 1,
cex.main = 1, main = "", xlab = "", ylab = "",
colourplot = TRUE, hires = FALSE, interior = FALSE,
alt.poli=TRUE, add=TRUE, nlongrid=10, nlatgrid=5,
lon.ind, lat.ind)
lon.ind, lat.ind, pollonshift = TRUE, smoothed = FALSE)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
......@@ -38,11 +28,12 @@ plotmap(file, file.small = NULL, sponge = 8,
\item{sponge}{Number of grid cells to mask out at boundary}
\item{sponge.small}{... for the nest in the large region}
\item{varname}{Variable to plot (defaults to \code{HSURF} for orography or any variable with at least lon and lat dimensions)}
\item{lsm.file}{Additional file containing land-sea mask and/or altitude information in \code{FR\_LAND} and \code{HSURF}}
\item{lsm.file}{Additional file containing land-sea mask and/or altitude information in \code{FR_LAND} and \code{HSURF}}
\item{lsm.file.small}{... for the nest in the large region}
\item{col}{Colours to use}
\item{levels}{Levels to use}
\item{sea.col}{Colour for masked out water grid points}
\item{na.col}{Colour for grid points with undefined values}
\item{rivers}{Switch for automatically added rivers}
\item{cities}{Switch for automatically added cities}
\item{label}{Switch for labels of cities}
......@@ -51,13 +42,15 @@ plotmap(file, file.small = NULL, sponge = 8,
\item{city.pch}{Symbol for city points}
\item{cex.txt}{Character expansion for city labels}
\item{alt.contour}{Switch for usage of the coastline as in file or lsm.file}
\item{alt.lev}{Level at which to draw coastline (if alt.contour == TRUE) in units of "\code{FR\_LAND}"}
\item{alt.lev}{Level at which to draw coastline (if alt.contour == TRUE) in units of "\code{FR_LAND}"}
\item{grid}{Switch for inclusion of grid lines}
\item{grid.txt}{Switch for inclusion of grid axis labels at the border of the plot}
\item{grid.txt}{Switch for inclusion of grid axis labels at the border of the plot. Can be set for each side separately by using grid.txt=c(T,T,T,T)}
\item{grid.lty}{Line type for grid lines}
\item{grid.lwd}{Line width for grid lines}
\item{i.time}{Time step to plot}
\item{i.lev}{Level to plot}
\item{map.lwd}{Line width for the coastline/ country border}
\item{map.lty}{Line type for the coastline/ country border}
\item{hires}{Use hi-resolution coastline}
\item{interior}{Draw political boundaries}
\item{colourplot}{Switch for colour or grayscale plot}
......@@ -65,19 +58,34 @@ plotmap(file, file.small = NULL, sponge = 8,
\item{add}{Should plot be added to existing plot}
\item{nlongrid, nlatgrid}{Approximate number of longitude and latitude grid lines}
\item{lon.ind, lat.ind}{Sequence of longitudes (latitudes) at which to draw grid lines. Has to be increasing. Longitudes greater than 180 are converted.}
\item{pollonshift}{Effects only special cases where pollat=90. in rotated coordinates. For example for rotated==geographic coordinate system pollon=0., pollat=90.. However, due to a bug in nearly all existing conversion routines, this is mostly defined as pollon=180., pollat=90. or pollon=0., pollat=90., polgam=180.. In the latter case set pollonshift=T}
\item{smoothed}{Smooth the plot. Internally use of \code{filled.contour} instead of \code{image}}
}
\value{
A List of class "plotmap" containing the following objects:
For rotated pole grid mapping:
\item{pollon}{Longitude of the rotated pole}
\item{pollat}{Latitude of the rotated pole}
\item{polgam}{Switch for mirrored rotation (e.g. 0 or -180 degrees)}
\item{polgam}{Rotation angle about the North-South-Pole axis in the rotated system}
For multiple rotated pole grid mapping:
\item{loncent}{center longitude of the transformed system in degrees}
\item{latcent}{center latitude of the transformed system in degrees}
\item{false_easting}{false easting of x, i.e. shift of x-coordinate}
\item{false_northing}{false northing of y, i.e. shift of y-coordinate}
\item{earth_radius}{earth radius in meter}
For all grid mappings:
\item{levs}{The levels used}
\item{col}{The colours used}
\item{sea.col}{The colour used for water grid points}
\item{longname}{The longname attribute of the variable plotted}
\item{units}{The units of the variable plotted}
}
\author{Jonas Bhend: jonas.bhend@env.ethz.ch}
\note{
This function chooses the grid mapping dependent on the existance of the parameter "rotated_pole" or "multiple_rotated_pole".
If none of them exists geographical coordinates are assumed.
}
\author{Jonas Bhend / Burkhardt Rockel: Burkhardt.Rockel@hzg.de}
\seealso{\code{\link{plot_colourbar.plotmap}}}
\examples{
print("Sorry no examples, too complex...")
......
\name{polymask}
\alias{polymask}
\alias{polymask}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Create a mask from a given closed polygon}
\description{
This function reads a closed polygon given as geographical longitude and latitude pairs.
The inner part of the polygon is given the value 1. The value in the outer part can be chosen
by the user. This value will be interpreted as undefined in netCDF.
The inner part of the polygon is given the value 1. The value in the outer part can be chosen by the user. This value will be interpreted as undefined in netCDF.
Optionally the created mask can be written into a file
}
\usage{
polymask(Cfile, Pfile, Mfile=NULL, frac=1, skiplines=0, undef=-1.E20)
polymask(Cfile, Pfile, Mfile=NULL, multiply=1, skiplines=0, undef=-1.E20)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{Cfile}{NetCDF input file containing the information of the domain}
\item{Pfile}{ASCII input file containing the polygon points in geographical coordinates}
\item{Pfile}{ASCII input file containing the polygon points in geographical coordinates. One longitude latitude pair per line.}
\item{Mfile}{Output file receiving the mask}
\item{frac}{allows for fractional grid box values in the vicinity of the polygon line. 1 = no fraction, 2 = halfs, 4 = quarters, etc.}
\item{multiply}{allows for fractional grid box values in the vicinity of the polygon line. \code{multiply} is the factor by which the grid is inflated temporarily during the computation. 1 = no fraction, 2 = halfs, 3 = thirds, 4 = quarters, etc.}
\item{skiplines}{lines to be skipped when reading from Pfile}
\item{undef}{value in the outer part of the polygon}
}
\value{
A List of class "polymask" containing the following objects:
\item{outgrid}{array holding the mask}
Returns a matrix of dimension nlon x nlat of fractional gridbox area within the polygon.
}
\author{Jonas Bhend / Burkhardt Rockel: Burkhardt.Rockel@hzg.de}
\author{Burkhardt Rockel: Burkhardt.Rockel@hzg.de}
\examples{
# create a mask with fractional grid box coverage and skip the first line when reading the polygon file
polymask (Cfile="/path/lffd2001010100.nc", Pfile="/path/polygon.txt", Mfile="/path/mask.nc", frac=4, skiplines=1)
polymask (Cfile="/path/lffd2001010100.nc", Pfile="/path/polygon.txt", Mfile="/path/mask.nc", multiply=4, skiplines=1)
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ aplot }
\keyword{ spatial }
\name{windvec}
\alias{windvec}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Create a vector plot}
\description{
This function plots wind vectors over a given plot.
}
\usage{
windvec(u, v, x, y, scale=2., length=0.05, units=NA, lwd=1, colvar=NA, col=par("fg"), levels=1, n=5)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{u, v}{2D arrays holding the values for the velocity components in x and y direction}
\item{x, y}{1D arrays holding the coordinate values in x and y direction}
\item{scale}{scaling of the vector length}
\item{length}{length of the edges of the arrow head (in inches)}
\item{units}{units of u and v}
\item{lwd}{line width}
\item{colvar}{quantity to be plotted as colors of the vector}
\item{col}{colors of the vectors}
\item{levels}{levels for the colors}
\item{n}{plot every n's vector}
}
\value{
There is no return value
}
\author{Burkhardt Rockel: Burkhardt.Rockel@hzg.de}
\examples{
# plot vectors of 10m wind over an image created with plotmap
col<-c("#FFFF82","#F0F000","#82FF82","#00FF00","#00C800","#009600","#00A0FF",
"#0064FF","#0000FF","#8C1EDC","#A000A0","#BE0082","#BE005A","#BE0000")
levs<-seq(-23.,23.,2.)
nc<-nc_open(ncfile)
rlon <- ncvar_get(nc,"rlon")
rlat <- ncvar_get(nc,"rlat")
u <- ncvar_get(nc,"U_10M")
v <- ncvar_get(nc,"V_10M")
t <- ncvar_get(nc,"T_2M")
units <- paste("10 ",ncatt_get(ncu, "U_10M", "units")$value,sep="")
nc_close(nc)
tmp <- plotmap(.....)
# with colors
windvec(u, v, rlon, rlat,units=units,colvar=t,col=col,levels=levs)
# without colors
windvec(u, v, rlon, rlat,units=units)
}