Пример #1
0
    def plot_laser_driven(self, out_num):
        h_fig = plt.figure(figsize=(6.5, 5))
        self.outfile.spec_name = self.background_spec_name
        self.outfile.out_num = out_num
        h_ax = h_fig.add_subplot(111)
        #h_ax.set_aspect('equal', 'box')
        #plt.ylim(-10,10)
        self.outfile.open()
        self.outfile.read_data_slice(dir=self.dir)
        self.outfile.plot_data(h_fig, h_ax, cmap='gray', vmin=-5.)
        self.outfile._color_bar.set_label('$\\rho_e$')
        self.outfile.close()

        if self.trail_spec_name is not None:
            self.outfile.spec_name = self.trail_spec_name
            self.outfile.open()
            self.outfile.read_data_slice(dir=self.dir)
            self.outfile.plot_data(
                h_fig,
                h_ax,
                vmin=self.trail_vmin,
                vmax=self.trail_vmax,
                cmap=my_cmap.cmap_higher_range_transparent())
            self.outfile._color_bar.set_label('$\\rho_t$')
            self.outfile.close()

        self.outfile.field_name = 'e3'
        self.outfile.open()
        self.outfile.read_data_slice(dir=self.dir)
        self.outfile.plot_data(h_fig,
                               h_ax,
                               cmap=my_cmap.cmap_middle_range_transparent())
        self.outfile._color_bar.set_label('$E_y$')
        self.outfile.close()
        plt.tight_layout()
        return h_fig
Пример #2
0
    def plot_laser_driven(self, out_num, if_laser_profile=False):
        ''' When if_laser_profile is Ture, plot the laser profile instead of original E-field'''
        h_fig = plt.figure(figsize=(6.5,5))
        self.outfile.field_name='charge'
        self.outfile.spec_name=self.background_spec_name
        self.outfile.out_num=out_num
        h_ax = h_fig.add_subplot(111)
        #h_ax.set_aspect('equal', 'box')
        #plt.ylim(-10,10)
        self.outfile.open()
        self.outfile.read_data_slice(dir=self.dir)
        self.outfile.plot_data(h_fig, h_ax, cmap='gray', vmax=self.background_vmax, vmin=self.background_vmin)
        self.outfile._color_bar.set_label('$\\rho_e$')
        self.outfile.close()

        if self.trail_spec_name is not None:
            self.outfile.spec_name=self.trail_spec_name
            self.outfile.open()
            self.outfile.read_data_slice(dir=self.dir)
            self.outfile.plot_data(h_fig, h_ax, vmin=self.trail_vmin, vmax=self.trail_vmax, cmap=my_cmap.cmap_higher_range_transparent())
            self.outfile._color_bar.set_label('$\\rho_t$')
            self.outfile.close()

        self.outfile.field_name='e3'
        self.outfile.open()
        self.outfile.read_data_slice(dir=self.dir)
        if if_laser_profile:
            self.outfile.data_profile2d()
            self.outfile.plot_data(h_fig, h_ax, cmap=my_cmap.cmap_lower_range_transparent(plt.cm.Reds, transparency_transition_region=[0.15,0.4]))
        else: self.outfile.plot_data(h_fig, h_ax, cmap=my_cmap.cmap_middle_range_transparent())
        self.outfile._color_bar.set_label('$E_y$')
        self.outfile.close()
        plt.tight_layout()
        return h_fig
