Example #1
0
 def _initiate_plot_values(self, data, data_raw, interval_keys=None):
     """Sorts data into a format specific for the plotting method."""
     for ib, bn in enumerate(self.sorted_batch_names):
         values = {}
         if isinstance(interval_keys, types.NoneType):
             # Case where we have sub sections of observables, e.g. in
             # euclidean time.
             for sub_obs in self.observable_intervals[bn]:
                 sub_values = {}
                 sub_values["a"], sub_values["a_err"] = \
                     get_lattice_spacing(self.beta_values[bn])
                 sub_values["x"] = sub_values["a"] * \
                     np.sqrt(8*data[bn][sub_obs]["x"])
                 sub_values["y"] = data[bn][sub_obs]["y"]
                 sub_values["y_err"] = data[bn][sub_obs]["y_error"]
                 # sub_values["label"] = r"%s, %s, $\beta=%2.2f$, %s" % (
                 #     self.ensemble_names[bn],
                 #     self.size_labels[bn], self.beta_values[bn],
                 #     self._convert_label(sub_obs))
                 sub_values["label"] = r"%s, %s" % (
                     self.ensemble_names[bn], 
                     self._convert_label(sub_obs))
                 values[sub_obs] = sub_values
         else:
             int_key = interval_keys[ib]
             values["a"], values["a_err"] = \
                 get_lattice_spacing(self.beta_values[bn])
             values["x"] = values["a"] * np.sqrt(8*data[bn][int_key]["x"])
             values["y"] = data[bn][int_key]["y"]
             values["y_err"] = data[bn][int_key]["y_error"]
             values["label"] = r"%s, %s" % (
                 self.ensemble_names[bn],
                 self._convert_label(int_key))
             values["interval"] = int_key
         self.plot_values[beta] = values
Example #2
0
    def _initiate_plot_values(self, data, data_raw, interval_keys=None):
        """Sorts data into a format specific for the plotting method."""
        for ib, bn in enumerate(self.sorted_batch_names):
            values = {}
            if isinstance(interval_keys, types.NoneType):
                # Case where we have sub sections of observables, e.g. in
                # euclidean time.
                for sub_obs in self.observable_intervals[bn]:
                    sub_values = {}
                    sub_values["a"], sub_values["a_err"] = \
                        get_lattice_spacing(self.beta_values[bn])
                    sub_values["x"] = sub_values["a"] * \
                        np.sqrt(8*data[bn][sub_obs]["x"])
                    sub_values["y"] = data[bn][sub_obs]["y"]
                    sub_values["y_err"] = data[bn][sub_obs]["y_error"]

                    if self.with_autocorr:
                        sub_values["tau_int"] = \
                            data[bn][sub_obs]["ac"]["tau_int"]
                        sub_values["tau_int_err"] = \
                            data[bn][sub_obs]["ac"]["tau_int_err"]

                    # Retrieves raw data
                    sub_values["y_raw"] = \
                        data_raw[bn][self.observable_name_compact][sub_obs]

                    # sub_values["label"] = r"%s, %s, $\beta=%2.2f$, %s" % (
                    #     self.ensemble_names[bn], self.size_labels[bn],
                    #     self.beta_values[bn], self._convert_label(sub_obs))
                    sub_values["label"] = r"%s, %s" % (
                        self.ensemble_names[bn], self._convert_label(sub_obs))
                    values[sub_obs] = sub_values
            else:
                # sorted_intervals = sorted(data[beta].keys())

                # Modulo division in order to avoid going out of range in
                # intervals.
                int_key = interval_keys[ib]
                values["a"], values["a_err"] = \
                    get_lattice_spacing(self.beta_values[bn])
                values["x"] = values["a"] * np.sqrt(8 * data[bn][int_key]["x"])
                values["y"] = data[bn][int_key]["y"]
                values["y_err"] = data[bn][int_key]["y_error"]

                if self.with_autocorr:
                    values["tau_int"] = data[bn][int_key]["ac"]["tau_int"]
                    values["tau_int_err"] = \
                        data[bn][int_key]["ac"]["tau_int_err"]

                values["y_raw"] = \
                    data_raw[bn][self.observable_name_compact][int_key]
                # values["label"] = r"%s, %s, $\beta=%2.2f$, %s" % (
                #     self.ensemble_names, self.size_labels[bn],
                #     self.beta_values[bn], self._convert_label(int_key))
                values["label"] = r"%s, %s" % (self.ensemble_names,
                                               self._convert_label(int_key))
                values["interval"] = int_key
            self.plot_values[bn] = values
