コード例 #1
0
    def __init__(self):

        self.day = 80  #winter equinox
        self.lat = 51  #london
        self.hour = 12
        self.min = 0

        self.P = 1.0  #Preasure 1bar
        self.aod = 0.27  #AOD
        self.W = 1.42  #precip water
        self.No2_un = 0.0

        self.lat = float(inp_get_token_value("spectral2.inp",
                                             "#spectral2_lat"))  #51 london

        self.day = float(inp_get_token_value(
            "spectral2.inp", "#spectral2_day"))  #80 winter equinox
        self.hour = int(inp_get_token_value("spectral2.inp",
                                            "#spectral2_hour"))
        self.min = int(
            inp_get_token_value("spectral2.inp", "#spectral2_minute"))

        self.P = float(
            inp_get_token_value("spectral2.inp",
                                "#spectral2_preasure"))  #Preasure 1bar
        self.aod = float(inp_get_token_value("spectral2.inp",
                                             "#spectral2_aod"))  #AOD
        self.W = float(inp_get_token_value("spectral2.inp",
                                           "#spectral2_water"))  #precip water
        self.No2_un = float(
            inp_get_token_value("spectral2.inp", "#spectral2_no2"))

        file_name = os.path.join(get_atmosphere_path(), "SPECTRAL2", "etr.inp")
        self.etr = dat_file()
        self.etr.y_mul = 1e9
        self.etr.y_units = "nm"
        self.etr.data_mul = 1.0
        self.etr.data_units = "W m^{-3} m^{-1}"

        self.etr.load(file_name)

        file_name = os.path.join(get_atmosphere_path(), "SPECTRAL2", "h2o.inp")
        self.aw = dat_file()
        self.aw.load(file_name)

        file_name = os.path.join(get_atmosphere_path(), "SPECTRAL2", "o3.inp")
        self.ao = dat_file()
        self.ao.load(file_name)

        file_name = os.path.join(get_atmosphere_path(), "SPECTRAL2",
                                 "uni_abs.inp")
        self.au = dat_file()
        self.au.load(file_name)

        file_name = os.path.join(get_atmosphere_path(), "SPECTRAL2", "no2.inp")
        self.no2_data = dat_file()
        self.no2_data.load(file_name)
コード例 #2
0
    def on_selection_changed(self):
        self.selected = []

        if len(self.selectedItems()) > 0:
            item = self.selectedItems()[0]
            if type(item) != None:
                obj = self.decode_name(item.text())
                if obj == None:
                    return

                file_name = obj.file_name

                self.file_path = os.path.join(self.path, file_name)

            for item in self.selectedItems():
                self.selected.append(self.decode_name(item.text()))

            full_path = self.file_path

            if (file_name.endswith(".dat") == True):
                state = dat_file()
                get_plot_file_info(state, full_path)
                summary = "<big><b>" + file_name + "</b></big><br><br>" + _(
                    "title") + ": " + state.title + "<br>" + _(
                        "x axis"
                    ) + ": " + state.y_label + " (" + latex_to_html(
                        state.y_units) + ")<br>" + _(
                            "y axis"
                        ) + ": " + state.data_label + " (" + latex_to_html(
                            state.data_units) + ")<br><br><big><b>" + _(
                                "Double click to open") + "</b></big>"
                help_window().help_set_help(["dat_file.png", summary])

            if file_name.endswith("equilibrium"):
                state = dat_file()
                get_plot_file_info(state, full_path)
                summary = "<big><b>" + _(
                    "equilibrium"
                ) + "</b></big><br><br>" + _(
                    "This contains the simulation output at 0V in the dark.")
                help_window().help_set_help(["folder.png", summary])

            #if os.path.isdir(full_path)==True:
            if get_dir_type(full_path) == "material":

                summary = "<b><big>" + file_name + "</b></big><br>"
                ref_path = os.path.join(full_path, "mat.bib")
                b = bibtex()

                if b.load(ref_path) != False:
                    summary = summary + b.get_text()
                help_window().help_set_help(["organic_material", summary])

        self.selection_changed.emit()
コード例 #3
0
ファイル: plot_window.py プロジェクト: Ly0n/gpvdm
 def __init__(self):
     QWidget.__init__(self)
     self.main_vbox = QVBoxLayout()
     self.setMinimumSize(200, 200)
     self.shown = False
     self.data = dat_file()
     self.status_bar = QStatusBar()
コード例 #4
0
ファイル: gl.py プロジェクト: xj361685640/gpvdm
def draw_mode(z_size, depth):

    glLineWidth(5)
    set_color(1.0, 1.0, 1.0, "mode")
    glBegin(GL_LINES)
    t = []
    s = []
    z = []
    start = 0.0
    data = dat_file()

    path = os.path.join(get_sim_path(), "light_dump",
                        "light_1d_photons_tot_norm.dat")
    if dat_file_read(data, path) == True:
        array_len = data.y_len
        s = data.data[0][0]
        s.reverse()
        #print(path)
        #print(data.data)
        for i in range(1, array_len):
            glVertex3f(0.0, start + (z_size * (i - 1) / array_len),
                       depth + s[i - 1] * 0.5)
            glVertex3f(0.0, start + (z_size * i / array_len),
                       depth + s[i] * 0.5)

    glEnd()
コード例 #5
0
    def gen_gnu_plot_files(self):
        path = self.path
        if len(self.sims) > 0:
            for cur_file in self.sims[0].files:
                dat = dat_file()
                dat.load(os.path.join(self.sims[0].path, cur_file))
                found_files = []
                found_files.extend(dat_file_to_gnuplot_header(dat))
                found_files.append("plot \\")
                for s in self.sims:
                    if cur_file in s.files:
                        full_path_name = os.path.join(s.path, cur_file)
                        title = os.path.dirname(
                            subtract_paths(self.path, full_path_name))
                        found_files.append(
                            "\'" + full_path_name +
                            "' using ($1):($2) with l lw 3 title '" + title +
                            "',\\")

                if self.exp_data == "":
                    found_files[-1] = found_files[-1][:-1]
                else:
                    found_files.append("\'" + self.exp_data +
                                       "' using ($1):($2) with p title '" +
                                       "Experimental" + "'")

                out_file = os.path.join(path, cur_file)
                out_file = os.path.splitext(out_file)[0] + ".plot"

                self.make_dirs(out_file)
                f = inp()
                f.lines = found_files
                #print("saving as:",out_file)
                f.save_as(out_file)
コード例 #6
0
    def draw_mode(self):
        if self.false_color == True:
            return

        glLineWidth(5)
        glColor3f(1.0, 1.0, 1.0)

        t = []
        s = []

        data = dat_file()

        path = os.path.join(get_sim_path(), "optical_output",
                            "light_1d_photons_tot_norm.dat")

        if data.load(path) == True:
            glBegin(GL_LINES)
            array_len = data.y_len
            s = data.data[0][0]
            #print(path)
            #print(data.data)
            for i in range(1, array_len):
                x = gl_scale.project_m2screen_x(0)
                y = gl_scale.project_m2screen_y(data.y_scale[i - 1])
                z = gl_scale.project_m2screen_z(0) - s[i - 1] * 0.5
                glVertex3f(x, y, z)

                y = gl_scale.project_m2screen_y(data.y_scale[i])
                z = gl_scale.project_m2screen_z(0) - s[i] * 0.5
                glVertex3f(x, y, z)

            glEnd()
コード例 #7
0
ファイル: gl.py プロジェクト: roderickmackenzie/gpvdm
		def __init__(self, parent):
			self.ray_fast=fast_data()
			self.failed=True
			self.graph_path="./snapshots/159/Jn.dat"
			self.graph_z_max=1.0
			self.graph_z_min=1.0
			self.xRot =25.0
			self.yRot =-20.0
			self.zRot =0.0
			self.x_pos=-0.5
			self.y_pos=-0.5
			self.zoom=-12.0
			self.timer=None
			self.zoom_timer=None
			self.suns=0.0
			self.selected_layer=-1
			self.graph_data=dat_file()
			QGLWidget.__init__(self, parent)
			self.lastPos=None
			#glClearDepth(1.0)              
			#glDepthFunc(GL_LESS)
			#glEnable(GL_DEPTH_TEST)
			#glShadeModel(GL_SMOOTH)
		
			self.setMinimumSize(650, 500)
