找回密码
 注册
查看: 506|回复: 0

R语言 rootSolve包 plot.steady1D()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-27 22:59:53 | 显示全部楼层 |阅读模式
plot.steady1D(rootSolve)
plot.steady1D()所属R语言包:rootSolve

                                         Plot and Summary Method for steady1D, steady2D and steady3D Objects
                                         图和总结方法,为steady1D,steady2D和steady3D对象

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Plot the output of steady-state solver routines.
绘制的输出稳态求解器例程。


用法----------Usage----------


## S3 method for class 'steady1D'
plot(x, ..., which = NULL, grid = NULL,
              xyswap = FALSE, ask = NULL,
              obs = NULL, obspar = list(), vertical = FALSE)
## S3 method for class 'steady2D'
image(x, which = NULL, add.contour = FALSE,
              grid = NULL, ask = NULL,
              method = "image", legend = FALSE, ...)
## S3 method for class 'steady2D'
subset(x, which = NULL, ...)
## S3 method for class 'steady3D'
image(x, which = NULL, dimselect = NULL,
              add.contour = FALSE, grid = NULL, ask = NULL,
              method = "image", legend = FALSE, ...)
## S3 method for class 'rootSolve'
summary(object, ...)



参数----------Arguments----------

参数:x
an object of class steady1D, or steady2D as  returned by the solvers steady.1D and steady.2D, and  to be plotted.  For steady1D objects, it is allowed to pass several objects  after x (unnamed) - see second example.  
类的一个对象steady1D或steady2D返回的解算器steady.1D和steady.2D,并进行绘制。 steady1D对象,它允许通过几个对象后x(未命名) - 第二个例子。


参数:which
the name(s) or the index to the variables that should be plotted.  Default = all variables.  
的名称(s)或应被绘制的变量的索引。默认=所有变量。


参数:grid
For 1-D plots of output generated with steady.1D,  a vector of values against which the 1-D steady-state solution  has to be plotted. If NULL, then steady-state solutions  are plotted against the index.   for image plots of output generated with steady.2D or  steady.3D: the x- and y-grid, as a list.
1-D图形输出产生的steady.1D,对1-D稳态解要绘制一个矢量的值。如果NULL,然后稳态解的指数暗算。为image了输出steady.2D或steady.3D:x和y电网产生的,作为一个list。


参数:ask
logical; if TRUE, the user is asked before each plot, if NULL the user is only asked if more than one page of plots is necessary and the current graphics device is set interactive, see par(ask=.) and dev.interactive.
逻辑;TRUE,用户问过的每个图,如果NULL用户只要求如果多个页面的图是必要的,当前的图形设备设置互动,请参阅<X >和par(ask=.)。


参数:xyswap
if TRUE, then x-and y-values are swapped and the  y-axis is from top to bottom. Useful for drawing vertical profiles.
如果TRUE,则x和y值的交换和y轴是从顶部到底部。用于绘制垂直剖面。


参数:vertical
if TRUE, then 1. x-and y-values are swapped, the y-axis is from top to bottom, the x-axis is on top, margin 3 and the main title gets the value of the x-axis. Useful for drawing vertical profiles; see example 2.
如果TRUE,然后1。的x-轴的x-和y-值被交换,y轴是从顶部到底部,顶部,边缘3和主标题得到的x轴的值上。绘制垂直剖面图;见例2。


参数:obs
a data.frame or matrix with "observed data" that will be added as points to the plots. obs can also be a  list with multiple data.frames and/or matrices containing  observed data.   The first column of obs should contain the grid-variables as  specified in argument grid.  The other columns contain the observed values and they should have names that are known in x.      If the first column of obs consists of factors, or characters (strings), then it is assumed that the data are presented in long (database) format, where the first three columns contain (name, grid, value).    If obs is not NULL and  which is NULL, then the variables, common to both  obs and x will be plotted.  
一个data.frame或matrix“观测数据”,将增加一条,作为points图。 obs也可以是一个list与的多个data.frames和/或含有观测数据的矩阵。第一列obs应包含网格变量中指定的参数grid。其他列包含的观测值,他们应该被称为x的名称。如果第一列obs包括的因素,或字符(字符串),则它被假定,数据列于长(数据库)的格式,其中的前三列包含(姓名,网格,值)。如果obs是非NULL和which是NULL,那么变量,以双方共同的obs和x将被绘制。


