1 # -*- coding: cp1252 -*-
\r
2 # ======================== PSEN graphic interface ========================
\r
3 # This Python script creates a graphical interface to parameter and launch PSEN
\r
5 # ============== Import useful modules =================
\r
6 from Tkinter import *
\r
7 from ttk import Combobox
\r
8 import tkFileDialog, os
\r
10 from time import sleep
\r
13 # ============== Initialize some variables =================
\r
15 for i in range (60) : # config[] will be used as a list of preferences for PSEN study
\r
18 root = Tk() # Creates the main window
\r
19 root.wm_withdraw() # The main window is withdrawn/hidden
\r
21 CIST=PhotoImage(file="lib\CISTlogo.gif") # Load images
\r
22 header=PhotoImage(file="lib\header.gif")
\r
23 WTcurve=PhotoImage(file="lib\WTcurve.gif")
\r
25 # ============== Define functions =================
\r
27 # browse_PSSe function is used to get the .SAV file path from the user.
\r
28 # tkFileDialog.askopenfilename offers a browsing interface to the user
\r
31 savAdress = tkFileDialog.askopenfilename(parent=fenPref,title='Open PSSe SAV file',filetypes=[('SAV files', '.sav')])
\r
32 savAdressD.set(savAdress)
\r
33 fenPref.update_idletasks() # this updates the values in the fenPref window (defined in preferences())
\r
34 print 'Added: '+str(savAdress)
\r
37 # browse_ENR function is used to get a .CSV file path from the user
\r
38 # The CSV file contains a list of machines and their type (PV, Wind, Interconnexion)
\r
39 # tkFileDialog.askopenfilename offers a browsing interface to the user
\r
42 ENRpath = tkFileDialog.askopenfilename(parent=fenPref,title='Open ENR configuration',filetypes=[('CSV files', '.csv'),('All files', '.*')])
\r
43 ENRpathD.set(ENRpath)
\r
44 fenPref.update_idletasks() # this updates the values in the fenPref window (defined in preferences())
\r
45 print 'Added: '+str(ENRpath)
\r
48 # browse_folder function is used to get a folder path from the user
\r
49 # This folder is used to save all study files (.sav, .csv, ...)
\r
50 # tkFileDialog.askdirectory offers a browsing interface to the user
\r
51 def browse_folder() :
\r
53 folderPATH = tkFileDialog.askdirectory(parent=fenPref,title='Choose working folder')
\r
54 folderPATHD.set(folderPATH)
\r
55 fenPref.update_idletasks() # this updates the values in the fenPref window (defined in preferences())
\r
56 print 'Added: '+str(folderPATH)
\r
59 # savePref function is used to save preferences input in fenPref window (defined in preferences())
\r
61 global Vcin, Vrate, Vcout, Rho, lossrate # These variables are global because they are used in savePSEN()
\r
62 try : # Test if the user has defined all the requested variables
\r
71 except NameError : # If not a new window pops up and explains the data is missing
\r
73 champ_label = Label(fenetre2, text="ERROR\nNo file and/or folder selected", fg="red", font=("Century Gothic",16))
\r
74 champ_label.pack(side=TOP, fill=BOTH, expand=YES)
\r
75 else : # If it's OK it gets the data from the fields and save it into config[]
\r
76 config[9]=VcinD.get(); config[10]=VrateD.get(); config[11]=VcoutD.get(); config[12]=RhoD.get(); config[13]=lossrateD.get(); config[2]=ENRpathD.get(); config[1]=folderPATHD.get(); config[0]=savAdressD.get()
\r
81 lossrate=lossrateD.get()
\r
82 f=open("lib\pref.psen", "w") # Creates a config file with values to give to PSSEWrapper.py
\r
83 f.write(str(savAdress)+";"+str(folderPATH)+";"+str(ENRpath)+";"+str(Vcin)+";"+str(Vrate)+";"+str(Vcout)+";"+str(Rho)+";"+str(lossrate)+";0\n")
\r
91 print 'Preferences saved'
\r
93 # refresh_pref function is used to refresh fields value in fenPref window (defined in preferences())
\r
94 def refresh_pref () :
\r
97 except NameError : # if saved hasn't been created yet there is no data to update
\r
99 print 'No configuration yet'
\r
100 else : # if it has been created we set fields variables and update the window with update_idletasks()
\r
101 print 'Update values'
\r
105 VcinD.set(config[9])
\r
106 VrateD.set(config[10])
\r
107 VcoutD.set(config[11])
\r
108 RhoD.set(config[12])
\r
109 lossrateD.set(config[13])
\r
110 ENRpathD.set(ENRpath)
\r
111 folderPATHD.set(folderPATH)
\r
112 savAdressD.set(savAdress)
\r
113 fenPref.update_idletasks()
\r
115 # savePSEN function is used to create a .PSEN file containing all users parameters and preferences
\r
121 # === We get all the fields data ===
\r
123 MCS_num=var_MCS.get()
\r
126 Wind1_opt=Wind1.get()
\r
127 Wind2_opt=Wind1.get()
\r
128 Load_opt=Load.get()
\r
130 load_type=choix_load.get()
\r
131 load1=var_loadn1.get()
\r
132 load2=var_loadn2.get()
\r
133 load3=var_loadn3.get()
\r
134 load4=var_loadn4.get()
\r
135 loadPath=loadPathD.get()
\r
137 wind11_type=choix_wind11.get()
\r
138 wind11=var_windn11.get()
\r
139 wind12=var_windn12.get()
\r
140 wind13=var_windn13.get()
\r
141 wind14=var_windn14.get()
\r
142 wind1Path=wind1PathD.get()
\r
144 wind21_type=choix_wind21.get()
\r
145 wind21=var_windn21.get()
\r
146 wind22=var_windn22.get()
\r
147 wind23=var_windn23.get()
\r
148 wind24=var_windn24.get()
\r
149 wind2Path=wind2PathD.get()
\r
151 pv_type=choix_pv.get()
\r
156 pvPath=pvPathD.get()
\r
169 fuel_cost_opt = fuel_cost.get()
\r
170 bus_shunt_opt = bus_shunt.get()
\r
171 bus_loads_opt = bus_loads.get()
\r
173 rate_choice = rate_choiceD.get()
\r
178 except NameError : # If the user hasn't choose a path for the contingency CSV file, we create it as blank to save the data
\r
179 contin_lines_Path=''
\r
180 contin_groups_Path=''
\r
182 # We ask the user the name and path of the file
\r
183 savePATH = tkFileDialog.asksaveasfilename(parent=fenetre,title='Save the file as ...',defaultextension='.psen',filetypes=[('PSEN file', '.psen')])
\r
188 else : # Writing all the variables in a specific order (could be improved with XML file for instance)
\r
189 f=open(savePATH,'w')
\r
190 f.write(str(savAdress)+";"+str(folderPATH)+";"+str(ENRpath)+";"
\r
191 +str(contin_lines_Path)+";"+str(contin_groups_Path)+";"+str(model_Path)+";"+str(PSSEfolder)+";"+str(orange_Path)+";"+str(python_Path)+";"
\r
192 +str(Vcin)+";"+str(Vrate)+";"+str(Vcout)+";"+str(Rho)+";"+str(lossrate)+";"
\r
193 +str(MCS_num)+";"+str(N_1_opt)+";"+str(PV_opt)+";"+str(Wind1_opt)+";"+str(Wind2_opt)+";"+str(Load_opt)+";"
\r
194 +str(load_type)+";"+str(load1)+";"+str(load2)+";"+str(load3)+";"+str(load4)+";"+str(loadPath)+";"
\r
195 +str(wind11_type)+";"+str(wind11)+";"+str(wind12)+";"+str(wind13)+";"+str(wind14)+";"+str(wind1Path)+";"
\r
196 +str(wind21_type)+";"+str(wind21)+";"+str(wind22)+";"+str(wind23)+";"+str(wind24)+";"+str(wind2Path)+";"
\r
197 +str(pv_type)+";"+str(pv1)+";"+str(pv2)+";"+str(pv3)+";"+str(pv4)+";"+str(pvPath)+";"
\r
198 +str(C01)+";"+str(C02)+";"+str(C03)+";"+str(C04)+";"+str(C12)+";"+str(C13)+";"+str(C14)+";"+str(C23)+";"+str(C24)+";"+str(C34)+";"
\r
199 +str(fuel_cost_opt)+";"+str(bus_shunt_opt)+";"+str(bus_loads_opt)+";"
\r
200 +str(rate_choice)+";0\n")
\r
202 print 'Successfuly saved case study'
\r
204 # preferences function is a new window to update some PSEN parameters
\r
205 def preferences () :
\r
217 fenPref = Toplevel(root) # Creating a new window
\r
218 fenPref.wm_iconbitmap('lib\PSEN.ico') # Window icon
\r
219 fenPref.wm_title('PSEN - Probabilistic Studies of Electrical Networks') # Window title
\r
221 f0p=Frame(fenPref, height=70, width=500, bd=2, relief=RIDGE)
\r
222 f0p.pack_propagate(0) # don't shrink
\r
225 Label(f0p, text="PSSe .SAV file", fg="black", justify=LEFT, font=("Century Gothic",12)).pack(anchor=NW, padx=10, expand=YES)
\r
226 savAdressD=StringVar()
\r
227 Entry(f0p, textvariable=savAdressD, width=50).pack(side=LEFT, padx=15, expand=YES)
\r
228 Button(f0p, text="Load SAV file", command=browse_PSSe, height=15, width=30).pack(side=LEFT, fill=BOTH, expand=1, padx=5, pady=3)
\r
230 fline=Frame(fenPref, height=2, width=500, bg="grey")
\r
231 fline.pack_propagate(0) # don't shrink
\r
232 fline.pack(expand=1)
\r
234 f1p=Frame(fenPref, height=70, width=500, bd=2, relief=RIDGE)
\r
235 f1p.pack_propagate(0) # don't shrink
\r
238 Label(f1p, text="Working folder adress :", fg="black", justify=LEFT, font=("Century Gothic",12)).pack(anchor=NW, padx=10, expand=YES)
\r
239 folderPATHD=StringVar()
\r
240 Entry(f1p, textvariable=folderPATHD, width=50).pack(side=LEFT, padx=15, expand=YES)
\r
241 Button(f1p, text="Browse to working folder", command=browse_folder, height=15, width=30).pack(side=LEFT, fill=BOTH, expand=1, padx=5, pady=3)
\r
243 fline=Frame(fenPref, height=5, width=500, bg="grey")
\r
244 fline.pack_propagate(0) # don't shrink
\r
245 fline.pack(expand=1)
\r
247 f3p=Frame(fenPref, height=100, width=500, bd=2, relief=RIDGE)
\r
248 f3p.pack_propagate(0) # don't shrink
\r
251 Label(f3p, text="Machines configuration :", fg="black", justify=LEFT, font=("Century Gothic",12)).pack(anchor=NW, padx=10, expand=YES)
\r
252 Label(f3p, text="N.B. Use the PSSe machine tab, insert a new column in first and write PV for PV, W1 for wind 1, W2 for wind 2 or do nothing for non-ENR. Save as CSV", fg="black", justify=LEFT, wraplength=450).pack(anchor=NW, padx=10, expand=YES)
\r
253 ENRpathD=StringVar()
\r
254 Entry(f3p, textvariable=ENRpathD, width=50).pack(side=LEFT, padx=15, expand=YES)
\r
255 Button(f3p, text="Browse to ENR CSV file", command=browse_ENR, height=15, width=30).pack(side=LEFT, fill=BOTH, expand=1, padx=5, pady=3)
\r
257 fline=Frame(fenPref, height=5, width=500, bg="grey")
\r
258 fline.pack_propagate(0) # don't shrink
\r
259 fline.pack(expand=1)
\r
261 f4p=Frame(fenPref, height=120, width=500, bd=2, relief=RIDGE)
\r
262 f4p.pack_propagate(0) # don't shrink
\r
265 # Creates 5 entry for wind turbines characteristics
\r
266 Label(f4p, text="Wind 1 & 2 characteristics :", fg="black", justify=LEFT, font=("Century Gothic",12)).pack(anchor=NW, padx=10, expand=YES)
\r
267 Label(f4p, text="If wind law, enter the following parameters : \nVcin, Vrate, Vcout, rho (air density kg.m-3, base is 1.225), lossrate (base is 0.05)\nIf power law: Vcin=0, Vrate=1, Vcout>=1. Law must take values between 0 and 1.", fg="black", justify=LEFT, wraplength=450).pack(anchor=NW, padx=10, expand=YES)
\r
268 VcinD = StringVar()
\r
269 Entry(f4p, textvariable=VcinD, width=13).pack(side=LEFT, padx=5, pady=5)
\r
270 VrateD = StringVar()
\r
271 Entry(f4p, textvariable=VrateD, width=13).pack(side=LEFT, padx=5, pady=5)
\r
272 VcoutD = StringVar()
\r
273 Entry(f4p, textvariable=VcoutD, width=13).pack(side=LEFT, padx=5, pady=5)
\r
275 Entry(f4p, textvariable=RhoD, width=13).pack(side=LEFT, padx=5, pady=5)
\r
276 lossrateD = StringVar()
\r
277 Entry(f4p, textvariable=lossrateD, width=13).pack(side=LEFT, padx=5, pady=5)
\r
279 fline=Frame(fenPref, height=2, width=500, bg="grey")
\r
280 fline.pack_propagate(0) # don't shrink
\r
281 fline.pack(expand=1)
\r
283 f2p=Frame(fenPref, height=40, width=500, bd=2, relief=RIDGE)
\r
284 f2p.pack_propagate(0) # don't shrink
\r
287 Button(f2p, text="Save and quit", command=savePref, height=1, width=30).pack(anchor=N, fill=BOTH, expand=1, padx=5, pady=3)
\r
289 # Refresh the window data
\r
292 # openPSEN function opens a .PSEN file with all PSEN parameters, read them and updates their value in the GUI
\r
298 global contin_lines_Path
\r
299 global contin_groups_Path
\r
301 global loadPath, wind1Path, wind2Path, pvPath
\r
306 global Vcin; global Vrate; global Vcout; global Rho; global lossrate
\r
309 openPATH = tkFileDialog.askopenfilename(parent=fenetre,title='Open PSEN file',filetypes=[('PSEN files', '.psen'),('All files', '.*'),])
\r
312 except WindowsError : # If the user doesn't choose any file we don't open it
\r
314 except NameError : # If the user doesn't choose any file we don't open it
\r
317 global saved # Create a saved variable : config list will be created
\r
319 f=open(openPATH,'r')
\r
320 lines=f.readlines()
\r
321 config=lines[0].split(";")
\r
322 savAdress=config[0]; folderPATH=config[1]; ENRpath=config[2];
\r
323 contin_lines_Path=config[3]; contin_groups_Path=config[4]; model_Path=config[5]; PSSEfolder=config[6]; orange_Path=config[7]; python_Path=config[8];
\r
324 Vcin=config[9]; Vrate=config[10]; Vcout=config[11]; Rho=config[12]; lossrate=config[13];
\r
325 loadPath=config[25]; wind1Path=config[31]; wind2Path=config[37]; pvPath=config[43];
\r
327 f=open("lib\pref.psen", "w")
\r
328 f.write(str(savAdress)+";"+str(folderPATH)+";"+str(ENRpath)+";"+str(Vcin)+";"+str(Vrate)+";"+str(Vcout)+";"+str(Rho)+";"+str(lossrate)+";0\n")
\r
330 print 'Successfuly opened '+str(openPATH)
\r
332 # This function is not used yet
\r
333 def numToName (num) :
\r
336 name = "Normal(mean, stdev)"
\r
338 name = "Uniform(min, max)"
\r
340 name = "Exponential(lambda, gamma)"
\r
342 name = "Weibull(alpha, beta, gamma)"
\r
344 name = "TruncatedNormal(mean, stdev, min, max)"
\r
346 name = "Value list ([[v1,p1],[v2,p2],...])"
\r
348 name = "Histogram (steps, probabilities)"
\r
350 name = "PDF from file ()"
\r
352 name = "Time Serie from file (stepsize, number of points)"
\r
355 # refresh function updates fields values in fenetre window
\r
356 def refresh (config) :
\r
357 var_MCS.set(config[14])
\r
358 N_1.set(config[15])
\r
360 Wind1.set(config[17])
\r
361 Wind2.set(config[18])
\r
362 Load.set(config[19])
\r
364 choix_load.set(config[20])
\r
365 var_loadn1.set(config[21])
\r
366 var_loadn2.set(config[22])
\r
367 var_loadn3.set(config[23])
\r
368 var_loadn4.set(config[24])
\r
369 loadPathD.set(config[25])
\r
371 choix_wind11.set(config[26])
\r
372 var_windn11.set(config[27])
\r
373 var_windn12.set(config[28])
\r
374 var_windn13.set(config[39])
\r
375 var_windn14.set(config[30])
\r
376 wind1PathD.set(config[31])
\r
378 choix_wind21.set(config[32])
\r
379 var_windn21.set(config[33])
\r
380 var_windn22.set(config[34])
\r
381 var_windn23.set(config[35])
\r
382 var_windn24.set(config[36])
\r
383 wind2PathD.set(config[37])
\r
385 choix_pv.set(config[38])
\r
386 var_pvn1.set(config[39])
\r
387 var_pvn2.set(config[40])
\r
388 var_pvn3.set(config[41])
\r
389 var_pvn4.set(config[42])
\r
390 pvPathD.set(config[43])
\r
392 C01D.set(config[44])
\r
393 C02D.set(config[45])
\r
394 C03D.set(config[46])
\r
395 C04D.set(config[47])
\r
396 C12D.set(config[48])
\r
397 C13D.set(config[49])
\r
398 C14D.set(config[50])
\r
399 C23D.set(config[51])
\r
400 C24D.set(config[52])
\r
401 C34D.set(config[53])
\r
403 fuel_cost.set(config[54])
\r
404 bus_shunt.set(config[55])
\r
405 bus_loads.set(config[56])
\r
407 rate_choiceD.set(config[57])
\r
409 fenetre.update_idletasks()
\r
411 # PCpreferences function creates a window in which the user can choose some requested paths
\r
412 def PCpreferences ():
\r
419 fenPrefPC.wm_iconbitmap('lib\PSEN.ico')
\r
420 fenPrefPC.wm_title('PSEN - Probabilistic Studies of Electrical Networks')
\r
422 Label(fenPrefPC, text="Configure PSEN for your computer : ", fg="black", justify=LEFT, font=("Century Gothic",12)).pack(anchor=NW, padx=10, expand=YES)
\r
423 Button(fenPrefPC, text="Path to Python 2.7.exe...", command=browse_Python, height=3, width=30).pack(side=LEFT, fill=BOTH, expand=1, padx=5, pady=3)
\r
424 Button(fenPrefPC, text="Path to orngCanvas.pyw...", command=browse_Orange, height=3, width=30).pack(side=LEFT, fill=BOTH, expand=1, padx=5, pady=3)
\r
425 Button(fenPrefPC, text="Path to PSSE33\PSSBIN...", command=browse_PSSEfolder, height=3, width=30).pack(side=LEFT, fill=BOTH, expand=1, padx=5, pady=3)
\r
426 Button(fenPrefPC, text="Save and close", command=closePCpref, height=3, width=15).pack(anchor=S, fill=BOTH, expand=1, padx=5, pady=10)
\r
428 def closePCpref () :
\r
429 try : # Test if the user has defined all the requested variables
\r
433 except NameError : # If not a new window pops up and explains the data is missing
\r
435 champ_label = Label(fenetre2, text="ERROR\nNo file and/or folder selected", fg="red", font=("Century Gothic",16))
\r
436 champ_label.pack(side=TOP, fill=BOTH, expand=YES)
\r
437 else : # If it's OK it gets the data from the fields and save it into config[]
\r
438 config[6]=PSSEfolder; config[7]=orange_Path; config[8]=python_Path
\r
444 fenPrefPC.destroy()
\r
447 # PCpreferences function creates a window in which the user can choose some requested paths
\r
448 def ContinPreferences ():
\r
450 global contin_lines_Path
\r
451 global contin_groups_Path
\r
454 fenPrefC.wm_iconbitmap('lib\PSEN.ico')
\r
455 fenPrefC.wm_title('PSEN - Probabilistic Studies of Electrical Networks')
\r
457 Label(fenPrefC, text="Choose contingency files with probabilities : ", fg="black", justify=LEFT, font=("Century Gothic",12)).pack(anchor=NW, padx=10, expand=YES)
\r
458 Button(fenPrefC, text="Path to branches file", command=contin_lines, height=3, width=30).pack(side=LEFT, fill=BOTH, expand=1, padx=5, pady=3)
\r
459 Button(fenPrefC, text="Path to groups file", command=contin_groups, height=3, width=30).pack(side=LEFT, fill=BOTH, expand=1, padx=5, pady=3)
\r
460 Button(fenPrefC, text="Save and close", command=closeCpref, height=3, width=15).pack(anchor=S, fill=BOTH, expand=1, padx=5, pady=10)
\r
462 def closeCpref () :
\r
463 try : # Test if the user has defined all the requested variables
\r
466 except NameError : # If not a new window pops up and explains the data is missing
\r
468 champ_label = Label(fenetre2, text="ERROR\nNo file and/or folder selected", fg="red", font=("Century Gothic",16))
\r
469 champ_label.pack(side=TOP, fill=BOTH, expand=YES)
\r
470 else : # If it's OK it gets the data from the fields and save it into config[]
\r
471 config[3]=contin_lines_Path; config[4]=contin_lines_Path
\r
472 f=open("lib\contin.psen", "w")
\r
473 f.write(str(contin_lines_Path)+";"+str(contin_groups_Path)+";0\n")
\r
480 print 'Added :\n'+str(contin_lines_Path)+'\n'+str(contin_groups_Path)
\r
481 fenPrefC.destroy()
\r
482 print 'Saved contingency data'
\r
484 def contin_lines () :
\r
485 global contin_lines_Path
\r
486 contin_lines_Path = tkFileDialog.askopenfilename(parent=fenetre,title='Choose contingency lines file',filetypes=[('CSV file', '.csv'),('All files', '.*')])
\r
487 return contin_lines_Path
\r
489 def contin_groups () :
\r
490 global contin_groups_Path
\r
491 contin_groups_Path = tkFileDialog.askopenfilename(parent=fenetre,title='Choose contingency groups file',filetypes=[('CSV file', '.csv'),('All files', '.*')])
\r
492 return contin_groups_Path
\r
494 # Hide command window
\r
495 if os.name == 'nt': # The functions only work with Windows OS
\r
497 import win32gui, win32console, win32con
\r
498 win32console.GetConsoleWindow() # do nothing, this is just a test
\r
499 def set_attached_console_visible():
\r
500 state=is_attached_console_visible()
\r
501 win32gui.ShowWindow(win32console.GetConsoleWindow(), win32con.SW_HIDE if state else win32con.SW_SHOW)
\r
502 def is_attached_console_visible():
\r
503 return win32gui.IsWindowVisible(win32console.GetConsoleWindow())
\r
504 except (ImportError, NotImplementedError):
\r
508 # config_save function is used to save configuration for PSSEWrapper
\r
510 MCS_num=var_MCS.get()
\r
513 Wind1_opt=Wind1.get()
\r
514 Wind2_opt=Wind2.get()
\r
515 Load_opt=Load.get()
\r
517 load_type=choix_load.get()
\r
518 load1=var_loadn1.get()
\r
519 load2=var_loadn2.get()
\r
520 load3=var_loadn3.get()
\r
521 load4=var_loadn4.get()
\r
522 loadPath=loadPathD.get()
\r
524 wind11_type=choix_wind11.get()
\r
525 wind11=var_windn11.get()
\r
526 wind12=var_windn12.get()
\r
527 wind13=var_windn13.get()
\r
528 wind14=var_windn14.get()
\r
529 wind1Path=wind1PathD.get()
\r
531 wind21_type=choix_wind21.get()
\r
532 wind21=var_windn21.get()
\r
533 wind22=var_windn22.get()
\r
534 wind23=var_windn23.get()
\r
535 wind24=var_windn24.get()
\r
536 wind2Path=wind2PathD.get()
\r
538 pv_type=choix_pv.get()
\r
543 pvPath=pvPathD.get()
\r
556 fuel_cost_opt = fuel_cost.get()
\r
557 bus_shunt_opt = bus_shunt.get()
\r
558 bus_loads_opt = bus_loads.get()
\r
560 rate_choice=rate_choiceD.get()
\r
562 f=open("lib\config.psen", "w")
\r
563 # Write probabilistic model data
\r
564 f.write(str(MCS_num)+";"+str(N_1_opt)+";"+str(PV_opt)+";"+str(Wind1_opt)+";"+str(Wind2_opt)+";"+str(Load_opt)+";"+str(fuel_cost_opt)+";"+str(bus_shunt_opt)+";"+str(bus_loads_opt)+"\n")
\r
566 # Write load probabilistic model data
\r
567 if load_type == "Normal(mean, stdev)" :
\r
568 f.write('1;'+str(load1)+";"+str(load2)+';0')
\r
569 elif load_type == "Uniform(min, max)" :
\r
570 f.write('2;'+str(load1)+";"+str(load2)+';0')
\r
571 elif load_type == "Exponential(lambda, gamma)" :
\r
572 f.write('3;'+str(load1)+";"+str(load2)+';0')
\r
573 elif load_type == "Weibull(alpha, beta, gamma)" :
\r
574 f.write('4;'+str(load1)+";"+str(load2)+";"+str(load3)+';0')
\r
575 elif load_type == "TruncatedNormal(mean, stdev, min, max)" :
\r
576 f.write('5;'+str(load1)+";"+str(load2)+";"+str(load3)+";"+str(load4)+';0')
\r
577 elif load_type == "Value list (values, probabilities)" :
\r
578 f.write('6;'+str(load1)+";"+str(load2)+';0')
\r
579 elif load_type == 'Histogram (steps, probabilities)' :
\r
580 f.write('7;'+str(load1)+";"+str(load2)+';0')
\r
581 elif load_type== "PDF from file ()" :
\r
586 Label(fenetre2, text="ERROR\nNo file selected", fg="red", font=("Century Gothic",16)).pack(side=TOP, fill=BOTH, expand=YES)
\r
588 f.write('10;'+loadPath+';0')
\r
589 elif load_type== "Time Serie from file (stepsize, number of points)" :
\r
594 Label(fenetre2, text="ERROR\nNo file selected", fg="red", font=("Century Gothic",16)).pack(side=TOP, fill=BOTH, expand=YES)
\r
596 f.write('20;'+loadPath+";"+str(load1)+";"+str(load2)+';0')
\r
599 Label(fenetre2, text="ERROR\nNo load model selected", fg="red", font=("Century Gothic",16)).pack(side=TOP, fill=BOTH, expand=YES)
\r
602 # Write wind 1 probabilistic model data
\r
603 if wind11_type == "Normal(mean, stdev)" :
\r
604 f.write('1;'+str(wind11)+";"+str(wind12)+';0')
\r
605 elif wind11_type == "Uniform(min, max)" :
\r
606 f.write('2;'+str(wind11)+";"+str(wind12)+';0')
\r
607 elif wind11_type == "Exponential(lambda, gamma)" :
\r
608 f.write('3;'+str(wind11)+";"+str(wind12)+';0')
\r
609 elif wind11_type == "Weibull(alpha, beta, gamma)" :
\r
610 f.write('4;'+str(wind11)+";"+str(wind12)+";"+str(wind13)+';0')
\r
611 elif wind11_type == "TruncatedNormal(mean, stdev, min, max)" :
\r
612 f.write('5;'+str(wind11)+";"+str(wind12)+";"+str(wind13)+";"+str(wind14)+';0')
\r
613 elif wind11_type == "Value list (values, probabilities)" :
\r
614 f.write('6;'+str(wind11)+";"+str(wind12)+';0')
\r
615 elif wind11_type == 'Histogram (steps, probabilities)' :
\r
616 f.write('7;'+str(wind11)+";"+str(wind12)+';0')
\r
617 elif wind11_type== "PDF from file ()" :
\r
622 Label(fenetre2, text="ERROR\nNo file selected", fg="red", font=("Century Gothic",16)).pack(side=TOP, fill=BOTH, expand=YES)
\r
624 f.write('10;'+wind1Path+';0')
\r
625 elif wind11_type== "Time Serie from file (stepsize, number of points)" :
\r
630 Label(fenetre2, text="ERROR\nNo file selected", fg="red", font=("Century Gothic",16)).pack(side=TOP, fill=BOTH, expand=YES)
\r
632 f.write('20;'+wind1Path+";"+str(wind11)+";"+str(wind12)+';0')
\r
635 Label(fenetre2, text="ERROR\nNo wind model selected", fg="red", font=("Century Gothic",16)).pack(side=TOP, fill=BOTH, expand=YES)
\r
638 # Write wind 2 probabilistic model data
\r
639 if wind21_type == "Normal(mean, stdev)" :
\r
640 f.write('1;'+str(wind21)+";"+str(wind22)+';0')
\r
641 elif wind21_type == "Uniform(min, max)" :
\r
642 f.write('2;'+str(wind21)+";"+str(wind22)+';0')
\r
643 elif wind21_type == "Exponential(lambda, gamma)" :
\r
644 f.write('3;'+str(wind21)+";"+str(wind22)+';0')
\r
645 elif wind21_type == "Weibull(alpha, beta, gamma)" :
\r
646 f.write('4;'+str(wind21)+";"+str(wind22)+";"+str(wind23)+';0')
\r
647 elif wind21_type == "TruncatedNormal(mean, stdev, min, max)" :
\r
648 f.write('5;'+str(wind21)+";"+str(wind22)+";"+str(wind23)+";"+str(wind24)+';0')
\r
649 elif wind21_type == "Value list (values, probabilities)" :
\r
650 f.write('6;'+str(wind21)+";"+str(wind22)+';0')
\r
651 elif wind21_type == 'Histogram (steps, probabilities)' :
\r
652 f.write('7;'+str(wind21)+";"+str(wind22)+';0')
\r
653 elif wind21_type== "PDF from file ()" :
\r
658 Label(fenetre2, text="ERROR\nNo file selected", fg="red", font=("Century Gothic",16)).pack(side=TOP, fill=BOTH, expand=YES)
\r
660 f.write('10;'+wind2Path+';0')
\r
661 elif wind21_type== "Time Serie from file (stepsize, number of points)" :
\r
666 Label(fenetre2, text="ERROR\nNo file selected", fg="red", font=("Century Gothic",16)).pack(side=TOP, fill=BOTH, expand=YES)
\r
668 f.write('20;'+wind2Path+";"+str(wind21)+";"+str(wind22)+';0')
\r
671 Label(fenetre2, text="ERROR\nNo wind 2 model selected", fg="red", font=("Century Gothic",16)).pack(side=TOP, fill=BOTH, expand=YES)
\r
674 # Write correlation probabilistic model data
\r
675 f.write(str(C01)+";"+str(C02)+";"+str(C03)+";"+str(C04)+";"+str(C12)+";"+str(C13)+";"+str(C14)+";"+str(C23)+";"+str(C24)+";"+str(C34)+";0")
\r
678 # Write pv probabilistic model data
\r
679 if pv_type == "Normal(mean, stdev)" :
\r
680 f.write('1;'+str(pv1)+";"+str(pv2)+';0')
\r
681 elif pv_type == "Uniform(min, max)" :
\r
682 f.write('2;'+str(pv1)+";"+str(pv2)+';0')
\r
683 elif pv_type == "Exponential(lambda, gamma)" :
\r
684 f.write('3;'+str(pv1)+";"+str(pv2)+';0')
\r
685 elif pv_type == "Weibull(alpha, beta, gamma)" :
\r
686 f.write('4;'+str(pv1)+";"+str(pv2)+";"+str(pv3)+';0')
\r
687 elif pv_type == "TruncatedNormal(mean, stdev, min, max)" :
\r
688 f.write('5;'+str(pv1)+";"+str(pv2)+";"+str(pv3)+";"+str(pv4)+';0')
\r
689 elif pv_type == "Value list (values, probabilities)" :
\r
690 f.write('6;'+str(pv1)+";"+str(pv2)+';0')
\r
691 elif pv_type == 'Histogram (steps, probabilities)' :
\r
692 f.write('7;'+str(pv1)+";"+str(pv2)+';0')
\r
693 elif pv_type== "PDF from file ()" :
\r
698 champ_label = Label(fenetre2, text="ERROR\nNo file selected", fg="red", font=("Century Gothic",16))
\r
699 champ_label.pack(side=TOP, fill=BOTH, expand=YES)
\r
701 f.write('10;'+pvPath+';0')
\r
702 elif pv_type== "Time Serie from file (stepsize, number of points)" :
\r
707 champ_label = Label(fenetre2, text="ERROR\nNo file selected", fg="red", font=("Century Gothic",16))
\r
708 champ_label.pack(side=TOP, fill=BOTH, expand=YES)
\r
710 f.write('20;'+pvPath+";"+str(pv1)+";"+str(pv2)+';0')
\r
713 champ_label = Label(fenetre2, text="ERROR\nNo wind model selected", fg="red", font=("Century Gothic",16))
\r
714 champ_label.pack(side=TOP, fill=BOTH, expand=YES)
\r
717 # Write OPF data model
\r
718 f.write(str(fuel_cost_opt) +";"+ str(bus_shunt_opt) +";"+ str(bus_loads_opt)+";0\n")
\r
720 # Write Imap rate choice
\r
721 f.write(str(rate_choice)+";0\n")
\r
725 print 'Successfuly saved case data'
\r
727 # launch_PSEN function is used to run PSSEWrapper code with the configuration in the GUI
\r
729 config_save() # Current configuration is fist saved
\r
730 PSEN_Path='PSEN/PSSEWrapper.py'
\r
731 subprocess.Popen([python_Path,PSEN_Path])
\r
733 # launch_orange function is used to launch Orange with the model file
\r
734 def launch_Orange():
\r
735 subprocess.Popen([python_Path,orange_Path,model_Path])
\r
737 # browse_load is used to select a .CSV file with a 1D array of load measures
\r
738 def browse_load() :
\r
740 loadPath = tkFileDialog.askopenfilename(parent=fenetre,title='Open file for load data estimation',filetypes=[('CSV files', '.csv'),('All files', '.*')])
\r
741 loadPathD.set(loadPath)
\r
742 fenetre.update_idletasks() # updates the fields paths
\r
745 # browse_wind is used to select a .CSV file with a 1D array of wind measures
\r
746 def browse_wind1() :
\r
748 wind1Path = tkFileDialog.askopenfilename(parent=fenetre,title='Open file for wind 1 data estimation',filetypes=[('CSV files', '.csv'),('All files', '.*')])
\r
749 wind1PathD.set(wind1Path)
\r
750 fenetre.update_idletasks() # updates the fields paths
\r
753 # browse_wind is used to select a .CSV file with a 1D array of wind measures
\r
754 def browse_wind2() :
\r
756 wind2Path = tkFileDialog.askopenfilename(parent=fenetre,title='Open file for wind 2 data estimation',filetypes=[('CSV files', '.csv'),('All files', '.*')])
\r
757 wind2PathD.set(wind2Path)
\r
758 fenetre.update_idletasks() # updates the fields paths
\r
761 # browse_pv is used to select a .CSV file with a 1D array of PV measures
\r
764 pvPath = tkFileDialog.askopenfilename(parent=fenetre,title='Open file for PV data estimation',filetypes=[('CSV files', '.csv'),('All files', '.*')])
\r
765 pvPathD.set(pvPath)
\r
766 fenetre.update_idletasks() # updates the fields paths
\r
769 # continload function is a browsing window returning the path to the contingency CSV file
\r
770 def continload () :
\r
772 continpath = tkFileDialog.askopenfilename(parent=fenetre,title='Open contingency file',filetypes=[('CSV files', '.csv'),('All files', '.*')])
\r
777 else : # Saves the path into a file for PSSEWrapper.py
\r
778 f=open("lib\contin.psen", "w")
\r
779 f.write(str(continpath)+";0\n")
\r
783 # orangeload function is a browsing window returning the path to the orange model file OWS
\r
784 def orangeload () :
\r
786 model_Path = tkFileDialog.askopenfilename(parent=fenetre,title='Open orange file...',filetypes=[('Orange Widget Scripts', '.ows')])
\r
788 def browse_PSSEfolder () :
\r
790 if os.path.exists("C:\Program Files\PTI\PSSE33\PSSBIN") == True :
\r
791 path="C:\Program Files\PTI\PSSE33\PSSBIN"
\r
794 PSSEfolder = tkFileDialog.askdirectory(parent=fenPrefPC,title='Choose PSSE/PSSBIN folder', initialdir=path)
\r
797 def browse_Python () :
\r
799 if os.path.exists("C:\Python27") == True :
\r
803 python_Path = tkFileDialog.askopenfilename(parent=fenetre,title='Choose python.exe',filetypes=[('Executables', '.exe'),('All files', '.*')], initialdir=path)
\r
806 def browse_Orange () :
\r
808 if os.path.exists("C:\Python27\Lib\site-packages\Orange\OrangeCanvas") == True :
\r
809 path="C:\Python27\Lib\site-packages\Orange\OrangeCanvas"
\r
812 orange_Path = tkFileDialog.askopenfilename(parent=fenetre,title='Choose orngCanvas.pyw',filetypes=[('Python file', '.pyw'),('All files', '.*')], initialdir=path)
\r
814 # On crée une fenêtre, racine de notre interface
\r
816 global fenetre,var_MCS,N_1,PV,Wind1,Wind2,Load,choix_load,var_loadn1,var_loadn2,var_loadn3,var_loadn4,loadPathD,choix_wind11,var_windn11,var_windn12,var_windn13,var_windn14,wind1PathD,choix_wind21,var_windn21,var_windn22,var_windn23,var_windn24,wind2PathD,choix_pv,var_pvn1,var_pvn2,var_pvn3,var_pvn4,pvPathD,C01D,C02D,C03D,C04D,C12D,C13D,C14D,C23D,C24D,C34D,fuel_cost,bus_shunt,bus_loads,rate_choiceD
\r
817 fenetre = Toplevel(root)
\r
818 fenetre.wm_iconbitmap('lib\PSEN.ico')
\r
819 fenetre.wm_title('PSEN - Probabilistic Studies of Electrical Networks')
\r
821 def openshort (event):
\r
823 def saveshort (event) :
\r
825 def quitshort (event) :
\r
827 def orangeshort (event):
\r
829 def runshort (event) :
\r
831 def prefshort (event) :
\r
834 fenetre.bind_all("<Control-q>", quitshort)
\r
835 fenetre.bind_all("<Control-o>", openshort)
\r
836 fenetre.bind_all("<Control-s>", saveshort)
\r
837 fenetre.bind_all("<Control-a>", orangeshort)
\r
838 fenetre.bind_all("<Control-r>", runshort)
\r
839 fenetre.bind_all("<Control-p>", prefshort)
\r
843 # Create a toplevel menu
\r
844 menubar=Menu(fenetre)
\r
846 filemenu = Menu(menubar, tearoff=0)
\r
847 filemenu.add_command(label="Open PSEN", command=openPSEN, accelerator="Ctrl+O")
\r
848 filemenu.add_command(label="Save PSEN", command=savePSEN, accelerator="Ctrl+S")
\r
849 filemenu.add_separator()
\r
850 filemenu.add_command(label="Exit", command=fenetre.quit, accelerator="Ctrl+Q")
\r
851 menubar.add_cascade(label="File", menu=filemenu)
\r
853 editmenu = Menu(menubar, tearoff=0)
\r
854 editmenu.add_command(label="Computer preferences", command=PCpreferences)
\r
855 editmenu.add_separator()
\r
856 editmenu.add_command(label="Study preferences", command=preferences, accelerator="Ctrl+P")
\r
857 menubar.add_cascade(label="Edit", menu=editmenu)
\r
859 exemenu = Menu(menubar, tearoff=0)
\r
860 exemenu.add_command(label="Run PSEN", command=preferences, accelerator="Ctrl+R")
\r
861 menubar.add_cascade(label="Execution", menu=exemenu)
\r
863 contmenu = Menu(menubar, tearoff=0)
\r
864 contmenu.add_command(label="Load contingency file", command=ContinPreferences)
\r
865 menubar.add_cascade(label="Contingency analysis", menu=contmenu)
\r
867 orangemenu = Menu(menubar, tearoff=0)
\r
868 orangemenu.add_command(label="Choose Orange model", command=orangeload)
\r
869 orangemenu.add_command(label="Open Orange", command=launch_Orange, accelerator="Ctrl+A")
\r
870 menubar.add_cascade(label="Orange analysis", menu=orangemenu)
\r
872 viewmenu = Menu(menubar, tearoff=0)
\r
873 viewmenu.add_command(label="Show/Hide cmd window", command=set_attached_console_visible)
\r
874 menubar.add_cascade(label="View", menu=viewmenu)
\r
877 fenetre.config(menu=menubar)
\r
879 ftop=Frame(fenetre, height=140, width=2*wd, bd=2, relief=RIDGE)
\r
880 ftop.pack_propagate(0) # don't shrink
\r
883 fmid=Frame(fenetre, height=500, width=2*wd)
\r
884 fmid.pack_propagate(0) # don't shrink
\r
887 fleft=Frame(fmid, height=500, width=wd, bd=2, relief=RIDGE)
\r
888 fleft.pack_propagate(0) # don't shrink
\r
889 fleft.pack(side=LEFT)
\r
891 fright=Frame(fmid, height=500, width=wd, bd=2, relief=RIDGE)
\r
892 fright.pack_propagate(0) # don't shrink
\r
893 fright.pack(side=RIGHT)
\r
895 #canvas=Canvas(fenetre, width=600, height=100, bg='ivory')
\r
896 Label(ftop, image=header).pack(side=TOP, fill=BOTH, expand=YES)
\r
897 #canvas.pack(side=TOP,padx=5,pady=5)
\r
899 fline=Frame(ftop, height=2, width=2*wd, bg="grey")
\r
900 fline.pack_propagate(0) # don't shrink
\r
901 fline.pack(expand=1)
\r
903 fl0=Frame(fleft, height=55, width=wd)
\r
904 fl0.pack_propagate(0) # don't shrink
\r
907 Label(fl0, text="Simulation parameters", fg="black", justify=LEFT, font=("Century Gothic",14)).pack(anchor=NW, padx=10, expand=NO)
\r
909 # Change Monte Carlo samplings
\r
910 Label(fl0, text="Choose the number of samples:", fg="black").pack(side=LEFT, padx=10, expand=NO)
\r
912 var_MCS = StringVar()
\r
913 Entry(fl0, textvariable=var_MCS, width=15).pack(side=LEFT, padx=15, expand=NO)
\r
915 fl01=Frame(fleft, height=30, width=wd)
\r
916 fl01.pack_propagate(0) # don't shrink
\r
919 # Change N-1 study or not
\r
921 Checkbutton(fl01, text="N-1 study ?", variable=N_1).pack(side=LEFT, padx=2)
\r
925 Checkbutton(fl01, text="Load study ?", variable=Load).pack(side=LEFT, padx=2)
\r
929 Checkbutton(fl01, text="Wind 1 study ?", variable=Wind1).pack(side=LEFT, padx=2)
\r
933 Checkbutton(fl01, text="Wind 2 study ?", variable=Wind2).pack(side=LEFT, padx=2)
\r
937 Checkbutton(fl01, text="PV study ?", variable=PV).pack(side=LEFT, padx=2)
\r
939 Frame(fleft, height=2, width=wd, bg="grey").pack(pady=10, expand=NO)
\r
941 fl1=Frame(fleft, height=152, width=wd)
\r
942 fl1.pack_propagate(0) # don't shrink
\r
943 fl1.pack(pady=0, expand=NO)
\r
945 champ_label = Label(fl1, text="Correlation upper matrix :", fg="black", justify=LEFT, font=("Century Gothic",14))
\r
946 champ_label.pack(anchor=NW, padx=10, expand=NO)
\r
948 champ_label = Label(fl1, text="Load N-1 Wind1 Wind2 Solar ", fg="black")
\r
949 champ_label.pack(anchor=NE, padx=10)
\r
951 fl11=Frame(fl1, height=25, width=wd)
\r
952 fl11.pack_propagate(0) # don't shrink
\r
953 fl11.pack(padx=10, expand=NO)
\r
955 Entry(fl11, textvariable=C04D, width=10).pack(side=RIGHT, padx=10, pady=5)
\r
958 Entry(fl11, textvariable=C03D, width=10).pack(side=RIGHT, padx=10, pady=5)
\r
961 Entry(fl11, textvariable=C02D, width=10).pack(side=RIGHT, padx=10, pady=5)
\r
964 Entry(fl11, textvariable=C01D, width=10).pack(side=RIGHT, padx=10, pady=5)
\r
967 champ_label = Label(fl11, text="Load ", fg="black")
\r
968 champ_label.pack(side=RIGHT, padx=10)
\r
970 fl12=Frame(fl1, height=25, width=wd)
\r
971 fl12.pack_propagate(0) # don't shrink
\r
972 fl12.pack(padx=10, expand=NO)
\r
974 Entry(fl12, textvariable=C14D, width=10).pack(side=RIGHT, padx=10, pady=5)
\r
977 Entry(fl12, textvariable=C13D, width=10).pack(side=RIGHT, padx=10, pady=5)
\r
980 Entry(fl12, textvariable=C12D, width=10).pack(side=RIGHT, padx=10, pady=5)
\r
983 champ_label = Label(fl12, text="N-1 ", fg="black")
\r
984 champ_label.pack(side=RIGHT, padx=10)
\r
986 fl13=Frame(fl1, height=25, width=wd)
\r
987 fl13.pack_propagate(0) # don't shrink
\r
988 fl13.pack(padx=10, expand=NO)
\r
990 Entry(fl13, textvariable=C24D, width=10).pack(side=RIGHT, padx=10, pady=5)
\r
993 Entry(fl13, textvariable=C23D, width=10).pack(side=RIGHT, padx=10, pady=5)
\r
996 champ_label = Label(fl13, text="Wind1 ", fg="black")
\r
997 champ_label.pack(side=RIGHT, padx=10)
\r
999 fl14=Frame(fl1, height=25, width=wd)
\r
1000 fl14.pack_propagate(0) # don't shrink
\r
1001 fl14.pack(padx=10, expand=NO)
\r
1002 C34D = StringVar()
\r
1003 Entry(fl14, textvariable=C34D, width=10).pack(side=RIGHT, padx=10, pady=5)
\r
1006 champ_label = Label(fl14, text="Wind2 ", fg="black")
\r
1007 champ_label.pack(side=RIGHT, padx=10)
\r
1009 fline=Frame(fleft, height=2, width=wd, bg="grey")
\r
1010 fline.pack(pady=10, expand=NO)
\r
1012 fl2=Frame(fleft, height=20, width=wd)
\r
1013 fl2.pack_propagate(0) # don't shrink
\r
1016 champ_label = Label(fl2, text="PSSe OPF parameters", fg="black", justify=LEFT, font=("Century Gothic",14))
\r
1017 champ_label.pack(anchor=NW, padx=10, expand=NO)
\r
1019 fl21=Frame(fleft, height=30, width=wd)
\r
1020 fl21.pack_propagate(0) # don't shrink
\r
1023 # "Minimize fuel cost"
\r
1024 fuel_cost = IntVar()
\r
1025 Checkbutton(fl21, text="Minimize fuel cost", variable=fuel_cost).pack(side=LEFT, padx=10)
\r
1027 # "Minimize adj. bus shunts"
\r
1028 bus_shunt = IntVar()
\r
1029 Checkbutton(fl21, text="Minimize adj. bus shunts", variable=bus_shunt).pack(side=LEFT, padx=10)
\r
1031 # "Minimize adj. bus loads"
\r
1032 bus_loads = IntVar()
\r
1033 Checkbutton(fl21, text="Minimize adj. bus loads", variable=bus_loads).pack(side=LEFT, padx=10)
\r
1035 fline=Frame(fleft, height=2, width=wd, bg="grey")
\r
1036 fline.pack(pady=10, expand=NO)
\r
1038 fl3=Frame(fleft, height=20, width=wd)
\r
1039 fl3.pack_propagate(0) # don't shrink
\r
1042 champ_label = Label(fl3, text="PSSe Irate choice :", fg="black", justify=LEFT, font=("Century Gothic",14))
\r
1043 champ_label.pack(side=LEFT, padx=10, expand=NO)
\r
1045 # "Minimize fuel cost"
\r
1046 rate_choiceD = IntVar()
\r
1047 Radiobutton(fl3, text="Rate A", variable=rate_choiceD, value=1).pack(side=LEFT, padx=20)
\r
1048 Radiobutton(fl3, text="Rate B", variable=rate_choiceD, value=2).pack(side=LEFT, padx=10)
\r
1049 Radiobutton(fl3, text="Rate C", variable=rate_choiceD, value=3).pack(side=LEFT, padx=10)
\r
1051 #---- Choose the probability laws ---
\r
1052 #---- Load model ----
\r
1053 fr0=Frame(fright, height=55, width=wd)
\r
1054 fr0.pack_propagate(0) # don't shrink
\r
1055 fr0.pack(expand=NO, anchor=NW)
\r
1057 champ_label = Label(fr0, text="Load model :", fg="black", justify=LEFT, font=("Century Gothic",14))
\r
1058 champ_label.pack(anchor=NW, padx=10, expand=NO)
\r
1060 choix_load=StringVar()
\r
1061 laws_choice = ('Normal(mean, stdev)','Uniform(min, max)','Exponential(lambda, gamma)','Weibull(alpha, beta, gamma)', 'TruncatedNormal(mean, stdev, min, max)', 'Value list (values, probabilities)', 'Histogram (steps, probabilities)', 'PDF from file ()', 'Time Serie from file (stepsize, number of points)' )
\r
1062 Combobox(fr0, textvariable = choix_load, values = laws_choice, state = 'readonly', width=50).pack(side=LEFT, padx=10, expand=NO)
\r
1063 choix_load.set('Choose your load model')
\r
1065 fr01=Frame(fright, height=30, width=wd)
\r
1066 fr01.pack_propagate(0) # don't shrink
\r
1067 fr01.pack(expand=NO)
\r
1068 champ_label = Label(fr01, text="Parameters :", fg="black").pack(side=LEFT, padx=10, pady=0)
\r
1070 var_loadn1 = StringVar()
\r
1071 Entry(fr01, textvariable=var_loadn1, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1072 var_loadn2 = StringVar()
\r
1073 Entry(fr01, textvariable=var_loadn2, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1074 var_loadn3 = StringVar()
\r
1075 Entry(fr01, textvariable=var_loadn3, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1076 var_loadn4 = StringVar()
\r
1077 Entry(fr01, textvariable=var_loadn4, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1079 fr011=Frame(fright, height=35, width=wd)
\r
1080 fr011.pack_propagate(0) # don't shrink
\r
1081 fr011.pack(expand=NO)
\r
1083 # We create the browse button
\r
1084 loadPathD=StringVar()
\r
1085 Entry(fr011, textvariable=loadPathD, width=50).pack(side=LEFT, padx=15, expand=YES)
\r
1087 Button(fr011, text="Load data", command=browse_load).pack(side=LEFT, fill=BOTH, expand=1, padx=5, pady=3)
\r
1089 fline=Frame(fright, height=2, width=wd, bg="grey")
\r
1090 fline.pack(pady=2, expand=NO)
\r
1092 #---- Wind 1 model ----
\r
1093 fr1=Frame(fright, height=55, width=wd)
\r
1094 fr1.pack_propagate(0) # don't shrink
\r
1095 fr1.pack(expand=NO, pady=0)
\r
1097 champ_label = Label(fr1, text="Wind 1 distribution model :", fg="black", justify=LEFT, font=("Century Gothic",14))
\r
1098 champ_label.pack(anchor=NW, padx=10, expand=NO)
\r
1100 choix_wind11=StringVar()
\r
1101 laws_choice = ('Normal(mean, stdev)','Uniform(min, max)','Exponential(lambda, gamma)','Weibull(alpha, beta, gamma)', 'TruncatedNormal(mean, stdev, min, max)', 'Value list (values, probabilities)', 'Histogram (steps, probabilities)', 'PDF from file ()', 'Time Serie from file (stepsize, number of points)' )
\r
1102 Combobox(fr1, textvariable = choix_wind11, values = laws_choice, state = 'readonly', width=50).pack(side=LEFT, padx=10, expand=NO)
\r
1103 choix_wind11.set('Choose your wind model')
\r
1105 fr11=Frame(fright, height=30, width=wd)
\r
1106 fr11.pack_propagate(0) # don't shrink
\r
1107 fr11.pack(expand=NO)
\r
1108 Label(fr11, text="Parameters :", fg="black").pack(side=LEFT, padx=10, pady=0)
\r
1110 var_windn11 = StringVar()
\r
1111 Entry(fr11, textvariable=var_windn11, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1112 var_windn12 = StringVar()
\r
1113 Entry(fr11, textvariable=var_windn12, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1114 var_windn13 = StringVar()
\r
1115 Entry(fr11, textvariable=var_windn13, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1116 var_windn14 = StringVar()
\r
1117 Entry(fr11, textvariable=var_windn14, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1119 fr111=Frame(fright, height=35, width=wd)
\r
1120 fr111.pack_propagate(0) # don't shrink
\r
1121 fr111.pack(expand=NO)
\r
1123 # We create the browse button
\r
1124 wind1PathD=StringVar()
\r
1125 Entry(fr111, textvariable=wind1PathD, width=50).pack(side=LEFT, padx=15, expand=YES)
\r
1127 Button(fr111, text="Wind 1 data", command=browse_wind1).pack(side=LEFT, fill=BOTH, expand=1, padx=5, pady=3)
\r
1129 fline=Frame(fright, height=2, width=wd, bg="grey")
\r
1130 fline.pack(pady=2, expand=NO)
\r
1132 #---- Wind 2 model ----
\r
1133 fr2=Frame(fright, height=55, width=wd)
\r
1134 fr2.pack_propagate(0) # don't shrink
\r
1135 fr2.pack(expand=NO, pady=0)
\r
1137 champ_label = Label(fr2, text="Wind 2 distribution model :", fg="black", justify=LEFT, font=("Century Gothic",14))
\r
1138 champ_label.pack(anchor=NW, padx=10, expand=NO)
\r
1140 choix_wind21=StringVar()
\r
1141 laws_choice = ('Normal(mean, stdev)','Uniform(min, max)','Exponential(lambda, gamma)','Weibull(alpha, beta, gamma)', 'TruncatedNormal(mean, stdev, min, max)', 'Value list (values, probabilities)', 'Histogram (steps, probabilities)', 'PDF from file ()', 'Time Serie from file (stepsize, number of points)' )
\r
1142 Combobox(fr2, textvariable = choix_wind21, values = laws_choice, state = 'readonly', width=50).pack(side=LEFT, padx=10, expand=NO)
\r
1143 choix_wind21.set('Choose your wind model')
\r
1145 fr21=Frame(fright, height=30, width=wd)
\r
1146 fr21.pack_propagate(0) # don't shrink
\r
1147 fr21.pack(expand=NO)
\r
1148 Label(fr21, text="Parameters :", fg="black").pack(side=LEFT, padx=10, pady=0)
\r
1150 var_windn21 = StringVar()
\r
1151 Entry(fr21, textvariable=var_windn21, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1152 var_windn22 = StringVar()
\r
1153 Entry(fr21, textvariable=var_windn22, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1154 var_windn23 = StringVar()
\r
1155 Entry(fr21, textvariable=var_windn23, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1156 var_windn24 = StringVar()
\r
1157 Entry(fr21, textvariable=var_windn24, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1159 fr211=Frame(fright, height=35, width=wd)
\r
1160 fr211.pack_propagate(0) # don't shrink
\r
1161 fr211.pack(expand=NO)
\r
1163 # We create the browse button
\r
1164 wind2PathD=StringVar()
\r
1165 Entry(fr211, textvariable=wind2PathD, width=50).pack(side=LEFT, padx=15, expand=YES)
\r
1167 Button(fr211, text="Wind 2 data", command=browse_wind2).pack(side=LEFT, fill=BOTH, expand=1, padx=5, pady=3)
\r
1169 fline=Frame(fright, height=2, width=wd, bg="grey")
\r
1170 fline.pack(pady=2, expand=NO)
\r
1172 #---- PV model ----
\r
1173 fr3=Frame(fright, height=55, width=wd)
\r
1174 fr3.pack_propagate(0) # don't shrink
\r
1175 fr3.pack(expand=NO, pady=0)
\r
1177 champ_label = Label(fr3, text="Photovoltaic distribution model :", fg="black", justify=LEFT, font=("Century Gothic",14))
\r
1178 champ_label.pack(anchor=NW, padx=10, expand=NO)
\r
1180 choix_pv=StringVar()
\r
1181 laws_choice = ('Normal(mean, stdev)','Uniform(min, max)','Exponential(lambda, gamma)','Weibull(alpha, beta, gamma)', 'TruncatedNormal(mean, stdev, min, max)', 'Value list (values, probabilities)', 'Histogram (steps, probabilities)', 'PDF from file ()', 'Time Serie from file (stepsize, number of points)' )
\r
1182 Combobox(fr3, textvariable = choix_pv, values = laws_choice, state = 'readonly', width=50).pack(side=LEFT, padx=10, expand=NO)
\r
1183 choix_pv.set('Choose your PV model')
\r
1185 fr31=Frame(fright, height=30, width=wd)
\r
1186 fr31.pack_propagate(0) # don't shrink
\r
1187 fr31.pack(expand=NO)
\r
1188 Label(fr31, text="Parameters :", fg="black").pack(side=LEFT, padx=10, pady=0)
\r
1190 var_pvn1 = StringVar()
\r
1191 Entry(fr31, textvariable=var_pvn1, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1192 var_pvn2 = StringVar()
\r
1193 Entry(fr31, textvariable=var_pvn2, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1194 var_pvn3 = StringVar()
\r
1195 Entry(fr31, textvariable=var_pvn3, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1196 var_pvn4 = StringVar()
\r
1197 Entry(fr31, textvariable=var_pvn4, width=12).pack(side=LEFT, padx=10, pady=5)
\r
1199 fr311=Frame(fright, height=35, width=wd)
\r
1200 fr311.pack_propagate(0) # don't shrink
\r
1201 fr311.pack(expand=NO)
\r
1203 # We create the browse button
\r
1204 pvPathD=StringVar()
\r
1205 Entry(fr311, textvariable=pvPathD, width=50).pack(side=LEFT, padx=15, expand=YES)
\r
1207 Button(fr311, text="PV data", command=browse_pv).pack(side=LEFT, fill=BOTH, expand=1, padx=5, pady=3)
\r
1209 fb=Frame(fenetre, height=50, width=2*wd, bd=2, relief=RIDGE)
\r
1210 fb.pack_propagate(0) # don't shrink
\r
1213 Frame(fb, height=2, width=2*wd, bg="grey").pack(expand=1)
\r
1215 # We create the launch button
\r
1216 Button(fb, text="Run PSEN", command=launch_PSEN, height=1, width=20, underline=YES).pack(expand=NO, padx=5, pady=3)
\r
1218 # On démarre la boucle Tkinter qui s'interompt quand on ferme la fenêtre
\r