Changeset 6362
- Timestamp:
- Feb 19, 2009, 10:45:22 AM (16 years ago)
- Location:
- misc/tools/event_selection
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
misc/tools/event_selection/EventSelection.py
r6333 r6362 53 53 # program name and version 54 54 APP_NAME = 'EventSelection' 55 APP_VERSION = '0. 7'55 APP_VERSION = '0.8' 56 56 57 57 # name of the configuration filename … … 170 170 171 171 class Config(object): 172 """ 173 An object that behaves like a dictionary but is persistent: 172 """An object that behaves like a dictionary but is persistent 174 173 175 174 cfg = Config('filename') … … 183 182 184 183 def __init__(self, configfile=None): 185 """ 186 __init__(self, String filename=None) -> Config 187 """ 184 """__init__(self, String filename=None) -> Config""" 188 185 189 186 self.delconf = False … … 207 204 208 205 def __setitem__(self, key, value): 209 """ 210 Override to allow: cfg[<key>] = <value> 211 """ 206 """Override to allow: cfg[<key>] = <value>""" 207 212 208 self.cfgdict[key] = value 213 209 self.changed = True 214 210 215 211 def __getitem__(self, key): 216 """ 217 Override to allow: <var> = cfg[<key>] 218 """ 212 """Override to allow: <var> = cfg[<key>]""" 213 219 214 return self.cfgdict.get(key, None) 220 215 221 216 def __str__(self): 222 """ 223 __str__(self) -> String 224 """ 217 """__str__(self) -> String""" 218 225 219 return "<config object at %s>" % hex(id(self)) 226 220 227 221 def getfilename(self): 228 """ 229 getfilename(self) -> String filename 230 """ 222 """getfilename(self) -> String filename""" 223 231 224 return self.configfile 232 225 233 226 def setdeleted(self): 234 """ 235 setdeleted(self) 236 """ 227 """setdeleted(self)""" 228 237 229 self.delconf = True 238 230 239 231 def save(self): 240 """ 241 save(self) 242 """ 232 """save(self) -> save data to a file""" 233 243 234 try: 244 235 f = open(self.configfile, "w") … … 252 243 253 244 def close(self): 254 """ 255 close(self) 256 """ 245 """close(self) - close the save file""" 257 246 if self.changed: 258 247 self.save() … … 262 251 263 252 def __del__(self): 264 """ 265 __del__(self) 266 """ 253 """__del__(self) - ensure save file is closed""" 254 267 255 self.close() 268 256 … … 805 793 ###### 806 794 def MultimuxClick(self, event): 795 # check we have an output base directory 796 output_base_dir = self.txtOutputDir.GetValue() 797 if len(output_base_dir) == 0: 798 self.error('You must select an output base directory first') 799 return 800 807 801 # check we have a quake ID 808 802 quake_ID = self.txtQuakeID.GetValue() … … 813 807 quake_ID = int(quake_ID) 814 808 except: 815 self.error("You must enter a Quake ID ")809 self.error("You must enter a Quake ID integer") 816 810 return 817 811 … … 839 833 self.panel.SetCursor(wx.StockCursor(wx.CURSOR_WAIT)) 840 834 841 fault_event_filename = ('%s/event_%6.6d.list' % 842 (ResultSubdir, quake_ID)) 835 fault_event_dir = os.path.join(output_base_dir, '%6.6d' % quake_ID) 836 os.makedirs(fault_event_dir) 837 fault_event_filename = os.path.join(fault_event_dir, 'event.list') 838 843 839 wx.Yield() # allow GUI refresh 844 840 … … 892 888 last_weight = weight 893 889 filenames.append(filename) 894 # write data to the file 895 urs_filename = '%s/%s' % (ResultSubdir, URSDataFilename % quake_ID) 896 try: 897 out_fd = open(urs_filename, "w") 898 except IOError, msg: 899 self.error("Error opening output file %s': %s" % 900 (urs_filename, msg)) 901 return 902 if last_weight and filenames: 903 out_fd.write('# Data for region %s,\n' 904 '# hazard %d,\n' 905 '# min height %.2f,\n' 906 '# max height %.2f,\n' 907 '# quake ID %d\n' % 908 (Region, GaugeNumber, MinimumHeight, 909 MaximumHeight, quake_ID)) 910 out_fd.write('# Generated on %s.\n' % time.asctime(time.localtime())) 911 out_fd.write('\n') 912 out_fd.write('import os.path\n') 913 out_fd.write('\n') 914 out_fd.write('def getInfo(base_directory):\n') 915 out_fd.write(' """\n') 916 out_fd.write(' Return the weight factor and list of URS data filenames\n') 917 out_fd.write('\n') 918 out_fd.write(' (weight_factor, [filenames]) <- get_urs_data(base_directory)\n') 919 out_fd.write('\n') 920 out_fd.write(' where base_directory is the path to the mux files.\n') 921 out_fd.write(' """\n') 922 out_fd.write('\n') 923 out_fd.write(' weight_factor = %f\n' % last_weight) 924 out_fd.write(' mux_filenames = [') 925 if filenames: 926 for fn in filenames[:-1]: 927 out_fd.write('"%%s" %% os.path.join(base_directory, "%s"),\n ' % fn) 928 out_fd.write('"%%s" %% os.path.join(base_directory, "%s")\n ' % filenames[-1]) 929 out_fd.write(']\n') 930 out_fd.write('\n') 931 out_fd.write(' return (weight_factor, mux_filenames)\n') 932 out_fd.close() 890 891 ## No longer generate the python data file 892 ## # write data to the file 893 ## urs_filename = '%s/%s' % (ResultSubdir, URSDataFilename % quake_ID) 894 ## try: 895 ## out_fd = open(urs_filename, "w") 896 ## except IOError, msg: 897 ## self.error("Error opening output file %s': %s" % 898 ## (urs_filename, msg)) 899 ## return 900 ## if last_weight and filenames: 901 ## out_fd.write('# Data for region %s,\n' 902 ## '# hazard %d,\n' 903 ## '# min height %.2f,\n' 904 ## '# max height %.2f,\n' 905 ## '# quake ID %d\n' % 906 ## (Region, GaugeNumber, MinimumHeight, 907 ## MaximumHeight, quake_ID)) 908 ## out_fd.write('# Generated on %s.\n' % time.asctime(time.localtime())) 909 ## out_fd.write('\n') 910 ## out_fd.write('import os.path\n') 911 ## out_fd.write('\n') 912 ## out_fd.write('def getInfo(base_directory):\n') 913 ## out_fd.write(' """\n') 914 ## out_fd.write(' Return the weight factor and list of URS data filenames\n') 915 ## out_fd.write('\n') 916 ## out_fd.write(' (weight_factor, [filenames]) <- get_urs_data(base_directory)\n') 917 ## out_fd.write('\n') 918 ## out_fd.write(' where base_directory is the path to the mux files.\n') 919 ## out_fd.write(' """\n') 920 ## out_fd.write('\n') 921 ## out_fd.write(' weight_factor = %f\n' % last_weight) 922 ## out_fd.write(' mux_filenames = [') 923 ## if filenames: 924 ## for fn in filenames[:-1]: 925 ## out_fd.write('"%%s" %% os.path.join(base_directory, "%s"),\n ' % fn) 926 ## out_fd.write('"%%s" %% os.path.join(base_directory, "%s")\n ' % filenames[-1]) 927 ## out_fd.write(']\n') 928 ## out_fd.write('\n') 929 ## out_fd.write(' return (weight_factor, mux_filenames)\n') 930 ## out_fd.close() 933 931 934 932 ###### -
misc/tools/event_selection/installer/EventSelection.nsi
r6331 r6362 1 1 !define PRODUCT_NAME "EventSelection" 2 !define PRODUCT_VERSION "0. 7"2 !define PRODUCT_VERSION "0.8" 3 3 !define ICON_FILE "tsunami.ico" 4 4
Note: See TracChangeset
for help on using the changeset viewer.