Example #3
0
    def _initiate_plot_values(self, data, data_raw):
        # Sorts data into a format specific for the plotting method
        for bn in self.sorted_batch_names:
            values = {}
            values["beta"] = self.beta_values[bn]
            values["a"], values["a_err"] = get_lattice_spacing(values["beta"])
            values["xraw"] = data[bn]["x"]  # t_f/a^2
            values["t"] = values["xraw"] * values["a"]**2
            values["sqrt8t"] = values["a"] * np.sqrt(8 * data[bn]["x"])
            values["x"] = values["t"] / self.r0**2
            values["y"] = data[bn]["y"]
            values["y_err"] = data[bn]["y_error"]
            values["flow_epsilon"] = self.flow_epsilon[bn]
            # values["tder"], values["W"], values["W_err"], values["W_raw"] = \
            #     self.calculateW(values["x"], data[bn]["y"],
            #         data[bn]["y_error"],
            #         data_raw[bn][self.observable_name_compact],
            #         values["flow_epsilon"], data[bn]["x"])
            # exit("Exits in plot values initiations.")

            if self.with_autocorr:
                values["tau_int"] = data[bn]["ac"]["tau_int"]
                values["tau_int_err"] = data[bm]["ac"]["tau_int_err"]
            else:
                values["tau_int"] = None
                values["tau_int_err"] = None

            values[self.analysis_data_type] = \
                (data_raw[bn][self.observable_name_compact].T \
                    *(data[bn]["x"]**2)).T

            values["label"] = (r"%s $\beta=%2.2f$" %
                               (self.size_labels[bn], values["beta"]))

            self.plot_values[bn] = values
	def _initiate_plot_values(self, data, data_raw):
		# Sorts data into a format specific for the plotting method
		for beta in sorted(data.keys()):
			values = {}
			values["beta"] = beta
			values["a"], values["a_err"] = get_lattice_spacing(beta)
			values["t"] = data[beta]["x"]*values["a"]**2
			values["x"] = values["t"]/self.r0**2
			values["y"] = data[beta]["y"]*data[beta]["x"]**2
			values["y_err"] = data[beta]["y_error"]*data[beta]["x"]**2
			values["flow_epsilon"] = self.flow_epsilon[beta]
			values["tder"], values["W"], values["W_err"], values["W_raw"] = \
				self.calculateW(values["t"], data[beta]["y"], 
					data[beta]["y_error"], 
					data_raw[beta][self.observable_name_compact], 
					values["flow_epsilon"], data[beta]["x"])
			# print values["x"]
			# exit("Exits in plot values initiations.")

			if self.with_autocorr:
				values["tau_int"] = data[beta]["ac"]["tau_int"]
				values["tau_int_err"] = data[beta]["ac"]["tau_int_err"]
			else:
				values["tau_int"] = None
				values["tau_int_err"] = None

			values[self.analysis_data_type] = \
				(data_raw[beta][self.observable_name_compact].T \
					*(data[beta]["x"]**2)).T

			values["label"] = (r"%s $\beta=%2.2f$" %
				(self.size_labels[beta], beta))

			self.plot_values[beta] = values
Example #5
0
    def _initiate_plot_values(self, data, data_raw):
        """Sorts data into a format specific for the plotting method."""
        for beta in sorted(data):
            values = {}
            values["a"], values["a_err"] = get_lattice_spacing(beta)
            values["x"] = values["a"] * np.sqrt(8 * data[beta]["x"])
            values["y"] = data[beta]["y"]
            values["y_err"] = data[beta]["y_error"]
            values["y_raw"] = data_raw[beta][self.observable_name_compact]
            values["y_uraw"] = self.data_raw["unanalyzed"][beta]\
             [self.observable_name_compact]

            # print values["y_raw"].shape, values["y_uraw"].shape
            # print "%s beta: %f" % (self.observable_name_compact, beta)
            # print np.mean(values["y_raw"][-1,:]), np.std(values["y_raw"][-1,:])
            # print np.mean(values["y_uraw"][-1,:]), np.std(values["y_uraw"][-1,:])

            if self.with_autocorr:
                values["tau_int"] = data[beta]["ac"]["tau_int"]
                values["tau_int_err"] = data[beta]["ac"]["tau_int_err"]
            else:
                values["tau_int"] = None
                values["tau_int_err"] = None
            values["label"] = r"%s $\beta=%2.2f$" % (self.size_labels[beta],
                                                     beta)
            values["color"] = self.colors[beta]

            self.plot_values[beta] = values
Example #6
0
	def _initialize_topsus_func_const(self):
		"""Sets the constant in the topsus function for found beta values."""
		for beta in self.beta_values:
			a, a_err = get_lattice_spacing(beta)
			V = float(self.lattice_sizes[beta][0]**3)
			self.chi_const[beta] = self.hbarc/a/V**0.25
			self.chi_const_err[beta] = self.hbarc*a_err/a**2/V**0.25
