def execute(self, parameters, messages):
        """The source code of the tool."""

        input_parameter = parameters[0]
        variable_parameter = parameters[1]
        dimension_parameter = parameters[2]
        output_parameter = parameters[3]
        output_var_parameter = parameters[4]
        type_parameter = parameters[5]

        dataset_name = input_parameter.valueAsText

        # Open dataset
        try:
            dataset = mds.netcdf.Dataset(dataset_name,'')
        except __HOLE__, exception:
            # Handle errors not detected by updateMessages.
            messages.addErrorMessage(str(exception))
            raise arcpy.ExecuteError

        # Variable of interest
        var1 = dataset.variable(variable_parameter.valueAsText)

        # Dimension of interest
        dim1 = var1.dimensions.index(dimension_parameter.valueAsText)

        # Perform statistic
        result1 = self.calculate_statistic(var1[:], dim1, \
            type_parameter.valueAsText)

        # Collect output dataset information
        output_dims = list(dataset.variable_dimension_names(
            variable_parameter.valueAsText))
        output_dims.remove(dimension_parameter.valueAsText)
        output_dims = tuple(output_dims)
        output_filename = output_parameter.valueAsText
        output_name = output_var_parameter.valueAsText

        # Create new dataset
        dataset.xcopy(dataset.data_variable_names(), output_filename)

        # Create new variable in dataset
        with netCDF4.Dataset(output_filename, mode="a") as newdataset:
            newvar = newdataset.createVariable(output_name, var1.dtype, \
                output_dims)
            for attribute_name in var1.ncattrs():
                newvar.setncattr(attribute_name, var1.getncattr(attribute_name))
            newvar[:] = result1

        # Output new variable name
        arcpy.SetParameter(5, output_name)

        return
dataset/ETHPy150Open Esri/solutions-geoprocessing-toolbox/suitability/toolboxes/scripts/MultidimensionSupplementalTools/MultidimensionSupplementalTools/Scripts/mds/tools/get_variable_statistics_over_dimension.py/GetVariableStatisticsOverDimension.execute