Skip to content

Commit

Permalink
Renamings.
Browse files Browse the repository at this point in the history
  • Loading branch information
lauri-codes committed Jun 5, 2024
1 parent d80ae9e commit 4e0cd53
Show file tree
Hide file tree
Showing 9 changed files with 261 additions and 113 deletions.
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ select = [
"UP",
# isort
"I",
# pylint
# pylint
"PL",
]

Expand Down Expand Up @@ -108,7 +108,6 @@ package-dir = { "" = "src" }
where = ["src"]

[project.entry-points.'nomad.plugin']
myparser = "nomad_tadf_molecules.parsers:myparser"
mypackage = "nomad_tadf_molecules.schema_packages:mypackage"

myapp = "nomad_tadf_molecules.apps:myapp"
parser = "nomad_tadf_molecules.parsers:tadf_molecules"
package = "nomad_tadf_molecules.schema_packages:tadf_molecules"
app = "nomad_tadf_molecules.apps:tadf_molecules"
25 changes: 5 additions & 20 deletions src/nomad_tadf_molecules/apps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
from nomad.config.models.plugins import AppEntryPoint
from nomad.config.models.ui import App, Column, Columns, FilterMenu, FilterMenus

from nomad_tadf_molecules.apps.tadf_molecules import tadf_molecules_app