Пример #3
0
    def plot_beam_driven(self, out_num):
        h_fig = plt.figure(figsize=(8,4.5))
        self.outfile.field_name='charge'
        self.outfile.spec_name=self.background_spec_name
        self.outfile.out_num=out_num
        h_ax = h_fig.add_subplot(111)
        h_ax.set_aspect('equal','box')
        self.outfile.open()
        self.outfile.read_data_slice(dir=self.dir)
        self.outfile.plot_data(h_fig, h_ax, vmin=self.background_vmin, vmax=self.background_vmax, cmap='gray')
        self.outfile._color_bar.set_label('$\\rho_e$')
        self.outfile.close()

        self.outfile.spec_name=self.driver_spec_name
        self.outfile.open()
        self.outfile.read_data_slice(dir=self.dir)
        self.outfile.plot_data(h_fig, h_ax, vmin=self.driver_vmin, vmax=self.driver_vmax, cmap=my_cmap.cmap_higher_range_transparent(plt.cm.hot))
        self.outfile._color_bar.set_label('$\\rho_d$')
        if self.if_driver_cm:
            try:
                self.outfile.data_center_of_mass2d()
                self.outfile.plot_data(h_fig, h_ax, linestyle='c--')
            # RuntimeError occurs when there is no particle
            except RuntimeError: pass
        self.outfile.close()

        if self.trail_spec_name is not None:
            self.outfile.spec_name=self.trail_spec_name
            self.outfile.open()
            self.outfile.read_data_slice(dir=self.dir)
            self.outfile.plot_data(h_fig, h_ax, vmin=self.trail_vmin, vmax=self.trail_vmax, cmap=my_cmap.cmap_higher_range_transparent())
            self.outfile._color_bar.set_label('$\\rho_t$')
            if self.if_trail_cm:
                try:
                    self.outfile.data_center_of_mass2d()
                    self.outfile.plot_data(h_fig, h_ax, linestyle='m--')
                # RuntimeError occurs when there is no particle
                except RuntimeError: pass
            self.outfile.close()

        if self.if_e1:
            self.outfile.field_name='e1'
            self.outfile.open()
            self.outfile.read_data_lineout()
            self.outfile.plot_data(h_fig, h_ax, linestyle='-r', if_ylabel=False, multiple=1)
            self.outfile.close()

        if self.if_psi:
            self.outfile.field_name='psi'
            self.outfile.open()
            self.outfile.read_data_lineout()
            self.outfile.plot_data(h_fig, h_ax, linestyle='-b', if_ylabel=False, multiple=1)
            self.outfile.close()

        plt.tight_layout()
        return h_fig
Пример #4
0
    def plot_beam_driven(self, out_num):
        h_fig = plt.figure(figsize=(8,4.5))
        self.outfile.field_name='charge'
        self.outfile.spec_name=self.background_spec_name
        self.outfile.out_num=out_num
        h_ax = h_fig.add_subplot(111)
        h_ax.set_aspect('equal','box')
        self.outfile.open()
        self.outfile.read_data_slice(dir=self.dir)
        self.outfile.plot_data(h_fig, h_ax, vmin=self.background_vmin, vmax=self.background_vmax, cmap='gray')
        self.outfile._color_bar.set_label('$\\rho_e$')
        self.outfile.close()

        self.outfile.spec_name=self.driver_spec_name
        self.outfile.open()
        self.outfile.read_data_slice(dir=self.dir)
        self.outfile.plot_data(h_fig, h_ax, vmin=self.driver_vmin, vmax=self.driver_vmax, cmap=my_cmap.cmap_higher_range_transparent(plt.cm.hot))
        self.outfile._color_bar.set_label('$\\rho_d$')
        if self.if_driver_cm:
            try:
                self.outfile.data_center_of_mass2d()
                self.outfile.plot_data(h_fig, h_ax, c='c', ls='--')
            # RuntimeError occurs when there is no particle
            except RuntimeError: pass
        self.outfile.close()

        if self.trail_spec_name is not None:
            self.outfile.spec_name=self.trail_spec_name
            self.outfile.open()
            self.outfile.read_data_slice(dir=self.dir)
            self.outfile.plot_data(h_fig, h_ax, vmin=self.trail_vmin, vmax=self.trail_vmax, cmap=my_cmap.cmap_higher_range_transparent())
            self.outfile._color_bar.set_label('$\\rho_t$')
            if self.if_trail_cm:
                try:
                    self.outfile.data_center_of_mass2d()
                    self.outfile.plot_data(h_fig, h_ax, c='m', ls='--')
                # RuntimeError occurs when there is no particle
                except RuntimeError: pass
            self.outfile.close()

        # Twin axis is deprecated
        if self.if_e1:
            self.outfile.field_name='e1'
            self.outfile.open()
            self.outfile.read_data_lineout()
            self.outfile.plot_data(h_fig, h_ax, if_ylabel=False, multiple=self.e1_multiple, c='r', ls='-')
            self.outfile.close()

        if self.if_psi:
            self.outfile.field_name='psi'
            if not os.path.isfile(self.outfile.path_filename):
                warnings.warn('Psi file not exit. Try to get psi by integrating Ez.')
            # No psi file, get psi by integrating e1 if e1 is already read
                if self.if_e1:
                    if self.code_name != 'quickpic':
                    # For OSIRIS and HiPACE, psi is e1 integration from right to left
                        e1 = np.flip(self.outfile._data)
                    else: e1 = self.outfile._data
                    np.cumsum(e1*self.outfile._axis_slices[0].step, out=self.outfile._data)
                    if self.code_name != 'quickpic':
                    # For OSIRIS and HiPACE, flip the data
                        self.outfile._data = np.flip(self.outfile._data)
                else: warnings.warn('Ez is not read. Please set if_e1 to True.')
            else:
            # There is psi file, read psi normally
                self.outfile.open()
                self.outfile.read_data_lineout()
                self.outfile.close()
            self.outfile.plot_data(h_fig, h_ax, if_ylabel=False, multiple=self.psi_multiple, c='b', ls='-')
        plt.tight_layout()
        return h_fig
