Commit c9f25702 authored by Matthijs's avatar Matthijs
Browse files

work towards mirrored_kspace support

parent 0795b636
......@@ -13,15 +13,21 @@ def data_processor(config):
sensitivity = imread(config['sensitivity_filename'])
# Add the negative K_z part to determine a real-valued orbital?
if 'add_negative_kz' in config and config['add_negative_kz']:
inp, sensitivity = mirror_kspace(inp, sensitivity)
if 'kz_dimension' not in config:
config['kz_dimension'] = 0
inp = np.moveaxis(inp, config['kz_dimension'], 2)
sensitivity = np.moveaxis(sensitivity, config['kz_dimension'], 2)
inp, sensitivity = mirror_kspace(inp, sensitivity, square_array=True)
inp = np.moveaxis(inp, 2, config['kz_dimension'])
sensitivity = np.moveaxis(sensitivity, 2, config['kz_dimension'])
ny, nx, nz = inp.shape
config['data'] = abs(inp)
config['data_zeros'] = sensitivity == 0
config['data_zeros'] = (sensitivity == 0)
# Keep the same resolution?
if 'Ny' not in config or 'Nx' not in config or 'Nz' not in config:
config['Ny'], config['Nx'], config['Nz'] = ny, nx, nz
print('Setting problem dimensions based on data, i.e. %s' % str(ny, nx, nz))
print('Setting problem dimensions based on data, i.e. %s' % str((ny, nx, nz)))
elif ny != config['Ny'] or nx != config['Nx'] or nz != config['Nz']:
nandata = np.where(config['data_zeros'], np.nan, config['data'])
if not ('from intensity data' in config and config['from intensity data']):
......@@ -42,15 +48,16 @@ def data_processor(config):
config['norm_data'] = np.sqrt(np.sum(config['data'] ** 2))
# Object support determination
try:
config['support'] = imread(config['support_filename'])
except KeyError: # 'support filename does not exist, so define a support here'
if 'threshold for support' not in config:
config['threshold for support'] = 0.1
config['support'] = support_from_autocorrelation(config['data'],
threshold=config['threshold for support'],
absolute_autocorrelation=True,
binary_dilate_support=1)
if config['constraint'] in ['support only', 'real and support', 'nonnegative and support']:
try:
config['support'] = imread(config['support_filename'])
except KeyError: # 'support filename does not exist, so define a support here'
if 'threshold for support' not in config:
config['threshold for support'] = 0.1
config['support'] = support_from_autocorrelation(config['data'],
threshold=config['threshold for support'],
absolute_autocorrelation=True,
binary_dilate_support=1)
if ('use_sparsity_with_support' in config
and config['use_sparsity_with_support']
......@@ -89,7 +96,7 @@ def data_processor(config):
def mirror_kspace(kspace: np.ndarray, sensitivity: np.ndarray = None, shift_mirror: tuple = (1, 1, 1),
square_array: bool = True):
"""
Mirror a 3d kspace array in the kz=0 plane.
Mirror a 3d kspace array in the kz=0 plane. (where the kz-dimension corresponds to the last axis)
:param kspace: kspace array, e.g. from arpes_wvlscan_to_kspace
:param sensitivity: if given (from arpes_wvlscan_to_kspace), test
......
......@@ -12,6 +12,7 @@ new_config = {
'from intensity data': False, # File gives field amplitudes
'sensitivity_filename': 'pentacene_3d_arpes_sensitivity.tif',
'add_negative_kz': False,
'kz_dimension': 0, # integer indicating the kz-axis
# What type of object are we working with?
# Options are: 'phase', 'real', 'nonnegative', 'complex'
......
......@@ -127,7 +127,7 @@ class Phase(Problem):
# the second tolerance relative to the order of magnitude of the metric
self.config['TOL2'] = self.config['data_ball'] * 1e-15
# self.config['proxoperators']
self.algorithm = getattr(Algorithms, self.config['algorithm'])(self.config)#, self.back_end)
self.algorithm = getattr(Algorithms, self.config['algorithm'])(self.config)
def _presolve(self):
"""
......@@ -175,7 +175,7 @@ class Phase(Problem):
print("Calculation time:")
print(self.elapsed_time)
_graphics = getattr(Graphics, self.config['graphics_display'])
self.output_plots = _graphics(self.config, self.output)
self.output['plots'] = _graphics(self.config, self.output)
def save(self, save_dir=None):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment