注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

阿弥陀佛

街树飘影未见尘 潭月潜水了无声 般若观照心空静...

 
 
 

日志

 
 
关于我

一直从事气象预报、服务建模实践应用。 注重气象物理场、实况场、地理信息、本体知识库、分布式气象内容管理系统建立。 对Barnes客观分析, 小波,计算神经网络、信任传播、贝叶斯推理、专家系统、网络本体语言有一定体会。 一直使用Java、Delphi、Prolog、SQL编程。

网易考拉推荐

NcML Cookbook Examples  

2015-03-20 08:15:36|  分类: DOC |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

NcML Cookbook Examples


Modify existing metadata

Rename the variable lflx to LavaFlow:

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="nc/cldc.mean.nc">
<variable name="LavaFlow" orgName="lflx" />
...
</netcdf>

Remove the variable LavaFlow from the dataset.

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="nc/cldc.mean.nc">
<remove name="LavaFlow" type="variable" />
</netcdf>

Remove the attribute unwantedVariableAttribute from the variable LavaFlow.

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="nc/cldc.mean.nc"> <variable name="LavaFlow">
<remove name="unwantedVariableAttribute" type="attribute" /> </variable>
</netcdf>

Remove the global attribute unwantedGlobalAttribute from the dataset.

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="nc/cldc.mean.nc">
<remove name="unwantedAttribute" type="attribute" />
</netcdf>

Rename a nested variable in a group:

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="grid_1_2d.h5">
  <group name="HDFEOS">
    <group name="GRIDS">
      <group name="GeoGrid">
        <group name="Data_Fields">
          <variable name="temp" orgName="temperature" />
        </group>
      </group>
    </group>
  </group>
</netcdf>

Override the values in a Variable:

<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="myFile.nc">
  <variable name="longitude">
    <values start="-67.95" incr="1.05" />
  </variable>
</netcdf>
  • The longitude variable already exists, and all its metadata is used; its better not to respecify it so that its clear exactly what the NcML does.
  • The number of points is taken from the size of the variable
  • The variables' values are replaced with the values -67.95, -66.90, -65.85, ..., start*incr*(npts-1)

Copy only some data into a new netCDF file

  1. First, use ToolsUI NcML tab to read in existing file or remote dataset.
  2. Modify the NcML to add the <explicit /> element and remove the dimensions, variables, and attributes not wanted (leave just the ones that you want), eg:
  3. <netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="dods://thredds.ucar.edu/thredds/dodsC/grib/NCEP/NAM/CONUS_12km/conduit/Best">
      <explicit />
      <dimension name="reftime" length="56" />
      ...
      <attribute name="Originating_or_generating_Subcenter" value="0" />
      ...
      <variable name="reftime_ISO" shape="reftime" type="String">
    <attribute name="units" value="ISO8601" />
    </variable> ... </netcdf>
  4. Use the ToolsUI NcML "Write Netcdf File" button to copy just those variables to a new netCDF file.
  5. (or) Save the NcML file and use the command line copy. One can generate the NcML from a script and automate the process.

Logical Views

The original variable has extraneous dimensions "latitude" and "longitude" :

<dimension name="time" length="143" />
<dimension name="pressure" length="63" />
<dimension name="latitude" length="1" />
<dimension name="longitude" length="1" /> <variable name="temperature" shape="time pressure latitude longitude" type="float"> <attribute name="long_name" value="Sea Temperature" /> <attribute name="units" value="Celsius" /> </variable>

Here is the NcML to remove them:

<variable name="temperature">
  <logicalReduce dimNames="latitude longitude" />
</variable>

Union Aggregation

Create union of datasets cldc.mean.nc and lflx.mean.nc located in the directory nc relative to where the NcML file is found:

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2"> <attribute name="title" type="string" value="Union cldc and lflx"/> <aggregation type="union"> <netcdf location="nc/cldc.mean.nc"/> <netcdf location="nc/lflx.mean.nc"/> </aggregation> </netcdf>

Create union of all datasets ending in mean.nc located in the directory nc reletive to where the NcML file is found:

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2"> <attribute name="title" type="string" value="Union all mean.nc files"/> <aggregation type="union">
<scan location="file:src/test/data/ncml/nc/" suffix="mean.nc"/>
</aggregation> </netcdf>

See Dataset URLS for more information on the location attribute.

JoinNew Aggregation

Name each dataset in a netcdf element and assign coordinate values there:

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
 <variable name="time" type="int">
   <attribute name="units" value="months since 2000-6-16 6:00"/>
 </variable>
 <aggregation  dimName="time" type="joinNew">
   <variableAgg name="T"/>
   <netcdf location="file:src/test/data/ncml/nc/time0.nc" coordValue="0"/>
   <netcdf location="file:src/test/data/ncml/nc/time1.nc" coordValue="10"/>
   <netcdf location="file:src/test/data/ncml/nc/time2.nc" coordValue="99"/>
 </aggregation>
</netcdf>

