SGrid Reader error understanding

I figured that do the bit you need for your domain case was likely. Annoyingly, this is taxpayer funded and could have been at least ascii or something like that.

I have uploaded to drive SA_Geophysics_Reference_Model_SGrid__flags@@.zip - Google Drive

Hi Richard,

thanks, got the files and gave it a try. Also got errors, though slightly different. Then after removing “NAME Default” line 82 in the .sg file it magically worked producing a vtu file with reasonable distributions of measurements.

Give it a try too, please. Meanwhile I’ll look with the debugger into the reader.

– d

> bin/GocadSGridReader -s SA_Geophysics_Reference_Model_SGrid.sg -o x.vtu
[2021-11-03 21:01:54.761] [ogs] [info] Start reading Gocad SGrid.
[2021-11-03 21:01:57.787] [ogs] [info] End reading Gocad SGrid.
[2021-11-03 21:02:27.393] [ogs] [info] There are 11 properties in the mesh:
[2021-11-03 21:02:27.400] [ogs] [info]  Gravity_Inversion_Constrained: (7992586 values) [-99999, 3.2188799381256104]
[2021-11-03 21:02:27.407] [ogs] [info]  Gravity_Inversion_Unconstrained: (7992586 values) [-99999, 3.0738370418548584]
[2021-11-03 21:02:27.414] [ogs] [info]  Magnetic_Inversion_Constrained: (7992586 values) [-99999, 0.11462300270795822]
[2021-11-03 21:02:27.421] [ogs] [info]  Magnetic_Inversion_Unconstrained: (7992586 values) [-99999, 0.09801190346479416]
[2021-11-03 21:02:27.425] [ogs] [info]  RegionFlags: (7992586 values) [-1, 1427]
[2021-11-03 21:02:27.430] [ogs] [info]  Rock_Unit: (7992586 values) [-99999, 6]
[2021-11-03 21:02:27.434] [ogs] [info]  SA_Geophysics_AWAGS_Log_Resistivity: (7992586 values) [-99999, 3.7394332885742188]
[2021-11-03 21:02:27.439] [ogs] [info]  SA_Geophysics_AusREM_Crust_Vp: (7992586 values) [-99999, 8.297428131103516]
[2021-11-03 21:02:27.444] [ogs] [info]  SA_Geophysics_AusREM_Crust_Vsv: (7992586 values) [-99999, 4.777806758880615]
[2021-11-03 21:02:27.448] [ogs] [info]  SA_Geophysics_AusREM_Crust_rho: (7992586 values) [-99999, 3.4011118412017822]
[2021-11-03 21:02:27.453] [ogs] [info]  SA_Geophysics_Magnetotellurics_Gawler_Resistivity: (7992586 values) [-99999, 5.930550575256348]
[2021-11-03 21:02:27.453] [ogs] [info] Writing mesh to 'x.vtu'.

Nicely done dmitri, thank you very much! Just deleted the old one, so will give it a go now.

I still get errors - am I using a different version to you?
OpenGeoSys-6 software, version 6.4.1-79-g69a2996020.

