def parse_args(args): if len(args) == 1: print('Usage is: ws2ModEM <input data> <output data>') return False elif len(args) == 2: in_file = sys.argv[1] print('No output specified. Using "ModEM_input.data".\n') out_file = 'ModEM_input.data' elif len(args) == 3: in_file = sys.argv[1] out_file = sys.argv[2] else: print('Too many inputs.\n') print('Usage is: ws2ModEM <input data> <output data>\n') return if not utils.check_file(in_file): print('{} not found.\n') return False if utils.check_file(out_file): print('{} already exists.\n'.format(out_file)) user_response = WSIO.verify_input('Overwrite?', expected='yn', default='y') if user_response.lower() == 'n': out_file = WSIO.verify_input('Please specify another output file.', expected='write') return in_file, out_file
def main(): if len(sys.argv) < 3: print('Command line arguments are: <data file (string)> ' + ' <percentage noise (double)> <static shift (binary)') return if not utils.check_file(sys.argv[1]): print('File {} not found'.format(sys.argv[1])) return else: datafile = sys.argv[1] if len(sys.argv) > 1: perc_error = float(sys.argv[2]) else: perc_error = 5.0 if len(sys.argv) > 2: static_shift = int(sys.argv[3]) else: static_shift = 0 data, headings = read_occam_data(datafile) if perc_error > 0: new_data = add_noise(data, perc_error) else: print('Not adding noise...') new_data = data if static_shift: new_data = add_shift(new_data) write_occam_data(new_data, headings, datafile + '_noise')
def main(): # If a model file is not specified, a uniformly spaced model should be generated based on the data.the # i.e., use sites as bounds, and use smallest period as a starting point for cell sizes. files = sys.argv[1:] for file in files: if not utils.check_file(file): print('File {} not found.'.format(file)) return files = utils.sort_files(files=files) try: data = WSDS.Data(datafile=files['dat']) except KeyError: print('No data file given. Site locations will not be available.') data = None try: model = WSDS.Model(files['model']) except KeyError: if data is None: print('One or more of <model_file> and <data_file> must be given!') return else: print('Generating initial model...') model = WSDS.Model(data=data) print([model.vals.shape, model.nx, model.ny, model.nz]) app = QtWidgets.QApplication(sys.argv) viewer = model_viewer_2d(model=model, data=data) viewer.show() ret = app.exec_() sys.exit(ret) viewer.disconnect_mpl_events()
def write_file(parent=None, default=None, label='Input', ext=None): if ext is None: ext = '' while True: dialog = FileDialog(parent) dialog.setTextValue(default) dialog.setLabelText(label) ret = dialog.exec_() file = dialog.textValue() if ret and file: if utils.check_file(file) or utils.check_file(''.join([file, ext])): reply = QtWidgets.QMessageBox.question(parent, 'Message', 'File already exists. Overwrite?', QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.Yes: return file, ret else: return file, ret else: return file, 0
def read_file(parent=None, default=None, label='Output'): while True: dialog = FileDialog(parent) dialog.setTextValue(default) dialog.setLabelText(label) ret = dialog.exec_() file = dialog.textValue() if ret and file: if not utils.check_file(file): QtWidgets.QMessageBox.about(parent, 'Message', 'File not found') else: return file, ret else: return file, 0
def main(): files = sys.argv[1:] for file in files: if not check_file(file): print('File {} not found.'.format(file)) return files = sort_files(files=files) try: data = WSDS.Data(datafile=files['dat']) except KeyError: print('No data file given. Site locations will not be available.') data = None try: model = WSDS.Model(files['model']) except KeyError: print('Model must be specified') return app = Qt.QApplication(sys.argv) viewer = ModelWindow(files) viewer.show() ret = app.exec_() sys.exit(ret)