-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eaa337c
commit 194c3b3
Showing
9 changed files
with
431 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from __future__ import annotations | ||
from aiidalab_qe.common.mvc import Model | ||
from aiida.common.extendeddicts import AttributeDict | ||
from ase.atoms import Atoms | ||
import traitlets as tl | ||
|
||
from aiidalab_qe_vibroscopy.utils.raman.result import export_iramanworkchain_data | ||
|
||
|
||
class IRRamanModel(Model): | ||
vibro = tl.Instance(AttributeDict, allow_none=True) | ||
input_structure = tl.Instance(Atoms, allow_none=True) | ||
|
||
needs_raman_tab = tl.Bool() | ||
needs_ir_tab = tl.Bool() | ||
|
||
def fetch_data(self): | ||
spectra_data = export_iramanworkchain_data(self.vibro) | ||
if spectra_data["Ir"] == "No IR modes detected.": | ||
self.needs_ir_tab = False | ||
else: | ||
self.needs_ir_tab = True | ||
if spectra_data["Raman"] == "No Raman modes detected.": | ||
self.needs_raman_tab = False | ||
else: | ||
self.needs_raman_tab = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from aiidalab_qe_vibroscopy.app.widgets.ir_ramanmodel import IRRamanModel | ||
from aiidalab_qe_vibroscopy.app.widgets.ramanwidget import RamanWidget | ||
from aiidalab_qe_vibroscopy.app.widgets.ramanmodel import RamanModel | ||
import ipywidgets as ipw | ||
|
||
|
||
class IRRamanWidget(ipw.VBox): | ||
def __init__(self, model: IRRamanModel, node: None, input_structure, **kwargs): | ||
super().__init__( | ||
children=[ipw.HTML("Loading Raman data...")], | ||
**kwargs, | ||
) | ||
self._model = model | ||
self._model.vibro = node | ||
self._model.input_structure = input_structure | ||
self.rendered = False | ||
|
||
def render(self): | ||
if self.rendered: | ||
return | ||
|
||
self.children = [] | ||
|
||
self.rendered = True | ||
self._model.fetch_data() | ||
self._needs_raman_widget() | ||
self._needs_ir_widget() | ||
self.render_widgets() | ||
|
||
def _needs_raman_widget(self): | ||
if self._model.needs_raman_tab: | ||
self.raman_model = RamanModel() | ||
self.raman_widget = RamanWidget( | ||
model=self.raman_model, | ||
node=self._model.vibro, | ||
input_structure=self._model.input_structure, | ||
spectrum_type="Raman", | ||
) | ||
self.children = (*self.children, self.raman_widget) | ||
|
||
def _needs_ir_widget(self): | ||
if self._model.needs_ir_tab: | ||
self.ir_model = RamanModel() | ||
self.ir_widget = RamanWidget( | ||
model=self.ir_model, | ||
node=self._model.vibro, | ||
input_structure=self._model.input_structure, | ||
spectrum_type="IR", | ||
) | ||
self.children = (*self.children, self.ir_widget) | ||
else: | ||
self.children = (*self.children, ipw.HTML("No IR modes detected.")) | ||
|
||
def render_widgets(self): | ||
if self._model.needs_raman_tab: | ||
self.raman_widget.render() | ||
if self._model.needs_ir_tab: | ||
self.ir_widget.render() |
Oops, something went wrong.