Example #7
0
    def _initiate_plot_values(self, data, data_raw):
        """Sorts data into a format specific for the plotting method."""
        for bn in self.sorted_batch_names:
            values = {}
            values["beta"] = self.beta_values[bn]
            values["a"], values["a_err"] = get_lattice_spacing(values["beta"])
            values["sqrt8t"] = values["a"] * np.sqrt(8 * data[bn]["x"])
            values["x"] = values["a"] * np.sqrt(8 * data[bn]["x"])
            values["y"] = data[bn]["y"]
            values["y_err"] = data[bn]["y_error"]
            values["y_raw"] = data_raw[bn][self.observable_name_compact]
            values["y_uraw"] = \
                self.data_raw["unanalyzed"][bn][self.observable_name_compact]

            if self.with_autocorr and not "blocked" in self.analysis_data_type:
                values["tau_int"] = data[bn]["ac"]["tau_int"]
                values["tau_int_err"] = data[bn]["ac"]["tau_int_err"]
                values["tau_raw"] = self.ac_raw["ac_raw"][bn]
                values["tau_raw_err"] = self.ac_raw["ac_raw_error"][bn]
            else:
                values["tau_int"] = None
                values["tau_int_err"] = None
                values["tau_raw"] = None
                values["tau_raw_err"] = None
            # values["label"] = r"%s, %s, $\beta=%2.2f$" % (
            #     self.ensemble_names[bn], self.size_labels[bn], values["beta"])
            values["label"] = r"%s" % self.ensemble_names[bn]
            values["color"] = self.colors[bn]

            self.plot_values[bn] = values
Example #8
0
 def _initialize_topsus_func_const(self):
     """Sets the constant in the topsus function for found batches."""
     for bn in self.batch_names:
         a, a_err = get_lattice_spacing(self.beta_values[bn])
         V = float(self.lattice_sizes[bn][0]**3 * self.lattice_sizes[bn][1])
         self.chi_const[bn] = self.hbarc / a / V**0.25
         self.chi_const_err[bn] = self.hbarc * a_err / a**2 / V**0.25
Example #9
0
 def _initiate_plot_values(self, data, data_raw):
     """Sorts data into a format specific for the plotting method."""
     for beta in self.beta_values:
         values = {}
         values["a"] = get_lattice_spacing(beta)[0]
         values["x"] = values["a"] * np.sqrt(8 * data[beta]["x"])
         values["y"] = data[beta]["y"]
         values["y_err"] = data[beta]["y_error"]
         # values["y_raw"] = data_raw[beta][self.observable_name_compact]
         # values["tau_int"] = data[beta]["ac"]["tau_int"]
         values["label"] = r"%s $\beta=%2.2f$" % (self.size_labels[beta],
                                                  beta)
         self.plot_values[beta] = values
    def _initiate_plot_values(self, data, data_raw, interval_keys=None):
        """Sorts data into a format specific for the plotting method."""
        for ib, beta in enumerate(sorted(data.keys())):
            values = {}
            if isinstance(interval_keys, types.NoneType):
                # Case where we have sub sections of observables, e.g. in
                # euclidean time.
                for sub_obs in self.observable_intervals[beta]:
                    sub_values = {}
                    sub_values["a"], sub_values["a_err"] = \
                        get_lattice_spacing(beta)
                    sub_values["x"] = sub_values["a"] * \
                        np.sqrt(8*data[beta][sub_obs]["x"])
                    sub_values["y"] = data[beta][sub_obs]["y"]
                    sub_values["y_err"] = data[beta][sub_obs]["y_error"]
                    sub_values["label"] = r"%s, $\beta=%2.2f$, %s" % (
                        self.size_labels[beta], beta,
                        self._convert_label(sub_obs))
                    values[sub_obs] = sub_values
            else:
                # sorted_intervals = sorted(data[beta].keys())

                # Modulo division in order to avoid going out of range in
                # intervals.
                int_key = interval_keys[ib]
                # print data[beta].keys()
                # print data[beta][int_key].keys()
                # print data_raw[beta].keys()
                # exit(1)
                values["a"], values["a_err"] = get_lattice_spacing(beta)
                values["x"] = values["a"] * np.sqrt(
                    8 * data[beta][int_key]["x"])
                values["y"] = data[beta][int_key]["y"]
                values["y_err"] = data[beta][int_key]["y_error"]
                values["label"] = r"%s, $\beta=%2.2f$, %s" % (
                    self.size_labels[beta], beta, self._convert_label(int_key))
                values["interval"] = int_key
            self.plot_values[beta] = values