コード例 #8
0
    def draw_mode(self, qp, start_x, start_y):
        t = []
        s = []
        z = []
        x = start_x
        y = start_y
        pen = QPen()
        pen.setWidth(3)
        pen.setColor(QColor(0, 0, 0))

        qp.setPen(pen)
        data = dat_file()
        if dat_file_read(
                data,
                os.path.join(get_sim_path(), "light_dump",
                             "light_1d_photons_tot_norm.dat")) == True:
            for i in range(1, data.y_len):

                x0 = (start_x - data.data[0][0][i - 1] * 40 - 10)
                y0 = (start_y + (200 * (i - 1) / data.y_len))
                x1 = (start_x - data.data[0][0][i] * 40 - 10)
                y1 = (start_y + (200 * i / data.y_len))
                if math.isnan(x0) == False and math.isnan(y0) == False:
                    x0 = (int)(x0)
                    y0 = (int)(y0)
                    x1 = (int)(x1)
                    y1 = (int)(y1)
                    qp.drawLine(x0, y0, x1, y1)
コード例 #9
0
    def save_mesh(self):
        d = dat_file()
        d.title = "title Ray trace triange file"
        d.type = "poly"
        d.x_label = "Position"
        d.z_label = "Position"
        d.data_label = "Position"
        d.x_units = "m"
        d.z_units = "m"
        d.data_units = "m"
        d.r = 1.0
        d.g = 0.0
        d.b = 0.0

        d.x_len = 3
        d.y_len = len(self.triangles)

        d.data = []

        for t in self.triangles:
            d.data.append(t)

        d.save(os.path.join(self.path, "shape.inp"))

        self.changed.emit()
コード例 #10
0
	def sub_zero_frame(self,data,i):
		if self.zero_frame_enable==True:
			data_zero=dat_file()
			if dat_file_read(data_zero,self.zero_frame_list[i])==True:
				for x in range(0,data.x_len):
					for y in range(0,data.y_len):
						for z in range(0,data.z_len):
							data.data[z][x][y]=data.data[z][x][y]-data_zero.data[z][x][y]
コード例 #11
0
    def gen_plot(self,
                 base_path,
                 file0,
                 token0,
                 file1,
                 token1,
                 output_file=""):
        x = []
        y = []
        plot_labels = []
        my_token_lib = tokens()

        print(base_path, output_file)
        if output_file == "":
            out_file_name = os.path.join(
                base_path,
                os.path.splitext(file0)[0] + token0 + "#" +
                os.path.splitext(file1)[0] + token1 + ".dat")
        else:
            out_file_name = output_file

        sims = search_simulations(base_path)
        out = dat_file()

        t0 = my_token_lib.find(token0)
        t1 = my_token_lib.find(token1)

        out.title = t0.info + " v.s. " + t1.info
        out.y_label = t0.info
        out.data_label = t1.info
        out.y_units = t0.units
        out.data_units = t1.units

        for s in sims:
            f = inp()
            f.load(os.path.join(s, file0))
            x.append(float(f.get_token(token0)))

            f = inp()
            f.load(os.path.join(s, file1))
            y.append(float(f.get_token(token1)))

        x, y = zip(*sorted(zip(x, y)))

        out.x_len = 1
        out.y_len = len(y)
        out.z_len = 1

        out.init_mem()

        for i in range(0, len(x)):
            out.y_scale[i] = x[i]
            out.data[0][0][i] = y[i]

        out.save(out_file_name)

        return [out_file_name], plot_labels, ""
コード例 #12
0
        def __init__(self, parent):
            QGLWidget.__init__(self, parent)
            gl_move_view.__init__(self)
            gl_base_widget.__init__(self)
            gl_objects.__init__(self)
            gl_lib_ray.__init__(self)
            gl_text.__init__(self)
            gl_color.__init__(self)
            gl_render_obj.__init__(self)
            gl_input.__init__(self)

            self.lit = True
            self.setAutoBufferSwap(False)

            self.lights = []

            l = open_gl_light()
            l.xyz = [0, 5, -10, 1.0]
            l.number = GL_LIGHT0
            self.lights.append(l)

            l = open_gl_light()
            l.xyz = [0, 5, 10, 1.0]
            l.number = GL_LIGHT1
            self.lights.append(l)

            self.failed = True
            self.graph_path = None
            self.scene_built = False
            #view pos

            self.graph_data = dat_file()

            self.tab_active_layers = True
            self.dy_layer_offset = 0.05

            self.draw_electrical_mesh = False
            self.draw_device_cut_through = False
            self.enable_draw_ray_mesh = False
            self.enable_draw_light_source = False
            self.enable_draw_rays = True
            self.enable_cordinates = True
            self.plot_graph = False
            self.plot_circuit = False

            #For image
            #self.render_grid=False
            #self.render_text=False
            #self.tab_active_layers=False
            #self.dy_layer_offset=0.1
            self.font = QFont("Arial")
            self.font.setPointSize(15)
            self.called = False
            self.enable_light_profile = True
            self.build_main_menu()
            self.pre_built_scene = None
コード例 #13
0
    def build_mesh(self):
        width, height = self.im.size

        self.dat_file = dat_file()
        if self.dat_file.load(os.path.join(self.path, "shape.inp")) == True:
            if len(self.dat_file.data) != 0:
                width, height = self.im.size
                min = triangles_get_min(self.dat_file.data)
                self.dat_file.data = triangles_sub_vec(self.dat_file.data, min)
                max = triangles_get_max(self.dat_file.data)

                self.dat_file.data = triangles_div_vec(self.dat_file.data, max)
コード例 #14
0
    def reload(self):
        self.data = []
        self.done_log = False

        for i in range(0, len(self.input_files)):
            dat = dat_file()
            ret = dat.load(self.input_files[i])
            if ret != False:
                dat.chop_y(0, -3)
                self.data.append(dat)

        self.norm_data()
コード例 #15
0
    def callback_reopen_xy_window(self, widget, data=None):
        if len(self.plotted_graphs) > 0:
            pos = len(self.plotted_graphs) - 1
            plot_data = dat_file()
            plot_data.file0 = self.plotted_graphs[pos].file0
            plot_xy_window = plot_dlg_class(plot_data)
            plot_xy_window.run()
            plot_now = plot_xy_window.ret

            if plot_now == True:
                self.plot_results(plot_data)
                self.plotted_graphs.refresh()
コード例 #16
0
ファイル: shape.py プロジェクト: Ly0n/gpvdm
	def load_triangles(self):
		#print("reload")
		self.shape_path=os.path.join(get_shape_path(),self.type,"shape.inp")
		if os.path.isfile(self.shape_path)==True:
			self.triangles=dat_file()
			self.triangles.load(self.shape_path)
			if self.triangles.data!=None:
				min_vec=triangles_get_min(self.triangles.data)

				self.triangles.data=triangles_sub_vec(self.triangles.data,min_vec)

				max_vec=triangles_get_max(self.triangles.data)

				self.triangles.data=triangles_div_vec(self.triangles.data,max_vec)
コード例 #17
0
    def load_data(self):
        data = dat_file()

        if data.load(os.path.join(self.path, "shape.inp")) == True:
            self.three_d_shape.gl_objects_remove_regex("bing")
            a = gl_base_object()
            a.id = ["bing"]
            a.type = "solid_and_mesh_color"
            a.r = data.r
            a.g = data.g
            a.b = data.b

            a.triangles = triangles_scale_for_gl(data.data)
            if a.triangles != False:
                self.three_d_shape.gl_objects_add(a)
                self.three_d_shape.scene_built = True