myapp = AppEntryPoint(
name='MyApp',
description='App defined using the new plugin mechanism.',
app=App(
label='MyApp',
path='myapp',
category='simulation',
columns=Columns(
selected=['entry_id'],
options={
'entry_id': Column(),
},
),
filter_menus=FilterMenus(
options={
'material': FilterMenu(label='Material'),
}
),
),
tadf_molecules = AppEntryPoint(
name='TADF Molecules',
description='Search information about thermally activated delayed fluorescent (TADF) molecules.',
app=tadf_molecules_app,
)
88 changes: 88 additions & 0 deletions src/nomad_tadf_molecules/apps/tadf_molecules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
from nomad.config.models.ui import (
App,
Axis,
Column,
Columns,
Dashboard,
FilterMenu,
FilterMenus,
Filters,
Layout,
WidgetPeriodicTable,
WidgetHistogram,
WidgetScatterPlot,
WidgetTerms,
)

schema = 'nomad_tadf_molecules.schema_packages.tadf.TADFMolecule'
tadf_molecules_app = App(
label='Fluorescent Molecules',
path='fluorescent-molecules',
description='Search for fluorescent molecule data',
category='Experiment',
filters=Filters(include=[f'*#{schema}'],),
filters_locked={'section_defs.definition_qualified_name': schema},
columns=Columns(
selected=[
'results.material.chemical_formula_hill',
f'data.photoluminescence_quantum_yield#{schema}',
f'data.peak_emission_wavelength#{schema}',
f'data.delayed_lifetime#{schema}',
f'data.singlet_triplet_energy_splitting#{schema}',
f'data.DOI_number#{schema}',
],
options={
'results.material.chemical_formula_hill': Column(),
f'data.photoluminescence_quantum_yield#{schema}': Column(),
f'data.peak_emission_wavelength#{schema}': Column(),
f'data.delayed_lifetime#{schema}': Column(),
f'data.singlet_triplet_energy_splitting#{schema}': Column(),
f'data.DOI_number#{schema}': Column(),
}
),
filter_menus=FilterMenus(
options={
'material': FilterMenu(label='Material'),
'elements': FilterMenu(label='Elements / Formula', level=1, size='xl'),
'custom_quantities': FilterMenu(label='Custom Quantities', size='l'),
}
),
dashboard=Dashboard(
widgets=[
WidgetPeriodicTable(
type='periodictable',
scale='linear',
quantity='results.material.elements',
layout={'lg': Layout(w=11, h=7, x=0, y=0)},
),
WidgetScatterPlot(
type='scatterplot',
layout={'lg':Layout(w=7, h=7, x=11, y=0)},
x=Axis(quantity=f'data.peak_emission_wavelength#{schema}', unit='nm'),
y=Axis(quantity=f'data.photoluminescence_quantum_yield#{schema}'),
),
WidgetTerms(
type='terms',
layout={'lg': Layout(w=6, h=7, x=18, y=0)},
quantity='results.material.chemical_fomula_fill',
scale='linear',
),
WidgetHistogram(
type='histogram',
layout={'lg': Layout(w=12, h=4, x=12, y=7)},
autorange=True,
nbins=30,
scale='linear',
quantity=f'data.delayed_lifetime#{schema}',
),
WidgetHistogram(
type='histogram',
layout={'lg': Layout(w=12, h=4, x=12, y=7)},
autorange=True,
nbins=30,
scale='linear',
quantity=f'data.singlet_triplet_energy_splitting#{schema}',
)
]
)
)
17 changes: 7 additions & 10 deletions src/nomad_tadf_molecules/parsers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
from nomad.config.models.plugins import ParserEntryPoint
from pydantic import Field


class MyParserEntryPoint(ParserEntryPoint):
parameter: int = Field(0, description='Custom configuration parameter')

class TADFMoleculesParserEntryPoint(ParserEntryPoint):
def load(self):
from nomad_tadf_molecules.parsers.myparser import MyParser
from nomad_tadf_molecules.parsers.tadf_molecules import TADFMoleculesParser

return MyParser(**self.dict())
return TADFMoleculesParser(**self.dict())


myparser = MyParserEntryPoint(
name='MyParser',
description='Parser defined using the new plugin mechanism.',
mainfile_name_re='.*\.myparser',
tadf_molecules = TADFMoleculesParserEntryPoint(
name='TADFMoleculesParser',
description='Used to parse information about thermally activated fluorescent molecules from JSON files.',
mainfile_name_re='.*molecule\d+.json',
)
31 changes: 0 additions & 31 deletions src/nomad_tadf_molecules/parsers/myparser.py

This file was deleted.

41 changes: 41 additions & 0 deletions src/nomad_tadf_molecules/parsers/tadf_molecules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import json

from nomad.datamodel.datamodel import EntryArchive
from nomad.parsing.parser import MatchingParser
from nomad.units import ureg
from structlog.stdlib import BoundLogger

from nomad_tadf_molecules.schema_packages.tadf_molecules import TADFMolecule


class TADFMoleculesParser(MatchingParser):
def parse(
self,
mainfile: str,
archive: EntryArchive,
logger: BoundLogger,
) -> None:
# Extract file contents
with open(mainfile) as file:
raw = json.load(file)

# Fill information about the chemical composition
schema_instance = TADFMolecule()
schema_instance.DOI_number = raw['doi']
schema_instance.name = raw['abbreviated_name']
schema_instance.iupac_name = raw['iupac_name']
schema_instance.smile = raw['smiles']

# Extract the four measured properties
for name in [
'photoluminescence_quantum_yield',
'peak_emission_wavelength',
'delayed_lifetime',
'singlet_triplet_energy_splitting',
]:
value = raw.get(f'{name}_value')
if value is not None:
setattr(schema_instance, name, value * ureg(raw[f'{name}_unit']))

# Save schema instance into archive.data
archive.data = schema_instance
15 changes: 6 additions & 9 deletions src/nomad_tadf_molecules/schema_packages/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
from nomad.config.models.plugins import SchemaPackageEntryPoint
from pydantic import Field


class MySchemaPackageEntryPoint(SchemaPackageEntryPoint):
parameter: int = Field(0, description='Custom configuration parameter')

class TADFMoleculesSchemaPackageEntryPoint(SchemaPackageEntryPoint):
def load(self):
from nomad_tadf_molecules.schema_packages.mypackage import m_package
from nomad_tadf_molecules.schema_packages.tadf_molecules import m_package

return m_package


mypackage = MySchemaPackageEntryPoint(
name='MyPackage',
description='Schema package defined using the new plugin mechanism.',
tadf_molecules = TADFMoleculesSchemaPackageEntryPoint(
name='TADF molecules',
description='Schema package for thermally activated delayed fluorescent (TADF) molecules.',
)
38 changes: 0 additions & 38 deletions src/nomad_tadf_molecules/schema_packages/mypackage.py

This file was deleted.

Loading

0 comments on commit 4e0cd53

Please sign in to comment.