Example #11
0
 def _initiate_plot_values(self, data, data_raw):
     """Sorts data into a format specific for the plotting method."""
     for bn in self.sorted_batch_names:
         values = {}
         values["a"] = get_lattice_spacing(self.beta_values[bn])[0]
         values["sqrt8t"] = values["a"] * np.sqrt(8 * data[bn]["x"])
         values["x"] = values["a"] * np.sqrt(8 * data[bn]["x"])
         values["y"] = data[bn]["y"]
         values["y_err"] = data[bn]["y_error"]
         # values["y_raw"] = data_raw[bn][self.observable_name_compact]
         # values["tau_int"] = data[bn]["ac"]["tau_int"]
         # values["label"] = r"%s, %s, $\beta=%2.2f$" % (
         #     self.ensemble_names[bn],
         #     self.size_labels[bn], self.beta_values[bn])
         values["label"] = r"%s" % self.ensemble_names[bn]
         self.plot_values[bn] = values
    def _setup_volumes(self):
        """Sets up lattice volumes."""

        # Sets up the lattice spacing values with errors
        self.a_vals, self.a_vals_err = \
            zip(*[get_lattice_spacing(b) for b in self.beta_values])
        self.a_vals = {b: self.a_vals[i] \
            for i, b in enumerate(self.beta_values)}
        self.a_vals_err = {b: self.a_vals_err[i] \
            for i, b in enumerate(self.beta_values)}

        # Sets up the volumes
        vol = lambda b: self.lattice_sizes[b] * self.a_vals[b]**4
        vol_err = lambda b: \
            4*self.lattice_sizes[b]*self.a_vals[b]**3*self.a_vals_err[b]
        self.V = {b: vol(b) for b in self.beta_values}
        self.V_err = {b: vol_err(b) for b in self.beta_values}
    def _initiate_plot_values(self, data, data_raw):
        # Sorts data into a format specific for the plotting method
        for bn in self.sorted_batch_names:
            values = {}
            values["beta"] = self.beta_values[bn]
            values["a"], values["a_err"] = get_lattice_spacing(values["beta"])
            values["t"] = data[bn]["x"] * values["a"]**2
            values["sqrt8t"] = values["a"] * np.sqrt(8 * data[bn]["x"])
            values["x"] = values["t"] / self.r0**2
            values["y"] = data[bn]["y"] * data[bn]["x"]**2
            values["y_err"] = data[bn]["y_error"] * data[bn]["x"]**2
            values["flow_epsilon"] = self.flow_epsilon[bn]
            values["y_raw"] = data_raw[bn][self.observable_name_compact]
            values["y_uraw"] = \
                self.data_raw["unanalyzed"][bn][self.observable_name_compact]

            # Calculates the energy derivatve
            values["tder"], values["W"], values["W_err"], values["W_raw"] = \
                self.calculateW(values["t"], data[bn]["y"],
                                data[bn]["y_error"],
                                data_raw[bn][self.observable_name_compact],
                                values["flow_epsilon"], data[bn]["x"])

            if self.with_autocorr and not "blocked" in self.analysis_data_type:
                values["tau_int"] = data[bn]["ac"]["tau_int"]
                values["tau_int_err"] = data[bn]["ac"]["tau_int_err"]
                values["tau_raw"] = self.ac_raw["ac_raw"][bn]
                values["tau_raw_err"] = self.ac_raw["ac_raw_error"][bn]
            else:
                values["tau_int"] = None
                values["tau_int_err"] = None
                values["tau_raw"] = None
                values["tau_raw_err"] = None

            # Calculates the t^2<E> for the raw values
            values[self.analysis_data_type] = \
                (data_raw[bn][self.observable_name_compact].T
                 * (data[bn]["x"]**2)).T

            # values["label"] = (r"%s, %s, $\beta=%2.2f$" %
            #                    (self.ensemble_names[bn], self.size_labels[bn],
            #                     values["beta"]))
            values["label"] = r"%s" % self.ensemble_names[bn]

            self.plot_values[bn] = values
