예제 #1
0
    def CmapChanged(self, *args):
        # Note here that Tkinter passes an event object to onselect()
        if self.cmapvar.get() == self.main_params['ColorMap']:
            pass
        else:
            self.main_params['ColorMap'] = self.cmapvar.get()
            cmaps_with_green = self.oengus.MainParamDict['cmaps_with_green']
            if self.main_params['ColorMap'] in cmaps_with_green:

                self.oengus.MainParamDict['ion_color'] = cmap_to_hex(
                    0.55, 'plasma')
                self.oengus.MainParamDict['electron_color'] = cmap_to_hex(
                    0.8, 'plasma')

                self.oengus.MainParamDict['ion_fit_color'] = 'r'
                self.oengus.MainParamDict['electron_fit_color'] = 'yellow'

            else:
                self.oengus.MainParamDict['ion_color'] = cmap_to_hex(
                    0.45, 'viridis')
                self.oengus.MainParamDict['electron_color'] = cmap_to_hex(
                    0.75, 'viridis')

                self.oengus.MainParamDict['ion_fit_color'] = 'mediumturquoise'
                self.oengus.MainParamDict['electron_fit_color'] = 'lime'

            self.oengus.figure.clf()
            self.oengus.create_graphs()
            self.oengus.canvas.draw()
예제 #2
0
    def cmap_changed(self):
        if self.cmap_combo.currentText() == self.main_params['ColorMap']:
            pass
        else:
            self.main_params['ColorMap'] = self.cmap_combo.currentText()
            cmaps_with_green = self.oengus.MainParamDict['cmaps_with_green']
            if self.main_params['ColorMap'] in cmaps_with_green:

                self.oengus.MainParamDict['ion_color'] = cmap_to_hex(
                    0.55, 'plasma')
                self.oengus.MainParamDict['electron_color'] = cmap_to_hex(
                    0.8, 'plasma')

                self.oengus.MainParamDict['ion_fit_color'] = 'r'
                self.oengus.MainParamDict['electron_fit_color'] = 'yellow'

            else:
                self.oengus.MainParamDict['ion_color'] = cmap_to_hex(
                    0.45, 'viridis')
                self.oengus.MainParamDict['electron_color'] = cmap_to_hex(
                    0.75, 'viridis')

                self.oengus.MainParamDict['ion_fit_color'] = 'mediumturquoise'
                self.oengus.MainParamDict['electron_fit_color'] = 'lime'

            self.oengus.figure.clf()
            self.oengus.create_graphs()
            self.oengus.canvas.draw()
예제 #3
0
    def update_labels_and_colors(self):
        sim = self.parent.sims[self.param_dict['sim_num']]

        if self.param_dict['cmap'] == 'None':
            cmap = self.parent.MainParamDict['ColorMap']
            x_color = new_cmaps.cmap_to_hex(0.2, cmap)
            y_color = new_cmaps.cmap_to_hex(0.5, cmap)
            z_color = new_cmaps.cmap_to_hex(0.8, cmap)

            if self.param_dict['UseDivCmap']:
                cmap = self.parent.MainParamDict['DivColorMap']

        else:
            cmap = self.param_dict['cmap']
            x_color = new_cmaps.cmap_to_hex(0.2, cmap)
            y_color = new_cmaps.cmap_to_hex(0.5, cmap)
            z_color = new_cmaps.cmap_to_hex(0.8, cmap)

        if self.param_dict['twoD']:
            self.image.set_cmap(new_cmaps.cmaps[cmap])
            self.cbar.set_cmap(new_cmaps.cmaps[cmap])

        else:
            self.axes.set_ylabel(
                sim.get_data(data_class='vec_flds',
                             fld=self.param_dict['field_type'],
                             component='x')['axis_label'],
                labelpad=self.parent.MainParamDict['yLabelPad'],
                color='black',
                size=self.parent.MainParamDict['AxLabelSize'])

            self.vec_x = sim.get_data(data_class='vec_flds',
                                      fld=self.param_dict['field_type'],
                                      component='x')
            self.anx.set_text(self.vec_x['label'])
            self.line_x[0].set_color(x_color)
            self.anx.set_color(x_color)

            self.vec_y = sim.get_data(data_class='vec_flds',
                                      fld=self.param_dict['field_type'],
                                      component='y')
            self.any.set_text(self.vec_y['label'])
            self.line_y[0].set_color(y_color)
            self.any.set_color(y_color)

            self.vec_z = sim.get_data(data_class='vec_flds',
                                      fld=self.param_dict['field_type'],
                                      component='z')

            self.anz.set_text(self.vec_z['label'])
            self.line_z[0].set_color(z_color)
            self.anz.set_color(z_color)
