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

R语言 RNCEP包 NCEP.gather()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-27 19:38:25 | 显示全部楼层 |阅读模式
NCEP.gather(RNCEP)
NCEP.gather()所属R语言包:RNCEP

                                        Queries Weather Data
                                         查询天气数据

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

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

This function queries weather data over the Internet from the NCEP/NCAR Reanalysis<br> or NCEP/DOE Reanalysis II datasets for the spatial and temporal extents specified in the function call and maintains the spatial and temporal structure of the data in a 3-D array.
此功能查询天气数据在互联网上的NCEP / NCAR再分析参考或NCEP / DOE再分析数据集的空间和时间的函数调用中指定的区和维护的时间和空间数据结构的3-D阵列。


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


NCEP.gather(variable, level, months.minmax, years.minmax,
    lat.southnorth, lon.westeast, reanalysis2 = FALSE,
    return.units = TRUE, status.bar=TRUE)

## NCEP.gather is a wrapper function that calls one of the
## following functions based on the value of level.
## Users should avoid using these functions directly.
NCEP.gather.gaussian(variable, months.minmax, years.minmax,
    lat.minmax, lon.minmax, reanalysis2 = FALSE,
    return.units = TRUE, increments=NULL, pb=NULL)
NCEP.gather.pressure(variable, months.minmax, years.minmax,
    lat.minmax, lon.minmax, pressure, reanalysis2 = FALSE,
    return.units = TRUE, increments=NULL, pb=NULL)
NCEP.gather.surface(variable, months.minmax, years.minmax,
    lat.minmax, lon.minmax, reanalysis2 = FALSE,
    return.units = TRUE, increments=NULL, pb=NULL)



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

参数:variable
Character. The name of the weather variable to be obtained.  See "Details" for possible variable names.  
字符。以下方式获得的天气变量的名称。请参阅“详细资料”,为可能出现的变量名。


参数:level
A numeric pressure level or one of either "gaussian" or "surface". See "Details".  
一个数字压力水平的“高斯”或“面”。请参阅“详细信息”。


参数:months.minmax
Numeric.  Specifies the range of months to be obtained from each year.  
数字。指定个月的范围内从每年以下方式获得。


参数:years.minmax
Numeric.  Specifies the range of years to be obtained.  
数字。指定的范围内以以下方式获得的年。


参数:lat.southnorth
Numeric. Specifies the range of latitudes to be obtained in the order<br> c(southernmost, northernmost).  
数字。的顺序<br>物理化学学报c(southernmost, northernmost),以获得在指定的范围内的纬度。


参数:lat.minmax
Same as lat.southnorth.  
与lat.southnorth相同。


参数:lon.westeast
Numeric. Specifies the range of longitudes to be obtained in the order<br> c(westernmost, easternmost).  
数字。的顺序<br>物理化学学报c(westernmost, easternmost),以获得在指定的经度范围。


参数:lon.minmax
Same as lat.westeast.  
与lat.westeast相同。


参数:reanalysis2
Logical.  Should the data be obtained from the Reanalysis I dataset (default) or from Reanalysis II?  
逻辑。我再分析数据集(默认)或再分析II的数据应得到?


参数:return.units
Logical.  Should the units of the variable being obtained be printed after the query finishes?  
逻辑。应变量的单位获得被打印后的查询完成?


参数:pressure
Numeric.  A pressure level in millibars that is assigned automatically from the value of level when needed.   
数字。一个压力水平毫巴,是自动分配的价值level在需要的时候。


参数:status.bar
Logical.  Should a status bar be shown indicating the percentage of completion?  
逻辑。如果状态栏显示完成的百分比?


参数:increments
Numeric.  This value, which is assigned automatically when using NCEP.gather, indicates the number of queries necessary to retrieve all data.  
数字。这个值,自动分配时,使用NCEP.gather,表示需要检索的所有数据的查询的数量。


参数:pb
An object of class "tkProgressBar", which is assigned automatically when using NCEP.gather.  
对象的类的“tkProgressBar”,自动分配时使用NCEP.gather。


Details

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

NCEP.gather is a wrapper function that applies one of NCEP.gather.gaussian,<br> NCEP.gather.pressure, or NCEP.gather.surface depending on the value of level.
NCEP.gather是一个包装函数适用NCEP.gather.gaussian,参考NCEP.gather.pressure,或NCEP.gather.surface的价值level根据。

