Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FEFF schema #41

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions aimmdb/adapters/feff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from tiled.adapters.dataframe import DataFrameAdapter


# dataframe adapter representing FEFF data
class FEFFAdapter(DataFrameAdapter):
specs = ["FEFF"]
38 changes: 38 additions & 0 deletions aimmdb/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,41 @@ class BatteryChargeMetadataInternal(pydantic.BaseModel):

class BatteryChargeMetadata(pydantic.BaseModel, extra=pydantic.Extra.allow):
charge: BatteryChargeMetadataInternal

class FEFFpotentials(pydantic.BaseModel, extra=pydantic.Extra.allow):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too fine-grained. We can simply remove it for now. All of this is going into input_script.

x: Optional[str]
ipot: int
Z: str
element: int
l_scmt: int
l_fms: int


class FEFFcards(pydantic.BaseModel, extra=pydantic.Extra.allow):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as my previous comment:

This is too fine-grained. We can simply remove it for now. All of this is going into input_script.

atoms: float
control: int
exchange: float
title: Optional[str]
rpath: int
potentials: FEFFpotentials
xanes: float
edge: str
scf: float
fms: float
S02: float
corehole: str

class FEFFInputMetadata(pydantic.BaseModel, extra=pydantic.Extra.allow):
element: XDIElement
measurement_type: MeasurementEnum = pydantic.Field("FEFF", const=True)
dataset: str
sample_id: str
input_script: str
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input_script not input_scripts.


class FEFFOutputMetadata(pydantic.BaseModel, extra=pydantic.Extra.allow):
element: XDIElement
measurement_type: MeasurementEnum = pydantic.Field("FEFF", const=True)
dataset: str
sample_id: str
output_log: str

13 changes: 12 additions & 1 deletion aimmdb/validation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pydantic
from tiled.validation_registration import ValidationError

from .schemas import BatteryChargeMetadata, ExperimentalXASMetadata
from .schemas import BatteryChargeMetadata, ExperimentalXASMetadata, ExperimentalFEFFMetadata


def validate_xas_metadata(metadata, structure_family, structure, spec):
Expand Down Expand Up @@ -45,3 +45,14 @@ def validate_battery_charge_data(metadata, structure_family, structure, spec):
metadata = BatteryChargeMetadata.parse_obj(metadata)
except pydantic.ValidationError as e:
raise ValidationError(str(e))

def validate_feff(metadata, structure_family, structure, spec):
#validate_xas_metadata(metadata, structure_family, structure, spec)

columns = set(structure.macro.columns)

required_columns = {"omega", "e", "k", "mu", "mu0", "chi"}


if not required_columns.issubset(columns):
raise ValidationError(f"columns {columns} must contain {required_columns}")
Loading