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

Cleanup xrdutil #663

Merged
merged 16 commits into from
Jul 3, 2024
3 changes: 2 additions & 1 deletion hexrd/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DeprecatedFunctionError(Exception):
pass


def deprecated(new_func: str = None):
def deprecated(new_func: str = None, deprecation_date: str = None):
"""
Decorator to mark functions as deprecated. Raises an error if
the 'ACK_DEPRECATED' environment variable is not set. Alerts the
Expand All @@ -21,6 +21,7 @@ def wrapper(*args, **kwargs):
print(
f"Warning: {func.__name__} is deprecated and is marked for"
f" removal. Please use {new_func} instead."
f" Deprecation date: {deprecation_date}"
psavery marked this conversation as resolved.
Show resolved Hide resolved
)
if os.getenv('ACK_DEPRECATED') != 'true':
raise DeprecatedFunctionError(
Expand Down
2 changes: 1 addition & 1 deletion hexrd/findorientations.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def generate_eta_ome_maps(cfg, hkls=None, save=True):
map_fname
)

eta_ome.save(fn)
eta_ome.save_eta_ome_maps(fn)

logger.info('saved eta/ome orientation maps to "%s"', fn)

Expand Down
28 changes: 12 additions & 16 deletions hexrd/xrdutil/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ def __init__(self, ome_eta_archive: str):
self.etas = ome_eta['etas']
self.omegas = ome_eta['omegas']

def save(self, filename: str) -> None:
self.save_eta_ome_maps(self, filename)

@staticmethod
def save_eta_ome_maps(eta_ome, filename: str) -> None:
def save_eta_ome_maps(self, filename: str) -> None:
"""
eta_ome.dataStore
eta_ome.planeData
Expand All @@ -109,19 +105,19 @@ def save_eta_ome_maps(eta_ome, filename: str) -> None:
eta_ome.etas
eta_ome.omegas
"""
args = np.array(eta_ome.planeData.getParams(), dtype=object)[:4]
args = np.array(self.planeData.getParams(), dtype=object)[:4]
args[2] = valWUnit('wavelength', 'length', args[2], 'angstrom')
hkls = np.vstack([i['hkl'] for i in eta_ome.planeData.hklDataList]).T
hkls = np.vstack([i['hkl'] for i in self.planeData.hklDataList]).T
save_dict = {
'dataStore': eta_ome.dataStore,
'etas': eta_ome.etas,
'etaEdges': eta_ome.etaEdges,
'iHKLList': eta_ome.iHKLList,
'omegas': eta_ome.omegas,
'omeEdges': eta_ome.omeEdges,
'dataStore': self.dataStore,
'etas': self.etas,
'etaEdges': self.etaEdges,
'iHKLList': self.iHKLList,
'omegas': self.omegas,
'omeEdges': self.omeEdges,
'planeData_args': args,
'planeData_hkls': hkls,
'planeData_excl': eta_ome.planeData.exclusions,
'planeData_excl': self.planeData.exclusions,
}
np.savez_compressed(filename, **save_dict)

Expand Down Expand Up @@ -370,7 +366,7 @@ def validateAngleRanges(
return reflInRange


@deprecated
@deprecated(deprecation_date='2025-01-01')
def simulateOmeEtaMaps(
omeEdges,
etaEdges,
Expand Down Expand Up @@ -1141,7 +1137,7 @@ def simulateGVecs(
return valid_ids, valid_hkl, valid_ang, valid_xy, ang_ps


@deprecated(new_func=simlp)
@deprecated(new_func=simlp, deprecation_date='2025-01-01')
def simulateLauePattern(
hkls,
bMat,
Expand Down
Loading