refid and decimate with Python gxapi/gxpy
DavidHoward
Posts: 10
Newbie looking for some howto help with refidding and decimating channels. Basic script is below. Thanks.
##import geosoft.gxpy as gxpy
##import geosoft.gxpy.project as gxprj
##import geosoft.gxpy.utility as gxu
import geosoft.gxpy.gdb as gxdb
##import geosoft.gxapi as gxapi
##import geosoft.gxpy.vv as gxvv
##import geosoft.gxapi.GXDU as gxdu
import numpy as np
#https://geosoftgxdev.atlassian.net/wiki/spaces/GXD93/pages/103415898/Geosoft+Databases
##gxc = gxpy.gx.GXpy()
def rungx():
# open the database
with gxdb.Geosoft_gdb.open() as gdb:
newdbName = str(gdb).replace('.gdb','_refid.gdb')
#create a new database for refid data with annotated channel names
new_db = gxdb.Geosoft_gdb.new(newdbName, overwrite=True)
##
for channel in gdb.list_channels():
new_channel = gxdb.Channel.new(new_db, channel + '_r')
# get a list of selected lines
lines = gdb.list_lines()
# work through each line
for line in gdb.list_lines():
print ('processing line {}'.format(line))
#read each channel as a vv, refid and write to new db
for channel in gdb.list_channels():
myVvData = gdb.read_channel_vv(line, channel)
#refid the data -- HOW? **************************
## gxvv.GXvv.refid(myVvData, (0,1), myVvData.length) #this doesn't work
#decimate the data -- HOW? **************************
## gxapi.GXVVU.decimate(myVvData, 10)
new_db.write_channel_vv(line, channel + '_r', myVvData)
input("Press return to continue...")
exit()
0
Best Answers
-
Hi @DavidHoward I’m going to move your discussion over to The GX Developer Forum. It’s the more appropriate place for python questions and where other developers are more likely to see your questions.Community Manager5
-
Hi @DavidHoward,
The refid method is not a static method and needs to be called as follows:myVvData.refid((0,1), myVvData.length)
Jacques
5 -
@DavidHoward
The gxvv.GXvv.refid() can be used to decimate by multiplying the fid separation by your decimation. Something like this should work:myVvData = gdb.read_channel_vv(line, channel) start, separation = myVVData.fid myVvdata.refid((start, separation * 10), myVvData.length // 10) new_db.write_channel_vv(line, channel + '_r', myVvData)
5
Answers
-
Thanks, all. Both work a treat. Easy when you know how.
(Sorry about the Geonet tag. I thought I'd selected the GX Developer tag but missed.)1
This discussion has been closed.