Skip to content

Commit

Permalink
STOFS-3D postprocessing: added one level to geo json outputs for nowc…
Browse files Browse the repository at this point in the history
…oast.
  • Loading branch information
feiye-vims committed Nov 4, 2024
1 parent 87821a0 commit fa233ab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ def split_quads(elements=None): # modified by FY
idxs=np.argmax(elev,axis=0)
time_maxelev=times[idxs]

#disturbance
#disturbance, maxdist = maxelev in ocean, so just need to deal with land values
maxdist=copy.deepcopy(maxelev)
land_node_idx = depth < 0
maxdist[land_node_idx]=np.maximum(0, maxelev[land_node_idx]+depth[land_node_idx])
maxdist[land_node_idx]=np.maximum(0, maxelev[land_node_idx]+depth[land_node_idx]) # need to include city idx

#find city nodes
if input_city_identifier_file is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def contour_to_gdf(disturbance, levels, triangulation):

#MinMax = [(-99999, levels[0])]
MinMax = [(disturbance.min(), levels[0])]
for i in np.arange(len(levels)-1):
for i in np.arange(len(levels)-1):
MinMax.append((levels[i], levels[i+1]))
#MinMax.append((levels[-1], np.max(disturbance)))

Expand Down Expand Up @@ -88,12 +88,12 @@ def contour_to_gdf(disturbance, levels, triangulation):
mpoly = MultiPolygon(mpoly)
polygons.append(mpoly)
colors.append(polygon.get_facecolor().tolist()[0])
data.append({'id': i+1, 'minWaterLevel': MinMax[i][0], 'maxWaterLevel': MinMax[i][1],
data.append({'id': i+1, 'minWaterLevel': MinMax[i][0], 'maxWaterLevel': MinMax[i][1],
'verticalDatum': 'XGEOID20B', 'units': 'meters', 'geometry': mpoly})
elif len(mpoly) == 1:
polygons.append(mpoly[0])
colors.append(polygon.get_facecolor().tolist()[0])
data.append({'id': i+1, 'minWaterLevel': MinMax[i][0], 'maxWaterLevel': MinMax[i][1],
data.append({'id': i+1, 'minWaterLevel': MinMax[i][0], 'maxWaterLevel': MinMax[i][1],
'verticalDatum': 'XGEOID20B', 'units': 'meters', 'geometry': mpoly[0]})
plt.close('all')

Expand Down Expand Up @@ -124,7 +124,7 @@ def contour_to_gdf(disturbance, levels, triangulation):
args = argparser.parse_args()

input_filename = args.input_filename
input_fileindex = os.path.basename(input_filename).replace("_", ".").split(".")[1]
input_fileindex = os.path.basename(input_filename).replace("_", ".").split(".")[1]

#reading netcdf dataset
ds = Dataset(input_filename)
Expand Down Expand Up @@ -162,6 +162,8 @@ def contour_to_gdf(disturbance, levels, triangulation):

#t0 = time()
levels = [round(i, 1) for i in np.arange(0.3, 2.1, 0.1)]
levels.append(20) # Add 20 as the maximum level

#print(levels)
#get_disturbance(maxelev, depth, levels, my_fillvalue, filename_output)
#print(f'Calculating and masking disturbance took {time()-t0} seconds')
Expand All @@ -175,7 +177,7 @@ def contour_to_gdf(disturbance, levels, triangulation):
# + f't00z_{dates[i].strftime("%Y%m%d")}t{dates[i].strftime("%H")}z.gpkg' for i in range(len(times))]
#print(filenames)
filenames = [f'stofs_3d_atl.t12z.disturbance.n{i-1:03d}.gpkg' for i in range(24, 0,-1)]

#for i in range(48):
for i in range(96):
filenames.append(f'stofs_3d_atl.t12z.disturbance.f{i+1:03d}.gpkg')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,9 @@ def main():
print(f'{DRIVER_PRINT_PREFIX}Generating {name}.gr3 ...')
try_remove(f'{model_input_path}/{sub_dir}/{name}.gr3')
hgrid.write(f'{model_input_path}/{sub_dir}/{name}.gr3', value=value)

os.chdir(run_dir)
os.system(f'ln -sf ../I{runid}/{sub_dir}/*.gr3 .')

os.chdir(model_input_path)

# -------------------------------------------------
Expand Down

0 comments on commit fa233ab

Please sign in to comment.