Example #14
0
    def _setup_volumes(self):
        """Sets up lattice volumes."""

        # Sets up the lattice spacing values with errors
        self.a_vals = {}
        self.a_vals_err = {}
        for bn in self.sorted_batch_names:
            self.a_vals[bn], self.a_vals_err[bn] = \
                get_lattice_spacing(self.beta_values[bn])

        # Sets up the volumes
        def vol(bn_):
            return self.lattice_volumes[bn_] * self.a_vals[bn_]**4

        def vol_err(bn_):
            return 4 * self.lattice_volumes[bn_] * self.a_vals[
                bn_]**3 * self.a_vals_err[bn_]

        self.V = {bn: vol(bn) for bn in self.sorted_batch_names}
        self.V_err = {bn: vol_err(bn) for bn in self.sorted_batch_names}
    def _initiate_plot_values(self, data, data_raw, flow_index=None):
        """interval_index: int, should be in euclidean time."""

        # Sorts data into a format specific for the plotting method
        for beta in self.beta_values:
            values = {}

            if flow_index == None:
                # Case where we have sub sections of observables, e.g. in
                # euclidean time.
                for sub_obs in self.observable_intervals[beta]:
                    sub_values = {}
                    sub_values["a"], sub_values["a_err"] = get_lattice_spacing(
                        beta)
                    sub_values["x"] = np.linspace(
                        0, self.lattice_sizes[beta][1] * sub_values["a"],
                        self.lattice_sizes[beta][1])

                    sub_values["y"], sub_values["y_err"] = self.analyse_raw(
                        data[beta][sub_obs],
                        data_raw[beta][self.observable_name_compact][sub_obs])

                    sub_values["label"] = r"%s, $\beta=%2.2f$, $t_f=%.2f$" % (
                        self.size_labels[beta], beta,
                        self._convert_label(sub_obs))

                    sub_values["raw"] = data_raw[beta] \
                     [self.observable_name_compact][sub_obs]

                    if self.fold:
                        sub_values["x"] = np.linspace(
                            0, (int(sub_values["y"].shape[0] / 2)) *
                            sub_values["a"],
                            int(sub_values["y"].shape[0] / 2) + 1)
                        sub_values["y"] = self.fold_array(
                            sub_values["y"]) * self.r0 / sub_values["a"]
                        # sub_values["y_err"] = \
                        # 	self.fold_error_array(sub_values["y_err"]) * self.r0 / sub_values["a"]

                        # Error propagation with lattice spacing error
                        sub_values["y_err"] = np.sqrt(
                         (self.fold_error_array(sub_values["y_err"])*self.r0/sub_values["a"])**2 + \
                         (sub_values["y"]/sub_values["a"]*sub_values["a_err"])**2)

                        # sub_values["raw"] = self.fold_array(sub_values["raw"],
                        # 	axis=0)
                        self.fold_position = sub_values["x"][self.fold_range]

                    if self.with_autocorr:
                        sub_values["tau_int"] = \
                         data[beta][sub_obs]["ac"]["tau_int"]
                        sub_values["tau_int_err"] = \
                         data[beta][sub_obs]["ac"]["tau_int_err"]

                    values[sub_obs] = sub_values
                self.plot_values[beta] = values

            else:
                tf_index = "tflow%04.4f" % flow_index
                values["a"], values["a_err"] = get_lattice_spacing(beta)

                # For exact box sizes
                values["x"] = np.linspace(
                    0, self.lattice_sizes[beta][1] * values["a"],
                    self.lattice_sizes[beta][1])

                values["y_raw"] = data_raw[beta] \
                 [self.observable_name_compact][tf_index]

                if self.with_autocorr:
                    values["tau_int"] = data[beta][tf_index]["ac"]["tau_int"]
                    values["tau_int_err"] = \
                     data[beta][tf_index]["ac"]["tau_int_err"]

                values["y"], values["y_err"] = \
                 self.analyse_data(data[beta][tf_index])

                if self.fold:
                    values["x"] = np.linspace(
                        0, (int(values["y"].shape[0] / 2)) * values["a"],
                        int(values["y"].shape[0] / 2) + 1)

                    values["y"] = self.fold_array(
                        values["y"]) * self.r0 / values["a"]
                    # values["y_err"] = \
                    # 	self.fold_error_array(values["y_err"]) * self.r0 / values["a"]

                    # Error propagation with lattice spacing error
                    values["y_err"] = np.sqrt(
                      (self.fold_error_array(values["y_err"])*self.r0/values["a"])**2 + \
                      (values["y"]/values["a"]*values["a_err"])**2)

                    # values["y_raw"] = self.fold_array(values["y_raw"], axis=0)
                    self.fold_position = values["x"][self.fold_range]

                values["label"] = r"%s $\beta=%2.2f$, $t_f=%.2f$" % (
                    self.size_labels[beta], beta, flow_index)

                self.plot_values[beta] = values
