Changeset 7200
- Timestamp:
- Jun 12, 2009, 4:19:24 PM (15 years ago)
- Location:
- branches/numpy_misc/tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/numpy_misc/tools/event_selection/EventSelection.py
r6366 r7200 14 14 import tempfile 15 15 try: 16 import cpickle 16 import cpickle as pickle 17 17 except: 18 18 import pickle … … 536 536 size=(CTL_WIDTH, CTL_HEIGHT), style=wx.ALIGN_RIGHT) 537 537 self.txtQuakeID = wx.TextCtrl(p, -1, size=(100, 20), 538 pos=(GEN_TEXTXOFFSET, Y_OFFSET)) 538 pos=(GEN_TEXTXOFFSET, Y_OFFSET), 539 style=wx.TE_READONLY) 539 540 Y_OFFSET += GEN_DELTAY 540 541 x = FORM_WIDTH/2 - BUTTON_WIDTH - DOUBLE_BUTTON_OFFSET … … 962 963 multimux_dir = os.path.join(BaseDirectory, region_dir_name, 'multimux') 963 964 grid_dir = os.path.join(BaseDirectory, region_dir_name, 'static_2m') 965 # check that the sub-directory has been created 966 if ResultSubdir == '' or not os.path.isdir(ResultSubdir): 967 self.error("Sorry, you must 'list' earthquakes first.") 968 return 964 969 965 970 #################################################################### … … 1048 1053 out_fd.write('WEIGHT_FACTOR=%f\n' % weight_factor) 1049 1054 out_fd.write('DATA_PATH=%s\n' % grid_dir) 1050 for fn in filenames[1:]: 1055 #for fn in filenames[1:]: 1056 for fn in filenames: 1051 1057 owning_dir = filenames[0].split('-')[0] 1052 1058 out_fd.write('GRID=%s\n' % (os.path.join(owning_dir, fn))) -
branches/numpy_misc/tools/event_selection/installer/EventSelection.nsi
r6364 r7200 1 1 !define PRODUCT_NAME "EventSelection" 2 !define PRODUCT_VERSION "1. 0"2 !define PRODUCT_VERSION "1.1" 3 3 !define ICON_FILE "tsunami.ico" 4 4 -
branches/numpy_misc/tools/plotcsv/installer/plotcsv.nsi
r6906 r7200 1 1 !define PRODUCT_NAME "plotcsv" 2 !define PRODUCT_VERSION "0. 5"2 !define PRODUCT_VERSION "0.7" 3 3 !define ICON_FILE "plotcsv.ico" 4 4 -
branches/numpy_misc/tools/plotcsv/plotcsv.py
r6906 r7200 15 15 import string 16 16 try: 17 import cpickle 17 import cpickle as pickle 18 18 except: 19 19 import pickle … … 54 54 # program name and version 55 55 APP_NAME = 'plotcsv' 56 APP_VERSION = '0. 5'56 APP_VERSION = '0.7' 57 57 58 58 # name of the configuration filename … … 73 73 BOX_CSV_HEIGHT = 265 74 74 BOX_PLOT_WIDTH = 400 75 BOX_PLOT_HEIGHT = 140 75 BOX_PLOT_HEIGHT = 140+25+25+30 76 76 77 77 TXT_CSVFILE_WIDTH = 390 … … 84 84 85 85 FORM_WIDTH = BOX_WIDTH + 15 86 FORM_HEIGHT = 450 86 FORM_HEIGHT = 450+25+25+30 87 87 88 88 START_YOFFSET = 7 … … 206 206 self.changed = True 207 207 208 def get(self, key, default=None): 209 """Override to allow: <var> = cfg.get(<key>, default=None)""" 210 211 return self.cfgdict.get(key, default) 212 208 213 def __getitem__(self, key): 209 214 """Override to allow: <var> = cfg[<key>]""" … … 306 311 # @brief Plot data files. 307 312 # @param filenames List of full pathnames to plot. 308 # @param x_hdr The X axis labelstring.309 # @param y_hdr The Y axis labelstring.313 # @param x_hdr The X axis data header string. 314 # @param y_hdr The Y axis data header string. 310 315 # @param title The string used to title the graph. 311 316 # @param legend True if a legend is to be displayed. 312 317 # @param legend_path True if legend is to contain full file paths. 318 # @param grid True if grid is to be displayed. 319 # @param fontsize Point size of font. 320 # @param plot_width Width of plot lines. 321 # @param x_label Override X axis label. 322 # @param y_label Override Y axis label. 313 323 def plot_files(filenames, x_hdr, y_hdr, title='', legend=False, 314 legend_path=False): 324 legend_path=False, grid=False, fontsize=10, 325 plot_width=2, x_label=None, y_label=None): 326 if x_label is None: 327 x_label = x_hdr 328 if y_label is None: 329 y_label = y_hdr 330 315 331 pylab.rc('axes', linewidth=2) 316 pylab.xlabel(x_hdr.title()) 317 pylab.ylabel(y_hdr.title()) 318 pylab.grid(True) 332 pylab.rc('lines', linewidth=float(plot_width)) 333 pylab.rc(('xtick', 'ytick'), labelsize=float(fontsize)*0.75,) 334 pylab.rc(('xtick.major', 'ytick.major'), size=5, pad=5) 335 pylab.rc('axes', labelsize=float(fontsize)) 336 pylab.xlabel(x_label) 337 pylab.ylabel(y_label) 338 339 pylab.grid(grid) 319 340 320 341 for f in filenames: … … 328 349 329 350 if title: 330 pylab.title(title) 351 pylab.title(title, fontsize=float(fontsize)*1.5) 352 331 353 if legend: 354 pylab.rc('legend', fancybox=True) 332 355 (min_y, max_y) = pylab.ylim() 333 356 range_y = max_y - min_y … … 383 406 size=(100, BUTTON_HEIGHT)) 384 407 x = FORM_WIDTH/2 + DOUBLE_BUTTON_OFFSET 385 self.btnDelCSVFile = wx.Button(p, label="Delete ", pos=(x, Y_OFFSET),408 self.btnDelCSVFile = wx.Button(p, label="Delete All", pos=(x, Y_OFFSET), 386 409 size=(100, BUTTON_HEIGHT)) 387 410 Y_OFFSET += BUTTON_HEIGHT + MARGIN … … 390 413 size=(BOX_PLOT_WIDTH, BOX_PLOT_HEIGHT)) 391 414 Y_OFFSET += GEN_DELTAY 415 392 416 wx.StaticText(p, -1, 'X-Column', 393 417 pos=(COLLAB_X_OFFSET, Y_OFFSET+LAB_CTRL_OFFSET), style=wx.ALIGN_LEFT) 394 self.cbXColHdr = wx.Choice(p, -1, pos=(COLLAB_X_OFFSET+ 65, Y_OFFSET),418 self.cbXColHdr = wx.Choice(p, -1, pos=(COLLAB_X_OFFSET+50, Y_OFFSET), 395 419 size=(80, -1)) 396 420 self.XColHdr = [] 397 421 wx.StaticText(p, -1, 'Y-Column', 398 pos=(FORM_WIDTH/2 +COLLAB_X_OFFSET,422 pos=(FORM_WIDTH/2, 399 423 Y_OFFSET+LAB_CTRL_OFFSET), style=wx.ALIGN_LEFT) 400 x = FORM_WIDTH/2 + COLLAB_X_OFFSET401 self.cbYColHdr = wx.Choice(p, -1, pos=(x +65, Y_OFFSET), size=(80, -1))424 x = FORM_WIDTH/2+50 425 self.cbYColHdr = wx.Choice(p, -1, pos=(x, Y_OFFSET), size=(80, -1)) 402 426 self.YColHdr = [] 403 Y_OFFSET += GEN_DELTAY*2 427 Y_OFFSET += GEN_DELTAY*1.5 428 429 wx.StaticText(p, -1, 'X-Label', 430 pos=(COLLAB_X_OFFSET, Y_OFFSET+LAB_CTRL_OFFSET), style=wx.ALIGN_LEFT) 431 self.txtXLabel = wx.TextCtrl(p, -1, "", size=(100, -1), 432 pos=(COLLAB_X_OFFSET+50, 433 Y_OFFSET+LAB_CTRL_OFFSET), 434 style=wx.ALIGN_LEFT) 435 wx.StaticText(p, -1, 'Y-Label', 436 pos=(FORM_WIDTH/2, 437 Y_OFFSET+LAB_CTRL_OFFSET), style=wx.ALIGN_LEFT) 438 x = FORM_WIDTH/2 + 50 439 self.txtYLabel = wx.TextCtrl(p, -1, "", size=(100, -1), 440 pos=(x, 441 Y_OFFSET+LAB_CTRL_OFFSET), 442 style=wx.ALIGN_LEFT) 443 Y_OFFSET += GEN_DELTAY*2.5 404 444 405 445 self.chkLegend = wx.CheckBox(p, -1, " Show graph legend", … … 407 447 self.chkLegendPath = wx.CheckBox(p, -1, " Full file path in legend", 408 448 pos=(COLLAB_X_OFFSET+180, Y_OFFSET)) 449 Y_OFFSET += GEN_DELTAY*2 450 451 font_sizes = ['10', '12', '14', '16', '18', '20', 452 '22', '24', '26', '28', '30', '32'] 453 self.cbLabFontSize = wx.ComboBox(p, -1, "10", 454 (COLLAB_X_OFFSET+20, Y_OFFSET-5), 455 (47, -1), font_sizes, 456 wx.CB_DROPDOWN) 457 wx.StaticText(p, -1, 'Label fontsize', 458 pos=(COLLAB_X_OFFSET+72, Y_OFFSET), 459 style=wx.ALIGN_LEFT) 460 461 self.chkShowGrid = wx.CheckBox(p, -1, " Show grid", 462 pos=(COLLAB_X_OFFSET+180, Y_OFFSET)) 463 464 Y_OFFSET += GEN_DELTAY*2 465 466 plot_widths = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] 467 self.cbPlotWidth = wx.ComboBox(p, -1, "2", 468 (COLLAB_X_OFFSET+20, Y_OFFSET-5), 469 (47, -1), plot_widths, 470 wx.CB_DROPDOWN) 471 wx.StaticText(p, -1, 'Plot width', 472 pos=(COLLAB_X_OFFSET+72, Y_OFFSET), 473 style=wx.ALIGN_LEFT) 409 474 Y_OFFSET += GEN_DELTAY + 3 410 475 … … 415 480 Y_OFFSET+LAB_CTRL_OFFSET), 416 481 style=wx.ALIGN_LEFT) 417 418 Y_OFFSET += BUTTON_HEIGHT + MARGIN 482 Y_OFFSET += BUTTON_HEIGHT # + MARGIN 419 483 x = FORM_WIDTH/2 - BUTTON_WIDTH/2 420 484 self.btnPlot = wx.Button(p, label="Plot", pos=(x, Y_OFFSET), … … 426 490 self.Bind(wx.EVT_BUTTON, self.PlotFiles, self.btnPlot) 427 491 self.Bind(wx.EVT_CHECKBOX, self.ChangeLegend, self.chkLegend) 492 self.Bind(wx.EVT_CHOICE, self.ChangeXLabel, self.cbXColHdr) 493 self.Bind(wx.EVT_CHOICE, self.ChangeYLabel, self.cbYColHdr) 428 494 429 495 self.Bind(wx.EVT_CLOSE, self.doStateSave) … … 434 500 self.doStateRestore() 435 501 self.updateHdrChoices() 436 502 503 def ChangeXLabel(self, event): 504 sel = self.cbXColHdr.GetCurrentSelection() 505 self.txtXLabel.SetValue(self.cbXColHdr.GetItems()[sel].title()) 506 507 def ChangeYLabel(self, event): 508 sel = self.cbYColHdr.GetCurrentSelection() 509 self.txtYLabel.SetValue(self.cbYColHdr.GetItems()[sel].title()) 510 437 511 def AddCSVFile(self, event): 438 512 """Add a CSV file to the listbox""" … … 442 516 defaultFile='', 443 517 wildcard=CSVWildcard, 444 style=wx.OPEN | wx. CHANGE_DIR)518 style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR) 445 519 446 520 if dlg.ShowModal() == wx.ID_OK: 447 521 # This returns a list of files that were selected. 448 path = dlg.GetPath()522 files = dlg.GetFilenames() 449 523 self.file_dir = dlg.GetDirectory() 450 524 dlg.Destroy() 451 if path not in self.CSVFiles: 452 headers = self.getHeaders(path) 453 if headers: 454 common_headers = self.orHeaders(headers) 455 if not common_headers or len(common_headers) < 2: 456 self.error("Sorry, file '%s' doesn't have enough headers in common with current files" % path) 525 for f in files: 526 path = os.path.join(self.file_dir, f) 527 if path not in self.CSVFiles: 528 headers = self.getHeaders(path) 529 if headers: 530 common_headers = self.orHeaders(headers) 531 if not common_headers or len(common_headers) < 2: 532 self.error("Sorry, file '%s' doesn't have enough headers in common with current files" % path) 533 else: 534 self.headers.append(headers) 535 self.common_headers = common_headers 536 self.CSVFiles.append(path) 537 self.txtCSVFiles.Append(path) 457 538 else: 458 self.headers.append(headers) 459 self.common_headers = common_headers 460 self.CSVFiles.append(path) 461 self.txtCSVFiles.Append(path) 462 else: 463 self.error("Sorry, file '%s' doesn't appear to be a CSV file" % path) 464 self.updateHdrChoices() 539 self.error("Sorry, file '%s' doesn't appear to be a CSV file" % path) 540 self.updateHdrChoices() 465 541 466 542 def DelCSVFile(self, event): 467 """Delete a CSV file from the listbox""" 468 469 sel = self.txtCSVFiles.GetSelections() 470 if sel: 471 sel = sel[0] 472 self.txtCSVFiles.Delete(sel) 473 del self.CSVFiles[sel] 474 del self.headers[sel] 475 self.common_headers = self.GenCommonHeaders(self.headers) 476 self.updateHdrChoices() 477 543 """Delete all CSV files from the listbox""" 544 545 self.txtCSVFiles.Clear() 546 self.CSVFiles = [] 547 self.common_headers = None 548 self.updateHdrChoices() 549 478 550 def ChangeLegend(self, event): 479 551 if self.chkLegend.GetValue(): … … 494 566 self.cfg['GraphLegend'] = self.chkLegend.GetValue() 495 567 self.cfg['LegendPath'] = self.chkLegendPath.GetValue() 568 self.cfg['ShowGrid'] = self.chkShowGrid.GetValue() 569 self.cfg['FontSize'] = self.cbLabFontSize.GetValue() 570 self.cfg['PlotWidth'] = self.cbPlotWidth.GetValue() 571 self.cfg['XLabel'] = self.txtXLabel.GetValue() 572 self.cfg['YLabel'] = self.txtYLabel.GetValue() 496 573 497 574 self.cfg.save() … … 529 606 if self.YColHdrSelection >= 0: 530 607 self.cbYColHdr.SetSelection(self.YColHdrSelection) 531 title = self.cfg['GraphTitle']532 if title is None:533 title = ''534 self. txtTitle.SetValue(title)535 if self.cfg['GraphLegend']:536 self.chkLegend.SetValue(True)537 if self.cfg['LegendPath']:538 self.chkLegendPath.SetValue(True)608 self.txtTitle.SetValue(self.cfg.get('GraphTitle', '')) 609 self.chkLegend.SetValue(self.cfg.get('GraphLegend', False)) 610 self.chkLegendPath.SetValue(self.cfg.get('LegendPath', False)) 611 self.cbLabFontSize.SetValue(self.cfg.get('FontSize', '14')) 612 self.cbPlotWidth.SetValue(self.cfg.get('PlotWidth', '1')) 613 self.chkShowGrid.SetValue(self.cfg.get('ShowGrid', True)) 614 self.txtXLabel.SetValue(self.cfg.get('XLabel', '')) 615 self.txtYLabel.SetValue(self.cfg.get('YLabel', '')) 539 616 self.ChangeLegend(None) 540 617 … … 581 658 index = self.common_headers.index(selected_y) 582 659 self.cbYColHdr.SetSelection(index) 660 self.txtXLabel.Enable() 661 self.txtYLabel.Enable() 583 662 else: 584 663 self.cbXColHdr.Disable() 585 664 self.cbYColHdr.Disable() 665 self.txtXLabel.Disable() 666 self.txtYLabel.Disable() 586 667 self.btnPlot.Disable() 587 668 … … 620 701 selected_y = self.cbYColHdr.GetStringSelection() 621 702 703 x_label = self.txtXLabel.GetValue() 704 y_label = self.txtYLabel.GetValue() 705 622 706 if selected_x and selected_y: 707 grid_on = self.chkShowGrid.GetValue() 708 fontsize = self.cbLabFontSize.GetValue() 709 plot_width = self.cbPlotWidth.GetValue() 623 710 plot_files(self.CSVFiles, selected_x, selected_y, 711 x_label=x_label, y_label=y_label, 624 712 title=self.txtTitle.GetValue(), 625 713 legend=self.chkLegend.GetValue(), 626 legend_path=self.chkLegendPath.GetValue()) 714 legend_path=self.chkLegendPath.GetValue(), 715 grid=grid_on, fontsize=fontsize, 716 plot_width = plot_width) 717 627 718 # hide problem with wxPython and matplotlib - close app! 628 719 self.Close(True) 720 else: 721 self.error('Sorry, you must select X- and Y-column data values') 629 722 630 723 def error(self, msg):
Note: See TracChangeset
for help on using the changeset viewer.