def test_multifile(): ret = gxprj.get_user_input('Testing a multi-file string default', 'Multiple files:', kind='file', default='maki.dat,mak2.dat;yamma.grd', filemask="**") print('multifile from string default return: {}'.format(ret)) ret = gxprj.get_user_input('Testing a multi-file list default', 'Multiple files:', kind='file', default=['maki.dat', 'list.', '4.5'], filemask="**") print('multifile from list default return: {}'.format(ret)) ret = gxprj.get_user_input('Testing a multi-file *.grd', 'Multiple grids:', kind='file', filemask="**,*.grd") print('multifile grid return: {}'.format(ret)) ret = gxprj.get_user_input('Testing a multi-file *.map,*.gdb', 'Multiple maps/gdb:', kind='file', filemask=["**", "*.map", "*.gdb"]) print('multifile map/gdb return: {}'.format(ret)) input("File inputs test finished, press enter to continue...")
def test_get_user_input(): gxprj.user_message('TEST', 'Starting get_user_info test') gxprj.pause( 'Testing pause\nSome descriptive text\nLine 2\nLine 3\nThis tests the ability for DGW to properly resize a a dialog..........' ) gxprj.pause('Testing pause with cancel', cancel=True) ret = gxprj.get_user_input('Testing string input', 'String is a bit long', default='test') print('string return: {}'.format(ret)) ret = gxprj.get_user_input('Testing float', 'Float', kind='float', default=1.5) print('float return: {}'.format(ret)) ret = gxprj.get_user_input('Testing int\nThis must be an integer value.', 'Int', kind='int', default=7) print('int return: {}'.format(ret)) ret = gxprj.get_user_input('Testing a list', 'List', kind='list', default='maki', items='maki, rider, explorer') print('list return: {}'.format(ret)) input("Simple inputs test finished, press enter to continue...")
def test_file(): ret = gxprj.get_user_input('Testing a file', 'Any file', kind='file', default='anyfile.dat') print('file return: {}'.format(ret)) ret = gxprj.get_user_input('Testing a file', 'New file', kind='newfile', default='new.dat') print('new file return: {}'.format(ret)) ret = gxprj.get_user_input('Testing a file', 'Old file', kind='oldfile') print('old file return: {}'.format(ret)) ret = gxprj.get_user_input('Testing a file *.grd,*.gdb', 'Some file', kind='file', default='maki.dat', filemask="*.grd,*.gdb") print('grid file return: {}'.format(ret)) input("File inputs test finished, press enter to continue...")
def rungx(): float_val = gxa.GXSYS.get_double("SCRIPT_GX", "VALUE") if gxa.GXSYS.interactive() != 0: ret_val = gxprj.get_user_input('SCRIPT GX (interactive)', 'Float', kind='float', default=float_val) print('float return: {}'.format(ret_val)) gxa.GXSYS.set_double("SCRIPT_GX", "VALUE", ret_val) else: gxa.GXSYS.set_interactive(1) # Restore interactive mod to make dialogs appear gxprj.user_message('SCRIPT GX (non interactive)', "Received value: {}".format(float_val))
def rungx(): line = gxproj.get_user_input(title="test", prompt="line?", kind="string") rownumber = gxproj.get_user_input(title="test", prompt="Row Number", kind="string") channel_list = [ "UTCTime2", "unixtime", "Latitude", "Longitude", "SurfHell_lidar" ] new_row_list = [] list_of_rows = [] # gxpy.utility.display_message("GX Python", np.version.version) gdb = gxdb.Geosoft_gdb.open() for channel in channel_list: print("testing on row " + str(rownumber)) if channel == "UTCTime2": print( str( datetime.timedelta( seconds=gdb.read_channel(line, channel)[0][1] * 60**2))) new_row_list.append( str( datetime.timedelta( seconds=gdb.read_channel(line, channel)[0][1] * 60**2))) else: print(gdb.read_channel(line, channel)[0][1]) new_row_list.append(gdb.read_channel(line, channel)[0][1]) input("done with channel") print(new_row_list) list_of_rows.append(new_row_list) input("done with row")
def rungx(): # get the name of a grid from the user grid_file = gxproj.get_user_input(title='Grid statistics', prompt='Grid file', kind='file', filemask='*.grd') stats = grid_stats(grid_file) gxproj.user_message( grid_file, 'min: {}\nmax: {}\nmean: {}\nstd_dev: {}'.format( stats.get_info(gxapi.ST_MIN), stats.get_info(gxapi.ST_MAX), stats.get_info(gxapi.ST_MEAN), stats.get_info(gxapi.ST_STDDEV)))
def rungx(): project = gxpj.Geosoft_project() # there must be grids in the project if len(project.project_grids) == 0: raise Exception('This project contains no grids.') # default grid will be the current grid, or the first grid in the list of project grids if project.current_grid: default_grid = project.current_grid else: default_grid = project.project_grids[0] # ask the user to select a grid grid_name = gxpj.get_user_input(title='Vertical derivative of a grid', prompt='Grid to process', kind='list', items=project.project_grids, default=default_grid) # ask for a new grid file name new_grid = gxpj.get_user_input( title='Vertical derivative of a grid', prompt='Output vertical derivative grid name', kind='file', filemask='*.grd') # calculate vertical derivative with gxgrd.Grid(grid_name) as g_input: with gxgrd.Grid.new(new_grid, properties=g_input.properties(), overwrite=True) as g_output: gxapi.GXIMU.grid_vd(g_input.gximg, g_output.gximg) # open the vertical derivative grid gxpj.add_document(new_grid)
def rungx(): # parameter 'GRID_FILE' is the last-specified grid file name for this script. grid_parameter = 'GRID_FILE' group = os.path.basename(__file__).split('.')[0] parms = gxu.get_parameters(group, {grid_parameter: ''}) # get the name of a grid from the user grid_file = gxproj.get_user_input(title='Grid statistics', prompt='Grid file', default=parms.get(grid_parameter), kind='file', filemask='*.grd') # save the grid file name as the default the next time this script is run parms[grid_parameter] = grid_file gxu.save_parameters(group, parms) stats = grid_stats(grid_file) gxproj.user_message( grid_file, 'min: {}\nmax: {}\nmean: {}\nstd_dev: {}'.format( stats.get_info(gxapi.ST_MIN), stats.get_info(gxapi.ST_MAX), stats.get_info(gxapi.ST_MEAN), stats.get_info(gxapi.ST_STDDEV)))
def rungx(): # api version gxpy.utility.check_version('9.2') # get the current database db = gxpy.gdb.Geosoft_gdb.open() # project parameters group = 'CHANADD' p_chan = 'CHANNEL' p_addval = 'ADDVAL' # get previous parameters from the parameter block, initializing to start-up defaults '' and 0.0 parms = gxu.get_parameters(group, {p_chan: '', p_addval: 0.0}) # if interactive, get user input if not gxprj.running_script(): try: # get channel to process from list of database channels chan = gxprj.get_user_input( 'Channel to process', 'Channel:', kind='list', default=parms.get(p_chan), items=sorted([k for k in db.list_channels().keys()])) # value to add to the channel addval = gxprj.get_user_input( 'Value to add to the data', 'value to add:', kind='float', default=parms.get(p_addval)) except gxprj.ProjectException: exit() # save parameters to new user settings parms[p_chan] = chan parms[p_addval] = addval gxu.save_parameters(group, parms) # work through the data a line at a time - get a list of selected lines lines = db.list_lines() # for each line, get the data, add a value, return the data to the line for l in lines: # print to the console to reflect progress print('line {}...'.format(str(l))) # get the data and determine the dummy to the data type data, ch, fid = db.read_line(l, channels=chan) dummy = gxu.gx_dummy(data.dtype) # make a dummy mask so we can replace dummies after processing dMask = gxu.dummy_mask(data) # process - add the value, then replace the dummies sum = data + addval sum[dMask] = dummy # write the data back to the database db.write_channel(l, chan, sum, fid) # pause the console so user can review input("Press return to continue...")
def getline(): line = gxproj.get_user_input(title="test", prompt="line?", kind="string") print(line) input()