コード例 #18
0
def make_man():
	file_paths = []  # List which will store all of the full filepaths.
	out=""
	files=glob.glob("*.dat")
	section_one=[]
	section_two=[]
	text_list=[]
	for filename in files:

		if filename.endswith(".dat")==True:

			temp=dat_file()
			ret=plot_load_info(temp,filename)
			if ret==True:

				section_one.append(temp.section_one)
				section_two.append(temp.section_two)
				out=""
				filename=filename.replace("_","\\_")
				out=out+"\\textbf{"+filename+"}:"+ temp.title+"\\newline\n"
				out=out+"x-axis:"+temp.x_label+"($"+temp.x_units+"$)\\newline\n"
				out=out+"y-axis:"+temp.data_label+"($"+temp.data_units+"$)\\newline\n"
				out=out+"\\newline\n"
				text_list.append(out)


				file_paths.append(filename)

	section_one, section_two, text_list = zip(*sorted(zip(section_one, section_two,text_list),key = operator.itemgetter(1, 2)))



	text_file = open("./man_src/files.tex", "w")
	last_section_one=""
	last_section_two=""
	for i in range(0,len(text_list)):
		if section_one[i]!="":
			if last_section_one!=section_one[i]:
				last_section_one=section_one[i]
				text_file.write("\subsubsection{"+section_one[i]+"}\n")

			if last_section_two!=section_two[i]:
				last_section_two=section_two[i]
				text_file.write("\paragraph{"+section_two[i]+"}\n")

			text_file.write(text_list[i])
	text_file.close()
コード例 #19
0
ファイル: workbook.py プロジェクト: roderickmackenzie/gpvdm
def gen_workbook(input_file_or_dir,output_file):
	wb = Workbook()
	info_token=plot_state()
	if os.path.isfile(input_file_or_dir):
		files=[input_file_or_dir]
	if os.path.isdir(input_file_or_dir):
		files=glob.glob(os.path.join(input_file_or_dir,"*.dat"))
	else:
		return
	
	for my_file in files:
		print("about to save1",my_file)

		if plot_load_info(info_token,my_file)==True:
			x=[]
			y=[]
			z=[]
			data=dat_file()
			if dat_file_read(data,my_file)==True:
				print("read",my_file)
				ws = wb.create_sheet(title=title_truncate(os.path.basename(my_file)))
				ws.cell(column=1, row=1, value=info_token.title)
				ws.cell(column=1, row=2, value=info_token.x_label+" ("+info_token.x_units+") ")
				ws.cell(column=2, row=2, value=info_token.y_label+" ("+info_token.y_units+") ")
		
				for i in range(0,data.y_len):
					ws.cell(column=1, row=i+3, value=data.y_scale[i])
					ws.cell(column=2, row=i+3, value=data.data[0][0][i])

				c1 = ScatterChart()
				c1.title = info_token.title
				c1.style = 13
				c1.height=20
				c1.width=20
				c1.y_axis.title = info_token.y_label+" ("+info_token.y_units+") "
				c1.x_axis.title = info_token.x_label+" ("+info_token.x_units+") "

				xdata = Reference(ws, min_col=1, min_row=3, max_row=3+data.y_len)
				ydata = Reference(ws, min_col=2, min_row=3, max_row=3+data.y_len)

				series = Series(ydata,xdata,  title_from_data=True)
				c1.series.append(series)
				ws.add_chart(c1, "G4")

	print("about to save1")
	wb.save(filename = output_file)
	print("about to save0")
コード例 #20
0
ファイル: equation.py プロジェクト: roderickmackenzie/gpvdm
    def draw_graph(self):
        self.fig.clf()
        self.fig.subplots_adjust(bottom=0.2)
        self.fig.subplots_adjust(left=0.1)
        self.ax1 = self.fig.add_subplot(111)
        self.ax1.ticklabel_format(useOffset=False)

        self.ax1.set_ylabel(self.ylabel)

        x_nm = [x * 1e9 for x in self.x]
        frequency, = self.ax1.plot(x_nm, self.y, "ro-", linewidth=3, alpha=1.0)

        if os.path.isfile(os.path.join(self.path, self.exp_file)) == True:
            data = dat_file()
            dat_file_read(data, os.path.join(self.path, self.exp_file))
            x_nm = [x * 1e9 for x in data.y_scale]
            frequency, = self.ax1.plot(x_nm, data.data[0][0], "bo-", linewidth=3, alpha=1.0)

        self.ax1.set_xlabel(_("Wavelength (nm)"))
コード例 #21
0
	def transform(self,file_name):

		data=dat_file()
		ret=data.import_data(file_name,x_col=self.x_spin.value(),y_col=self.data_spin.value())
		if ret==True:
			self.populate_boxes()
		else:
			return False

		data.title=self.get_title()

		data.y_label=self.get_xlabel()
		data.data_label=self.get_data_label()

		data.y_units=self.x_units
		data.data_units=self.data_units
		
		data.y_mul=self.x_disp_mul
		data.data_mul=self.data_disp_mul


		#rescale the data
		for i in range(0,data.y_len):
			y=0
			y_command="data.y_scale[i]*"+self.x_mul_to_si
			y=eval(y_command)

			dat_command="data.data[0][0][i]*"+self.data_mul_to_si
			dat=eval(dat_command)

			if self.x_invert.isChecked() == True:
				y=y*-1

			if self.data_invert.isChecked() == True:
				dat=dat*-1

			data.data[0][0][i]=dat
			data.y_scale[i]=y

		data.y_scale, data.data[0][0] = zip(*sorted(zip(data.y_scale, data.data[0][0])))

		return data
コード例 #22
0
    def calculate(self):

        self.plot.data = []
        self.water_edit.text()

        day = self.cal.selectedDate().dayOfYear()
        hour = self.time.time().hour()
        minute = self.time.time().minute()

        inp_update_token_value("spectral2.inp", "#spectral2_day", str(day))
        inp_update_token_value("spectral2.inp", "#spectral2_hour", str(hour))
        inp_update_token_value("spectral2.inp", "#spectral2_minute",
                               str(minute))

        inp_update_token_value("spectral2.inp", "#spectral2_lat",
                               self.lat_edit.text())
        inp_update_token_value("spectral2.inp", "#spectral2_aod",
                               self.aod_edit.text())
        inp_update_token_value("spectral2.inp", "#spectral2_preasure",
                               self.preasure_edit.text())
        inp_update_token_value("spectral2.inp", "#spectral2_water",
                               self.water_edit.text())
        inp_update_token_value("spectral2.inp", "#spectral2_no2",
                               self.no2_edit.text())

        s = spectral2()
        s.calc()

        am = dat_file()
        am.load(os.path.join(get_spectra_path(), "AM1.5G", "spectra.inp"))
        am.key_text = "AM1.5G"
        self.plot.data.append(am)

        self.plot.data.append(s.Iglobal)

        self.plot.data.append(s.Id)

        self.plot.data.append(s.Is)

        self.plot.norm_data()
        self.plot.do_plot()
コード例 #23
0
ファイル: snapshot_slider.py プロジェクト: xingangahu/gpvdm
	def cal_min_max(self):

		self.z_max=-1e40
		self.z_min=1e40

		for i in range(0,len(self.dirs)):
			fname=os.path.join(self.dirs[i],self.files_combo.currentText())
			x=[]
			y=[]
			z=[]

			my_data=dat_file()
			if dat_file_read(my_data,fname) == True:
				#print(z)
				temp_max,temp_min=dat_file_max_min(my_data)

				if temp_max>self.z_max:
					self.z_max=temp_max

				if temp_min<self.z_min:
					self.z_min=temp_min
コード例 #24
0
	def cal_min_max(self):

		self.z_max=-1e40
		self.z_min=1e40

		for i in range(0,len(self.dirs)):
			fname=os.path.join(self.dirs[i],self.files_combo.currentText())
			x=[]
			y=[]
			z=[]

			my_data=dat_file()
			if dat_file_read(my_data,fname) == True:
				#print(z)
				temp_max,temp_min=dat_file_max_min(my_data)

				if temp_max>self.z_max:
					self.z_max=temp_max

				if temp_min<self.z_min:
					self.z_min=temp_min
コード例 #25
0
    def draw_mode(self, qp, start_x, start_y):
        t = []
        s = []
        z = []
        x = start_x
        y = start_y
        pen = QPen()
        pen.setWidth(3)
        pen.setColor(QColor(0, 0, 0))

        qp.setPen(pen)
        data = dat_file()
        if dat_file_read(data, os.path.join(os.getcwd(), "light_dump", "light_1d_photons_tot_norm.dat")) == True:
            for i in range(1, data.y_len):
                qp.drawLine(
                    start_x - data.data[0][0][i - 1] * 40 - 10,
                    start_y + (200 * (i - 1) / data.y_len),
                    start_x - data.data[0][0][i] * 40 - 10,
                    start_y + (200 * i / data.y_len),
                )
        else:
            print("no mode")
