NetCDFFileProperties
汇总
NetCDFFileProperties 对象从网络公用数据格式 (netCDF) 访问属性。netCDF 为独立于计算机的二进制自描述文件格式,可用于存储科学数据。
语法
NetCDFFileProperties(netcdffile)
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
netcdffile |
The input netCDF file. |
String |
方法
getAttributeNames({variable_name[variable_name,...]})
返回 netCDF 文件中的变量的属性名称。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
variable_name[variable_name,...] (可选) |
A variable name of the netCDF file. |
String |
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
变量的属性名称。 |
getAttributeValue(variable_name, attribute_name)
返回属性的值。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
variable_name |
A variable name of the netCDF file. |
String |
|
attribute_name |
An attribute name of the netCDF file. |
String |
返回值
| 数据类型 | 说明 |
|---|---|
|
Object |
属性的值。 返回值的类型取决于维度类型。 |
getDimensionIndex(dimension_name, value)
返回维度索引。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
dimension_name |
A dimension name of the netCDF file. |
String |
|
value |
The dimension value. |
Integer |
返回值
| 数据类型 | 说明 |
|---|---|
|
Integer |
维度索引。 |
getDimensionSize(dimension_name)
返回维度大小。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
dimension_name |
A dimension name of the netCDF file. |
String |
返回值
| 数据类型 | 说明 |
|---|---|
|
Integer |
维度大小。 |
getDimensionValue(dimension_name, index)
返回维度值。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
dimension_name |
A dimension name of the netCDF file. |
String |
|
index |
The index position. |
Integer |
返回值
| 数据类型 | 说明 |
|---|---|
|
Object |
维度值。 返回值的类型取决于维度类型。 |
getDimensions()
返回维度。
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
维度列表。 |
getDimensionsByVariable(variable_name)
按变量返回维度。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
variable_name |
A variable name of the netCDF file. |
String |
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
按变量获取的维度。 |
getFieldType(name)
返回变量或维度的字段类型。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
name |
A variable or dimension name of the netCDF file. |
String |
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
字段类型 |
getSpatialReference(variable_name, x_dimension, y_dimension)
返回变量的空间参考。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
variable_name |
A variable name of the netCDF file. |
String |
|
x_dimension |
The x-dimension. |
Integer |
|
y_dimension |
The y-dimension. |
Integer |
返回值
| 数据类型 | 说明 |
|---|---|
|
SpatialReference |
变量的空间参考。 |
getVariables()
返回变量。
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
变量列表。 |
getVariablesByDimension(dimension_name)
按维度返回变量。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
dimension_name |
A variable name of the netCDF file. |
String |
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
按维度获取的变量列表。 |
代码示例
显示 netCDF 文件属性。
import arcpy
in_netcdf = "c:/netCDF/crwr.nc"
nc_fp = arcpy.NetCDFFileProperties(in_netcdf)
# Get Variables
for nc_var in nc_fp.getVariables():
print("Variable: {}".format(nc_var))
print("\tVariable type: {}".format(nc_fp.getFieldType(nc_var)))
# Get dimensions by variable
for nc_dim_by_var in nc_fp.getDimensionsByVariable(nc_var):
print("Dimension: {}".format(nc_dim_by_var))
print(nc_fp.getAttributeValue(nc_var, "units"))
# Get Variable Attributes
for nc_va_name in nc_fp.getAttributeNames(nc_var):
print("Attribute Name: {}".format(nc_va_name))
# Get Dimensions
for nc_dim in nc_fp.getDimensions():
print("Dimension: {}".format(nc_dim))
print("\tDimension size: {}".format(nc_fp.getDimensionSize(nc_dim)))
print("\tDimension type: {}".format(nc_fp.getFieldType(nc_dim)))
for i in range(0, nc_fp.getDimensionSize(nc_dim)):
nc_dim_value = nc_fp.getDimensionValue(nc_dim, i)
print("\tDimension value: {}".format(nc_dim_value))
print("\tDimension index: {}".format(
nc_fp.getDimensionIndex(nc_dim, nc_dim_value)))
# Get Variable by dimension
for nc_vars_by_dim in nc_fp.getVariablesByDimension(nc_dim):
print("\tVariable by dimension: {}".format(nc_vars_by_dim))
# Get Global Attributes
for nc_att_name in nc_fp.getAttributeNames(""):
print("Attribute Name: {}".format(nc_att_name))
print(nc_fp.getAttributeValue("", nc_att_name))