level must specify one of either "gaussian" or "surface" or give a numerical pressure level in millibars.  Numeric pressure levels must be one of 1000, 925, 850, 700, 600, 500, 400, 300, 250, 200, 150, 100, 70, 50, 30, 20, 10 See "Variable Naming Conventions" below to determine if your variable of interest is stored relative to the surface, a pressure level, or a T62 Gaussian grid. Note that variables on a T62 Gaussian grid are evenly spaced in longitude but unevenly spaced in latitude while variables from either the surface or a particular pressure level are evenly spaced in both latitude and longitude (2.5 deg. x 2.5 deg.)
level必须指定的“高斯”或“面”的数字压力毫巴。数字压力水平必须是一个1000,925,850,700,600,500,400,300,250,200,150,100,70,50,30,20,10,请参阅“变量命名约定,以确定如果您感兴趣的变量存储的相对的表面,压力水平,或T62高斯电网的。注意T62高斯网格上的变量被均匀地间隔开的经度,但不均匀间隔的纬度而从任一表面或一个特定的压力水平的变量在两个纬度和经度(2.5度×2.5度均匀地隔开。)

Months and years in months.minmax and years.minmax must be numeric and given in the order c(minimum,maximum).
几个月和几年中months.minmax和years.minmax必须是数字的顺序c(minimum,maximum)。

Latitude and longitude ranges should be given in decimal degrees.  If the latitudes or longitudes given do not match a grid point in the NCEP dataset, the function moves to the next grid point such that the specified range is always included.  Latitude should always be given in the order c(southernmost, northernmost) and longitude should always be given in the order c(westernmost, easternmost).
经度和纬度的范围应以十进制度。如果给定的纬度或经度的NCEP数据集不匹配的网格点,移动到下一个网格点指定的范围包括。应该始终纬度的顺序c(southernmost, northernmost)和东经应得到的顺序c(westernmost, easternmost)。

Latitudes below the equator are negative.  Longitudes west of the Prime Meridian can be specified using either positive (i.e. 350) or negative (i.e. -10) notation.
以下赤道的纬度是否定的。可以指定经度的本初子午线以西,无论是正面的(如350)或负(即-10)的符号。

Some variables are not in both the Reanalysis I and II datasets.  If a variable is chosen that is not in the specified dataset, the other dataset will be used... with a warning.
一些变量是不是再分析I和II的数据集。如果选择一个变量,是不是在指定的数据集,数据集将用于...一个警告。

Very large queries may cause errors due to memory limitations in R.   See Memory-limits for more information or memory.limit to increase available memory. Alternatively, consider querying subsets of your total desired range. For instance, subset a very large spatial domain into several smaller regions, perform analyses on each geographical subset independently, and then combine the results. Functions in the raster-package may be useful for managing subsets in the temporal domain.
查询可能会导致非常大的错误,由于内存限制,在R. Memory-limits了解更多信息或memory.limit以增加可用内存。另外,考虑查询您的总要求范围的子集。例如,一个子集非常大的空间域划分为几个较小的区域,进行分析独立地对每个地域的子集,然后合并结果。在raster-package功能可能是用于管理在时域的子集。

Note that the status bar may be hidden behind an active R window.
需要注意的是,背后可能隐藏着活性R窗口的状态栏。

variable must be specified using one of the names found in the section "Variable Naming Conventions" below...
“variable必须指定使用一个发现”一节中的变量命名约定“下面的名字...


值----------Value----------

This function returns a three dimensional array of weather data.  The three dimensions are latitude, longitude, and datetime reflected in the dimnames of the array.  Datetimes are always expressed in UTC with the format "%Y_%m_%d_%H".
这个函数返回一个三维数组的气象资料。的三个尺寸为纬度,经度,和datetime的数组中的dimnames反射。日期时间总是UTC表示的格式"%Y_%m_%d_%H"。

Optionally, the units of the variable being queried are printed upon completion.
任选地,被查询的变量的单位打印完成后。


变量命名约定----------Variable Naming Conventions----------

VARIABLES IN REFERENCE TO A PARTICULAR PRESSURE LEVEL
参考特定的压力水平的变量

Air Temperature
气温

Geopotential Height
位势高度场

Relative Humidity
相对湿度

Specific Humidity
比湿

Omega [Vertical Velocity]
欧米茄垂直速度]

U-Wind Component [East/West]
U-风组件[东/西]

V-Wind Component [North/South]
V-风组件[北/南]

VARIABLES IN REFERENCE TO THE SURFACE
变量的表面

Air Temperature
气温

Surface Lifted Index
表面抬升指数

Best (4-layer) Lifted Index
(4层)抬升指数

Omega [Vertical Velocity]
欧米茄垂直速度]

Potential Temperature
位温

Precipitable Water
降水量的

Pressure
压力

Relative Humidity
相对湿度

Sea Level Pressure
海平面气压