コード例 #26
0
    def callback_gen_plot_command(self):
        dialog = gpvdm_open(self.scan_io.scan_dir, act_as_browser=False)
        ret = dialog.exec_()

        if ret == QDialog.Accepted:
            full_file_name = dialog.get_filename()

            dir_type = get_dir_type(full_file_name)
            if dir_type == "snapshots":
                from cmp_class import cmp_class
                self.snapshot_window = cmp_class(full_file_name)
                self.snapshot_window.show()
                return

            #dialog.destroy()
            #print cur_dir=os.getcwd()
            #print full_file_name
            file_name = os.path.basename(full_file_name)

            plot_data = dat_file()
            plot_data.path = self.scan_io.scan_dir
            plot_data.example_file0 = full_file_name
            plot_data.example_file1 = full_file_name

            plot_now = False
            if check_info_file(file_name) == True:
                plot_data.file0 = file_name
                plot_xy_window = plot_dlg_class(plot_data)
                plot_xy_window.run()
                plot_now = plot_xy_window.ret
            else:
                plot_data.file0 = file_name
                plot_data.tag0 = ""
                plot_data.file1 = ""
                plot_data.tag1 = ""
                plot_now = True

            if plot_now == True:
                self.plot_results(plot_data)
コード例 #27
0
ファイル: gl.py プロジェクト: mandulaj/gpvdm
		def __init__(self, parent):
			QGLWidget.__init__(self, parent)
			self.setAutoBufferSwap(False)

			self.failed=True
			self.graph_path="./snapshots/159/Jn.dat"
			self.graph_z_max=1.0
			self.graph_z_min=1.0
			#view pos
			self.view=view_point()
			self.view.xRot =25.0
			self.view.yRot =-20.0
			self.view.zRot =0.0
			self.view.x_pos=-0.5
			self.view.y_pos=-0.5
			self.view.zoom=-12.0

			self.viewtarget=view_point()
			#self.viewtarget.set_value(self.view)
			self.viewtarget.xRot=0.0
			self.viewtarget.yRot=0.0
			self.viewtarget.zRot=0.0
			self.viewtarget.x_pos=-2.0
			self.viewtarget.y_pos=-1.7
			self.viewtarget.zoom=-8.0


			self.timer=None
			
			self.suns=0.0
			self.selected_layer=-1
			self.graph_data=dat_file()
			self.lastPos=None
			self.ray_file=""
			self.mouse_click_time=0.0

			self.tab_active_layers=True
			self.gl_device_height=1.4
			self.dy_layer_offset=0.05
コード例 #28
0
ファイル: gl.py プロジェクト: roderickmackenzie/gpvdm
def draw_mode(z_size,depth):

	glLineWidth(5)
	glColor3f(1.0, 1.0, 1.0)
	glBegin(GL_LINES)
	t=[]
	s=[]
	z=[]
	start=0.0
	data=dat_file()
			
	path=os.path.join(os.getcwd(),"light_dump","light_1d_photons_tot_norm.dat")
	if dat_file_read(data,path)==True:
		array_len=data.y_len
		s=data.data[0][0]
		s.reverse()
		#print(path)
		#print(data.data)
		for i in range(1,array_len):
			glVertex3f(0.0, start+(z_size*(i-1)/array_len), depth+s[i-1]*0.5)
			glVertex3f(0.0, start+(z_size*i/array_len), depth+s[i]*0.5)

	glEnd()
コード例 #29
0
    def load_data(self, input_files, config_file):
        self.lx = None
        self.ly = None
        self.input_files = input_files
        self.config_file = config_file

        if len(input_files) == 0:
            print(_("No files were given to load"))
            return

        if self.config_file == "":
            base = os.path.splitext(input_files[0])
            self.config_file = base[0] + ".oplot"

        self.data = []

        for i in range(0, len(self.input_files)):
            dat = dat_file()
            ret = dat_file_read(dat, self.input_files[i])
            self.data.append(dat)

        #Try and get the data from the config file
        self.norm_data()
コード例 #30
0
def gen_workbook(input_file_or_dir, output_file):
    if work_book_enabled == False:
        print("python3-openpyxl not found")
        return

    wb = Workbook()
    if os.path.isfile(input_file_or_dir):
        files = [input_file_or_dir]
    if os.path.isdir(input_file_or_dir):
        files = glob.glob(os.path.join(input_file_or_dir, "*.dat"))
    else:
        return

    ws = wb.active
    pos = 1
    for i in range(0, epitaxy_get_layers()):
        dos_layer = epitaxy_get_dos_file(i)
        if dos_layer.startswith("dos") == True:
            pos = workbook_from_inp(ws,
                                    pos,
                                    dos_layer + ".inp",
                                    title=epitaxy_get_name(i))

    for my_file in files:
        #print("about to save1",my_file)
        #print(my_file)
        data = dat_file()
        if data.load(my_file, guess=False) == True:
            x = []
            y = []
            z = []
            if data.load(my_file) == True:
                #print("read",my_file)
                ws = wb.create_sheet(
                    title=title_truncate(os.path.basename(my_file)))
                ws.cell(column=1, row=1, value=data.title)
                ws.cell(column=1,
                        row=2,
                        value=data.x_label + " (" + data.x_units + ") ")
                ws.cell(column=2,
                        row=2,
                        value=data.data_label + " (" + data.data_units + ") ")

                for i in range(0, data.y_len):
                    ws.cell(column=1, row=i + 3, value=data.y_scale[i])
                    ws.cell(column=2, row=i + 3, value=data.data[0][0][i])

                c1 = ScatterChart()
                c1.title = data.title
                c1.style = 13
                c1.height = 20
                c1.width = 20
                c1.y_axis.title = data.data_label + " (" + data.data_units + ") "
                c1.x_axis.title = data.x_label + " (" + data.x_units + ") "

                xdata = Reference(ws,
                                  min_col=1,
                                  min_row=3,
                                  max_row=3 + data.y_len)
                ydata = Reference(ws,
                                  min_col=2,
                                  min_row=3,
                                  max_row=3 + data.y_len)

                series = Series(ydata, xdata, title_from_data=True)
                c1.series.append(series)
                ws.add_chart(c1, "G4")
    #print("about to save1")
    try:
        wb.save(filename=output_file)
    except:
        return False

    return True
