4646import pandas as pd
4747from scipy .cluster .vq import vq
4848import importlib
49+ import os
4950
50- def create_event (asset_file , event_grid_file , doParallel ):
51+ def create_event (asset_file , event_grid_file , multipleEvents , doParallel ):
5152
5253
5354 # check if running parallel
@@ -172,13 +173,25 @@ def create_event(asset_file, event_grid_file, doParallel):
172173 event_df = pd .read_csv (event_dir / event_collection_file , header = 0 )
173174
174175 # append the GM record name to the event list
175- event_list .append (event_df .iloc [idx ,0 ])
176+ event_list .append (event_df .iloc [0 ,0 ])
176177
177178 # append the scale factor (or 1.0) to the scale list
178179 if len (event_df .columns ) > 1 :
179- scale_list .append (float (event_df .iloc [idx ,1 ]))
180+ scale_list .append (float (event_df .iloc [0 ,1 ]))
180181 else :
181182 scale_list .append (1.0 )
183+
184+ # If GP_file contains multiple events
185+ if multipleEvents :
186+ # Read the GP_file
187+ if event_df .shape [0 ] > 1 :
188+ for row in range (1 ,event_df .shape [0 ]):
189+ event_list .append (event_df .iloc [row ,0 ])
190+ # append the scale factor (or 1.0) to the scale list
191+ if len (event_df .columns ) > 1 :
192+ scale_list .append (float (event_df .iloc [row ,1 ]))
193+ else :
194+ scale_list .append (1.0 )
182195
183196 # if the grid has intensity measures
184197 elif event_type == 'intensityMeasure' :
@@ -189,6 +202,16 @@ def create_event(asset_file, event_grid_file, doParallel):
189202 # IM collections are not scaled
190203 scale_list .append (1.0 )
191204
205+ # If GP_file contains multiple events
206+ if multipleEvents :
207+ # Read the GP_file
208+ GP_file = os .path .join (event_dir , closestPnt ['GP_file' ])
209+ GP_file_df = pd .read_csv (GP_file , header = 0 )
210+ if GP_file_df .shape [0 ] > 1 :
211+ for row in range (1 ,GP_file_df .shape [0 ]):
212+ event_list .append (closestPnt ['GP_file' ]+ f'x{ row } ' )
213+ scale_list .append (1.0 )
214+
192215 # TODO: update the LLNL input data and remove this clause
193216 else :
194217 event_list = []
@@ -210,8 +233,7 @@ def create_event(asset_file, event_grid_file, doParallel):
210233
211234
212235 # save the event dictionary to the AIM
213- # TODO: we assume there is only one event
214- # handling multiple events will require more sophisticated inputs
236+
215237 # save the event dictionary to the BIM
216238 asset_data ['Events' ] = [{}]
217239 asset_data ['Events' ][0 ] = {
@@ -230,9 +252,10 @@ def create_event(asset_file, event_grid_file, doParallel):
230252 parser = argparse .ArgumentParser ()
231253 parser .add_argument ('--assetFile' )
232254 parser .add_argument ('--filenameEVENTgrid' )
255+ parser .add_argument ('--multipleEvents' , default = "True" )
233256 parser .add_argument ('--doParallel' , default = "False" )
234257 parser .add_argument ("-n" , "--numP" , default = '8' )
235258 parser .add_argument ("-m" , "--mpiExec" , default = 'mpixece' )
236259 args = parser .parse_args ()
237260
238- create_event (args .assetFile , args .filenameEVENTgrid , args .doParallel )
261+ create_event (args .assetFile , args .filenameEVENTgrid , args .multipleEvents , args . doParallel )
0 commit comments