Mean Sea Level Pressure
平均海平面气压

U-Wind Component [East/West]
U-风组件[东/西]

V-Wind Component [North/South]
V-风组件[北/南]

VARIABLES IN REFERENCE TO A T62 GAUSSIAN GRID
参考一个T62高斯电网中的变量

&mdash;&ndash; These variables are forecasts valid 6 hours after the reference time &mdash;&ndash;
- 这些变量的预测是有效的参考时间6小时后 -

&mdash;&ndash; These variables are 6 hour hindcasts from the reference time &mdash;&ndash;
- 从基准时间,这些变量是6小时的后报 -

&mdash;&ndash; These variables are 6 hour averages starting at the reference time &mdash;&ndash;
- 这些变量在统计时点开始的6小时平均 -

&mdash;&ndash; These variables are 6 hour averages starting at the reference time &mdash;&ndash;
- 这些变量在统计时点开始的6小时平均 -


(作者)----------Author(s)----------


Michael U. Kemp <a href="mailto:M.U.Kemp@UvA.nl">M.U.Kemp@UvA.nl</a>



参考文献----------References----------


(2011). RNCEP: global weather and climate data at your fingertips. Methods in Ecology and Evolution, DOI:10.1111/j.2041-210X.2011.00138.x.

Amer. Meteor. Soc., 77, 437-470

Amer. Meteor. Soc., 83, 1631-1643
including text such as, &ldquo;NCEP Reanalysis data provided by the NOAA/OAR/ESRL PSD, Boulder, Colorado, USA, from their Web site at http://www.esrl.noaa.gov/psd/&rdquo;. They would also appreciate a copy of any publications using NCEP data.

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


## Not run: [#不运行:]
library(RNCEP)
## Query the temperature from a particular pressure level ##[#查询从一个特定的压力水平的温度##]
wx.extent1 <- NCEP.gather(variable='air', level=850,
    months.minmax=c(9,10), years.minmax=c(1996,1997),
    lat.southnorth=c(50,55), lon.westeast=c(5,10),
    reanalysis2 = FALSE, return.units = TRUE)

## Query the temperature at 2 meters altitude with reference to[#查询参考温度在2万米高空]
## the surface[#表面]
wx.extent2 <- NCEP.gather(variable='air.sig995', level='surface',
    months.minmax=c(2,3), years.minmax=c(2000,2001),
    lat.southnorth=c(50,55), lon.westeast=c(0,5),
    reanalysis2 = FALSE, return.units = TRUE)

## Query the temperature at 2 meters altitude with reference to[#查询参考温度在2万米高空]
## a T62 Gaussian grid[#一个T62高斯网格]
wx.extent3 <- NCEP.gather(variable='air.2m', level='gaussian',
    months.minmax=c(4,5), years.minmax=c(2006,2007),
    lat.southnorth=c(32,35), lon.westeast=c(-35,-32),
    reanalysis2 = FALSE, return.units = TRUE)

## Note that the dimnames of the data array indicate the [#需要注意的是数组的数据表明dimnames]
## latitudes, longitudes, and datetimes        of the data. ##[#纬度,经度,和日期时间的数据。 ##]
dimnames(wx.extent1)
## Therefore, the latitudes, longitudes, and datetimes[#因此,纬度,经度和日期时间]
## can be called. ##[#可以调用。 ##]
dimnames(wx.extent1)[[1]] ## latitudes[#纬度]
dimnames(wx.extent1)[[2]] ## longitudes[#经度]
dimnames(wx.extent1)[[3]] ## datetimes[#日期时间]

#################################################################[################################################## ##############]
#################################################################[################################################## ##############]
#################################################################[################################################## ##############]
## THERE ARE MANY OPTIONS FOR CREATING DIFFERENT R OBJECTS  [#里面有很多选项,用于创建不同的R对象]
## AND/OR FOR EXPORTING THESE WEATHER DATA.[#和/或出口这些气象数据。]
## HERE ARE A FEW EXAMPLES[#这里有几个例子]

#########################################################[################################################## ######]
#########################################################[################################################## ######]
## The data array may be saved directly as an R object ##[#的数据数组可以被直接保存为R对象##]
save(wx.extent, file='wx_extent.Rdata')
## And then later recalled ##[###后来回忆]
load(file='wx_extent.Rdata')


################################################################[################################################## #############]
################################################################[################################################## #############]
## Another option is to create a raster object from the array ##[#另一种选择是创建一个栅格对象##从数组]
## For more info, see package raster[#欲了解更多信息,请参阅包光栅]
library(raster)