Assign coordinate values in the coordinate variable:

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
 <variable name="time" type="int">
   <attribute name="units" value="months since 2000-6-16 6:00"/>
   <values>0 10 99</values>
 </variable>
 <aggregation  dimName="time" type="joinNew">
   <variableAgg name="T"/>
   <netcdf location="file:src/test/data/ncml/nc/time0.nc"/>
   <netcdf location="file:src/test/data/ncml/nc/time1.nc"/>
   <netcdf location="file:src/test/data/ncml/nc/time2.nc"/>
 </aggregation>
</netcdf>

Assign coordinate values to unknown number of datasets. You dont have to know the number of files found in the scan, but they must be evenly spaced, and they must be in alphabetic order.

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
 <variable name="time" type="int" shape="time">
   <attribute name="long_name" type="string" value="time coordinate" />
   <attribute name="units" type="string" value="days since 2001-8-31 00:00:00 UTC" />
   <values start="0" increment="1" />
 </variable>
 <aggregation  dimName="time" type="joinNew">
   <variableAgg name="T"/>
   <scan location="src/test/data/ncml/nc/" suffix="Dir.nc"/>
 </aggregation>
</netcdf>

Scan directory, assign date coordinate value from filename. The date coordinate must be derivable from the filename, using the dateFormatMark attribute.

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
  <aggregation dimName="time" type="joinNew">
    <variableAgg name="T"/>
    <scan location="/data/goes/" suffix=".gini" dateFormatMark="SUPER-NATIONAL_1km_SFC-T_#yyyyMMdd_HHmm" />
  </aggregation>
</netcdf> 

JoinExisting Aggregation

Name each dataset in a netcdf element and read coordinate values from the files. A coordinate variable named time must exist in each file.

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
 <aggregation dimName="time" type="joinExisting">
   <netcdf location="file:src/test/data/ncml/nc/jan.nc"/>
   <netcdf location="file:src/test/data/ncml/nc/feb.nc"/>
 </aggregation>
   
</netcdf>

Name each dataset in a netcdf element and assign coordinate values explicitly. Overrides existing coordinate variable, if any.

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
 <variable name="time">
   <attribute name="long_name" value="climatological time"/>
   <attribute name="units" value="days since 000-00-00 0:00"/>
   <attribute name="_CoordinateAxisType" value="Time" />
 </variable>
 <aggregation dimName="time" type="joinExisting">
   <netcdf location="file:src/test/data/ncml/nc/jan.nc"
      coordValue="0 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"/>
   <netcdf location="file:src/test/data/ncml/nc/feb.nc"
      coordValue="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"/>
 </aggregation>
</netcdf>


Scan directory, assign date coordinate value from filename. Each file must have exactly one time slice. The date coordinate must be derivable from the filename, using the dateFormatMark attribute.

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
<aggregation dimName="time" type="joinExisting">
<scan dateFormatMark="CG#yyyyDDD_HHmmss" location="src/test/data/ncml/nc/cg/" suffix=".nc" subdirs="false" /> </aggregation>
</netcdf> <?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
<aggregation dimName="time" type="joinExisting" timeUnitsChange="true">
<netcdf location="20060925_0600.nc" ncoords="2"/>
<netcdf location="20060925_1200.nc" ncoords="2"/>
<netcdf location="20060925_1800.nc" ncoords="2"/>
<netcdf location="20060926_0000.nc" ncoords="2"/>
</aggregation>
</netcdf>

Name each dataset in a netcdf element and read coordinate values from the files, whose units change. Add the timeUnitsChange attribute. Also works for Fmrc.

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
<aggregation dimName="time" type="joinExisting" timeUnitsChange="true">
<netcdf location="20060925_0600.nc" ncoords="2"/>
<netcdf location="20060925_1200.nc" ncoords="2"/>
<netcdf location="20060925_1800.nc" ncoords="2"/>
<netcdf location="20060926_0000.nc" ncoords="2"/>
</aggregation>
</netcdf>

New Features in Netcdf-Java 4.0

Global Attributes to Variables (OuterDimension Aggregations only: JoinExisting, JoinNew, Fmrc)

The value(s) of the attribute in each file are placed into the named Variable. In the following, the Variable is given a different name ("times") than the global attribute ("time_coverage_end"):

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
<aggregation dimName="time" type="joinExisting" recheckEvery="4 sec">
<promoteGlobalAttribute name="times" orgName="time_coverage_end" />
<scan dateFormatMark="CG#yyyyDDD_HHmmss" location="src/test/data/ncml/nc/cg/" suffix=".nc" subdirs="false" />
</aggregation>
</netcdf>

Each file has a global attribute of type String:

 :time_coverage_end = "2006-06-07T13:00:00Z";

In the aggregation dataset, a String variable is created using the aggregation dimension:

  String times(time=3);
  data:
   "2006-06-07T12:00:00Z",   "2006-06-07T13:00:00Z",   "2006-06-07T14:00:00Z"
  评论这张
 
阅读(360)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017