예제 #4
0
    def draw(self):
        sim = self.parent.sims[self.param_dict['sim_num']]

        if self.param_dict['cmap'] == 'None':
            if self.param_dict['UseDivCmap']:
                self.cmap = self.parent.MainParamDict['DivColorMap']

            else:
                self.cmap = self.parent.MainParamDict['ColorMap']

        else:
            self.cmap = self.param_dict['cmap']

        self.dens_color = new_cmaps.cmap_to_hex(0.5, self.cmap)

        # get c_omp and istep to convert cells to physical units
        self.c_omp = sim.get_data(data_class='param', attribute='c_omp')
        self.istep = sim.get_data(data_class='param', attribute='istep')

        # FIND THE SLICE
        self.ySlice = self.parent.calc_slices('y', sim)
        self.zSlice = self.parent.calc_slices('z', sim)

        self.scalar_fld = sim.get_data(data_class='scalar_flds',
                                       fld=self.param_dict['flds_type'])

        # Now that the data is loaded, start making the plots
        # Make the plots
        if self.param_dict['twoD']:
            self.image = self.axes.imshow(np.array([[1, 1], [1, 1]]),
                                          norm=self.norm(),
                                          origin='lower')

            if not self.parent.MainParamDict['ImageAspect']:
                self.image = self.axes.imshow(np.array([[1, 1], [1, 1]]),
                                              norm=self.norm(),
                                              origin='lower',
                                              aspect='auto')

            self.image.set_cmap(new_cmaps.cmaps[self.cmap])
            self.cbar.set_cmap(new_cmaps.cmaps[self.cmap])

            self.image.set_interpolation(self.param_dict['interpolation'])

            self.an_2d = self.axes.annotate('',
                                            xy=(0.9, 0.9),
                                            xycoords='axes fraction',
                                            color='white',
                                            **self.annotate_kwargs)

            self.an_2d.set_visible(self.param_dict['show_labels'])

            if not self.param_dict['show_cbar']:
                self.axC.set_visible(False)

            self.axes.set_xlabel(
                r'$x$',
                labelpad=self.parent.MainParamDict['xLabelPad'],
                color='black',
                size=self.parent.MainParamDict['AxLabelSize'])

            if self.parent.MainParamDict['2DSlicePlane'] == 0:
                self.axes.set_ylabel(
                    r'$y$',
                    labelpad=self.parent.MainParamDict['yLabelPad'],
                    color='black',
                    size=self.parent.MainParamDict['AxLabelSize'])

            if self.parent.MainParamDict['2DSlicePlane'] == 1:
                self.axes.set_ylabel(
                    r'$z$',
                    labelpad=self.parent.MainParamDict['yLabelPad'],
                    color='black',
                    size=self.parent.MainParamDict['AxLabelSize'])

        # 1D simulations
        else:
            self.axC.set_visible(False)
            self.xaxis = sim.get_data(data_class='axes', attribute='x')

            self.linedens = self.axes.plot([1, 1], [-0.5, 0.5],
                                           color=self.dens_color)

            self.axes.set_xlim(self.xaxis['data'][0], self.xaxis['data'][-1])

            # Handle the axes labeling
            self.axes.set_xlabel(
                self.xaxis['label'],
                labelpad=self.parent.MainParamDict['xLabelPad'],
                color='black',
                size=self.parent.MainParamDict['AxLabelSize'])

            self.axes.set_ylabel(
                self.scalar_fld['label'],
                labelpad=self.parent.MainParamDict['yLabelPad'],
                color='black',
                size=self.parent.MainParamDict['AxLabelSize'])

        self.refresh()
        self.link_handler()