コード例 #31
0
    def calc(self):
        self.debug = True
        self.cal_earth_sun_distance()

        #zenith
        self.Z_rad = zenith(self.lat, self.day, self.hour, self.min)
        self.Z_deg = self.Z_rad * 360 / 2 / pi
        print("Zenith", self.Z_deg)

        if self.Z_deg > 90.0:
            self.Iglobal = dat_file()
            self.Iglobal.copy(self.etr)
            self.Iglobal.file_name = "Iglobal.dat"
            self.Iglobal.key_text = "Global"

            self.Is = dat_file()
            self.Is.copy(self.etr)
            self.Is.file_name = "Idiffuse.dat"
            self.Is.key_text = "Diffuse"

            self.Id = dat_file()
            self.Id.copy(self.etr)
            self.Id.file_name = "Idirect.dat"
            self.Id.key_text = "Direct"
            return

        #self.D=1.0
        #se0lf.Z_deg=48.2
        #self.Z_rad=(self.Z_deg/360.0)*2.0*pi
        #Direct

        self.Tr = dat_file()
        self.Tr.copy(self.etr)
        self.cal_rayleigh()
        if self.debug == True:
            self.Tr.save("Tr.dat")

        self.Ta = dat_file()
        self.Ta.copy(self.etr)
        self.tau_a = dat_file()
        self.tau_a.copy(self.etr)
        self.cal_arosol()
        if self.debug == True:
            self.Ta.save("Ta.dat")

        self.Tw = dat_file()
        self.Tw.copy(self.etr)
        self.cal_water()

        self.To = dat_file()
        self.To.copy(self.etr)
        self.cal_ozone()
        if self.debug == True:
            self.To.save("To.dat")

        self.Tu = dat_file()
        self.Tu.copy(self.etr)
        self.cal_mixed_gas()
        if self.debug == True:
            self.Tu.save("Tu.dat")

        self.Tno2 = dat_file()
        self.Tno2.copy(self.etr)
        self.cal_Tno2()
        if self.debug == True:
            self.Tno2.save("Tno.dat")

        self.Id = self.etr * self.D * self.Tr * self.Ta * self.Tw * self.To * self.Tu * self.Tno2
        self.Id.file_name = "Idirect.dat"
        self.Id.key_text = "Direct"

        #Diffuse
        self.omega = dat_file()
        self.omega.copy(self.etr)
        self.cal_omega()
        if self.debug == True:
            self.omega.save("omega.dat")

        self.Taa = dat_file()
        self.Taa.copy(self.etr)
        self.cal_Taa()
        if self.debug == True:
            self.Taa.save("Taa.dat")

        self.Cs = dat_file()
        self.Cs.copy(self.etr)
        self.cal_Cs()
        if self.debug == True:
            self.Cs.save("Cs.dat")

        self.Ir = self.etr * self.D * cos(
            self.Z_rad) * self.To * self.Tu * self.Tw * self.Taa * (
                1.0 - self.Tr.pow(0.95)) * self.Cs
        if self.debug == True:
            self.Ta.save("Ir.dat")

        self.Tas = dat_file()
        self.Tas.copy(self.etr)
        self.cal_Tas()
        if self.debug == True:
            self.Tas.save("Tas.dat")

        self.Fs = dat_file()
        self.Fs.copy(self.etr)
        self.cal_Fs()

        self.Ia = self.etr * self.D * cos(
            self.Z_rad) * self.To * self.Tu * self.Tw * self.Taa * self.Tr.pow(
                1.5) * (1.0 - self.Tas) * self.Fs * self.Cs
        #Ig

        self.TuP = dat_file()
        self.TuP.copy(self.etr)
        self.cal_mixed_gas_P()
        if self.debug == True:
            self.TuP.save("TuP.dat")

        self.TwP = dat_file()
        self.TwP.copy(self.etr)
        self.cal_water_P()
        if self.debug == True:
            self.TwP.save("TwP.dat")

        self.TaaP = dat_file()
        self.TaaP.copy(self.etr)
        self.cal_TaaP()
        if self.debug == True:
            self.TaaP.save("Taap.dat")

        self.TrP = dat_file()
        self.TrP.copy(self.etr)
        self.cal_rayleigh_P()
        if self.debug == True:
            self.TrP.save("TrP.dat")

        self.TasP = dat_file()
        self.TasP.copy(self.etr)
        self.cal_TasP()
        if self.debug == True:
            self.TasP.save("TasP.dat")

        FsP = 1.0 - 0.5 * exp((self.AFS + self.BFS / 1.8) / 1.8)
        self.r_s = self.TuP * self.TwP * self.TaaP * (0.5 * (1.0 - self.TrP) +
                                                      (1 - FsP) * self.TrP *
                                                      (1.0 - self.TasP))
        if self.debug == True:
            self.r_s.save("r_s.dat")

        r_g = 0.2  #Mohamed
        self.Ig = (self.Id * cos(self.Z_rad) + self.Ir +
                   self.Ia) * self.r_s * r_g * self.Cs / (1.0 - self.r_s * r_g)
        if self.debug == True:
            self.Ig.save("Ig.dat")

        self.Is = self.Ir + self.Ia + self.Ig
        self.Is.file_name = "Idiffuse.dat"
        self.Is.key_text = "Diffuse"

        self.Ir.save("Ir.dat")
        self.Ia.save("Ia.dat")
        self.Ig.save("Ig.dat")

        self.Is.save("Is.dat")
        self.Id.save("Id.dat")

        self.Iglobal = self.Is + self.Id
        self.Iglobal.file_name = "Iglobal.dat"
        self.Iglobal.key_text = "Global"
        self.Iglobal.save("Iglobal.dat")
コード例 #32
0
    def __init__(self):
        QWidget.__init__(self)
        self.complex_display = False

        self.hbox = QVBoxLayout()
        self.data = dat_file()
        self.my_server = server_get()
        mesh = get_mesh()
        if mesh.y.circuit_model == True and mesh.x.tot_points == 1 and mesh.z.tot_points == 1:
            self.display = circuit_editor()

            epi = get_epi()
            pos = 3
            self.display.ersatzschaltbild.add_object(pos, 3, pos + 1, 3, "bat")
            pos = pos + 1

            for l in epi.layers:
                f = inp()
                f.load(
                    os.path.join(get_sim_path(), l.shape_electrical + ".inp"))
                component = f.get_token("#electrical_component")
                if component == "resistance":
                    self.display.ersatzschaltbild.add_object(
                        pos, 3, pos + 1, 3, "resistor")
                if component == "diode":
                    self.display.ersatzschaltbild.add_object(
                        pos, 3, pos + 1, 3, "diode")

                pos = pos + 1
            self.display.ersatzschaltbild.add_object(pos, 3, pos + 1, 3,
                                                     "ground")
            self.display.ersatzschaltbild.objects_push()

            if inp().isfile(os.path.join(get_sim_path(),
                                         "diagram.inp")) == True:
                self.display.ersatzschaltbild.load()
        else:
            toolbar = QToolBar()
            toolbar.setIconSize(QSize(42, 42))

            spacer = QWidget()
            spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
            toolbar.addWidget(spacer)

            self.tb_refresh = QAction(icon_get("view-refresh"), _("Refresh"),
                                      self)
            self.tb_refresh.triggered.connect(self.rebuild_mesh)
            toolbar.addAction(self.tb_refresh)

            self.xy = QAction(icon_get("xy"), _("xy"), self)
            self.xy.triggered.connect(self.callback_xy)
            toolbar.addAction(self.xy)

            self.yz = QAction(icon_get("yz"), _("yz"), self)
            self.yz.triggered.connect(self.callback_yz)
            toolbar.addAction(self.yz)

            self.xz = QAction(icon_get("xz"), _("xz"), self)
            self.xz.triggered.connect(self.callback_xz)
            toolbar.addAction(self.xz)

            self.tb_rotate = QAction(icon_get("rotate.png"), _("Rotate"), self)
            self.tb_rotate.triggered.connect(self.tb_rotate_click)
            toolbar.addAction(self.tb_rotate)
            self.tb_rotate.setEnabled(True)

            self.hbox.addWidget(toolbar)

            self.display = glWidget(self)
            #self.data.load(os.path.join(get_sim_path(),"electrical_mesh.dat")
            #self.display.pre_built_scene=gl_scale.project_base_objects_from_m_2_screen(self.data.data)
            self.display.draw_electrical_mesh = False
            self.display.view.draw_device = False
            self.display.enable_draw_ray_mesh = False
            self.display.enable_draw_light_source = False
            self.display.enable_draw_rays = False
            self.display.view.render_photons = False

            self.display.force_redraw()
            #global_object_register("display_mesh_recalculate",self.recalculate)

        self.hbox.addWidget(self.display)

        self.setLayout(self.hbox)
