-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors in extraction of thalweg polygons in the Alaska domain #8
Comments
@BahramKhazaei-NOAA The dem file has "nan" values, which may cause this error because pyDEM takes "-9999" as nodata. The gdal command to change nodata value cannot process this file: Do you have any method to change 'nan' to -9999? @BahramKhazaei-NOAA @SorooshMani-NOAA |
Thank you. I was trying with QGIS, but it crashed. Did that work for you? |
@BahramKhazaei-NOAA
|
I'll try this out and let you know if we still see issues. Thanks @cuill |
Thanks, Soroosh. |
@cuill using GMRT DEM, I read the raster values and set all nan's to -9999, but I still get the same error as before:
This is my raster now:
|
Thank you Soroosh for testing again. Looks like |
@cuill, any thoughts on this error message? |
@BahramKhazaei-NOAA I just came back from vacation. I'll take a look at this error when I get a chance. |
Appreciate your help and quick responses as always. Looks like for this error something is not compatible wit the definition of the |
@BahramKhazaei-NOAA @SorooshMani-NOAA I've pushed the version that worked on my side, please pull it. Here are the thalwegs extracted with a threshold of 1e4. |
@cuill thanks for your feedback, so you just used the original DEMs and set all the nans to -9999 and ran pyDEM? |
@SorooshMani-NOAA correct. |
Hi @cuill I was able to install Traceback (most recent call last):
File "/work2/noaa/nos-surge/bkhazaei/work/run_dir/Alaska_Modeling/pre_processing/grid/bearing_sea_ocsmesh/pyDEM/run_serial.py", line 47, in <module>
gdf = S.write_shapefile(npt_smooth=3)
File "/work2/noaa/nos-surge/bkhazaei/envs/miniconda3/envs/RiverMesh3_10/lib/python3.10/site-packages/pyDEM/dem.py", line 2400, in write_shapefile
idxs=np.squeeze(np.argwhere(np.isnan(river[:,0])))
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed I made sure that the nan values in my DEM are replaced with -9999 as we discussed above. I'm using #!/usr/bin/env python3
import sys
import glob
import time
from pylib import *
from pyDEM.dem import *
if __name__ == '__main__':
#input tiff files
PathToInputDEMs = '/work2/noaa/nos-surge/bkhazaei/work/run_dir/alaska_domain/mesh/ocsmesh/cook_inlet/DEMs_inputs'
PathToDomainBoundary = PathToInputDEMs+"/GMRTv4_1_1_20230815topo_NaN_removed.tif"
print('Path to DEM input:', str(PathToInputDEMs))
files = glob.glob(PathToDomainBoundary)
files.sort()
t0 = time.time()
for fname in files:
names = [fname]
#output filename
sname = f"./{fname.split('.')[0].split('/')[-1]}_1e7"
print(sname)
#declaer a dem object
S=dem()
#read data
if not os.path.exists('{}.npz'.format(sname)):
S.proc_demfile(names,sname=sname,depth_limit=[-100,1000],subdomain_size=2e10)
S.read_data('{}.npz'.format(sname))
#compuate watershed information
S.compute_watershed()
#extract river network (area_limit: catchment area)
S.compute_river(acc_limit=1e7)
#write shapefile for river network
gdf = S.write_shapefile(npt_smooth=3)
gdf.to_file(f'{sname}.shp')
print(f'It took {(time.time() - t0)/60} mins!') Did you use the same script to get the result you shared above? If not, could you please share that with me? |
@BahramKhazaei-NOAA Yes, I used the same script but with a smaller threshold (acc_limit=1e4). As you can see from the thalwegs above, the threshold of 1e4 has a relatively coarse thalwegs. I think your threshold of 1e7 results in zero thalwegs which causes the error. I will change the script to throw the error if this happens. At the time being, you can test with different threshold. |
Thank you for your response. I'm going to try with your recommended acc_limit. |
@cuill I was able to reproduce your results with acc_limit=1e4. Thank you for your help. |
@cuill @feiye-vims I'm running the |
@BahramKhazaei-NOAA Normally, we don't need thalwegs in the water areas (e.g., lakes, ponds) to guide meshing. We deleted these straight lines with the pre-defined polygons. |
@BahramKhazaei-NOAA It was done in either ArcGIS or QGIS. |
I see. By |
@BahramKhazaei-NOAA No, in the opposite way, a polygon that covers areas where thalwegs are needed. Then after clipping, thalwegs outside the polygon are removed. |
Sounds good, thank you for your quick response. |
When we created the RiverMeshTool, we already had polygons manually made that roughly delineate the shoreline of the ocean and large lakes/estuaries. These waterbodies are considered well resolved so the thalwegs inside them were clipped out. The target of the RiverMeshTool are rivers that have a clear direction, so we always cut out lakes. However, even if you retain the thalwegs in the lakes, it won't do much harm for the final mesh. I would always cut out the ocean part though. |
That is reasonable. As a side note for future developments: by taking into account the open water areas, the tool can be used to inform mesh generation process for important underwater features like ridges and continental slopes. These features might not be of immediate importance for physical models but could be important for local or biological applications. |
Saeed also mentioned this and I agree. I'm taking a note on this for future development. I'm thinking maybe using the location of largest bathymetry gradient to identify the edge of an underwater dredged channel or ridges. |
That is probably the best strategy to start with. |
@cuill After fixing the problem with impi, @SorooshMani-NOAA were trying to run the
pyDEM
package on a DEM in the Alaska domain which is extracted from GMRT. However, there was a problem with processing the DEM and his pyDEM script failed. We then tried another DEM that has coverage over the Cook Inlet and got another error that seems like is due to existence of missing values in the DEM (it has 'no data' value in some pixels). Here are the error messages in processing of each DEM:Cook Inlet DEM:
GMRT DEM:
These errors occur when using the sample code from pyDEM readme (run_serial.py just with updated paths for our DEMs). He tried to perform some pre-processing on both DEMs but even with fixed DEMs he got the exact same errors.
I will send you the GMRT file (too big to attach here). It would be great if you can take a look at this and see if you have a solution/fix for this.
The text was updated successfully, but these errors were encountered: