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

        input_parameter = parameters[0]
        variable_parameter = parameters[1]
        type_parameter = parameters[2]

        dataset_name = input_parameter.valueAsText

        # Open dataset
        try:
            dataset = mds.netcdf.Dataset(dataset_name, '')
        except RuntimeError, exception:
            # Handle errors not detected by updateMessages.
            messages.addErrorMessage(str(exception))
            raise arcpy.ExecuteError
Esempio n. 2
0
    def execute(self, parameters, messages):
        """The source code of the tool."""
        def pprint(text):
            """Override print statement."""
            arcpy.AddMessage(text)
            if (parameters[1].value):
                print >> f, text
            return

        try:
            dataset_name = parameters[0].valueAsText
            dataset = mds.netcdf.Dataset(dataset_name, '')
        except RuntimeError, exception:
            # Handle errors not detected by updateMessages.
            messages.addErrorMessage(str(exception))
            raise arcpy.ExecuteError
    def execute(self, parameters, messages):
        """The source code of the tool."""

        input_parameter = parameters[0]
        variable_parameter = parameters[1]
        type_parameter = parameters[2]

        dataset_name = input_parameter.valueAsText

        # Open dataset
        try:
            dataset = mds.netcdf.Dataset(dataset_name,'')
        except RuntimeError, exception:
            # Handle errors not detected by updateMessages.
            messages.addErrorMessage(str(exception))
            raise arcpy.ExecuteError
    def execute(self, parameters, messages):
        """The source code of the tool."""
        def pprint(text):
            """Override print statement."""
            arcpy.AddMessage(text)
            if (parameters[1].value):
                print >> f, text
            return

        try:
            dataset_name = parameters[0].valueAsText
            dataset = mds.netcdf.Dataset(dataset_name,'')
        except RuntimeError, exception:
            # Handle errors not detected by updateMessages.
            messages.addErrorMessage(str(exception))
            raise arcpy.ExecuteError
    def execute(self,
            parameters,
            messages):
        dataset_name = parameters[0].valueAsText
        variable_names = mds.OrderedSet(parameters[1].values)
        output_filename = parameters[2].valueAsText

        extent = None
        if parameters[3].value is not None:
            extent = [float(value) for value in
                parameters[3].valueAsText.split(" ")]

        dimension_records = parameters[4].values
        value_selection_method = mds.SELECT_BY_VALUE if \
            parameters[5].valueAsText == "BY_VALUE" else mds.SELECT_BY_INDEX
        date_time_string = time.strftime("%m/%d/%Y %H:%M", time.localtime())
        history_message = mds.messages.OPENDAP_TO_NETCDF_HISTORY.format(
            date_time_string, dataset_name)

        try:
            dataset = mds.netcdf.Dataset(dataset_name,
                filter_out_nd_coordinates=True)

            # Get rid of the variable names that are not part of the dataset.
            known_variable_names = \
                variable_names & dataset.data_variable_names()
            assert len(known_variable_names) > 0  # See updateMessages.
            unknown_variable_names = variable_names - known_variable_names

            if unknown_variable_names:
                messages.addWarningMessage(
                    mds.messages.VARIABLES_DO_NOT_EXIST.format(", ".join(
                        unknown_variable_names), "Input OPeNDAP Dataset"))

            mds.netcdf.copy(dataset, known_variable_names, output_filename,
                extent, dimension_records, value_selection_method,
                history_message)
        except RuntimeError, exception:
            # Handle errors not detected by updateMessages.
            messages.addErrorMessage(str(exception))
            raise arcpy.ExecuteError
Esempio n. 6
0
    def execute(self, parameters, messages):
        dataset_name = parameters[0].valueAsText
        variable_names = mds.OrderedSet(parameters[1].values)
        output_filename = parameters[2].valueAsText

        extent = None
        if parameters[3].value is not None:
            extent = [
                float(value) for value in parameters[3].valueAsText.split(" ")
            ]

        dimension_records = parameters[4].values
        value_selection_method = mds.SELECT_BY_VALUE if \
            parameters[5].valueAsText == "BY_VALUE" else mds.SELECT_BY_INDEX
        date_time_string = time.strftime("%m/%d/%Y %H:%M", time.localtime())
        history_message = mds.messages.OPENDAP_TO_NETCDF_HISTORY.format(
            date_time_string, dataset_name)

        try:
            dataset = mds.netcdf.Dataset(dataset_name,
                                         filter_out_nd_coordinates=True)

            # Get rid of the variable names that are not part of the dataset.
            known_variable_names = \
                variable_names & dataset.data_variable_names()
            assert len(known_variable_names) > 0  # See updateMessages.
            unknown_variable_names = variable_names - known_variable_names

            if unknown_variable_names:
                messages.addWarningMessage(
                    mds.messages.VARIABLES_DO_NOT_EXIST.format(
                        ", ".join(unknown_variable_names),
                        "Input OPeNDAP Dataset"))

            mds.netcdf.copy(dataset, known_variable_names, output_filename,
                            extent, dimension_records, value_selection_method,
                            history_message)
        except RuntimeError, exception:
            # Handle errors not detected by updateMessages.
            messages.addErrorMessage(str(exception))
            raise arcpy.ExecuteError