参数:obspar
additional graphics arguments passed to points, for  plotting the observed data. If obs is a list containing multiple observed data sets, then the graphics arguments can be  a vector or a list (e.g. for xlim, ylim), specifying each data set  separately.  
额外的图形参数传递给points,绘制的观测数据。如果obs是一个list含有多个观测到的数据集,然后在图形参数可以是一个向量或列表(例如,用于xlim,ylim),并指定每个数据集分开。


参数:dimselect
a list or NULL. The dimension over which the  3-D image loops.  If NULL, will loop over the 3rd (z) dimension. This is similar as setting dimselect = list(z = 1:Nz) where Nz is the number of grid cells in the 3rd dimension; setting  dimselect = list(z = seq(1, Nz, by =2)) will loop over the 3rd dimension, but every 2nd cell; dimselect = list(x = ...) or dimselect = list(y = ...) will loop over the x respectively y-dimension. See steady.3D for some examples.   
list或NULL。循环的3-D图像的尺寸。如果NULL,将循环第3(z)的尺寸。这是类似的设置dimselect = list(z = 1:Nz),其中,NZ的网格单元中的第三维是多少;设置dimselect = list(z = seq(1, Nz, by =2))循环的第三维,但每2单元;dimselect = list(x = ...)或<X >循环的x,y维度。见dimselect = list(y = ...)的一些例子。


参数:add.contour
if TRUE, will add contours to the image plot.  
如果TRUE,将增加轮廓的图像绘图。


参数:method
the name of the plotting function to use, one of "image",  "filled.contour", "contour" or "persp".
绘图功能使用的名称,“图像”,“filled.contour”,“轮廓”或“persp”。


参数:legend
if TRUE, a color legend will be drawn next to  the "image", or "persp" plot.
TRUE,一个传奇的色彩将画下的“形象”,或“persp”的图。


参数:object
object of class rootSolve whose summary has to be  calculated.   
对象的类rootSolve的总结来计算。


参数:...
additional arguments passed to the methods.  The graphical arguments are passed to plot.default (for 1D) or image (for 2D, 3D)  For plot.steady1D, the dots may contain other objects of class  steady1D, as returned by steady.1D, and  to be plotted on the same graphs as x  - see second example. x and and these other objects should be compatible,  i.e. the column names should be the same.  For plot.steady1D, the arguments after ... must be matched exactly.      
额外的参数传递给方法。图形化的参数被传递给plot.default(1D)或image(2D,3D)plot.steady1D,点可能包含其他类的对象,“steady1D,返回steady.1D,并要绘制在同一图表x - 看第二个例子。 x和其他天体的应该是兼容的,即列名应该是相同的。对于plot.steady1D,后的参数...必须完全匹配。


Details

详细信息----------Details----------

The number of panels per page is automatically determined up to 3 x 3 (par(mfrow=c(3, 3))). This default can be overwritten by specifying user-defined settings for mfrow or mfcol. Set mfrow equal to NULL to avoid the plotting function to  change user-defined mfrow or mfcol settings
被自动确定在每页的面板的数目为3×3(par(mfrow=c(3, 3)))。此默认值可以通过指定用户定义的设置为mfrow或mfcol覆盖。设置mfrow等于NULL,以避免绘图功能,改变用户自定义的mfrow或mfcol设置

Other graphical parameters can be passed as well. Parameters are vectorized, either according to the number of plots  (xlab, ylab, main, sub, xlim, ylim, log, asp, ann, axes, frame.plot,panel.first,panel.last, cex.lab,cex.axis,cex.main) or  according to the number of lines within one plot (other parameters  e.g. col, lty, lwd etc.) so it is possible to assign specific axis labels to individual plots, resp. different plotting  style. Plotting parameter ylim, or xlim can also be a list  to assign different axis limits to individual plots.
可以通过为其他图形参数。参数量化的,根据数图(xlab, ylab,main, sub,xlim, ylim,log,asp, ann, axes, frame.plot,panel.first,panel.last,cex.lab,cex.axis,cex.main),或根据积内的行数(其他参数,如col,lty,lwd等),这样就可以指定特定的轴标签,个别图分别。不同的绘图风格。绘图参数ylim或xlim也可以是一个列表来指定不同的轴限制,个别图。

