Accessing date and string channels with python


I'm using python to pull info from a gdb. I'm using the as an example and am able to use vv.get_data_np to get float or integers channels, but I'm not sure how to get a string channel. I set the datatype using numpy to a string, with
but when I run the command
channel_array = vv.get_data_np(0, nrows, datatype)

it gives the error: Numpy array type does not map to supported GS_TYPES

I've tried just assigning it to an unsigned byte as well and still get the unsupported GS_TYPES warning.

Thanks for any help!



  • Here is a set of modules that "pythonify" important parts of the Geosoft GX API, and you may find this useful as a guide. These include the system, GX base functions, VV, GDB, GRD and IPJ.

    There is a lot of useful code here that you can use to pattern your own Python. Note that this is not released as part of the current GX Developer (and of course unsupported) because we are working on a more comprehensive and improved interface for Oasis 9, which is natively 64-bit and includes the ability for Oasis to call Python scripts directly. We expect/hope to release GX Developer for Oasis 9 as part of the 9.1 release in October.

    See gdb/tests/ Function test_read_GDB has a string read test at line 152:

    npd,ch,fid = gdb.readLine(ls,channels=['ianClass','dx','class'], dtype='<U32')
    self.assertEqual(npd[10,:3].tolist(),['0', '0.00', '29'])

    Follow this through into the gdb/ readLine function. At line 747 you will see the numpy string data type:

    # data type wanted
    dtype = np.dtype(dtype)

    and at line 799 we call gdb._vvCh(line, channel, dtype=dtype) to read the string data.

    I hope this gets you going.
  • Thanks for the response. I think the code will be very useful. However, I'm having trouble downloading it. Dropbox tells me "The owner hasn’t granted you access to this link."
  • Apologies - it should work now...
  • I'm able to download it now, thanks!
This discussion has been closed.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!