コード例 #33
0
    def gen_mesh(self):
        self.mesh = []
        try:
            Xi = -float(
                inp_get_token_value(
                    os.path.join(get_sim_path(), self.dos_file), "#Xi"))
            Eg = float(
                inp_get_token_value(
                    os.path.join(get_sim_path(), self.dos_file), "#Eg"))

            srh_stop = float(
                inp_get_token_value(
                    os.path.join(get_sim_path(), self.dos_file), "#srh_start"))
            bands = int(
                inp_get_token_value(
                    os.path.join(get_sim_path(), self.dos_file), "#srh_bands"))
        except:
            return

        start = Xi
        stop = Xi - Eg
        pos = start
        dx = (stop - start) / 100
        while (pos > stop):
            pos = pos + dx
            self.mesh.append(pos)

        self.data_lumo = dat_file()
        self.data_lumo.data_min = 1e10
        self.data_lumo.data_max = 1e27
        self.data_lumo.title = "LUMO Density of states"

        self.data_lumo.y_label = "Energy"
        self.data_lumo.data_label = "States"

        self.data_lumo.y_units = "Ev"
        self.data_lumo.data_units = "m^{-3} eV"

        self.data_lumo.y_mul = 1.0
        self.data_lumo.data_mul = 1.0

        self.data_lumo.logdata = True

        self.data_lumo.x_len = 1
        self.data_lumo.y_len = len(self.mesh)
        self.data_lumo.z_len = 1

        self.data_lumo.init_mem()

        self.data_numerical_lumo = dat_file()
        self.data_numerical_lumo.title = "LUMO Numberical DoS"

        self.data_numerical_lumo.data_min = 1e10
        self.data_numerical_lumo.data_max = 1e27

        self.data_numerical_lumo.y_label = "Energy"
        self.data_numerical_lumo.data_label = "States"

        self.data_numerical_lumo.y_units = "Ev"
        self.data_numerical_lumo.data_units = "m^{-3} eV"

        self.data_numerical_lumo.y_mul = 1.0
        self.data_numerical_lumo.data_mul = 1.0

        self.data_numerical_lumo.logdata = True

        self.data_numerical_lumo.x_len = 1
        self.data_numerical_lumo.y_len = len(self.mesh)
        self.data_numerical_lumo.z_len = 1

        self.data_numerical_lumo.init_mem()

        self.data_homo = dat_file()

        self.data_homo.title = "H**O Density of states"

        self.data_homo.data_min = 1e10
        self.data_homo.data_max = 1e27

        self.data_homo.y_label = "Energy"
        self.data_homo.data_label = "States"

        self.data_homo.y_units = "Ev"
        self.data_homo.data_units = "m^{-3} eV"

        self.data_homo.y_mul = 1.0
        self.data_homo.data_mul = 1.0

        self.data_homo.logdata = True

        self.data_homo.x_len = 1
        self.data_homo.y_len = len(self.mesh)
        self.data_homo.z_len = 1

        self.data_homo.init_mem()

        self.data_numerical_homo = dat_file()
        self.data_numerical_homo.title = "H**O Numerical DoS"

        self.data_numerical_homo.data_min = 1e10
        self.data_numerical_homo.data_min = 1e27

        self.data_numerical_homo.y_label = "Energy"
        self.data_numerical_homo.data_label = "States"

        self.data_numerical_homo.y_units = "Ev"
        self.data_numerical_homo.data_units = "m^{-3} eV"

        self.data_numerical_homo.y_mul = 1.0
        self.data_numerical_homo.data_mul = 1.0

        self.data_numerical_homo.logdata = True

        self.data_numerical_homo.x_len = 1
        self.data_numerical_homo.y_len = len(self.mesh)
        self.data_numerical_homo.z_len = 1

        self.data_numerical_homo.init_mem()

        for iy in range(0, len(self.mesh)):
            x = self.mesh[iy]
            y = 0
            homo_y = 0

            for i in range(0, self.lumo.tab.rowCount()):
                if self.lumo.tab.get_value(i, 1) == "true":
                    try:
                        a = float(self.lumo.tab.get_value(i, 2))
                        b = float(self.lumo.tab.get_value(i, 3))
                        c = float(self.lumo.tab.get_value(i, 4))
                    except:
                        a = 0.0
                        b = 0.0
                        c = 0.0

                    if self.lumo.tab.get_value(i, 0) == "exp":
                        if b != 0:
                            y = y + a * exp((x - Xi) / b)

                    if self.lumo.tab.get_value(i, 0) == "gaus":
                        if c != 0:
                            y = y + a * exp(-pow(((b + (x - Xi)) /
                                                  (sqrt(2.0) * c * 1.0)), 2.0))

            for i in range(0, self.h**o.tab.rowCount()):
                if self.h**o.tab.get_value(i, 1) == "true":

                    try:
                        a = float(self.h**o.tab.get_value(i, 2))
                        b = float(self.h**o.tab.get_value(i, 3))
                        c = float(self.h**o.tab.get_value(i, 4))
                    except:
                        a = 0.0
                        b = 0.0
                        c = 0.0

                    if self.h**o.tab.get_value(i, 0) == "exp":
                        if b != 0:
                            homo_y = homo_y + a * exp((Xi - Eg - x) / b)

                    if self.h**o.tab.get_value(i, 0) == "gaus":
                        if c != 0:
                            homo_y = homo_y + a * exp(-pow((
                                (Xi - Eg - x + b) /
                                (sqrt(2.0) * c * 1.0)), 2.0))

            self.data_numerical_lumo.y_scale[iy] = x
            self.data_numerical_homo.y_scale[iy] = x

            self.data_lumo.y_scale[iy] = x
            self.data_lumo.data[0][0][iy] = y

            self.data_homo.y_scale[iy] = x
            #print(x,homo_y)
            self.data_homo.data[0][0][iy] = homo_y

        if bands != 0:
            dE_band = srh_stop / bands

            srh_lumo_pos = Xi
            srh_homo_pos = Xi - Eg

            srh_lumo_stop_points = []
            srh_lumo_avg = []
            srh_lumo_count = []

            srh_homo_stop_points = []
            srh_homo_avg = []
            srh_homo_count = []

            for i in range(0, bands + 1):

                srh_lumo_stop_points.append(srh_lumo_pos)
                srh_homo_stop_points.append(srh_homo_pos)

                srh_lumo_avg.append(0.0)
                srh_homo_avg.append(0.0)

                srh_lumo_count.append(0.0)
                srh_homo_count.append(0.0)

                srh_lumo_pos = srh_lumo_pos + dE_band
                srh_homo_pos = srh_homo_pos - dE_band

            #build numeical LUMO
            for iy in range(0, len(self.mesh)):
                x = self.mesh[iy]
                for i in range(0, len(srh_lumo_stop_points) - 1):
                    if srh_lumo_stop_points[i + 1] < x:
                        srh_lumo_avg[i] = srh_lumo_avg[
                            i] + self.data_lumo.data[0][0][iy]
                        srh_lumo_count[i] = srh_lumo_count[i] + 1
                        break

            for iy in range(0, len(self.mesh)):
                x = self.mesh[iy]
                for i in range(0, len(srh_lumo_stop_points) - 1):
                    if srh_lumo_stop_points[i + 1] < x:
                        self.data_numerical_lumo.data[0][0][
                            iy] = srh_lumo_avg[i] / srh_lumo_count[i]
                        break

            #build numeical H**O
            for iy in range(0, len(self.mesh)):
                x = self.mesh[iy]
                for i in range(0, len(srh_homo_stop_points) - 1):
                    if srh_homo_stop_points[i + 1] > x:
                        srh_homo_avg[i] = srh_homo_avg[
                            i] + self.data_homo.data[0][0][iy]
                        srh_homo_count[i] = srh_homo_count[i] + 1
                        break

            for iy in range(0, len(self.mesh)):
                x = self.mesh[iy]
                for i in range(0, len(srh_homo_stop_points) - 1):
                    if srh_homo_stop_points[i + 1] > x:
                        if srh_homo_count[i] != 0:
                            self.data_numerical_homo.data[0][0][
                                iy] = srh_homo_avg[i] / srh_homo_count[i]
                        break

        self.data_numerical_lumo.file_name = os.path.join(
            self.dos_dir, "lumo_numberical.dat")
        self.data_numerical_homo.file_name = os.path.join(
            self.dos_dir, "homo_numberical.dat")

        self.data_lumo.file_name = os.path.join(self.dos_dir, "lumo.dat")
        self.data_homo.file_name = os.path.join(self.dos_dir, "h**o.dat")

        self.plot.data = [
            self.data_numerical_lumo, self.data_numerical_homo, self.data_lumo,
            self.data_homo
        ]
