Skip to content

Commit

Permalink
Better handle legacy calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
sivonxay committed Dec 23, 2023
1 parent 77e7964 commit d04699d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/NanoParticleTools/species_data/species.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,19 @@ def species_data(self) -> dict[str, tuple[list[str], list[float]]]:
symbol = self.SURFACE_DOPANT_SYMBOLS_TO_NAMES[self.symbol]
else:
symbol = self.symbol
# Load Data from json file
with open(os.path.join(SPECIES_DATA_PATH, f'{symbol}.json'), 'r') as f:
species_data = json.load(f)
try:
# Load Data from json file
with open(os.path.join(SPECIES_DATA_PATH, f'{symbol}.json'),
'r') as f:
species_data = json.load(f)
except FileNotFoundError:
# File was not found, check if it is a legacy calc
if self.symbol in self.LEGACY_SURFACE_NAMES:
# This is a legacy calc. Load the corresponding calc
symbol = self.LEGACY_SURFACE_NAMES[self.symbol]
with open(os.path.join(SPECIES_DATA_PATH, f'{symbol}.json'),
'r') as f:
species_data = json.load(f)

return species_data

Expand Down

0 comments on commit d04699d

Please sign in to comment.