<div dir="ltr"><div>Hi Paul</div><div><br></div><div>Looking great!</div><div><br></div><div>I understand this is still work in progress, may I just suggest to make the API look more pythonic, by using snake case (face_count) instead of camel case (faceCount)... Maybe also avoid using "get" prefix in getters?</div><div><br></div><div>Regards</div><div>Martin</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, May 29, 2021 at 2:46 PM Paul Harwood <<a href="mailto:runette@gmail.com">runette@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span>As promised - I have been working on some Python Bindings. I now have a 0.9.0b1 type release :</span><br><br><span>See </span><a href="https://github.com/ViRGIS-Team/mdal-python" target="_blank">https://github.com/ViRGIS-Team/mdal-python</a><br><br><div>There is a conda install for this in the process of being created.<br><br>There is some documentation in the process of being created.<br></div><div><br></div><div>Currently, this integration can:<br><br>- read all MDAL compatible file formats,<br>- access the metadata for the source,<br>- access the vertex, face and edge data as NumPy arrays,<br>- access 'double' datasets (both scalar and vector) as NumPy arrays, and<br>- convert the MDAL source mesh into a meshio mesh object (with some restrictions currently).</div><div>- This version does not currently allow the MDAL source mesh to be written or amended.<br></div><div><br></div><div>Note this very much beta and has not been comprehensively tested. The following script has been run successfully on a number of different test files and shows the usage.</div><div><br></div><div>All comments and improvements welcome.</div><div><br></div><div>"""</div><div><pre style="white-space:pre-wrap;box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;padding:16px;overflow:auto;line-height:1.45;border-radius:6px;word-break:normal;color:rgb(36,41,46)"><span style="box-sizing:border-box">import</span> <span style="box-sizing:border-box">mdal</span>
<span style="box-sizing:border-box">from</span> <span style="box-sizing:border-box">mdal</span> <span style="box-sizing:border-box">import</span> <span style="box-sizing:border-box">Datasource</span>
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"MDAL Version: <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mdal</span>.<span style="box-sizing:border-box">getVersionString</span>()<span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"MDAL Driver Count :<span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mdal</span>.<span style="box-sizing:border-box">getDriverCount</span>()<span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">mdal</span>.<span style="box-sizing:border-box">getLastStatus</span>())
<span style="box-sizing:border-box">for</span> <span style="box-sizing:border-box">driver</span> <span style="box-sizing:border-box">in</span> <span style="box-sizing:border-box">mdal</span>.<span style="box-sizing:border-box">getDrivers</span>():
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">driver</span>.<span style="box-sizing:border-box">long_name</span>)
<span style="box-sizing:border-box">ds</span> <span style="box-sizing:border-box">=</span> <span style="box-sizing:border-box">Datasource</span>(<span style="box-sizing:border-box">"data/ply/test_mesh.ply"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">ds</span>.<span style="box-sizing:border-box">meshes</span>)
<span style="box-sizing:border-box">mesh</span> <span style="box-sizing:border-box">=</span> <span style="box-sizing:border-box">ds</span>.<span style="box-sizing:border-box">load</span>(<span style="box-sizing:border-box">0</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Driver : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">driverName</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Vertex Count : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">vertexCount</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Face Count : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">faceCount</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Largest Face: <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">largestFace</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Edge Count : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">edgeCount</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"CRS : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">projection</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Mesh extent : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">extent</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"DatasetGroup Count : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">groupCount</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">""</span>)
<span style="box-sizing:border-box">mesh</span> <span style="box-sizing:border-box">=</span> <span style="box-sizing:border-box">ds</span>.<span style="box-sizing:border-box">load</span>(<span style="box-sizing:border-box">ds</span>.<span style="box-sizing:border-box">meshes</span>[<span style="box-sizing:border-box">0</span>])
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Driver : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">driverName</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Vertex Count : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">vertexCount</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Face Count : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">faceCount</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Largest Face: <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">largestFace</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Edge Count : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">edgeCount</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"CRS : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">projection</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Mesh extent : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">extent</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">vertex</span> <span style="box-sizing:border-box">=</span> <span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">getVertices</span>()
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Vertex Array Shape : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">vertex</span>.<span style="box-sizing:border-box">shape</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">faces</span> <span style="box-sizing:border-box">=</span> <span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">getFaces</span>()
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Face Array Shape : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">faces</span>.<span style="box-sizing:border-box">shape</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">edges</span> <span style="box-sizing:border-box">=</span> <span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">getEdges</span>()
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Edges Array Shape : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">edges</span>.<span style="box-sizing:border-box">shape</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">""</span>)
<span style="box-sizing:border-box">group</span> <span style="box-sizing:border-box">=</span> <span style="box-sizing:border-box">mesh</span>.<span style="box-sizing:border-box">getGroup</span>(<span style="box-sizing:border-box">0</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"DatasetGroup Name : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">group</span>.<span style="box-sizing:border-box">name</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"DatasetGroup Location : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">group</span>.<span style="box-sizing:border-box">location</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Dataset Count : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">group</span>.<span style="box-sizing:border-box">datasetCount</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Group has scalar values : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">group</span>.<span style="box-sizing:border-box">hasScalar</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Group has temporal values : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">group</span>.<span style="box-sizing:border-box">isTemporal</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Reference Time : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">group</span>.<span style="box-sizing:border-box">referenceTime</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Maximum Vertical Level Count : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">group</span>.<span style="box-sizing:border-box">levelCount</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Minimum / Maximum ; <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">group</span>.<span style="box-sizing:border-box">minmax</span><span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Metadata : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">group</span>.<span style="box-sizing:border-box">getMetadata</span>()<span style="box-sizing:border-box">}</span></span>"</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">""</span>)
<span style="box-sizing:border-box">data</span> <span style="box-sizing:border-box">=</span> <span style="box-sizing:border-box">group</span>.<span style="box-sizing:border-box">getDataAsDouble</span>(<span style="box-sizing:border-box">0</span>)
<span style="box-sizing:border-box">print</span>(<span style="box-sizing:border-box">f"Dataset Shape : <span style="box-sizing:border-box"><span style="box-sizing:border-box">{</span><span style="box-sizing:border-box">data</span>.<span style="box-sizing:border-box">shape</span><span style="box-sizing:border-box">}</span></span>"</span>)</pre></div><div>"""</div><div>(see next email to see results from this code)</div></div>
_______________________________________________<br>
MDAL-Developer mailing list<br>
<a href="mailto:MDAL-Developer@lists.osgeo.org" target="_blank">MDAL-Developer@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/mdal-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/mdal-developer</a><br>
</blockquote></div>