## Using the data from a query above ##[从上面的查询###使用数据]
## First create a stacked raster object using the first [#首先创建一个堆叠的的光栅对象使用第一]
## layer (i.e. datetime) of the weather data array ##[#层(即日期时间)的天气数据数组##]
## Notice the offset of 1.25 degrees (1/2 the spatial resolution)[#请注意,偏移量为1.25度(1/2的空间分辨率)]
## to describe the limits of the bounding box not the points[#描述的边界框的限制,而不是点]
ras <- stack(raster(wx.extent1[,,1], crs="+proj=longlat +datum=WGS84",
    xmn=min(as.numeric(dimnames(wx.extent1)[[2]])) - 1.25,
    xmx=max(as.numeric(dimnames(wx.extent1)[[2]])) + 1.25,
    ymn=min(as.numeric(dimnames(wx.extent1)[[1]])) - 1.25,
    ymx=max(as.numeric(dimnames(wx.extent1)[[1]])) + 1.25))

## Then add each subsequent layer to the raster stack ##[#然后添加每个后续层的光栅堆栈##]
for(i in 2:length(dimnames(wx.extent1)[[3]])){
    ras <- addLayer(ras, raster(wx.extent1[,,i],
        crs="+proj=longlat +datum=WGS84",
        xmn=min(as.numeric(dimnames(wx.extent1)[[2]])) - 1.25,
        xmx=max(as.numeric(dimnames(wx.extent1)[[2]])) + 1.25,
        ymn=min(as.numeric(dimnames(wx.extent1)[[1]])) - 1.25,
        ymx=max(as.numeric(dimnames(wx.extent1)[[1]])) + 1.25))
    }

#######################################################[################################################## ####]
## Optionally, export a layer from the raster stack to [#随意的,导出的光栅堆栈层]
## a format that can be imported by Esri's ArcGIS products ##[一个格式,可以在ESRI公司的ArcGIS产品的进口###]

## First, select a layer from the raster stack ##[#首先,选择一个层的光栅堆栈##]
ras1 <- raster(ras, layer=1)

## Then write the data from that layer to a .bil file ##[#然后将数据写入该层。亿文件##]
writeRaster(ras, filename='ras_example.bil', format="EHdr")
## The file will be saved in your current working directory ##[#该文件将被保存在当前工作目录##]

## The resulting file can be imported into ArcGIS ##[#生成的文件可以被导入到ArcGIS##]
## by using the "Raster to Other Format" tool in the [#使用其他格式“工具,在”光栅]
## "To Raster" section of the ArcToolbox.[#“要在ArcToolbox光栅”一节。]

###########################################################[################################################## ########]
## NOTE: Weather data obtained from a Gaussian grid must [#注:从高斯网格的气象数据,必须]
## first be resampled onto a regular grid !!! ##[#先进行重采样到规则的网格! ##]
## Here we use the interp.loess() function[#在这里我们使用的interp.loess()函数]
## from the tgp package[#三峡工程包]

## Using data from a T62 Gaussian grid queried above [从T62高斯电网#使用数据查询以上]
## Interpolate the data from the first layer (i.e. datetime)[#插补数据从第一层(即日期时间)]
## onto a regular grid ##[#规则的网格上##]
library(tgp)
wx.reg <- interp.loess(x=rep(as.numeric(dimnames(wx.extent3)[[2]]),
        each=length(dimnames(wx.extent3)[[1]])),
    y=rep(as.numeric(dimnames(wx.extent3)[[1]]),
         length(dimnames(wx.extent3)[[2]])),
    z=as.vector(wx.extent3[,,1]), span=0.6,
    gridlen=c(length(dimnames(wx.extent3)[[2]]),
        length(dimnames(wx.extent3)[[1]])))

## Create a stacked raster object from the first layer [#创建一个从第一层的层叠光栅对象]
## (i.e. datetime) after interpolation ##[#(即日期时间)内插后的##]
## Again, notice the offset (1/2 the resolution) ##[#再次提醒您注意的偏移量(1/2的分辨率)##]
## Also note that the matrix (i.e. wx.reg$z) must be flipped [#还要注意的是,必须翻转矩阵(即wx.reg $ Z)]
## along the y axis and transposed ##[沿y轴的###换位]
## This is required b/c of the interpolation performed above ##[#这是需要进行插值以上##B / C]
ras <- stack(raster(t(wx.reg$z[,length(wx.reg$y):1]),
    crs="+proj=longlat +datum=WGS84",
    xmn=min(as.numeric(wx.reg$x)) - abs(diff(wx.reg$x)[1]/2),
    xmx=max(as.numeric(wx.reg$x)) + abs(diff(wx.reg$x)[1]/2),
    ymn=min(as.numeric(wx.reg$y)) - abs(diff(wx.reg$y)[1]/2),
    ymx=max(as.numeric(wx.reg$y)) + abs(diff(wx.reg$y)[1]/2)))
       