コード例 #34
0
def command_args(argc, argv):
    if test_arg_for_sim_file() != False:
        return

    if argc >= 2:
        if args.version:
            print(version())
            sys.exit(0)
        elif args.ver:
            print(ver())
            sys.exit(0)
        elif args.syncver:
            ver_sync_ver()
            sys.exit(0)
        elif args.importscandirs:
            import_scan_dirs(os.getcwd(), args.importscandirs[0])
            exit(0)
        elif args.replace:
            device_lib_replace(args.replace[0], dir_name=args.replace[1])
            exit(0)
        elif args.clean:
            clean_sim_dir()
            sys.exit(0)
        elif args.export:
            export_as(args.export[0])
            sys.exit(0)
        elif args.makeman:
            make_man()
            sys.exit(0)
        elif args.cleanscandirs:
            scan = scans_io(os.getcwd())
            scan.clean_all()
            sys.exit(0)
        elif args.importfile:
            import_archive(args.importfile[0],
                           os.path.join(os.getcwd(), "sim.gpvdm"), False)
            sys.exit(0)
        elif args.dumptab:
            export_as(args.dumptab[0])
            sys.exit(0)
        elif args.patch:
            import_archive(args.patch[0], args.patch[1], True)
            sys.exit(0)
        elif args.patchfile:
            patch_file(args.patchfile[0], args.patchfile[1], args.patchfile[2])
            sys.exit(0)
        elif args.clone:
            gpvdm_clone(os.getcwd(), copy_dirs=True)
            sys.exit(0)
        elif args.matcompress:
            archive_materials(os.path.join(os.getcwd(), "materials"))
            sys.exit(0)
        elif args.clonesrc:
            gpvdm_copy_src(clone - src[0])
            sys.exit(0)
        elif args.editvalue:
            inp_update_token_value(args.editvalue[0], args.editvalue[1],
                                   args.editvalue[2])
            sys.exit(0)
        elif args.load:
            set_sim_path(os.path.dirname(args.load[0]))
            #print("a")
        elif args.encrypt:
            inp_encrypt(args.encrypt[0])
            sys.exit(0)
        elif args.unpack:
            archive_decompress(os.path.join(os.getcwd(), "sim.gpvdm"),
                               remove_gpvdm_file=False)
            sys.exit(0)
        elif args.pack:
            archive_compress(os.path.join(os.getcwd(), "sim.gpvdm"))
            sys.exit(0)
        elif args.scanplot:
            plot_token = dat_file()
            oplot_file = args.scan - plot[0]
            if plot_load_info(plot_token, oplot_file) == True:
                print("file0=", plot_token.file0, "<")
                plot_files, plot_labels, save_file = scan_gen_plot_data(
                    plot_token, os.path.dirname(oplot_file))
                print("written data to", save_file)
            else:
                print("Problem loading oplot file")
            sys.exit(0)
コード例 #35
0
ファイル: import_data.py プロジェクト: xj361685640/gpvdm
    def __init__(self, out_file, config_file):
        QDialog.__init__(self)
        self.out_file = out_file
        self.config_file_path = config_file
        self.path = os.path.dirname(self.out_file)
        self.file_name = None
        resize_window_to_be_sane(self, 0.6, 0.7)
        self.data = dat_file()
        self.info_token = dat_file()

        #self.setFixedSize(900, 600)
        self.setWindowIcon(icon_get("import"))

        self.setWindowTitle(_("Import data") + " (https://www.gpvdm.com)")

        self.main_vbox = QVBoxLayout()

        self.ribbon = ribbon_import()

        self.ribbon.open_data.triggered.connect(self.callback_open)

        self.ribbon.import_data.triggered.connect(self.callback_import)

        self.ribbon.plot.triggered.connect(self.callback_plot)

        self.ribbon.tb_help.triggered.connect(self.callback_help)

        self.main_vbox.addWidget(self.ribbon)

        self.input_output_hbox = QHBoxLayout()

        self.raw_data_widget = QWidget()
        self.raw_data_hbox = QVBoxLayout()
        self.raw_data_widget.setLayout(self.raw_data_hbox)
        self.raw_data = QTextEdit(self)
        self.raw_data.setReadOnly(True)
        self.raw_data.setLineWrapMode(QTextEdit.NoWrap)
        font = self.raw_data.font()
        font.setFamily("Courier")
        font.setPointSize(10)
        self.raw_data_label = QLabel(_("The file to import:"))
        self.raw_data_hbox.addWidget(self.raw_data_label)
        self.raw_data_hbox.addWidget(self.raw_data)
        self.raw_data_path = QLabel()
        self.raw_data_hbox.addWidget(self.raw_data_path)

        self.out_data_widget = QWidget()
        self.out_data_hbox = QVBoxLayout()
        self.out_data_widget.setLayout(self.out_data_hbox)
        self.out_data = QTextEdit(self)
        self.out_data.setReadOnly(True)
        self.out_data.setLineWrapMode(QTextEdit.NoWrap)
        font = self.out_data.font()
        font.setFamily("Courier")
        font.setPointSize(10)
        self.out_data_label = QLabel(
            _("The imported file, the numbers should now be in SI units"))
        self.out_data_hbox.addWidget(self.out_data_label)

        self.out_data_hbox.addWidget(self.out_data)

        self.out_data_path = QLabel()
        self.out_data_hbox.addWidget(self.out_data_path)

        self.input_output_hbox.addWidget(self.raw_data_widget)
        self.input_output_hbox.addWidget(self.out_data_widget)
        self.input_output_widget = QWidget()
        self.input_output_widget.setLayout(self.input_output_hbox)

        ###################
        self.build_top_widget()
        ###################

        self.main_vbox.addWidget(self.top_widget)
        self.main_vbox.addWidget(self.input_output_widget)
        self.input_output_widget.setSizePolicy(QSizePolicy.Expanding,
                                               QSizePolicy.Expanding)
        self.setLayout(self.main_vbox)

        self.out_data_path.setText(self.out_file)
        if self.load_config() == False:
            self.open_file()
        self.load_file()
        self.update()
コード例 #36
0
ファイル: equation.py プロジェクト: xingangahu/gpvdm
    def init(self):
        self.data = dat_file()
        self.fig = Figure(figsize=(5, 4), dpi=100)
        self.canvas = FigureCanvas(self.fig)
        self.canvas.figure.patch.set_facecolor('white')

        self.main_vbox = QVBoxLayout()

        toolbar = QToolBar()
        toolbar.setIconSize(QSize(48, 48))

        self.tb_save = QAction(QIcon_load("document-save-as"), _("Save image"),
                               self)
        self.tb_save.triggered.connect(self.callback_save)
        toolbar.addAction(self.tb_save)

        self.tb_ref = QAction(QIcon_load("ref"),
                              _("Insert reference information"), self)
        self.tb_ref.triggered.connect(self.callback_ref)
        toolbar.addAction(self.tb_ref)

        self.import_data = QAction(QIcon_load("import"), _("Import data"),
                                   self)
        self.import_data.triggered.connect(self.callback_import)
        toolbar.addAction(self.import_data)

        if self.show_solar_spectra == True:
            if enable_betafeatures() == True:
                self.solar_spectra = QAction(QIcon_load("weather-few-clouds"),
                                             _("Solar spectra"), self)
                self.solar_spectra.triggered.connect(
                    self.callback_solar_spectra)
                toolbar.addAction(self.solar_spectra)

        self.file_select = tb_item_mat_file(self.path, self.token)
        #self.file_select.changed.connect(self.callback_sun)
        toolbar.addWidget(self.file_select)

        self.main_vbox.addWidget(toolbar)

        self.main_vbox.addWidget(self.canvas)

        #toolbar 2

        toolbar2 = QToolBar()
        toolbar2.setIconSize(QSize(32, 32))

        self.tb_add = QAction(QIcon_load("list-add"), _("Add section"), self)
        self.tb_add.triggered.connect(self.callback_add_section)
        toolbar2.addAction(self.tb_add)

        self.tb_remove = QAction(QIcon_load("list-remove"),
                                 _("Delete section"), self)
        self.tb_remove.triggered.connect(self.callback_remove_item)
        toolbar2.addAction(self.tb_remove)

        self.tb_move = QAction(QIcon_load("go-down"), _("Move down"), self)
        self.tb_move.triggered.connect(self.callback_move_down)
        toolbar2.addAction(self.tb_move)

        self.tb_move_up = QAction(QIcon_load("go-up"), _("Move up"), self)
        self.tb_move_up.triggered.connect(self.callback_move_up)
        toolbar2.addAction(self.tb_move_up)

        self.tb_play = QAction(QIcon_load("media-playback-start"),
                               _("Calculate"), self)
        self.tb_play.triggered.connect(self.callback_play)
        toolbar2.addAction(self.tb_play)

        self.tb_fit = QAction(QIcon_load("fit"), _("Fit data"), self)
        self.tb_fit.triggered.connect(self.callback_fit)
        toolbar2.addAction(self.tb_fit)

        self.main_vbox.addWidget(toolbar2)

        self.tab = QTableWidget()
        self.tab.resizeColumnsToContents()

        self.tab.verticalHeader().setVisible(False)

        self.main_vbox.addWidget(self.tab)

        self.setLayout(self.main_vbox)

        self.load_data()

        self.build_mesh()
        self.draw_graph()

        self.tab.cellChanged.connect(self.on_cell_edited)