Example #16
0
    def _initiate_plot_values(self, data, data_raw, tf0, mc_int=None):
        """mc_int: int, should be in mc time."""

        tf0_key = "tflow%.4f" % tf0

        # Sorts data into a format specific for the plotting method
        for beta in self.beta_values:
            values = {}

            if isinstance(mc_int, types.NoneType):
                # Case where we have sub sections of observables, e.g. in
                # mc time.
                for sub_obs in self.observable_intervals[beta]:
                    sub_values = {}
                    sub_values["a"], sub_values["a_err"] = get_lattice_spacing(
                        beta)
                    sub_values["x"] = np.linspace(
                        0, self.lattice_sizes[beta][1] * sub_values["a"],
                        self.lattice_sizes[beta][1])
                    sub_values["y"], sub_values["y_err"] = self.analyse_raw(
                        data[beta][sub_obs][tf0_key], data_raw[beta][
                            self.observable_name_compact][sub_obs][tf0_key])

                    sub_values[
                        "label"] = r"%s, $\beta=%2.2f$, $t_f=%.2f$, $MC:%s$" % (
                            self.size_labels[beta], beta, tf0, sub_obs)

                    sub_values["raw"] = data_raw[beta] \
                     [self.observable_name_compact][sub_obs][tf0_key]

                    if self.fold:
                        # OLD FOLD METHOD - DO NOT INCREASE STATISTICS BY THIS WAY:|
                        # sub_values["x"] = np.linspace(-self.fold_range*sub_values["a"],
                        # 	(self.fold_range-1)*sub_values["a"], self.fold_range*2)
                        sub_values["x"] = np.linspace(
                            0, (int(sub_values["y"].shape[0] / 2)) *
                            sub_values["a"],
                            int(sub_values["y"].shape[0] / 2) + 1)
                        sub_values["y"] = self.fold_array(
                            sub_values["y"]) * self.r0 / sub_values["a"]

                        # Error propagation with lattice spacing error
                        sub_values["y_err"] = np.sqrt(
                         (self.fold_error_array(sub_values["y_err"])*self.r0/sub_values["a"])**2 + \
                         (sub_values["y"]/sub_values["a"]*sub_values["a_err"])**2)

                        # sub_values["raw"] = self.fold_array(sub_values["raw"],
                        # 	axis=0)
                        self.fold_position = sub_values["x"][self.fold_range]

                    if self.with_autocorr:
                        sub_values["tau_int"] = \
                         data[beta][sub_obs][tf0_key]["ac"]["tau_int"]
                        sub_values["tau_int_err"] = \
                         data[beta][sub_obs][tf0_key]["ac"]["tau_int_err"]

                    values[sub_obs] = sub_values
                self.plot_values[beta] = values

            else:
                mc_dict = {
                    b: mc_int[ib]
                    for ib, b in enumerate(self.beta_values)
                }
                # raise NotImplementedError("This section is not complete")
                values["a"], values["a_err"] = get_lattice_spacing(beta)

                # For exact box sizes
                values["x"] = np.linspace(
                    0, self.lattice_sizes[beta][1] * values["a"],
                    self.lattice_sizes[beta][1])

                values["y_raw"] = data_raw[beta] \
                 [self.observable_name_compact][mc_dict[beta]][tf0_key]

                if self.with_autocorr:
                    values["tau_int"] = data[beta][
                        mc_dict[beta]][tf0_key]["ac"]["tau_int"]
                    values["tau_int_err"] = \
                     data[beta][mc_dict[beta]][tf0_key]["ac"]["tau_int_err"]

                values["y"], values["y_err"] = \
                 self.analyse_data(data[beta][mc_dict[beta]][tf0_key])

                if self.fold:
                    values["x"] = np.linspace(
                        0, (int(values["y"].shape[0] / 2)) * values["a"],
                        int(values["y"].shape[0] / 2) + 1)

                    values["y"] = self.fold_array(
                        values["y"]) * self.r0 / values["a"]

                    # Error propagation with lattice spacing error
                    values["y_err"] = np.sqrt(
                      (self.fold_error_array(values["y_err"])*self.r0/values["a"])**2 + \
                      (values["y"]/values["a"]*values["a_err"])**2)

                    # values["y_raw"] = self.fold_array(values["y_raw"], axis=0)
                    self.fold_position = values["x"][self.fold_range]

                values["label"] = r"%s $\beta=%2.2f$, $t_f=%.2f$, $MC=%s$" % (
                    self.size_labels[beta], beta, tf0, ", ".join(
                        ["[%s)" % i for i in mc_int]))

                self.plot_values[beta] = values
