Skip to content

Commit

Permalink
more updates
Browse files Browse the repository at this point in the history
  • Loading branch information
RobHanna-NOAA committed Jul 2, 2024
1 parent e01df20 commit 5d3f826
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tools/generate_categorical_fim.py
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ def produce_stage_based_catfim_tifs(
child_log_file_prefix = FLOG.MP_calc_prefix_name(parent_log_output_file, f"MP_sb_{huc}_inundate")
with ProcessPoolExecutor(max_workers=number_of_jobs) as executor:
for branch in branches:
msg_id_w_branch = "{huc} -- {branch} -- {lid} -- {category}"
msg_id_w_branch = f"{huc} -- {branch} -- {lid} -- {category}"
MP_LOG.trace(f"{msg_id} : Determining HydroID")
# Define paths to necessary files to produce inundation grids.
full_branch_path = os.path.join(branch_dir, branch)
Expand Down
37 changes: 18 additions & 19 deletions tools/generate_categorical_fim_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def generate_flows_for_huc(
segments = filter_nwm_segments_by_stream_order(unfiltered_segments, desired_order, nwm_flows_df)

# If there are no segments, write message and exit out
if len(segments) == 0:
if not segments or len(segments) == 0:
message = f'{lid}: missing nwm segments'
all_messages.append(message)
MP_LOG.warning(message)
Expand All @@ -141,30 +141,29 @@ def generate_flows_for_huc(
for category in flood_categories:
# Get the flow
flow = flows[category]
if flow is None:
if flow:
MP_LOG.trace(f"{category} flow is none")
continue

# If there is a valid flow value, write a flow file.
# if flow:
# round flow to nearest hundredth
flow = round(flow, 2)
# If there is a valid flow value, write a flow file.
# if flow:
# round flow to nearest hundredth
flow = round(flow, 2)

# Create the guts of the flow file.
flow_info = flow_data(segments, flow)
# Create the guts of the flow file.
flow_info = flow_data(segments, flow)

# Define destination path and create folders
csv_output_folder = os.path.join(output_flows_dir, huc, lid, category)
os.makedirs(csv_output_folder, exist_ok=True)
output_file = os.path.join(csv_output_folder, f'ahps_{lid}_huc_{huc}_flows_{category}.csv')
# Define destination path and create folders
csv_output_folder = os.path.join(output_flows_dir, huc, lid, category)
os.makedirs(csv_output_folder, exist_ok=True)
output_file = os.path.join(csv_output_folder, f'ahps_{lid}_huc_{huc}_flows_{category}.csv')

# Write flow file to file
flow_info.to_csv(output_file, index=False)
# Write flow file to file
flow_info.to_csv(output_file, index=False)

# else:
# message = f'{lid}: magnitude : {category} is missing calculated flow'
# all_messages.append(message)
# MP_LOG.warning(message)
else:
message = f'{huc} - {lid}: magnitude : {category} is missing calculated flow'
all_messages.append(message)
MP_LOG.warning(message)

# Get various attributes of the site.
lat = float(metadata['nws_preferred']['latitude'])
Expand Down

0 comments on commit 5d3f826

Please sign in to comment.