Skip to content

Commit

Permalink
removing generic adding prismatic
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-rakowski committed Oct 13, 2023
1 parent b3b1829 commit 4c0fd9b
Showing 1 changed file with 45 additions and 20 deletions.
65 changes: 45 additions & 20 deletions py4DSTEM/process/diffraction/crystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,19 +423,12 @@ def from_ASE(
cell=atoms.cell.array,
)

def from_generic_file(filepath, **kwargs):
def from_prismatic(filepath):
"""
Create a py4DSTEM Crystal from a wide range of generic file types using
`ase.io.read`, kwargs are passed to `ase.io.read` function. For more details
and potentially compatible filetypes please see https://wiki.fysik.dtu.dk/ase/ase/io/io.html.
Note this has not been tested extensively. The loaded file must have these three properties:
.get_scaled_positions()
.numbers
.cell.array,
Create a py4DSTEM Crystal object from an prismatic style xyz co-ordinate file
Args:
filepath (str|Pathlib.Path): path to the file
kwargs: key word arguments to be passed to `ase.io.read`
filepath (str|Pathlib.Path): path to the prismatic format xyz file
"""

Expand All @@ -446,16 +439,48 @@ def from_generic_file(filepath, **kwargs):
)
else:
from ase.io import read
# try loading the file using ase read and get required properties
try:
atoms = read(filepath, **kwargs)
return Crystal(
positions=atoms.get_scaled_positions(), # fractional coords
numbers=atoms.numbers,
cell=atoms.cell.array,
)
except Exception as e:
raise e

atoms = read(filepath, format="prismatic")

return Crystal(
positions=atoms.get_scaled_positions(), # fractional coords
numbers=atoms.numbers,
cell=atoms.cell.array,
)

# def from_generic_file(filepath, **kwargs):
# """
# Create a py4DSTEM Crystal from a wide range of generic file types using
# `ase.io.read`, kwargs are passed to `ase.io.read` function. For more details
# and potentially compatible filetypes please see https://wiki.fysik.dtu.dk/ase/ase/io/io.html.
# Note this has not been tested extensively. The loaded file must have these three properties:
# .get_scaled_positions()
# .numbers
# .cell.array,

# Args:
# filepath (str|Pathlib.Path): path to the file
# kwargs: key word arguments to be passed to `ase.io.read`

# """

# # check if ase is installed
# if find_spec("ase") is None:
# raise ImportWarning(
# "Could not import ASE, please install, restart and try again"
# )
# else:
# from ase.io import read
# # try loading the file using ase read and get required properties
# try:
# atoms = read(filepath, **kwargs)
# return Crystal(
# positions=atoms.get_scaled_positions(), # fractional coords
# numbers=atoms.numbers,
# cell=atoms.cell.array,
# )
# except Exception as e:
# raise e

def from_unitcell_parameters(
latt_params,
Expand Down

0 comments on commit 4c0fd9b

Please sign in to comment.