Similarly, the graphical parameters for observed data, as passed by  obspar can be vectorized, according to the number of observed  data sets.
同样地,可以观察到的数据,如通过obspar的图形参数矢量,根据观测到的数据集的数量。

For steady3D objects, 2-D images are generated by looping over one of the axies; by default the third axis. See  steady.3D.
对于steady3D对象,生成的2-D图像循环的轴距,默认情况下,第三轴。见steady.3D。


参见----------See Also----------

steady.1D, steady.2D, steady.3D  
steady.1D,steady.2D,steady.3D


实例----------Examples----------


## =======================================================================[#================================================= ======================]
##  EXAMPLE 1: 1D model, BOD + O2                                [#例1:一维模式,BOD + O2]
## =======================================================================[#================================================= ======================]
## Biochemical Oxygen Demand (BOD) and oxygen (O2) dynamics[#生化需氧量(BOD)和氧气(O2)动态]
## in a river[#在河]

#==================#[==================#]
# Model equations  #[模型方程#]
#==================#[==================#]
O2BOD <- function(t, state, pars) {
  BOD <- state[1:N]
  O2  <- state[(N+1)2*N)]

# BOD dynamics[BOD动态]
  FluxBOD &lt;-  v * c(BOD_0, BOD)  # fluxes due to water transport[通量由于水路运输]
  FluxO2  <-  v * c(O2_0, O2)
  
  BODrate &lt;- r*BOD*O2/(O2+10)  # 1-st order consumption, Monod in oxygen[1,莫诺次消费中的氧]

#rate of change = flux gradient - consumption  + reaeration (O2)[变化率=通量梯度 - 消费+复氧(O2)]
  dBOD         <- -diff(FluxBOD)/dx  - BODrate
  dO2          <- -diff(FluxO2)/dx   - BODrate + p*(O2sat-O2)

  return(list(c(dBOD = dBOD, dO2 = dO2)))
}    # END O2BOD[END O2BOD]


#==================#[==================#]
# Model application#[典型应用#]
#==================#[==================#]
# parameters[参数]
dx      &lt;- 100       # grid size, meters[网格大小,米]
v       &lt;- 1e2       # velocity, m/day[速度,m /天]
x       &lt;- seq(dx/2,10000,by=dx)  # m, distance from river[米,距离河]
N       <- length(x)
r       &lt;- 0.1       # /day, first-order decay of BOD[/天,一阶衰减的BOD]
p       &lt;- 0.1       # /day, air-sea exchange rate[/天,海 - 气交换率]
O2sat   &lt;- 300       # mmol/m3 saturated oxygen conc[mmol/m3饱和的氧气浓度]
O2_0    &lt;- 50        # mmol/m3 riverine oxygen conc[mmol/m3河流氧浓]
BOD_0   &lt;- 1500      # mmol/m3 riverine BOD concentration[mmol/m3河流BOD浓度]

# initial guess:[最初的猜测:]
state <- c(rep(200,N), rep(200,N))

# running the model[运行模型]
out   <- steady.1D (y = state, func = O2BOD, parms = NULL,
                    nspec = 2, pos = TRUE,
                    names = c("BOD", "O2"))

summary(out)

# output[产量]
plot(out, grid = x, type = "l", lwd = 2,
     ylab = c("mmol/m3", "mmol O2/m3"))

# observations[观察]
obs <- matrix (ncol = 2, data = c(seq(0, 10000, 2000),
                                c(1400, 900,400,100,10,10)))

colnames(obs) <- c("Distance", "BOD")

# plot with observations[图与观测]
plot(out, grid = x, type = "l", lwd = 2, ylab = "mmol/m3", obs = obs,
     pch = 16, cex = 1.5)