コード例 #37
0
	def do_plot(self):
		#print("PLOT TYPE=",self.plot_token.type)
		if self.plot_token!=None and len(self.plot_id)!=0:
			plot_number=0
			#print(">>>>>>>>>>>>",self.plot_token.x_len,self.plot_token.y_len,self.plot_token.z_len)
			self.fig.clf()
			self.fig.subplots_adjust(bottom=0.2)
			self.fig.subplots_adjust(bottom=0.2)
			self.fig.subplots_adjust(left=0.1)
			self.fig.subplots_adjust(hspace = .001)

			title=""
			if self.plot_title=="":
				title=self.plot_token.title
			else:
				title=self.plot_title

			if self.plot_token.time!=-1.0 and self.plot_token.Vexternal!=-1.0:
				mul,unit=time_with_units(self.plot_token.time)
				title=title+" V="+str(self.plot_token.Vexternal)+" time="+str(self.plot_token.time*mul)+" "+unit

			self.fig.suptitle(title)

			self.ax=[]
			number_of_plots=max(self.plot_id)+1
			if self.plot_token.type=="heat":
				number_of_plots=1




			for i in range(0,number_of_plots):
				self.ax.append(self.fig.add_subplot(number_of_plots,1,i+1, axisbg='white'))
				#Only place label on bottom plot
				if i==number_of_plots-1:
					#print(self.plot_token.x_label,self.plot_token.x_units)
					self.ax[i].set_xlabel(self.plot_token.x_label+" ("+str(self.plot_token.x_units)+")")

				else:
					self.ax[i].tick_params(axis='x', which='both', bottom='off', top='off',labelbottom='off') # labels along the bottom edge are off

				#Only place y label on center plot
				if self.plot_token.normalize==True or self.plot_token.norm_to_peak_of_all_data==True:
					y_text="Normalized "+self.plot_token.y_label
					y_units="au"
				else:
					y_text=self.plot_token.y_label
					y_units=self.plot_token.y_units
				if i==math.trunc(number_of_plots/2):
					self.ax[i].set_ylabel(y_text+" ("+y_units+")")

				if self.plot_token.logx==True:
					self.ax[i].set_xscale("log")

				if self.plot_token.logy==True:
					self.ax[i].set_yscale("log")


			lines=[]
			files=[]
			data=dat_file()
			my_max=1.0

			if self.plot_token.x_len==1 and self.plot_token.z_len==1:

				all_max=1.0
				if self.plot_token.norm_to_peak_of_all_data==True:
					my_max=-1e40
					for i in range(0, len(self.input_files)):
						if self.read_data_file(data,i)==True:
							local_max,my_min=dat_file_max_min(data)
							if local_max>my_max:
								my_max=local_max
					all_max=my_max

				for i in range(0, len(self.input_files)):
					if self.read_data_file(data,i)==True:
						if all_max!=1.0:
							for x in range(0,data.x_len):
								for y in range(0,data.y_len):
									for z in range(0,data.z_len):
										data.data[z][x][y]=data.data[z][x][y]/all_max

						Ec, = self.ax[plot_number].plot(data.y_scale,data.data[0][0], linewidth=3 ,alpha=1.0,color=self.color[i],marker=self.marker[i])

						#label data if required
						#if self.plot_token.label_data==True:
						#	for ii in range(0,len(t)):
						#		if z[ii]!="":
						#			fx_unit=fx_with_units(float(z[ii]))
						#			label_text=str(float(z[ii])*fx_unit[0])+" "+fx_unit[1]
						#			self.ax[plot_number].annotate(label_text,xy = (t[ii], s[ii]), xytext = (-20, 20),textcoords = 'offset points', ha = 'right', va = 'bottom',bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0'))

						#if number_of_plots>1:
						#	self.ax[plot_number].yaxis.set_major_formatter(ticker.FormatStrFormatter('%0.1e'))
						#	if min(s)!=max(s):
						#		print("TICKS=",(max(s)-min(s))/4.0)
						#		self.ax[plot_number].yaxis.set_ticks(arange(min(s), max(s), (max(s)-min(s))/4.0 ))

						#print("roderick",self.labels,i,self.labels[i])
						if self.labels[i]!="":
							#print "Rod=",self.labels[i]
							#print self.plot_token.key_units
							files.append("$"+numbers_to_latex(str(self.labels[i]))+" "+pygtk_to_latex_subscript(self.plot_token.key_units)+"$")

							lines.append(Ec)

				self.lx = None
				self.ly = None
				if self.plot_token.legend_pos=="No key":
					self.ax[plot_number].legend_ = None
				else:
					self.fig.legend(lines, files, self.plot_token.legend_pos)
			elif self.plot_token.x_len>1 and self.plot_token.y_len>1 and self.plot_token.z_len==1:		#3d plot
				data=dat_file()

				if self.read_data_file(data,0)==True:
					im=self.ax[0].pcolor(data.y_scale,data.x_scale,data.data[0])
					self.fig.colorbar(im)
					#self.ax[0].plot_surface(x, y, z, rstride=1, cstride=1, cmap=cm.coolwarm,linewidth=0, antialiased=False)
					#self.ax[0].invert_yaxis()
					#self.ax[0].xaxis.tick_top()
			elif self.plot_token.type=="heat":
				x=[]
				y=[]
				z=[]

				pos=float(self.plot_token.x_start)
				x_step=(float(self.plot_token.x_stop)-float(self.plot_token.x_start))/self.plot_token.x_points
				while(pos<float(self.plot_token.x_stop)):
					x.append(pos)
					pos=pos+x_step

				pos=float(self.plot_token.y_start)
				y_step=(float(self.plot_token.y_stop)-float(self.plot_token.y_start))/self.plot_token.y_points
				while(pos<float(self.plot_token.y_stop)):
					y.append(pos)
					pos=pos+y_step

				data = zeros((len(y),len(x)))

				for ii in range(0,len(self.input_files)):
					t=[]
					s=[]
					z=[]
					if self.read_data_file(t,s,z,ii)==True:
						#print(self.input_files[ii])
						for points in range(0,len(t)):
							found=0
							if t[points]>x[0]:
								for x_pos in range(0,len(x)):
									if x[x_pos]>t[points]:
										found=found+1
										break

							if s[points]>y[0]:
								for y_pos in range(0,len(y)):
									if y_pos!=0:
										if y[y_pos]>s[points]:
											found=found+1
											break
							if found==2:
								#print("adding data at",x_pos,y_pos)
								if data[y_pos][x_pos]<10.0:
									data[y_pos][x_pos]=data[y_pos][x_pos]+1
							else:
								print("not adding point",t[points],s[points])

				#print(x)
				#print(y)
				#print(data)
				x_grid, y_grid = mgrid[float(self.plot_token.y_start):float(self.plot_token.y_stop):complex(0, len(y)), float(self.plot_token.x_start):float(self.plot_token.x_stop):complex(0, len(x))]
				self.ax[0].pcolor(y_grid,x_grid,data)
				
			else:
				x=[]
				y=[]
				z=[]

				if read_data_2d(x,y,z,self.input_files[0])==True:
					#print(len(x),len(y),len(z),self.input_files[0])
					maxx=-1
					maxy=-1
					for i in range(0,len(z)):
						if x[i]>maxx:
							maxx=x[i]

						if y[i]>maxy:
							maxy=y[i]

					maxx=maxx+1
					maxy=maxy+1

					data = zeros((maxy,maxx))


					for i in range(0,len(z)):
						data[y[i]][x[i]]= random.random()+5
						self.ax[0].text(x[i], y[i]+float(maxy)/float(len(z))+0.1,'%.1e' %  z[i], fontsize=12)

					#fig, ax = plt.subplots()
					self.ax[0].pcolor(data,cmap=plt.cm.Blues)
					
					self.ax[0].invert_yaxis()
					self.ax[0].xaxis.tick_top()

			#self.fig.tight_layout(pad=0.0, w_pad=0.0, h_pad=0.0)
			self.fig.canvas.draw()
コード例 #38
0
 def __init__(self):
     self.ray_data = dat_file()
     self.ray_mesh_data = dat_file()
     self.triangle_file = "triangles.dat"