SOLVED: Display new channels automatically (python)

Hi,

I'm writing a Python script to create two new channels (some existing data is copied to them). How could I automatically display the channels in the database without having to manually select them for displaying from the channel list? They are hidden by default. There doesn't seem to be a parameter related directly to the display option either in gxdb.Channel.new() or gxdb.Geosoft_gdb.write_channel() if I understand correctly?

Regards,
Hanna

import numpy as np
import geosoft.gxpy.gx as gxpy
import geosoft.gxpy.gdb as gxdb
import geosoft.gxpy.utility as gxu

def separate_inout(gdb):

ch_names = ['Depth', 'Value', 'Direction']

if gdb.is_channel('Direction'):
new_in_ch = gxdb.Channel.new(gdb, ch_names[1] + '_IN', dup=ch_names[1], replace=True)
new_out_ch = gxdb.Channel.new(gdb, ch_names[1] + '_OUT', dup=ch_names[1], replace=True)
for line in gdb.list_lines():
# read the direction channel as string and depth, value as float
dird, dirch, dirfid = gdb.read_line(line, ch_names[2], dtype='<U008') # read as 8-ch string
devald, devalch, devalfid = gdb.read_line(line, channels=[ch_names[0], ch_names[1]]) # default float64

# mask the value channel with IN/OUT
ind = np.where(dird[:,0] == 'IN', devald[:,1], np.nan)
outd = np.where(dird[:,0] == 'OUT', devald[:,1], np.nan)

# write the new channel data
gdb.write_channel(line, new_in_ch, ind, devalfid)
gdb.write_channel(line, new_out_ch, outd, devalfid)
else:
channels = gdb.list_channels()
gxu.display_message('Error', 'No channel named Direction!\n {}'.format(channels.keys()))

def rungx():
# running inside Oasis:
# open the current database in the open project
with gxdb.Geosoft_gdb.open() as gdb:
separate_inout(gdb)

Comments

  • Solved with the low-level library functions.
    def disp_channels(ch_names):
    ed_db = gxapi.GXEDB.current()
    if ed_db:
    ed_db.load_chan(ch_names[1] + '_IN')
    ed_db.load_chan(ch_names[1] + '_OUT')
Sign In or Register to comment.

Howdy, Stranger!

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