Skip to content

Commit bd319cf

Browse files
committed
feat: added DSM2 virtual xsects view
1 parent 45b36af commit bd319cf

7 files changed

Lines changed: 1024 additions & 2348 deletions

File tree

pydelmod/cli.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,14 @@ def exec_create_ann_inputs():
176176
type=click.Choice(["screened"], case_sensitive=False),
177177
default="screened",
178178
)
179-
def datastore_to_dss(datastore_dir, dssfile, param, repo_level="screened"):
179+
@click.option(
180+
"--unit-name",
181+
type=str,
182+
default=None,
183+
)
184+
def datastore_to_dss(
185+
datastore_dir, dssfile, param, repo_level="screened", unit_name=None
186+
):
180187
"""
181188
Reads datastore timeseries files and writes to a DSS file
182189
@@ -191,7 +198,7 @@ def datastore_to_dss(datastore_dir, dssfile, param, repo_level="screened"):
191198
e.g one of "flow","elev", "ec", etc.
192199
"""
193200
datastore2dss.read_from_datastore_write_to_dss(
194-
datastore_dir, dssfile, param, repo_level
201+
datastore_dir, dssfile, param, repo_level, unit_name=unit_name
195202
)
196203

197204

@@ -334,6 +341,7 @@ def dsm2_analyze(config_file):
334341
main.add_command(ptm_animator.ptm_animate)
335342
main.add_command(dsm2_analyze)
336343
main.add_command(deltacduimgr.show_deltacd_ui)
344+
main.add_command(dsm2ui.show_dsm2_tidefile_xsect_ui)
337345

338346
if __name__ == "__main__":
339347
sys.exit(main()) # pragma: no cover

pydelmod/datastore2dss.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def find_lastest_fname(pattern, dir="."):
2020

2121

2222
def read_from_datastore_write_to_dss(
23-
datastore_dir, dssfile, param, repo_level="screened"
23+
datastore_dir, dssfile, param, repo_level="screened", unit_name=None
2424
):
2525
"""
2626
Reads datastore timeseries files and writes to a DSS file
@@ -58,7 +58,12 @@ def read_from_datastore_write_to_dss(
5858
epart = ts.index.freqstr
5959
pathname = f'/{apart}/{bpart}/{row["param"]}///{fpart}/'
6060
print("Writing to ", pathname)
61-
f.write_rts(pathname, ts, row["unit"], "INST-VAL")
61+
f.write_rts(
62+
pathname,
63+
ts,
64+
unit_name if unit_name is not None else row["unit"],
65+
"INST-VAL",
66+
)
6267
print("Done")
6368

6469

pydelmod/dsm2study.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,25 @@ def join_channels_info_with_dsm2_channel_line(dsm2_chan_lines, tables, geo_id="i
116116

117117

118118
def load_dsm2_flowline_shapefile(shapefile):
119-
dsm2_chans = gpd.read_file(shapefile).to_crs(epsg=3857)
120-
dsm2_chans.geometry = dsm2_chans.geometry.simplify(tolerance=50)
121-
dsm2_chans.geometry = dsm2_chans.geometry.buffer(250, cap_style=1, join_style=1)
119+
dsm2_chans = gpd.read_file(shapefile).to_crs(epsg=26910)
120+
121+
# First, filter out invalid geometries
122+
valid_mask = dsm2_chans.geometry.is_valid & dsm2_chans.geometry.notna()
123+
if not valid_mask.all():
124+
print(
125+
f"Warning: {(~valid_mask).sum()} invalid or null geometries found and will be excluded from simplification"
126+
)
127+
128+
# Apply simplify only to valid geometries
129+
valid_indices = valid_mask[valid_mask].index
130+
if len(valid_indices) > 0:
131+
dsm2_chans.loc[valid_indices, "geometry"] = dsm2_chans.loc[
132+
valid_indices, "geometry"
133+
].simplify(tolerance=50)
134+
dsm2_chans.loc[valid_indices, "geometry"] = dsm2_chans.loc[
135+
valid_indices, "geometry"
136+
].buffer(250, cap_style=1, join_style=1)
137+
122138
return dsm2_chans
123139

124140

0 commit comments

Comments
 (0)