Esempio n. 1
0
def test_multifile():

    ret = gxom.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 = gxom.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 = gxom.get_user_input('Testing a multi-file *.grd;',
                              'Multiple grids:',
                              kind='file',
                              filemask="**,*.grd")
    print('multifile grid return: {}'.format(ret))

    ret = gxom.get_user_input('Testing a multi-file *.map,*.gdb',
                              'Multiple grids:',
                              kind='file',
                              filemask=["**", "*.map", "*.gdb"])
    print('multifile grid return: {}'.format(ret))

    input("File inputs test finished...")
Esempio n. 2
0
def test_get_user_input():

    gxom.user_message('TEST', 'Starting get_user_info test')
    gxom.pause(
        'Testing pause\nSome descriptive text\nLine 2\nLine 3\nThis tests the ability for DGW to properly resize a a dialog..........'
    )
    gxom.pause('Testing pause with cancel', cancel=True)

    ret = gxom.get_user_input('Testing string input',
                              'String is a bit long',
                              default='test')
    print('string return: {}'.format(ret))

    ret = gxom.get_user_input('Testing float',
                              'Float',
                              kind='float',
                              default=1.5)
    print('float return: {}'.format(ret))

    ret = gxom.get_user_input('Testing int\nThis must be an integer value.',
                              'Int',
                              kind='int',
                              default=7)
    print('int return: {}'.format(ret))

    ret = gxom.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...")
Esempio n. 3
0
def test_file():

    ret = gxom.get_user_input('Testing a file',
                              'Any file',
                              kind='file',
                              default='anyfile.dat')
    print('file return: {}'.format(ret))

    ret = gxom.get_user_input('Testing a file',
                              'New file',
                              kind='newfile',
                              default='new.dat')
    print('new file return: {}'.format(ret))

    ret = gxom.get_user_input('Testing a file', 'Old file', kind='oldfile')
    print('old file return: {}'.format(ret))

    ret = gxom.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...")
Esempio n. 4
0
def rungx():
    float_val = gxa.GXSYS.get_double("SCRIPT_GX", "VALUE")
    if gxa.GXSYS.interactive() != 0:
        ret_val = gxom.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
        gxom.user_message('SCRIPT GX (non interactive)',
                          "Received value: {}".format(float_val))
Esempio n. 5
0
def rungx():

    # get the current database
    db = gxpy.gdb.GXdb.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 gxom.running_script():

        try:
            # get channel to process from list of database channels
            chan = gxom.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 = gxom.get_user_input('Value to add to the data',
                                         'value to add:',
                                         kind='float',
                                         default=parms.get(p_addval))
        except gxom.OMException:
            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...")