Пример #5
0
    def plot_laser_driven(self, out_num, if_laser_profile=False):
        ''' When if_laser_profile is Ture, plot the laser profile instead of original E-field'''
        h_fig = plt.figure(figsize=(6.5, 5))
        self.outfile.field_name = 'charge'
        self.outfile.spec_name = self.background_spec_name
        self.outfile.out_num = out_num
        h_ax = h_fig.add_subplot(111)
        #h_ax.set_aspect('equal', 'box')
        #plt.ylim(-10,10)
        self.outfile.open()
        if self.outfile.num_dimensions >= 3:
            self.outfile.read_data_slice(dir=self.dir)
        else:
            self.outfile.read_data()
        self.outfile.plot_data(h_fig,
                               h_ax,
                               cmap='gray',
                               vmax=self.background_vmax,
                               vmin=self.background_vmin)
        self.outfile._color_bar.set_label('$\\rho_e$')
        self.outfile.close()

        if self.trail_spec_name is not None:
            self.outfile.spec_name = self.trail_spec_name
            self.outfile.open()
            if self.outfile.num_dimensions >= 3:
                self.outfile.read_data_slice(dir=self.dir)
            else:
                self.outfile.read_data()
            self.outfile.plot_data(
                h_fig,
                h_ax,
                vmin=self.trail_vmin,
                vmax=self.trail_vmax,
                cmap=my_cmap.cmap_higher_range_transparent())
            self.outfile._color_bar.set_label('$\\rho_t$')
            self.outfile.close()

        if self.laser_field_name is not None:
            self.outfile.field_name = self.laser_field_name
            self.outfile.open()
            if self.outfile.num_dimensions >= 3:
                self.outfile.read_data_slice(dir=self.dir)
            else:
                self.outfile.read_data()
            if if_laser_profile:
                self.outfile.data_profile2d()
                self.outfile.plot_data(
                    h_fig,
                    h_ax,
                    cmap=my_cmap.cmap_lower_range_transparent(
                        plt.cm.Reds,
                        transparency_transition_region=[0.15, 0.4]))
            else:
                self.outfile.plot_data(
                    h_fig, h_ax, cmap=my_cmap.cmap_middle_range_transparent())
            self.outfile._color_bar.set_label('$E_L$')
            self.outfile.close()

        if self.if_e1:
            self.outfile.field_name = 'e1'
            self.outfile.open()
            self.outfile.read_data_lineout()
            self.outfile.plot_data(h_fig,
                                   h_ax,
                                   if_ylabel=False,
                                   multiple=self.e1_multiple,
                                   c='r',
                                   ls='-')
            self.outfile.close()

        if self.if_psi:
            self.outfile.field_name = 'psi'
            if not os.path.isfile(self.outfile.path_filename):
                warnings.warn(
                    'Psi file not found. Try to get psi by integrating Ez.')
                # No psi file, get psi by integrating e1 if e1 is already read
                if self.if_e1:
                    if self.code_name != 'quickpic':
                        # For OSIRIS and HiPACE, psi is e1 integration from right to left
                        e1 = np.flip(self.outfile._data)
                    else:
                        e1 = self.outfile._data
                    np.cumsum(e1 * self.outfile._axis_slices[0].step,
                              out=self.outfile._data)
                    if self.code_name != 'quickpic':
                        # For OSIRIS and HiPACE, flip the data
                        self.outfile._data = np.flip(self.outfile._data)
                else:
                    warnings.warn('Ez is not read. Please set if_e1 to True.')
            else:
                # There is psi file, read psi normally
                self.outfile.open()
                self.outfile.read_data_lineout()
                self.outfile.close()
            self.outfile.plot_data(h_fig,
                                   h_ax,
                                   if_ylabel=False,
                                   multiple=self.psi_multiple,
                                   c='b',
                                   ls='-')

        plt.tight_layout()
        return h_fig