Example #17
0
    def _initiate_plot_values(self,
                              data,
                              data_raw,
                              euclidean_percent,
                              q0_flow_time=None):
        """interval_index: int, should be in euclidean time."""

        # Sorts data into a format specific for the plotting method
        for bn in self.sorted_batch_names:
            euclidean_index = self._get_euclidean_index(euclidean_percent, bn)
            te_index = "te%04d" % euclidean_index
            values = {}
            if q0_flow_time == None:
                # Case where we have sub sections of observables,
                # e.g. in euclidean time.
                for sub_obs in self.observable_intervals[bn]:
                    sub_values = {}
                    sub_values["a"], sub_values["a_err"] = \
                        get_lattice_spacing(self.beta_values[bn])
                    sub_values["x"] = np.linspace(
                        0, self.lattice_sizes[bn][1] * sub_values["a"],
                        self.lattice_sizes[bn][1])

                    sub_values["y"] = data[bn][sub_obs][te_index]["y"]
                    sub_values["y_err"] = \
                        data[bn][sub_obs][te_index]["y_error"]

                    sub_values["y_raw"] = \
                        data_raw[bn][self.observable_name_compact][sub_obs]

                    if self.with_autocorr:
                        sub_values["tau_int"] = \
                            data[bn][sub_obs][te_index]["ac"]["tau_int"]
                        sub_values["tau_int_err"] = \
                            data[bn][sub_obs][te_index]["ac"]["tau_int_err"]

                    # sub_values["label"] = (
                    #     r"%s, %s, $\beta=%2.2f$, $\sqrt{8t_{f}}=%.2f$"
                    #     % (self.ensemble_names[bn],
                    #        self.size_labels[bn],
                    #        self.beta_values[bn],
                    #        self._convert_label(sub_obs)))

                    sub_values["label"] = self.ensemble_names[bn]

                    values[sub_obs] = sub_values
                self.plot_values[bn] = values

            else:
                tf_index = "tflow%04.4f" % q0_flow_time
                values = {}
                values["a"], values["a_err"] = \
                    get_lattice_spacing(self.beta_values[bn])

                # FOR EXACT BOX SIZE:
                values["x"] = np.linspace(
                    0, self.lattice_sizes[bn][1] * values["a"],
                    self.lattice_sizes[bn][1])

                values["y"] = data[bn][tf_index][te_index]["y"]
                values["y_err"] = data[bn][tf_index][te_index]["y_error"]

                values["y_raw"] = \
                    data_raw[bn][self.observable_name_compact][tf_index]

                if self.with_autocorr:
                    values["tau_int"] = \
                        data[bn][tf_index][te_index]["ac"]["tau_int"]
                    values["tau_int_err"] = \
                        data[bn][tf_index][te_index]["ac"]["tau_int_err"]

                # values["label"] = (
                #     r"%s, %s, $\beta=%2.2f$, $\sqrt{8t_f}=%.2f$, $t_{e,0}/a=%d$" % (
                #         self.ensemble_names[bn],
                #         self.size_labels[bn], self.beta_values[bn],
                #         q0_flow_time, euclidean_index))

                values["label"] = (
                    r"%s, $\sqrt{8t_f}=%.2f$, $t_{e,0}/a=%d$" %
                    (self.ensemble_names[bn], q0_flow_time, euclidean_index))

                self.plot_values[bn] = values
Example #18
0
    def __init__(self,
                 data,
                 mc_interval=None,
                 figures_folder=False,
                 parallel=False,
                 numprocs=4,
                 dryrun=False,
                 verbose=False):
        """
        Parent class for analyzing flowed observables.

        Args:
                data: DataReader([observable_name]), an DataReader object
                        called with the compact observable name. Options:
                        "plaq", "energy", "topc".
                mc_interval: optional, tuple, will only look at Monte Carlo
                        history inside interval. Default is using all
                        Monte Carlo of the Monte Carlo history available.
                figures_folder: optional argument for where to place the
                        figures created. Default is "../figures".
                parallel: optinal argument if we are to run analysis in
                        parallel. Default is False.
                numprocs: optional argument for the number of processors to
                        use. Default is 4.
                dryrun: optional dryrun mode. Default is False.
                verbose: optional argument for a more verbose run. Default is
                        False.

        Returns:
                Object for analyzing flow.
        """
        # Retrieves data from data
        self.batch_name = data["batch_name"]
        self.batch_data_folder = data["batch_data_folder"]
        self.x = data["t"]
        self.y = data["obs"]
        self.flow_epsilon = data["FlowEpsilon"]

        # Sets lattice parameters
        self.beta = data["beta"]
        self.a, self.a_err = get_lattice_spacing(self.beta)
        self.r0 = 0.5  # Sommer Parameters

        # Sets the lattice sizes if one is provided
        self.lattice_size = data["lattice_size"]

        # Initializes up global constants
        self.N_bs = None
        self.dryrun = dryrun
        self.verbose = verbose
        if figures_folder != False:  # Default is just figures
            self.figures_folder = figures_folder

        # Parallel variables
        self.parallel = parallel
        self.numprocs = numprocs

        # Checks that a figures folder exists
        check_folder(self.figures_folder, self.dryrun, verbose=self.verbose)

        # Check that a data run folder exist, so one data anlysis performed on
        # different data sets do not mix
        self.data_batch_folder_path = \
            os.path.join(self.figures_folder,
                         os.path.split(self.batch_data_folder)[-1])
        check_folder(self.data_batch_folder_path,
                     self.dryrun,
                     verbose=self.verbose)

        # Checks that a batch folder exists
        self.batch_name_folder_path = os.path.join(self.data_batch_folder_path,
                                                   self.batch_name)
        check_folder(self.batch_name_folder_path,
                     self.dryrun,
                     verbose=self.verbose)

        # Checks that observable output folder exist, and if not will create it
        self.observable_output_folder_path = os.path.join(
            self.batch_name_folder_path, self.observable_name_compact)
        check_folder(self.observable_output_folder_path,
                     self.dryrun,
                     verbose=self.verbose)

        # Sets up the post analysis folder, but do not create it till its
        # needed.
        self.post_analysis_folder_base = os.path.join(self.batch_data_folder,
                                                      self.batch_name,
                                                      "post_analysis_data")
        check_folder(self.post_analysis_folder_base,
                     self.dryrun,
                     verbose=self.verbose)

        # Checks that {post_analysis_folder}/{observable_name} exists
        self.post_analysis_folder = \
            os.path.join(self.post_analysis_folder_base,
                         self.observable_name_compact)
        check_folder(self.post_analysis_folder,
                     self.dryrun,
                     verbose=self.verbose)

        # Sets the MC interval
        self._set_mc_interval(mc_interval)

        # Makes a backup, for later use
        self.post_analysis_folder_old = self.post_analysis_folder

        # Checks if we already have scaled the x values or not
        # print(np.all(np.abs(np.diff(self.x) - self.flow_epsilon) > 1e-14))
        if np.all(np.abs(np.diff(self.x) - self.flow_epsilon) > 1e-14):
            self.x = self.x * self.flow_epsilon
            self.pre_scale = False
        else:
            self.pre_scale = True

        # Max plotting window variables
        self.y_limits = [None, None]

        # Default type of observables, one per configuration per flow
        self.N_configurations, self.NFlows = self.y.shape[:2]

        self._analysis_arrays_setup()
