コード例 #1
0
    def plot2d_from_database(self,
                             tag,
                             x_param,
                             y_param,
                             filter,
                             output_filename,
                             title="",
                             x_label="",
                             y_label=""):
        """
        Plot two-dimensional simulation results from a database.
        :param tag: custom tag of the simulation results to be plotted
        :param x_param: parameter of the simulation results to be used on the x axis
        :param y_param: parameter of the simulation results to be used on the y axis
        :param output_filename: file to write the plot to
        :param title: title of the plot
        :param x_label: name of the plot x axis
        :param y_label: name of the plot y axis
        """
        results = self.persistence.retrieve_from_database(
            self.persistence.config["collection_name"],
            dict({"tag": tag}.items() + filter.items()), {
                "_id": 0,
                x_param: 1,
                y_param: 1
            }, [(x_param, 1)])

        xs, ys = self._get_corresponding_results(results, x_param, y_param)

        print xs
        print ys

        self._plot2d(util.strip_unit(xs), util.strip_unit(ys), output_filename,
                     title, x_label, y_label)
コード例 #2
0
    def plot3d_from_database(self,
                             tag,
                             x_param,
                             y_param,
                             z_param,
                             filter,
                             output_filename,
                             title="",
                             x_label="",
                             y_label="",
                             z_label=""):

        results = self.persistence.retrieve_from_database(
            self.persistence.config["collection_name"],
            dict({"tag": tag}.items() + filter.items()), {
                "_id": 0,
                x_param: 1,
                y_param: 1,
                z_param: 1
            }, [(x_param, 1), (y_param, 1)])

        xs, ys, zs = self._get_corresponding_results_3d(
            results, x_param, y_param, z_param)

        self._plot3d(util.strip_unit(xs), util.strip_unit(ys),
                     util.strip_unit(zs), output_filename, title, x_label,
                     y_label, z_label)
コード例 #3
0
    def generate_memory(self):
        output = list()
        cross_product = self._generate_cross_product_dict()

        if cross_product is None:
            return output

        for dynamic_field in cross_product:
            output_fields = dict()

            # process static fields
            if not self.static_fields is None:
                for field in self.static_fields:
                    output_fields[field] = self.static_fields[field]

            # process dynamic fields
            if not self.dynamic_fields is None:
                field_count = 0
                for field in self.dynamic_fields:
                    #print dynamic_field, field, dynamic_field[field_count]
                    output_fields[field] = dynamic_field[field_count]
                    field_count += 1

            # process dependent fields
            if not self.dependent_fields is None:
                for field in self.dependent_fields:
                    field_description = self.dependent_fields[field]
                    if "unit" in field_description:
                        field_unit = field_description["unit"]
                    else:
                        field_unit = ""

                    if "dependency" in field_description:
			dependency_type = field_description["type"]
			if dependency_type == "sum":
	                        value = 0
        	                for dependency in field_description["dependency"]:
	                            value += strip_unit([output_fields[dependency]])[0]
        	                output_fields[field] = str(value) + str(field_unit)
			if dependency_type == "min":
				minimum = float("infinity")
				for dependency in field_description["dependency"]:
			            value = strip_unit([output_fields[dependency]])[0]
				    minimum = min(minimum, value)
				output_fields[field] = str(minimum) + str(field_unit)    
                    else:
                        LOG.warning("Malformed field found: " + field)
                        return None
            output.append(output_fields)
	
	output = [dict(t) for t in set([tuple(d.items()) for d in output])]

        return output
コード例 #4
0
ファイル: Plotter.py プロジェクト: ClockworkOrigins/m2etis
    def plot3d_from_database(self, tag, x_param, y_param, z_param, filter, output_filename, title="", x_label="", y_label="", z_label=""):

        results = self.persistence.retrieve_from_database(
            self.persistence.config["collection_name"]
            , dict({"tag": tag}.items() + filter.items())
        , {"_id": 0, x_param: 1, y_param: 1, z_param:1}, [(x_param, 1), (y_param, 1)])

        xs, ys, zs = self._get_corresponding_results_3d(results, x_param, y_param, z_param)

        self._plot3d(util.strip_unit(xs),
                     util.strip_unit(ys),
                     util.strip_unit(zs),
                     output_filename, title, x_label, y_label, z_label)
コード例 #5
0
ファイル: Plotter.py プロジェクト: ClockworkOrigins/m2etis
 def plot2d_from_memory(self, results, x_param, y_param, output_filename, title="", x_label="", y_label=""):
     """
     Plot two-dimensional simulation results from a python data structure in memory.
     :param results: simulation results to be plotted
     :param x_param: parameter of the simulation results to be used on the x axis
     :param y_param: parameter of the simulation results to be used on the y axis
     :param output_filename: file to write the plot to
     :param title: title of the plot
     :param x_label: name of the plot x axis
     :param y_label: name of the y axis
     """
     params = self._get_corresponding_results(util.sanitize_results(results), x_param, y_param)
     self._plot2d(util.strip_unit(params[0]),
                  util.strip_unit(params[1]),
                  output_filename, title, x_label, y_label)
