lanl / LaGriT

Los Alamos Grid Toolbox (LaGriT) is a library of user callable tools that provide mesh generation, mesh optimization and dynamic mesh maintenance in two and three dimensions.
https://lanl.github.io/LaGriT/
Other
116 stars 48 forks source link

[tinerator] Interpolation of attributes.py fails if xll/yll_corners are not zero #200

Open zgxn opened 4 years ago

zgxn commented 4 years ago

(Using tinerator v0.3.3) -- If dem.xll_corner and dem.yll_corner are unequal zero, there seems to be an issue with correct offsets. Attempting to interpolate gives: Exception: ERROR: INTERPOLATE found zero sink points inside source grid.

daniellivingston commented 4 years ago

Thanks @zgxn - could you outline an approximate workflow to replicate this?

zgxn commented 4 years ago

Hi @daniellivingston,

Workflow to reproduce error

  1. In examples/data/dem.asc set xllcorner and yllcorner to nonzero values. For example:
    xllcorner 35000.0
    yllcorner 430000.0
  2. Execute this small script within the examples-folder:
    
    import tinerator as tin
    import numpy as np

my_dem = tin.load.from_file('data/dem.asc') my_dem.build_uniform_triplane(100.0) depths = [0.1, 0.3, 0.6, 10.0] ids = range(1, len(depths)+1) my_dem.build_layered_mesh(depths, matids = ids)

attr = np.zeros_like(my_dem, dtype = int) + 100 my_dem.add_attribute(attr, layers=[1], dtype=int)


## Error

This should results in something like:

Traceback (most recent call last): File "test.py", line 13, in my_dem.add_attribute(attr, layers=[1], dtype=int) File "/Users/IOzgen/opt/anaconda3/envs/geo/lib/python3.8/site-packages/tinerator/dem_class.py", line 633, in add_attribute self._stacked_mesh = attrib._add_attribute(self.lg, File "/Users/IOzgen/opt/anaconda3/envs/geo/lib/python3.8/site-packages/tinerator/attributes.py", line 226, in _add_attribute stacked_mesh.interpolate('map',attribute_name,mo_extrude,'id_strat', File "/Users/IOzgen/opt/anaconda3/envs/geo/lib/python3.8/site-packages/pylagrit/pylagrit.py", line 3226, in interpolate self.sendline('/'.join(cmd)) File "/Users/IOzgen/opt/anaconda3/envs/geo/lib/python3.8/site-packages/pylagrit/pylagrit.py", line 1248, in sendline self._parent.sendline(cmd,verbose=verbose,expectstr=expectstr) File "/Users/IOzgen/opt/anaconda3/envs/geo/lib/python3.8/site-packages/pylagrit/pylagrit.py", line 106, in sendline raise Exception(_line) Exception: ERROR: INTERPOLATE found zero sink points inside source grid.
Exception ignored in: <function DEM.del at 0x7f8cb96d9f70> Traceback (most recent call last): File "/Users/IOzgen/opt/anaconda3/envs/geo/lib/python3.8/site-packages/tinerator/dem_class.py", line 68, in del TypeError: 'NoneType' object is not callable


## Coda

Setting the `xllcorner` and `yllcorner` to zero fixes the issue:

import tinerator as tin import numpy as np

my_dem = tin.load.from_file('data/dem.asc') my_dem.xll_corner = 0.0 my_dem.yll_corner = 0.0 my_dem.build_uniform_triplane(100.0) depths = [0.1, 0.3, 0.6, 10.0] ids = range(1, len(depths)+1) my_dem.build_layered_mesh(depths, matids = ids)

attr = np.zeros_like(my_dem, dtype = int) + 100 my_dem.add_attribute(attr, layers=[1], dtype=int)

daniellivingston commented 4 years ago

Thanks @zgxn , will try to resolve today