<s> import arcpy <EOL> debug = False <EOL> class MakeNetCDFRegularPointsLayer ( object ) : <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . label = "<STR_LIT>" <EOL> self . description = "<STR_LIT>" "<STR_LIT>" <EOL> self . canRunInBackground = False <EOL> return <EOL> def getParameterInfo ( self ) : <EOL> """<STR_LIT>""" <EOL> param0 = arcpy . Parameter ( <EOL> displayName = "<STR_LIT>" , <EOL> name = "<STR_LIT>" , <EOL> datatype = "<STR_LIT>" , <EOL> parameterType = "<STR_LIT>" , <EOL> direction = "<STR_LIT>" ) <EOL> param1 = arcpy . Parameter ( <EOL> displayName = "<STR_LIT>" , <EOL> name = "<STR_LIT>" , <EOL> datatype = "<STR_LIT>" , <EOL> multiValue = True , <EOL> parameterType = "<STR_LIT>" , <EOL> direction = "<STR_LIT>" ) <EOL> param2 = arcpy . Parameter ( <EOL> displayName = "<STR_LIT>" , <EOL> name = "<STR_LIT>" , <EOL> datatype = "<STR_LIT>" , <EOL> parameterType = "<STR_LIT>" , <EOL> direction = "<STR_LIT>" ) <EOL> param3 = arcpy . Parameter ( <EOL> displayName = "<STR_LIT>" , <EOL> name = "<STR_LIT>" , <EOL> datatype = "<STR_LIT>" , <EOL> parameterType = "<STR_LIT>" , <EOL> direction = "<STR_LIT>" ) <EOL> params = [ param0 , param1 , param2 , param3 ] <EOL> return params <EOL> def isLicensed ( self ) : <EOL> """<STR_LIT>""" <EOL> return True <EOL> def updateParameters ( self , parameters ) : <EOL> """<STR_LIT>""" <EOL> if parameters [ <NUM_LIT:0> ] . value and arcpy . Exists ( parameters [ <NUM_LIT:0> ] . valueAsText ) : <EOL> ncFP = arcpy . NetCDFFileProperties ( parameters [ <NUM_LIT:0> ] . valueAsText ) <EOL> parameters [ <NUM_LIT:1> ] . filter . list = ncFP . getVariables ( ) <EOL> if parameters [ <NUM_LIT:1> ] . value and not parameters [ <NUM_LIT:2> ] . altered : <EOL> variable_name_list = str ( parameters [ <NUM_LIT:1> ] . valueAsText ) . split ( '<STR_LIT:;>' ) <EOL> out_layer_name = variable_name_list [ <NUM_LIT:0> ] + "<STR_LIT>" <EOL> i = <NUM_LIT:1> <EOL> temp_name = out_layer_name <EOL> while arcpy . Exists ( temp_name ) : <EOL> temp_name = out_layer_name + str ( i ) <EOL> i += <NUM_LIT:1> <EOL> out_layer_name = temp_name <EOL> parameters [ <NUM_LIT:2> ] . value = out_layer_name <EOL> return <EOL> def updateMessages ( self , parameters ) : <EOL> """<STR_LIT>""" <EOL> selectedVars = [ ] <EOL> if parameters [ <NUM_LIT:1> ] . value : <EOL> ncFP = arcpy . NetCDFFileProperties ( parameters [ <NUM_LIT:0> ] . valueAsText ) <EOL> selectedVars = [ ] <EOL> selectedVars = str ( parameters [ <NUM_LIT:1> ] . valueAsText ) . split ( '<STR_LIT:;>' ) <EOL> dimList = [ ] <EOL> [ dimList . append ( ncFP . getDimensionsByVariable ( v . replace ( "<STR_LIT:'>" , "<STR_LIT>" ) ) ) for v in selectedVars ] <EOL> if not all ( x == dimList [ <NUM_LIT:0> ] for x in dimList ) : <EOL> parameters [ <NUM_LIT:1> ] . setErrorMessage ( "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> return <EOL> def execute ( self , parameters , messages ) : <EOL> """<STR_LIT>""" <EOL> ncFP = arcpy . NetCDFFileProperties ( parameters [ <NUM_LIT:0> ] . valueAsText ) <EOL> selectedVars = parameters [ <NUM_LIT:1> ] . valueAsText . split ( '<STR_LIT:;>' ) <EOL> XCoordNamesList = [ "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ] <EOL> YCoordNamesList = [ "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ] <EOL> XUnitNamesList = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> YUnitNamesList = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> XAxisNameList = [ "<STR_LIT:X>" ] <EOL> YAxisNameList = [ "<STR_LIT:Y>" ] <EOL> dimNames = ncFP . getDimensionsByVariable ( str ( selectedVars [ <NUM_LIT:0> ] ) ) <EOL> x_variable = "<STR_LIT>" <EOL> y_variable = "<STR_LIT>" <EOL> for dimension in dimNames : <EOL> try : <EOL> SNattributeValue = ncFP . getAttributeValue ( dimension , <EOL> "<STR_LIT>" ) <EOL> except : <EOL> SNattributeValue = "<STR_LIT>" <EOL> try : <EOL> UNattributeValue = ncFP . getAttributeValue ( dimension , "<STR_LIT>" ) <EOL> except : <EOL> UNattributeValue = "<STR_LIT>" <EOL> try : <EOL> AXattributeValue = ncFP . getAttributeValue ( dimension , "<STR_LIT>" ) <EOL> except : <EOL> AXattributeValue = "<STR_LIT>" <EOL> if SNattributeValue in XCoordNamesList : <EOL> x_variable = dimension <EOL> if SNattributeValue in YCoordNamesList : <EOL> y_variable = dimension <EOL> if UNattributeValue in XUnitNamesList : <EOL> x_variable = dimension <EOL> if UNattributeValue in YUnitNamesList : <EOL> y_variable = dimension <EOL> if AXattributeValue in XAxisNameList : <EOL> x_variable = dimension <EOL> if AXattributeValue in YAxisNameList : <EOL> y_variable = dimension <EOL> rowDimensions = "<STR_LIT>" <EOL> rowDimensions = x_variable + "<STR_LIT:;>" + y_variable <EOL> if ( not x_variable ) or ( not y_variable ) : <EOL> try : <EOL> coordAttributeValue = ncFP . getAttributeValue ( str ( selectedVars [ <NUM_LIT:0> ] ) , <EOL> "<STR_LIT>" ) <EOL> coordVariables = coordAttributeValue . split ( '<STR_LIT:U+0020>' ) <EOL> for element in coordVariables : <EOL> try : <EOL> SNattributeValue = ncFP . getAttributeValue ( element , <EOL> "<STR_LIT>" ) <EOL> except : <EOL> SNattributeValue = "<STR_LIT>" <EOL> try : <EOL> UNattributeValue = ncFP . getAttributeValue ( element , <EOL> "<STR_LIT>" ) <EOL> except : <EOL> UNattributeValue = "<STR_LIT>" <EOL> try : <EOL> AXattributeValue = ncFP . getAttributeValue ( element , <EOL> "<STR_LIT>" ) <EOL> except : <EOL> AXattributeValue = "<STR_LIT>" <EOL> if SNattributeValue in XCoordNamesList : <EOL> x_variable = element <EOL> if SNattributeValue in YCoordNamesList : <EOL> y_variable = element <EOL> if UNattributeValue in XUnitNamesList : <EOL> x_variable = element <EOL> if UNattributeValue in YUnitNamesList : <EOL> y_variable = element <EOL> if AXattributeValue in XAxisNameList : <EOL> x_variable = element <EOL> if AXattributeValue in YAxisNameList : <EOL> y_variable = element <EOL> dimNames = ncFP . getDimensionsByVariable ( str ( selectedVars [ <NUM_LIT:0> ] ) ) <EOL> rowDimensions = str ( dimNames [ - <NUM_LIT:1> ] ) + "<STR_LIT:;>" + str ( dimNames [ - <NUM_LIT:2> ] ) <EOL> except : <EOL> CoordAttributeValue = "<STR_LIT>" <EOL> if selectedVars . count > <NUM_LIT:1> : <EOL> variable_list = '<STR_LIT:U+002C>' . join ( [ str ( x ) for x in selectedVars ] ) <EOL> else : <EOL> variable_list = selectedVars [ <NUM_LIT:0> ] <EOL> if ( x_variable ) and ( y_variable ) : <EOL> if ( debug ) : <EOL> arcpy . AddWarning ( "<STR_LIT>" % parameters [ <NUM_LIT:0> ] . valueAsText ) <EOL> arcpy . AddWarning ( "<STR_LIT>" % variable_list ) <EOL> arcpy . AddWarning ( "<STR_LIT>" % x_variable ) <EOL> arcpy . AddWarning ( "<STR_LIT>" % y_variable ) <EOL> arcpy . AddWarning ( "<STR_LIT>" % parameters [ <NUM_LIT:2> ] . valueAsText ) <EOL> arcpy . AddWarning ( "<STR_LIT>" % rowDimensions ) <EOL> result1 = arcpy . MakeNetCDFFeatureLayer_md ( parameters [ <NUM_LIT:0> ] . valueAsText , <EOL> variable_list , <EOL> x_variable , <EOL> y_variable , <EOL> parameters [ <NUM_LIT:2> ] . value , <EOL> rowDimensions ) <EOL> arcpy . SetParameter ( <NUM_LIT:3> , result1 ) <EOL> else : <EOL> arcpy . AddError ( "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> return </s>
