NetCDFFileProperties

Zusammenfassung

The Network Common Data Form (NetCDF) is a binary, self-describing, machine-independent file format for storing scientific data.

Syntax

NetCDFFileProperties ({netCDFFile})
ParameterErläuterungDatentyp
netCDFFile

The input netCDF file.

String

Methodenübersicht

MethodeErläuterung
getAttributeNames ({variable_name})

Gets the attribute names of a variable in a NetCDF file.

getAttributeValue (variable_name, attribute_name)

Get the value of an attribute.

getDimensionIndex (dimension_name, value)

Gets the dimension index.

getDimensionSize (dimension_name)

Gets the dimension size.

getDimensionValue (dimension_name, index)

Gets the dimension value.

getDimensions ()

Gets the dimensions.

getDimensionsByVariable (variable_name)

Gets the dimensions by variable.

getFieldType (name)

Gets the field type of a variable or dimension.

getSpatialReference (variable_name, x_dimension, y_dimension)

Gets the spatial reference of a variable.

getVariables ()

Gets the variables.

getVariablesByDimension (dimension_name)

Get the variables by dimension.

Methoden

getAttributeNames ({variable_name})
ParameterErläuterungDatentyp
variable_name
[variable_name,...]

Variable name of the NetCDF file.

String
Rückgabewert
DatentypErläuterung
String

The attribute names of the variable.

getAttributeValue (variable_name, attribute_name)
ParameterErläuterungDatentyp
variable_name

Variable name of the netCDF file.

String
attribute_name

Attribute name of the netCDF file.

String
Rückgabewert
DatentypErläuterung
Object

The value of the attribute. The type of returned value depends on the dimension type.

getDimensionIndex (dimension_name, value)
ParameterErläuterungDatentyp
dimension_name

Dimension name of the NetCDF file.

String
value

The dimension value.

Integer
Rückgabewert
DatentypErläuterung
Integer

The dimension index.

getDimensionSize (dimension_name)
ParameterErläuterungDatentyp
dimension_name

Dimension name of the NetCDF file.

String
Rückgabewert
DatentypErläuterung
Integer

The dimension size.

getDimensionValue (dimension_name, index)
ParameterErläuterungDatentyp
dimension_name

Dimension name of the NetCDF file.

String
index

The index position.

Integer
Rückgabewert
DatentypErläuterung
Object

The dimension value. The type of returned value depends on the dimension type.

getDimensions ()
Rückgabewert
DatentypErläuterung
String

List of dimensions.

getDimensionsByVariable (variable_name)
ParameterErläuterungDatentyp
variable_name

Variable name of the NetCDF file.

String
Rückgabewert
DatentypErläuterung
String

The dimensions by variable.

getFieldType (name)
ParameterErläuterungDatentyp
name

Variable or dimension name of the NetCDF file.

String
Rückgabewert
DatentypErläuterung
String

The field type.

getSpatialReference (variable_name, x_dimension, y_dimension)
ParameterErläuterungDatentyp
variable_name

Variable name of the NetCDF file.

String
x_dimension

The x-dimension.

Integer
y_dimension

The y-dimension.

Integer
Rückgabewert
DatentypErläuterung
SpatialReference

The spatial reference of a variable.

getVariables ()
Rückgabewert
DatentypErläuterung
String

List of variables.

getVariablesByDimension (dimension_name)
ParameterErläuterungDatentyp
dimension_name

Variable name of the netCDF file

String
Rückgabewert
DatentypErläuterung
String

List of variables by dimension

Codebeispiel

NetCDFFileProperties example

Display properties of NetCDF file.

import arcpy

InNetCDF = "c:/NetCDF/crwr.nc"
try:
    ncFP = arcpy.NetCDFFileProperties(InNetCDF)

    #Get Variables    
    ncVars = ncFP.getVariables()
    for ncVar in ncVars:
        print "Variable: %s" % ncVar
        ncVarType = ncFP.getFieldType(ncVar)        
        print "\t" + "Variable type: %s " % ncVarType

        #Get dimensions by variable        
        ncDimsByVar = ncFP.getDimensionsByVariable(ncVar)
        for ncDimByVar in ncDimsByVar:
            print "Dimension: %s " % ncDimByVar
        print ncFP.getAttributeValue(ncVar, "units")

        #Get Variable Attribues
        ncVANames = ncFP.getAttributeNames(ncVar)

        for ncVAName in ncVANames:
            print "Attribute Name: %s " % ncVAName        

    #Get Dimensions
    ncDims = ncFP.getDimensions()

    for ncDim in ncDims:
        print "Dimension: %s " % ncDim
        ncDimSize = ncFP.getDimensionSize(ncDim)
        print "\t" + "Dimension size: %s " % ncDimSize
        ncDimType = ncFP.getFieldType(ncDim)        
        print "\t" + "Dimension type: %s " % ncDimType

        for i in range(0, ncFP.getDimensionSize(ncDim)):
            ncDimValue = ncFP.getDimensionValue(ncDim, i)
            print "\t" + "Dimension value: %s" % ncDimValue
            ncDimIndex = ncFP.getDimensionIndex(ncDim, ncDimValue)
            print "\t" + "Dimension index: %s" % ncDimIndex

        #Get Variable by dimension
        ncVarsByDim = ncFP.getVariablesByDimension(ncDim)
        for ncVarByDim in ncVarsByDim:
            print "\t" + "Variable by dimension: %s" % ncVarByDim  

    #Get Global Attribues
    ncAttributeNames = ncFP.getAttributeNames("")
    for ncAttributeName in ncAttributeNames:
        print "Attribute Name: %s " % ncAttributeName
        print ncFP.getAttributeValue("", ncAttributeName)

except:
    print arcpy.GetMessages(2)

Verwandte Themen


7/10/2012