コード例 #6
0
ファイル: Plotter.py プロジェクト: ClockworkOrigins/m2etis
 def plot2d_from_file(self, input_filename, x_param, y_param, output_filename, title="", x_label="", y_label="", c_label=""):
     """
     Plot two-dimensional simulation results from a file in YAML format.
     :param input_filename: file containing the simulation results to be plotted
     :param x_param: parameter of the simulation results to be used on the x axis
     :param y_param: parameter of the simulation results to be used on the y axis
     :param output_filename: file to write the plot to
     :param title: title of the plot
     :param x_label: name of the plot x axis
     :param y_label: name of the plot y axis
     """
     results = self.persistence.retrieve_from_file(input_filename)
     params = self._get_corresponding_results(results, x_param, y_param)
     self._plot2d(util.strip_unit(params[0]),
                  util.strip_unit(params[1]),
                  output_filename, title, x_label, y_label, c_label)
コード例 #7
0
ファイル: Plotter.py プロジェクト: ClockworkOrigins/m2etis
    def _get_corresponding_results(self, results, x_param, y_param):
        resultList = [[] for i in range(0, 2)]

        for result in results:
            for position, parameter in enumerate([x_param, y_param]):
                category = parameter.split('.')[0]
                item = parameter.split('.')[1]
                resultList[position].append(float(util.strip_unit([result[category][item]])[0]))
        #print resultList
        return zip(*sorted(zip(*resultList)))
コード例 #8
0
    def _get_corresponding_results(self, results, x_param, y_param):
        resultList = [[] for i in range(0, 2)]

        for result in results:
            for position, parameter in enumerate([x_param, y_param]):
                category = parameter.split('.')[0]
                item = parameter.split('.')[1]
                resultList[position].append(
                    float(util.strip_unit([result[category][item]])[0]))
        #print resultList
        return zip(*sorted(zip(*resultList)))
コード例 #9
0
 def plot2d_from_memory(self,
                        results,
                        x_param,
                        y_param,
                        output_filename,
                        title="",
                        x_label="",
                        y_label=""):
     """
     Plot two-dimensional simulation results from a python data structure in memory.
     :param results: simulation results to be plotted
     :param x_param: parameter of the simulation results to be used on the x axis
     :param y_param: parameter of the simulation results to be used on the y axis
     :param output_filename: file to write the plot to
     :param title: title of the plot
     :param x_label: name of the plot x axis
     :param y_label: name of the y axis
     """
     params = self._get_corresponding_results(
         util.sanitize_results(results), x_param, y_param)
     self._plot2d(util.strip_unit(params[0]), util.strip_unit(params[1]),
                  output_filename, title, x_label, y_label)
コード例 #10
0
 def plot2d_from_file(self,
                      input_filename,
                      x_param,
                      y_param,
                      output_filename,
                      title="",
                      x_label="",
                      y_label="",
                      c_label=""):
     """
     Plot two-dimensional simulation results from a file in YAML format.
     :param input_filename: file containing the simulation results to be plotted
     :param x_param: parameter of the simulation results to be used on the x axis
     :param y_param: parameter of the simulation results to be used on the y axis
     :param output_filename: file to write the plot to
     :param title: title of the plot
     :param x_label: name of the plot x axis
     :param y_label: name of the plot y axis
     """
     results = self.persistence.retrieve_from_file(input_filename)
     params = self._get_corresponding_results(results, x_param, y_param)
     self._plot2d(util.strip_unit(params[0]), util.strip_unit(params[1]),
                  output_filename, title, x_label, y_label, c_label)
コード例 #11
0
ファイル: Plotter.py プロジェクト: ClockworkOrigins/m2etis
    def plot2d_from_database(self, tag, x_param, y_param, filter, output_filename, title="", x_label="", y_label=""):
        """
        Plot two-dimensional simulation results from a database.
        :param tag: custom tag of the simulation results to be plotted
        :param x_param: parameter of the simulation results to be used on the x axis
        :param y_param: parameter of the simulation results to be used on the y axis
        :param output_filename: file to write the plot to
        :param title: title of the plot
        :param x_label: name of the plot x axis
        :param y_label: name of the plot y axis
        """
        results = self.persistence.retrieve_from_database(self.persistence.config["collection_name"]
            , dict({"tag": tag}.items() + filter.items())
            , {"_id": 0, x_param: 1, y_param: 1}, [(x_param, 1)])

        xs, ys = self._get_corresponding_results(results, x_param, y_param)

        print xs
        print ys

        self._plot2d(util.strip_unit(xs),
                     util.strip_unit(ys),
                     output_filename, title, x_label, y_label)