예제 #5
0
    def draw(self):
        sim = self.parent.sims[self.param_dict['sim_num']]
        sim_params = self.parent.MainParamDict['sim_params'][sim.sim_num]
        shock_loc = sim.get_data(data_class='shock_finders',
                                 shock_method=sim_params['shock_method'])
        # at some point we may need to support
        # shocks along different axes but for now
        if shock_loc['axis'] != 'x' or shock_loc['shock_loc'] == 0:
            print("Shock must be defined along x axis.")
            self.param_dict['show_shock'] = False

        if self.param_dict['cmap'] == 'None':
            if self.param_dict['UseDivCmap']:
                self.cmap = self.parent.MainParamDict['DivColorMap']

            else:
                self.cmap = self.parent.MainParamDict['ColorMap']

        else:
            self.cmap = self.param_dict['cmap']

        self.dens_color = new_cmaps.cmap_to_hex(0.5, self.cmap)

        # get c_omp and istep to convert cells to physical units
        self.c_omp = sim.get_data(data_class='param', attribute='c_omp')
        self.istep = sim.get_data(data_class='param', attribute='istep')

        # FIND THE SLICE
        sim_params = self.parent.MainParamDict['sim_params'][sim.sim_num]
        slice_plane = sim_params['2DSlicePlane']
        self.xSlice = self.parent.calc_slices('x', sim)
        self.ySlice = self.parent.calc_slices('y', sim)
        self.zSlice = self.parent.calc_slices('z', sim)

        self.scalar_fld = sim.get_data(data_class='scalar_flds',
                                       fld=self.param_dict['flds_type'])
        ##
        #
        # Load all the axis data for their labels
        #
        ##

        self.xaxis = sim.get_data(data_class='axes', attribute='x')
        if slice_plane == 0:  # x-y plane
            self.yaxis = sim.get_data(data_class='axes', attribute='y')
        elif slice_plane == 1:  # x-z plane
            self.yaxis = sim.get_data(data_class='axes', attribute='z')
        elif slice_plane == 2:
            self.xaxis = sim.get_data(data_class='axes', attribute='y')
            self.yaxis = sim.get_data(data_class='axes', attribute='z')

        # Now that the data is loaded, start making the plots
        # Make the plots
        if self.param_dict['twoD']:
            self.image = self.axes.imshow(np.array([[1, 1], [1, 1]]),
                                          norm=self.norm(),
                                          origin='lower')

            if not self.parent.MainParamDict['ImageAspect']:
                self.image = self.axes.imshow(np.array([[1, 1], [1, 1]]),
                                              norm=self.norm(),
                                              origin='lower',
                                              aspect='auto')

            self.image.set_cmap(new_cmaps.cmaps[self.cmap])
            self.cbar.set_cmap(new_cmaps.cmaps[self.cmap])

            self.image.set_interpolation(self.param_dict['interpolation'])

            self.an_2d = self.axes.annotate('',
                                            xy=(0.9, 0.9),
                                            xycoords='axes fraction',
                                            color='white',
                                            **self.annotate_kwargs)

            self.an_2d.set_visible(self.param_dict['show_labels'])

            if not self.param_dict['show_cbar']:
                self.axC.set_visible(False)

            self.axes.set_xlabel(
                self.xaxis['label'],
                labelpad=self.parent.MainParamDict['xLabelPad'],
                color='black',
                size=self.parent.MainParamDict['AxLabelSize'])

            self.axes.set_ylabel(
                self.yaxis['label'],
                labelpad=self.parent.MainParamDict['yLabelPad'],
                color='black',
                size=self.parent.MainParamDict['AxLabelSize'])

        # 1D simulations
        else:
            self.axC.set_visible(False)

            self.linedens = self.axes.plot([1, 1], [-0.5, 0.5],
                                           color=self.dens_color)

            self.axes.set_xlim(self.xaxis['data'][0], self.xaxis['data'][-1])

            # Handle the axes labeling
            self.axes.set_xlabel(
                self.xaxis['label'],
                labelpad=self.parent.MainParamDict['xLabelPad'],
                color='black',
                size=self.parent.MainParamDict['AxLabelSize'])

            self.axes.set_ylabel(
                self.scalar_fld['label'],
                labelpad=self.parent.MainParamDict['yLabelPad'],
                color='black',
                size=self.parent.MainParamDict['AxLabelSize'])

        self.shock_line = self.axes.axvline(shock_loc['shock_loc'],
                                            linewidth=1.5,
                                            linestyle='--',
                                            color='w',
                                            path_effects=[
                                                PathEffects.Stroke(
                                                    linewidth=2,
                                                    foreground='k'),
                                                PathEffects.Normal()
                                            ])

        self.shock_line.set_visible(self.param_dict['show_shock']
                                    and slice_plane < 2)

        self.refresh()
        self.link_handler()