Beispiel #1
0
    def make_histograms(self):
         """ 
         plots histograms of the final sma results with respect 
         to the initial sma values of the particles
         
         sma = semi-major axis
         """

         ###### RE-FORMAT THIS ######

         two_stars = self.initial_state[0:2]
         
         transferred_sma = quantities.AdaptingVectorQuantity()
         keys_passing = self.passing[-1].key
         transferred = self.initial_state.select(lambda x : x in keys_passing , ["key"])

         for b in transferred:
             s_b = self.shift_to_star(b, two_stars, star_choice = 0)
             a, ecc, T = ps.orbital_parameters(s_b.position, s_b.velocity, self.info.m0)
             transferred_sma.append(a)
             
         ejected_sma = quantities.AdaptingVectorQuantity()
         keys_unbound = self.unbound[-1].key
         ejected = self.initial_state.select(lambda x : x in keys_unbound , ["key"])

         for b in ejected:
             s_b = self.shift_to_star(b, two_stars, star_choice = 0)
             a, ecc, T = ps.orbital_parameters(s_b.position, s_b.velocity, self.info.m0)
             ejected_sma.append(a)

         ###### RE-FORMAT THIS ######

         global_max = max( len(transferred_sma), len(ejected_sma) )
         
         name = "/plot_transferred_semimajor_axes_histogram.png"
         ps.make_sm_axis_histogram(transferred_sma, name, PlotFactory.c_PASSING,
                                         step_size = 5, max_count = global_max)

         name = "/plot_transferred_semimajor_axes_histogram_cum.png"
         ps.make_sm_axis_histogram(transferred_sma, name, PlotFactory.c_PASSING,
                                         cum = True, max_count = global_max)

         name = "/plot_ejected_semimajor_axes_histogram.png"
         ps.make_sm_axis_histogram(ejected_sma, name, PlotFactory.c_UNBOUND,
                                         step_size = 5, max_count = global_max)

         name = "/plot_ejected_semimajor_axes_histogram_cum.png"
         ps.make_sm_axis_histogram(ejected_sma, name, PlotFactory.c_UNBOUND,
                                         cum = True, max_count = global_max)
    def make_histograms(self):
        """ 
         plots histograms of the final sma results with respect 
         to the initial sma values of the particles
         
         sma = semi-major axis
         """

        # Ensure that the last index has been sorted
        self.tmp_mask[-1] = 1
        self.sort()

        ###### RE-FORMAT THIS ###### <--- Did I do this already?

        two_stars = self.initial_state[0:2]

        last_index = -1  # should be num_snapshots - 1, but not necessarily due to error in code (see below)

        transferred_sma = quantities.AdaptingVectorQuantity()
        keys_passing = self.passing[
            last_index].key  ##### There is a 'plus one' error in "multiple_code*.py" ####
        transferred = self.initial_state.select(lambda x: x in keys_passing,
                                                ["key"])

        for b in transferred:
            s_b = self.shift_to_star(b, two_stars, star_choice=0)
            a, ecc, T = ps.orbital_parameters(s_b.position, s_b.velocity,
                                              self.info.m0)
            transferred_sma.append(a)

        ejected_sma = quantities.AdaptingVectorQuantity()
        keys_unbound = self.unbound[last_index].key
        ejected = self.initial_state.select(lambda x: x in keys_unbound,
                                            ["key"])

        for b in ejected:
            s_b = self.shift_to_star(b, two_stars, star_choice=0)
            a, ecc, T = ps.orbital_parameters(s_b.position, s_b.velocity,
                                              self.info.m0)
            ejected_sma.append(a)

        ###### RE-FORMAT THIS ######

        global_max = max(len(transferred_sma), len(ejected_sma))

        if len(transferred_sma) > 0:
            #(a1)
            name = "/plot_transferred_semimajor_axes_histogram_bin5AU.png"
            ps.make_sm_axis_histogram(
                transferred_sma,
                name,
                PlotFactory.c_PASSING,
                step_size=5,
                max_count=global_max,
                min_a=int((self.info).r_in.value_in(units.AU)),
                max_a=int((self.info).r_out.value_in(units.AU)))
            #(a2)
            name = "/plot_transferred_semimajor_axes_histogram_bin1AU.png"
            ps.make_sm_axis_histogram(
                transferred_sma,
                name,
                PlotFactory.c_PASSING,
                max_count=global_max,
                min_a=int((self.info).r_in.value_in(units.AU)),
                max_a=int((self.info).r_out.value_in(units.AU)))
            #(a3)
            name = "/plot_transferred_semimajor_axes_histogram_cum_bin5AU.png"
            ps.make_sm_axis_histogram(
                transferred_sma,
                name,
                PlotFactory.c_PASSING,
                step_size=1,
                cum=True,
                max_count=global_max,
                min_a=int((self.info).r_in.value_in(units.AU)),
                max_a=int((self.info).r_out.value_in(units.AU)))
            #(a4)
            name = "/plot_transferred_semimajor_axes_histogram_cum_bin1AU.png"
            ps.make_sm_axis_histogram(
                transferred_sma,
                name,
                PlotFactory.c_PASSING,
                cum=True,
                max_count=global_max,
                min_a=int((self.info).r_in.value_in(units.AU)),
                max_a=int((self.info).r_out.value_in(units.AU)))

        if len(ejected_sma) > 0:
            #(b1)
            name = "/plot_ejected_semimajor_axes_histogram_bin5AU.png"
            ps.make_sm_axis_histogram(
                ejected_sma,
                name,
                PlotFactory.c_UNBOUND,
                step_size=5,
                max_count=global_max,
                min_a=int((self.info).r_in.value_in(units.AU)),
                max_a=int((self.info).r_out.value_in(units.AU)))
            #(b2)
            name = "/plot_ejected_semimajor_axes_histogram_bin1AU.png"
            ps.make_sm_axis_histogram(
                ejected_sma,
                name,
                PlotFactory.c_UNBOUND,
                max_count=global_max,
                min_a=int((self.info).r_in.value_in(units.AU)),
                max_a=int((self.info).r_out.value_in(units.AU)))
            #(b3)
            name = "/plot_ejected_semimajor_axes_histogram_cum_bin5AU.png"
            ps.make_sm_axis_histogram(
                ejected_sma,
                name,
                PlotFactory.c_UNBOUND,
                step_size=5,
                cum=True,
                max_count=global_max,
                min_a=int((self.info).r_in.value_in(units.AU)),
                max_a=int((self.info).r_out.value_in(units.AU)))
            #(b4)
            name = "/plot_ejected_semimajor_axes_histogram_cum_bin1AU.png"
            ps.make_sm_axis_histogram(
                ejected_sma,
                name,
                PlotFactory.c_UNBOUND,
                cum=True,
                max_count=global_max,
                min_a=int((self.info).r_in.value_in(units.AU)),
                max_a=int((self.info).r_out.value_in(units.AU)))
    def make_histograms(self):
         """ 
         plots histograms of the final sma results with respect 
         to the initial sma values of the particles
         
         sma = semi-major axis
         """

         # Ensure that the last index has been sorted
         self.tmp_mask[-1] = 1
         self.sort()

         ###### RE-FORMAT THIS ###### <--- Did I do this already?

         two_stars = self.initial_state[0:2]

         last_index = -1 # should be num_snapshots - 1, but not necessarily due to error in code (see below)
         
         transferred_sma = quantities.AdaptingVectorQuantity()
         keys_passing = self.passing[last_index].key ##### There is a 'plus one' error in "multiple_code*.py" ####
         transferred = self.initial_state.select(lambda x : x in keys_passing , ["key"])

         for b in transferred:
             s_b = self.shift_to_star(b, two_stars, star_choice = 0)
             a, ecc, T = ps.orbital_parameters(s_b.position, s_b.velocity, self.info.m0)
             transferred_sma.append(a)
             
         ejected_sma = quantities.AdaptingVectorQuantity()
         keys_unbound = self.unbound[last_index].key
         ejected = self.initial_state.select(lambda x : x in keys_unbound , ["key"])

         for b in ejected:
             s_b = self.shift_to_star(b, two_stars, star_choice = 0)
             a, ecc, T = ps.orbital_parameters(s_b.position, s_b.velocity, self.info.m0)
             ejected_sma.append(a)

         ###### RE-FORMAT THIS ######

         global_max = max( len(transferred_sma), len(ejected_sma) )
         
         if len(transferred_sma) > 0:
            #(a1)
            name = "/plot_transferred_semimajor_axes_histogram_bin5AU.png"
            ps.make_sm_axis_histogram(transferred_sma, name, PlotFactory.c_PASSING,
                                         step_size = 5, max_count = global_max,
                                     min_a = int((self.info).r_in.value_in(units.AU)), 
                                     max_a = int((self.info).r_out.value_in(units.AU)))
            #(a2)
            name = "/plot_transferred_semimajor_axes_histogram_bin1AU.png"
            ps.make_sm_axis_histogram(transferred_sma, name, PlotFactory.c_PASSING,
                                         max_count = global_max,
                                     min_a = int((self.info).r_in.value_in(units.AU)), 
                                     max_a = int((self.info).r_out.value_in(units.AU)))
            #(a3)
            name = "/plot_transferred_semimajor_axes_histogram_cum_bin5AU.png"
            ps.make_sm_axis_histogram(transferred_sma, name, PlotFactory.c_PASSING,
                                         step_size = 1, cum = True, max_count = global_max,
                                     min_a = int((self.info).r_in.value_in(units.AU)), 
                                     max_a = int((self.info).r_out.value_in(units.AU)))
            #(a4)
            name = "/plot_transferred_semimajor_axes_histogram_cum_bin1AU.png"
            ps.make_sm_axis_histogram(transferred_sma, name, PlotFactory.c_PASSING,
                                         cum = True, max_count = global_max,
                                     min_a = int((self.info).r_in.value_in(units.AU)), 
                                     max_a = int((self.info).r_out.value_in(units.AU)))
         
         if len(ejected_sma) > 0:
            #(b1)
            name = "/plot_ejected_semimajor_axes_histogram_bin5AU.png"
            ps.make_sm_axis_histogram(ejected_sma, name, PlotFactory.c_UNBOUND,
                                         step_size = 5, max_count = global_max,
                                     min_a = int((self.info).r_in.value_in(units.AU)), 
                                     max_a = int((self.info).r_out.value_in(units.AU)))
            #(b2)
            name = "/plot_ejected_semimajor_axes_histogram_bin1AU.png"
            ps.make_sm_axis_histogram(ejected_sma, name, PlotFactory.c_UNBOUND,
                                         max_count = global_max,
                                     min_a = int((self.info).r_in.value_in(units.AU)), 
                                     max_a = int((self.info).r_out.value_in(units.AU)))
            #(b3)
            name = "/plot_ejected_semimajor_axes_histogram_cum_bin5AU.png"
            ps.make_sm_axis_histogram(ejected_sma, name, PlotFactory.c_UNBOUND,
                                         step_size = 5, cum = True, max_count = global_max,
                                     min_a = int((self.info).r_in.value_in(units.AU)), 
                                     max_a = int((self.info).r_out.value_in(units.AU)))
            #(b4)
            name = "/plot_ejected_semimajor_axes_histogram_cum_bin1AU.png"
            ps.make_sm_axis_histogram(ejected_sma, name, PlotFactory.c_UNBOUND,
                                         cum = True, max_count = global_max,
                                     min_a = int((self.info).r_in.value_in(units.AU)), 
                                     max_a = int((self.info).r_out.value_in(units.AU)))