gxapi syntax: GXVV.add, subtract, multiply, divide
DavidHoward
Posts: 10
What is usage syntax for these methods?
Documentation for add shows (others are similar):
add(vv_y, vv_z): Add two VVs: VV_A + VV_B = VV_C
Parameters:
vv_y (GXVV) – GXVV B
vv_z (GXVV) – GXVV C (returned), C = A + B
So where does A go?
Documentation for add shows (others are similar):
add(vv_y, vv_z): Add two VVs: VV_A + VV_B = VV_C
Parameters:
vv_y (GXVV) – GXVV B
vv_z (GXVV) – GXVV C (returned), C = A + B
So where does A go?
0
Best Answer
-
Hi David,
Sorry for the delay. It seems my notifications form the forum were not working so I did not see this until someone over here asked me about it today...
The add method docs seems to have incorrect naming on the params, which I will fix. In the GXC and C APIS, this method will take the form:Add_VV(VV_A, VV_B, VV_C)
In the object oriented language (C++, Python, .Net) the methods act on the first parameter passed to the GX API wrapper, e.g.:vv_a.add(vv_b, vv_c)
Hope this clarifies it.
Jacques5
Answers
-
Many thanks, Jacques. This is what I have working for all methods but how do I create an empty vv rather than by my workaround? It looks as though the method does not automatically create vv_C, which has to be defined first.
David#read two channels as a vv, ... myVv_A = gdb.read_channel_vv(line, aChannel) myVv_B = gdb.read_channel_vv(line, bChannel) #instantiate C. How does one create an empty vv???? myVv_C = myVv_A # workaround to force creation of C. myVv_A.gxvv.add (myVv_B.gxvv, myVv_C.gxvv) gdb.write_channel_vv(line, 'sum', myVv_C)
0 -
Hi @DavidHoward ,
By constructing an empty VV of the same type as A and B. E.g.:import geosoft.gxpy.vv as gxvv ... myVv_C= gxvv.GXvv(dtype=myVv_A.dtype)
Cheers,
Jacques0 -
I should have added that your workaround to "force" the creation of C would in fact not be doing that. It would just create a local reference variable that also pointed at A. Then the line:
myVv_A.gxvv.add (myVv_B.gxvv, myVv_C.gxvv)
Would have the same effect as calling:myVv_A.gxvv.add (myVv_B.gxvv, myVv_A.gxvv)
Jacques0 -
Thanks again, Jacques.0
This discussion has been closed.