## Add each subsequent layer in the array to the raster stack ##[#添加数组中的每个后续层的光栅堆栈##]
## after interpolating onto a regular grid ##[插值到规则的网格###后,]

for(i in 2:length(dimnames(wx.extent3)[[3]])){

  ## Interpolate[#插]
  t.wx.reg <- interp.loess(x=rep(as.numeric(dimnames(wx.extent3)[[2]]),
      each=length(dimnames(wx.extent3)[[1]])),
      y=rep(as.numeric(dimnames(wx.extent3)[[1]]),
      length(dimnames(wx.extent3)[[2]])),
      z=as.vector(wx.extent3[,,i]), span=0.6,
      gridlen=c(length(dimnames(wx.extent3)[[2]]),
      length(dimnames(wx.extent3)[[1]])))
  
  ## Note the offset ##[#注意的偏移量##]
  ## Note flipping the matrix along the y axis and transposing ##[沿Y轴翻转矩阵和转###注意:]
  ## Add layer to stack[#加层堆叠]
  ras <- addLayer(ras, raster(t(t.wx.reg$z[,length(t.wx.reg$y):1]),
    crs="+proj=longlat +datum=WGS84",
    xmn=min(as.numeric(t.wx.reg$x)) - abs(diff(t.wx.reg$x)[1]/2),
    xmx=max(as.numeric(t.wx.reg$x)) + abs(diff(t.wx.reg$x)[1]/2),
    ymn=min(as.numeric(t.wx.reg$y)) - abs(diff(t.wx.reg$y)[1]/2),
    ymx=max(as.numeric(t.wx.reg$y)) + abs(diff(t.wx.reg$y)[1]/2)))
  }

##################################################################[################################################## ###############]
##################################################################[################################################## ###############]
## Another option is to create a Spatial object[#另一种选择是创建一个空间对象]
## using the sp package[#使用SP包]
## Again, data from a Gaussian grid may require special attention[#同样,从高斯网格的数据可能需要特别注意]
## as the grid points are unevenly spaced[#为网格点间隔不均]
library(sp)

## Using the data from a query above[#从上面的查询使用的数据]
## Convert the array to a data.frame ##[#数组转换为数据框##]
wx.df <- NCEP.array2df(wx.extent2)

## Specify that the data.frame is a spatial object[#指定的数据框是一个空间对象]
library(sp)
coordinates(wx.df) <- ~longitude+latitude
gridded(wx.df) <- TRUE
proj4string(wx.df) <- CRS('+proj=longlat + datum=WGS84')

#########################################################[################################################## ######]
## A Spatial object of a single datetime (i.e. layer) can [#空间对象的一个单一的日期时间(即层)]
## be written to .asc, a format that may then be [#被写入。的格式,然后可以递增,]
## imported into ArcGIS.[#导入到ArcGIS。]

## First, convert the first layer of the array to a data.frame ##[#首先,将第一层的数组的数据框##]
wx.df <- NCEP.array2df(wx.extent2[,,1])

## Specify that the data.frame is a spatial object[#指定的数据框是一个空间对象]
library(sp)
coordinates(wx.df) <- ~longitude+latitude
gridded(wx.df) <- TRUE
proj4string(wx.df) <- CRS('+proj=longlat + datum=WGS84')

## Save the data in .asc format[#将数据保存在递增格式]
write.asciigrid(wx.df, fname='wx.asc')
## Note: Data will be written to your working directory ##[#注:数据将被写入到你的工作目录##]

## The resulting .asc file can be imported into ArcMap[#产生的。asc文件可以导入到ArcMap]
## using ArcMap's "ASCII to Raster" tool in the "Conversion Tools"[#使用ArcMap中的“ASCII转栅格”工具“转换工具”]
## section of the ArcToolbox. ##[在ArcToolbox的部分。 ##]

##################################################################[################################################## ###############]
## There are still more options for writing these data to files ##[#有更多的选择,这些数据写入到文件中##]
## See e.g. writeMat() in the R.matlab package for writing Matlab files[#例如见在R.matlab包编写Matlab文件writeMat()]
## Also see the RSAGA package for GIS functionality in R[#RSAGA包GIS功能也看到了在R]
## One could even write the data array back to NetCDF [甚至可以写回的数据阵列的NetCDF]
## (see packages RNetCDF and ncdf)[#(见包RNetCDF和ncdf)]

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

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-24 18:41 , Processed in 0.020285 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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