Copyright (c) 2012-2021, OpenGeoSys Community
(http://www.opengeosys.org)

indent preformatted text by 4 spaces

(base) J:\ogs-6.4.1-79-g69a2996020-Windows-10.0.19043-python-3.8.2-utils\bin>GocadSGridReader -s SA_Geophysics_Reference_Model_SGrid.sg -o x.vtu
[2021-11-04 08:45:41.921] [ogs] [info] Start reading Gocad SGrid.
[2021-11-04 08:45:44.433] [ogs] [error] readBinaryArray(): Error while reading from file ‘SA_Geophysics_Reference_Model_SGrid_Gravity_Inversion_Unconstrained@@’.
[2021-11-04 08:45:44.434] [ogs] [error] Read different number of values. Expected 7992586, got 1315930.
[2021-11-04 08:45:44.435] [ogs] [error] Reading of element properties file ‘SA_Geophysics_Reference_Model_SGrid_Gravity_Inversion_Unconstrained@@’ failed.
[2021-11-04 08:45:44.521] [ogs] [error] readBinaryArray(): Error while reading from file ‘SA_Geophysics_Reference_Model_SGrid_Magnetic_Inversion_Unconstrained@@’.
[2021-11-04 08:45:44.522] [ogs] [error] Read different number of values. Expected 7992586, got 1314778.
[2021-11-04 08:45:44.523] [ogs] [error] Reading of element properties file ‘SA_Geophysics_Reference_Model_SGrid_Magnetic_Inversion_Unconstrained@@’ failed.
[2021-11-04 08:45:44.603] [ogs] [error] readBinaryArray(): Error while reading from file ‘SA_Geophysics_Reference_Model_SGrid_Magnetic_Inversion_Constrained@@’.
[2021-11-04 08:45:44.604] [ogs] [error] Read different number of values. Expected 7992586, got 1314814.
[2021-11-04 08:45:44.606] [ogs] [error] Reading of element properties file ‘SA_Geophysics_Reference_Model_SGrid_Magnetic_Inversion_Constrained@@’ failed.
[2021-11-04 08:45:44.686] [ogs] [error] readBinaryArray(): Error while reading from file ‘SA_Geophysics_Reference_Model_SGrid_Gravity_Inversion_Constrained@@’.
[2021-11-04 08:45:44.687] [ogs] [error] Read different number of values. Expected 7992586, got 1315201.
[2021-11-04 08:45:44.693] [ogs] [error] Reading of element properties file ‘SA_Geophysics_Reference_Model_SGrid_Gravity_Inversion_Constrained@@’ failed.
[2021-11-04 08:45:44.785] [ogs] [error] readBinaryArray(): Error while reading from file ‘SA_Geophysics_Reference_Model_SGrid_SA_Geophysics_Magnetotellurics_Gawler_Resistivity@@’.
[2021-11-04 08:45:44.786] [ogs] [error] Read different number of values. Expected 7992586, got 1347556.
[2021-11-04 08:45:44.787] [ogs] [error] Reading of element properties file ‘SA_Geophysics_Reference_Model_SGrid_SA_Geophysics_Magnetotellurics_Gawler_Resistivity@@’ failed.
[2021-11-04 08:45:44.901] [ogs] [error] readBinaryArray(): Error while reading from file ‘SA_Geophysics_Reference_Model_SGrid_SA_Geophysics_AusREM_Crust_Vp@@’.
[2021-11-04 08:45:44.902] [ogs] [error] Read different number of values. Expected 7992586, got 1468345.
[2021-11-04 08:45:44.903] [ogs] [error] Reading of element properties file ‘SA_Geophysics_Reference_Model_SGrid_SA_Geophysics_AusREM_Crust_Vp@@’ failed.
[2021-11-04 08:45:45.014] [ogs] [error] readBinaryArray(): Error while reading from file ‘SA_Geophysics_Reference_Model_SGrid_SA_Geophysics_AusREM_Crust_Vsv@@’.
[2021-11-04 08:45:45.015] [ogs] [error] Read different number of values. Expected 7992586, got 1469885.
[2021-11-04 08:45:45.017] [ogs] [error] Reading of element properties file ‘SA_Geophysics_Reference_Model_SGrid_SA_Geophysics_AusREM_Crust_Vsv@@’ failed.
[2021-11-04 08:45:45.126] [ogs] [error] readBinaryArray(): Error while reading from file ‘SA_Geophysics_Reference_Model_SGrid_SA_Geophysics_AusREM_Crust_rho@@’.
[2021-11-04 08:45:45.127] [ogs] [error] Read different number of values. Expected 7992586, got 1468759.
[2021-11-04 08:45:45.128] [ogs] [error] Reading of element properties file ‘SA_Geophysics_Reference_Model_SGrid_SA_Geophysics_AusREM_Crust_rho@@’ failed.
[2021-11-04 08:45:45.232] [ogs] [error] readBinaryArray(): Error while reading from file ‘SA_Geophysics_Reference_Model_SGrid_SA_Geophysics_AWAGS_Log_Resistivity@@’.
[2021-11-04 08:45:45.233] [ogs] [error] Read different number of values. Expected 7992586, got 1305248.
[2021-11-04 08:45:45.234] [ogs] [error] Reading of element properties file ‘SA_Geophysics_Reference_Model_SGrid_SA_Geophysics_AWAGS_Log_Resistivity@@’ failed.
[2021-11-04 08:45:48.751] [ogs] [info] End reading Gocad SGrid.
[2021-11-04 08:46:36.795] [ogs] [info] There are 11 properties in the mesh:
[2021-11-04 08:46:36.796] [ogs] [info] Mesh property vector ‘Gravity_Inversion_Constrained’ is empty.
[2021-11-04 08:46:36.797] [ogs] [info] Gravity_Inversion_Constrained: Could not get value bounds for property vector.
[2021-11-04 08:46:36.798] [ogs] [info] Mesh property vector ‘Gravity_Inversion_Unconstrained’ is empty.
[2021-11-04 08:46:36.799] [ogs] [info] Gravity_Inversion_Unconstrained: Could not get value bounds for property vector.
[2021-11-04 08:46:36.800] [ogs] [info] Mesh property vector ‘Magnetic_Inversion_Constrained’ is empty.
[2021-11-04 08:46:36.801] [ogs] [info] Magnetic_Inversion_Constrained: Could not get value bounds for property vector.
[2021-11-04 08:46:36.801] [ogs] [info] Mesh property vector ‘Magnetic_Inversion_Unconstrained’ is empty.
[2021-11-04 08:46:36.802] [ogs] [info] Magnetic_Inversion_Unconstrained: Could not get value bounds for property vector.
[2021-11-04 08:46:36.816] [ogs] [info] RegionFlags: (7992586 values) [-1, 1427]
[2021-11-04 08:46:36.831] [ogs] [info] Rock_Unit: (7992586 values) [-99999, 6]
[2021-11-04 08:46:36.831] [ogs] [info] Mesh property vector ‘SA_Geophysics_AWAGS_Log_Resistivity’ is empty.
[2021-11-04 08:46:36.832] [ogs] [info] SA_Geophysics_AWAGS_Log_Resistivity: Could not get value bounds for property vector.
[2021-11-04 08:46:36.833] [ogs] [info] Mesh property vector ‘SA_Geophysics_AusREM_Crust_Vp’ is empty.
[2021-11-04 08:46:36.834] [ogs] [info] SA_Geophysics_AusREM_Crust_Vp: Could not get value bounds for property vector.
[2021-11-04 08:46:36.835] [ogs] [info] Mesh property vector ‘SA_Geophysics_AusREM_Crust_Vsv’ is empty.
[2021-11-04 08:46:36.837] [ogs] [info] SA_Geophysics_AusREM_Crust_Vsv: Could not get value bounds for property vector.
[2021-11-04 08:46:36.839] [ogs] [info] Mesh property vector ‘SA_Geophysics_AusREM_Crust_rho’ is empty.
[2021-11-04 08:46:36.840] [ogs] [info] SA_Geophysics_AusREM_Crust_rho: Could not get value bounds for property vector.
[2021-11-04 08:46:36.840] [ogs] [info] Mesh property vector ‘SA_Geophysics_Magnetotellurics_Gawler_Resistivity’ is empty.
[2021-11-04 08:46:36.841] [ogs] [info] SA_Geophysics_Magnetotellurics_Gawler_Resistivity: Could not get value bounds for property vector.
[2021-11-04 08:46:36.841] [ogs] [info] Writing mesh to ‘x.vtu’.

(base) J:\ogs-6.4.1-79-g69a2996020-Windows-10.0.19043-python-3.8.2-utils\bin>

@dmitri.naumov Can you send me your edited .sg file for comparison please?

I am just running it on a fancy Windows 10 laptop.

For the OGS version, I’m also using one of the most recent 6.4.1-116-g59c212952c, but there should be no difference in the SGrid reader.

modified_sgrid.zip (2.4 KB)

Regarding the different behaviour, I’m not able to analyze it not having a Windows machine at hand.

Thanks - next time I will try a unix flavour perhaps - any compilation tips for the beginner?

We have an intro for this case: devguide intro

Could you convert the SGrid file?

I had a look on the SGrid file format, but the description (B-37 page there) I found does not mention the NAME xxx tag, which we don’t handle properly.

I removed that as you suggested - seemed to be the same - so that suggests a data type format error in the OS - I will try it again later with your header file to confirm.

1 Like

Thanks! PyVista and PVGeo I am familiar with, yes.

@dmitri.naumov - same when I run yours, which I figured - so presumably operating system related as far as I can guess.

Fyi just tried another one from a different source, same problem, so a windows thing will have to investigate more.

The earlier example ran ok on ubuntu compiled version after fixed a bug - can open an issue about that later?

Fairly simple I think - end of line character in coordinate parser.

So next trick is a windows compiler and find out what is going on there.

Basically this in CoordinateSystem.cpp in the Gocad Fileo section
richard = boost::algorith::trim(*it)
else if (richard == “END_ORIGINAL_COORDINATE_SYSTEM”)
{
std::cout << “testing END COORD”;
return true;
}

dataset from Windows machine originally most likely, and no trimming of that string in the code, so didn’t match the equality when just a single and only token.

Hi, thanks for further testing. I’m not sure I got you correctly, your suggestion is to trim the *it before testing against an expected/possible string?

Could you post (or send a private mail dmitri.naumov@ufz.de) the dataset where trimming is required? Or is it the same as above in the google-drive link? This would help to identify the parsing problems.

The one dataset we have for testing is this one: Top-Lower-Shaly.ts and there are no spaces (or similar) around the keywords…

For the windows, I could imagine that the different line ending then on linux hinders the parser.

– d

Yes, that was it - I can chase that up, pretty big so would have to upload - although public so can send you a link.

https://energymining.sa.gov.au/minerals/geoscience/geoscientific_data/3d_geological_models/sagrm

https://dsd-gdp.s3.amazonaws.com/GDP00037.zip