Skip to content

Commit d02e26e

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 7f5c66b + 21ceda2 commit d02e26e

3 files changed

Lines changed: 38 additions & 12 deletions

File tree

modules/Workflow/WorkflowApplications.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"ExecutablePath": "applications/createAIM/GeoJSON_to_ASSET/GeoJSON_to_ASSET.py",
8383
"ApplicationSpecificInputs": [
8484
{
85-
"id": "assetFile",
85+
"id": "assetSourceFile",
8686
"type": "path",
8787
"description": "path to asset database file"
8888
},

modules/createAIM/GeoJSON_to_ASSET/GeoJSON_to_ASSET.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,8 @@ def defineConnectivities(self, AIM_id_prefix = None, edges_file_name = None,\
193193
self.gdf = edges
194194
return
195195

196-
def split_and_select_components(input_config):
196+
def split_and_select_components(input_config, asset_source_file):
197197
component_dict = dict()
198-
asset_source_file = input_config["assetSourceFile"]
199198
with open(asset_source_file, 'r', encoding="utf-8") as f:
200199
source_data = json.load(f)
201200
crs = source_data["crs"]
@@ -251,7 +250,7 @@ def init_workdir(component_dict, outDir):
251250
component_dir.update({comp:compDir})
252251
return component_dir
253252

254-
def create_asset_files(output_file,
253+
def create_asset_files(output_file, asset_source_file,
255254
asset_type, input_file, doParallel):
256255
# check if running parallel
257256
numP = 1
@@ -281,7 +280,9 @@ def create_asset_files(output_file,
281280
["ApplicationData"]
282281
# if input_config.get("Roadway", None):
283282
# roadSegLength = float(input_config['Roadway'].get('maxRoadLength_m', "100000"))
284-
component_dict = split_and_select_components(input_config)
283+
284+
# assetSourceFile passed through command may be different from input_config when run on designsafe
285+
component_dict = split_and_select_components(input_config, asset_source_file)
285286
component_dir = init_workdir(component_dict, outDir)
286287
assets_array = []
287288
for component_type, component_data in component_dict.items():
@@ -341,6 +342,7 @@ def create_asset_files(output_file,
341342

342343
parser = argparse.ArgumentParser()
343344
parser.add_argument('--assetFile')
345+
parser.add_argument('--assetSourceFile')
344346
parser.add_argument('--assetType')
345347
parser.add_argument('--inputJsonFile')
346348
parser.add_argument('--doParallel', default="False")
@@ -350,7 +352,8 @@ def create_asset_files(output_file,
350352
args = parser.parse_args()
351353

352354
if args.getRV:
353-
sys.exit(create_asset_files(args.assetFile, args.assetType,\
355+
sys.exit(create_asset_files(args.assetFile, args.assetSourceFile,\
356+
args.assetType,\
354357
args.inputJsonFile, args.doParallel))
355358
else:
356359
pass # not used

modules/performRegionalMapping/SiteSpecifiedEvents/SSE.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@
4646
import pandas as pd
4747
from scipy.cluster.vq import vq
4848
import 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

Comments
 (0)