# similar but data in "long" format[在“长”格式相似,但数据]
OUT <- data.frame(name = "BOD", obs)
## Not run: [#不运行:]
plot(out, grid = x, type = "l", lwd = 2, ylab = "mmol/m3", obs = OBS,
     pch = 16, cex = 1.5)

## End(Not run)[#(不执行)]

## =======================================================================[#================================================= ======================]
##  EXAMPLE 2: 1D model, BOD + O2 - second run                               [例2:一维模式,BOD + O2  - 第二次运行]
## =======================================================================[#================================================= ======================]
# new runs with different v[新的运行与不同的V]
v       &lt;- 50       # velocity, m/day[速度,m /天]

# running the model a second time[第二次运行模型]
out2   <- steady.1D (y = state, func = O2BOD, parms = NULL,
                     nspec = 2, pos = TRUE, names = c("BOD", "O2"))


v       &lt;- 200       # velocity, m/day[速度,m /天]

# running the model a second time[第二次运行模型]
out3   <- steady.1D (y = state, func = O2BOD, parms = NULL,
                     nspec = 2, pos = TRUE, names = c("BOD", "O2"))

# output of all three scenarios at once[一次输出的所有三种情况]
plot(out, out2, out3, type = "l", lwd = 2,
     ylab = c("mmol/m3", "mmol O2/m3"), grid = x,
     obs = obs, which = c("BOD", "O2"))
  
# output of all three scenarios at once, and using vertical style[输出的所有三种情况一次,并使用垂直式]
plot(out, out2, out3, type = "l", lwd = 2, vertical = TRUE,
     ylab = "Distance [m]",
     main = c("BOD [mmol/m3]", "O2 [mmol O2/m3]"), grid = x,
     obs = obs, which = c("BOD", "O2"))

# change plot pars[改变图收杆]
plot(out, out2, out3, type = "l", lwd = 2,
     ylab = c("mmol/m3", "mmol O2/m3"),
     grid = x, col = c("blue", "green"), log = "y",  
     obs = obs, obspar = list(pch = 16, col = "red", cex = 2))

## =======================================================================[#================================================= ======================]
## EXAMPLE 3: Diffusion in 2-D; zero-gradient boundary conditions[#例3:在2-D;零梯度边界条件的扩散]
## =======================================================================[#================================================= ======================]

diffusion2D <- function(t,Y,par)  {
   y    &lt;- matrix(nr=n,nc=n,data=Y)  # vector to 2-D matrix[2-D矩阵向量]
   dY   &lt;- -r*y        # consumption[消费]
   BND   &lt;- rep(1,n)   # boundary concentration [边界浓度]

   #diffusion in X-direction; boundaries=imposed concentration[在X方向上的扩散;的边界=施加的浓度]
   Flux <- -Dx * rbind(y[1,]-BND, (y[2:n,]-y[1n-1),]), BND-y[n,])/dx
   dY   <- dY - (Flux[2n+1),]-Flux[1:n,])/dx

   #diffusion in Y-direction[在Y方向上的扩散]
   Flux <- -Dy * cbind(y[,1]-BND, (y[,2:n]-y[,1n-1)]), BND-y[,n])/dy
   dY    <- dY - (Flux[ ,2n+1)]-Flux[ ,1:n])/dy
                                             
   return(list(as.vector(dY)))
}

  # parameters[参数]
dy    &lt;- dx &lt;- 1   # grid size[网格大小]
Dy    &lt;- Dx &lt;- 1   # diffusion coeff, X- and Y-direction[扩散COEFF,X-和Y-方向]
r     &lt;- 0.025     # consumption rate[消费率]

n  <- 100
Y  <- matrix(nrow = n, ncol = n, 10.)

ST <- steady.2D(Y, func = diffusion2D, parms = NULL, pos = TRUE,
                dimens = c(n, n), lrw = 1000000,
                atol = 1e-10, rtol = 1e-10, ctol = 1e-10)
grid <- list(x = seq(dx/2, by = dx, length.out = n),
             y = seq(dy/2, by = dy, length.out = n))
image(ST, grid = grid)
summary(ST)

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-25 15:30 , Processed in 0.020150 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表