Example #19
0
    def _initiate_plot_values(self, data, data_raw, flow_index=None):
        """interval_index: int, should be in euclidean time."""

        # Sorts data into a format specific for the plotting method
        for bn in self.batch_names:
            values = {}

            if flow_index == None:
                # Case where we have sub sections of observables, e.g. in
                # euclidean time.
                for sub_obs in self.observable_intervals[bn]:
                    sub_values = {}
                    sub_values["a"], sub_values["a_err"] = \
                        get_lattice_spacing(self.beta_values[bn])
                    sub_values["x"] = np.linspace(
                        0, self.lattice_sizes[bn][1] * sub_values["a"],
                        self.lattice_sizes[bn][1])

                    sub_values["y"], sub_values["y_err"] = self.analyse_raw(
                        data[bn][sub_obs],
                        data_raw[bn][self.observable_name_compact][sub_obs])

                    sub_values["label"] = self.ensemble_names[bn]

                    sub_values["raw"] = \
                        data_raw[bn][self.observable_name_compact][sub_obs]

                    if self.fold:
                        sub_values["x"] = np.linspace(
                            0, (int(sub_values["y"].shape[0] / 2)) *
                            sub_values["a"],
                            int(sub_values["y"].shape[0] / 2) + 1)

                        sub_values["y"], sub_values["y_err"] = \
                            self._folder_and_propagate(sub_values)

                        self.fold_position = sub_values["x"][self.fold_range]

                    if self.with_autocorr:
                        sub_values["tau_int"] = \
                            data[bn][sub_obs]["ac"]["tau_int"]
                        sub_values["tau_int_err"] = \
                            data[bn][sub_obs]["ac"]["tau_int_err"]

                    values[sub_obs] = sub_values
                self.plot_values[bn] = values

            else:
                tf_index = "tflow%04.4f" % flow_index
                values["a"], values["a_err"] = \
                    get_lattice_spacing(self.beta_values[bn])

                # For exact box sizes
                values["x"] = np.linspace(
                    0, self.lattice_sizes[bn][1] * values["a"],
                    self.lattice_sizes[bn][1])

                values["y_raw"] = \
                    data_raw[bn][self.observable_name_compact][tf_index]

                if self.with_autocorr:
                    values["tau_int"] = data[bn][tf_index]["ac"]["tau_int"]
                    values["tau_int_err"] = \
                        data[bn][tf_index]["ac"]["tau_int_err"]

                values["y"], values["y_err"] = \
                    self.analyse_data(data[bn][tf_index])

                if self.fold:
                    values["x"] = \
                        np.linspace(
                            0, (int(values["y"].shape[0]/2))*values["a"],
                            int(values["y"].shape[0]/2)+1)

                    values["y"], values["y_err"] = self._folder_and_propagate(
                        values)

                    # values["y_raw"] = self.fold_array(values["y_raw"], axis=0)
                    self.fold_position = values["x"][self.fold_range]

                values["label"] = self.ensemble_names[bn]

                self.plot_values[bn] = values