def __on_run_button_click(self): """ Creates a HapiWorker to run the Select query. """ selected_params = self.get_select_parameters() table_name = self.get_select_table_name() new_table_name = self.get_output_table_name() expression = self.get_select_expression() parsed_expression = DSL.parse_expression(expression) if parsed_expression == None and expression.strip() != '': err_log('Invalid select expression.') return if table_name == new_table_name: err_log( 'Cannot have select output table be the same as the input table' ) return self.run_button.setDisabled(True) args = HapiWorker.echo(ParameterNames=selected_params, TableName=table_name, DestinationTableName=new_table_name, Conditions=parsed_expression) worker = HapiWorker(WorkRequest.SELECT, args, self.__on_run_done) self.parent.workers.append(worker) worker.start()
def graph_as(self, standard_params): path_length = self.get_path_length() instrumental_fn = self.get_instrumental_fn() AF_wing = self.get_instrumental_fn_wing() Resolution = self.get_instrumental_resolution() if standard_params['WavenumberStep'] is None: standard_params['WavenumberStep'] = Resolution / 2 elif standard_params['WavenumberStep'] <= Resolution: standard_params[ 'WavenumberStep'] = Resolution * 1.0001 # err_log('Wavenumber Step must be less # than Instrumental Resolution') # self.done_graphing() # return work = HapiWorker.echo(title=GraphingWidget.ABSORPTION_SPECTRUM_STRING, titlex="Wavenumber (cm$^{-1}$)", titley="Absorption Spectrum", path_length=path_length, instrumental_fn=instrumental_fn, Resolution=Resolution, AF_wing=AF_wing, **standard_params) if self.use_existing_window.isChecked(): selected_window = self.get_selected_window() if selected_window in GraphDisplayWidget.graph_windows: GraphDisplayWidget.graph_windows[selected_window].add_worker( GraphType.ABSORPTION_SPECTRUM, work) return GraphDisplayWidget(GraphType.ABSORPTION_SPECTRUM, work, self.backend.currentText()) self.update_existing_window_items()
def graph_bands(self, _standard_params): work = HapiWorker.echo(TableName=self.get_data_name(), title="Bands") if self.use_existing_window.isChecked(): selected_window = self.get_selected_window() if selected_window in GraphDisplayWidget.graph_windows: GraphDisplayWidget.graph_windows[selected_window].add_worker( GraphType.BANDS, work) return BandDisplayWidget(work, self.backend.currentText()) self.update_existing_window_items()
def __on_fetch_clicked(self, _checked: bool): xscs = self.get_selected_xscs() if len(xscs) == 0: return args = HapiWorker.echo(xscs=xscs, molecule_name=self.molecule.currentText()) self.fetch_button.setDisabled(True) self.worker = HapiWorker(WorkRequest.DOWNLOAD_XSCS, args, self.__on_fetch_xsc_done) self.worker.start()
def graph_xsc(self, standard_params): work = HapiWorker.echo(title=GraphingWidget.XSC_STRING, titlex="Wavenumber (cm$^{-1}$)", titley="Intensity", **standard_params) if self.use_existing_window.isChecked(): selected_window = self.get_selected_window() if selected_window in GraphDisplayWidget.graph_windows: GraphDisplayWidget.graph_windows[selected_window].add_worker( GraphType.XSC, work) return _ = GraphDisplayWidget(GraphType.XSC, work, self.backend.currentText())
def __on_select_table_name_selection_changed(self, new_selection): """ When the table that is being worked with changes, update the parameter list. """ self.run_button.setDisabled(True) if new_selection == '': return args = HapiWorker.echo(table_name=new_selection) worker = HapiWorker(WorkRequest.TABLE_META_DATA, args, self.__on_select_table_name_complete) worker.start() self.parent.workers.append(worker)
def graph_abs_coef(self, standard_parameters): work = HapiWorker.echo( title=GraphingWidget.ABSORPTION_COEFFICIENT_STRING, titlex="Wavenumber (cm$^{-1}$)", titley='Absorption Coefficient ', **standard_parameters) if work['SourceTables'][0].endswith('.xsc'): work['titley'] = 'molecules / cm$^2$' work['title'] = 'Absorption Cross-Section' if self.use_existing_window.isChecked(): selected_window = self.get_selected_window() if selected_window in GraphDisplayWidget.graph_windows: GraphDisplayWidget.graph_windows[selected_window].add_worker( GraphType.ABSORPTION_COEFFICIENT, work) return # No need to store a reference to it, since the GraphDisplayWidget will add itself to a list _ = GraphDisplayWidget(GraphType.ABSORPTION_COEFFICIENT, work, self.backend.currentText()) self.update_existing_window_items()
def get_standard_parameters(self): data_name = self.get_data_name() backend = self.backend.currentText() if data_name.endswith(".xsc"): Components = [] SourceTables = [data_name] Environment = {'p': self.xsc.pressure, 'T': self.xsc.temp} WavenumberRange = (self.xsc.numin, self.xsc.numax) WavenumberStep = self.xsc.step Diluent = {'air': 0.0, 'self': 1.0} # TODO: Verify that these are the proper values. WavenumberWing = 0.0 WavenumberWingHW = 0.0 else: hmd = HapiMetaData(data_name) Components = hmd.iso_tuples SourceTables = [data_name] Environment = {'p': self.get_pressure(), 'T': self.get_temp()} Diluent = self.get_diluent() WavenumberRange = self.get_wn_range() WavenumberStep = self.get_wn_step() WavenumberWing = self.get_wn_wing() WavenumberWingHW = self.get_wn_wing_hw() name = self.plot_name.text() graph_fn = self.get_line_profile() return HapiWorker.echo(graph_fn=graph_fn, Components=Components, SourceTables=SourceTables, Environment=Environment, Diluent=Diluent, HITRAN_units=False, WavenumberRange=WavenumberRange, WavenumberStep=WavenumberStep, WavenumberWing=WavenumberWing, WavenumberWingHW=WavenumberWingHW, backend=backend, name=name)
def graph_ts(self, standard_params): path_length = self.get_path_length() instrumental_fn = self.get_instrumental_fn() AF_wing = self.get_instrumental_fn_wing() Resolution = self.get_instrumental_resolution() if standard_params['WavenumberStep'] == None: standard_params['WavenumberStep'] = Resolution / 2 elif standard_params['WavenumberStep'] <= Resolution: err_log( 'Wavenumber Step must be less than Instrumental Resolution') self.data_name_error.setText( '<span style="color:#aa0000;">' + 'Wavenumber Step must be less than the ' 'Instrumental Resolution' + '</span>') self.done_graphing() return work = HapiWorker.echo( title=GraphingWidget.TRANSMITTANCE_SPECTRUM_STRING, titlex="Wavenumber (cm$^{-1}$)", titley="Transmittance", path_length=path_length, instrumental_fn=instrumental_fn, Resolution=Resolution, AF_wing=AF_wing, **standard_params) if self.use_existing_window.isChecked(): selected_window = self.get_selected_window() if selected_window in GraphDisplayWidget.graph_windows: GraphDisplayWidget.graph_windows[selected_window].add_worker( GraphType.TRANSMITTANCE_SPECTRUM, work) return GraphDisplayWidget(GraphType.TRANSMITTANCE_SPECTRUM, work, self.backend.currentText()) self.update_existing_window_items()