From da2b2f855b2002358b94e6533fdf19f5d2dad6dc Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Tue, 22 Mar 2022 19:57:21 +0100 Subject: [PATCH 01/57] Change plotting method to allow for multiple diffractograms --- beamtime/plotting.py | 11 ++++++ beamtime/xrd/io.py | 77 ++++++++++++++++++++++----------------- beamtime/xrd/plot.py | 87 +++++++++++++++++++++++++++++++++++--------- 3 files changed, 124 insertions(+), 51 deletions(-) diff --git a/beamtime/plotting.py b/beamtime/plotting.py index 3430a2a..dd9a481 100644 --- a/beamtime/plotting.py +++ b/beamtime/plotting.py @@ -313,6 +313,17 @@ def update_widgets(options): if widget['state'] != options['x_vals']: for arg in widget[f'{options["x_vals"]}_default']: + + # If new min value is larger than previous max, or new max value is smaller than previous min, set the opposite first + if arg == 'min': + if widget[f'{options["x_vals"]}_default']['min'] > getattr(widget['w'], 'max'): + setattr(widget['w'], 'max', widget[f'{options["x_vals"]}_default']['max']) + + elif arg == 'max': + if widget[f'{options["x_vals"]}_default']['max'] < getattr(widget['w'], 'min'): + setattr(widget['w'], 'min', widget[f'{options["x_vals"]}_default']['min']) + + setattr(widget['w'], arg, widget[f'{options["x_vals"]}_default'][arg]) widget['state'] = options['x_vals'] diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index 6b0bb7a..3e29b80 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -27,7 +27,7 @@ def get_image_headers(path): return image.header -def integrate_1d(data, options={}): +def integrate_1d(data, options={}, index=0): ''' Integrates an image file to a 1D diffractogram. Required content of data: @@ -51,11 +51,14 @@ def integrate_1d(data, options={}): 'overwrite': False} options = aux.update_options(options=options, required_options=required_options, default_options=default_options) + + if not isinstance(data['path'], list): + data['path'] = [data['path']] # Get image array from filename if not passed if 'image' not in data.keys(): - data['image'] = get_image_array(data['path']) + data['image'] = get_image_array(data['path'][index]) # Instanciate the azimuthal integrator from pyFAI from the calibrant (.poni-file) ai = pyFAI.load(data['calibrant']) @@ -70,18 +73,18 @@ def integrate_1d(data, options={}): res = ai.integrate1d(data['image'], data['nbins'], unit=options['unit'], filename=filename) - data['path'] = filename - diffractogram = read_xy(data=data, options=options) + data['path'][index] = filename + diffractogram, wavelength = read_xy(data=data, options=options) if not options['save']: os.remove(filename) shutil.rmtree('tmp') - return diffractogram + return diffractogram, wavelength -def make_filename(data, options): +def make_filename(options, path=None): # Define save location for integrated diffractogram data if not options['save']: @@ -93,7 +96,7 @@ def make_filename(data, options): # Case 1: No filename is given. if not options['save_filename']: # If a path is given instead of an image array, the path is taken as the trunk of the savename - if data['path']: + if path: # Make filename by joining the save_folder, the filename (with extension deleted) and adding the save_extension filename = os.path.join(options['save_folder'], os.path.split(data['path'])[-1].split('.')[0] + options['save_extension']) else: @@ -176,12 +179,12 @@ def view_integrator(calibrant): -def read_brml(data, options={}): +def read_brml(data, options={}, index=0): required_options = ['extract_folder', 'save_folder'] default_options = { - 'extract_folder': 'tmp', + 'extract_folder': 'tmp/', 'save_folder': None } @@ -194,7 +197,7 @@ def read_brml(data, options={}): # Extract the RawData0.xml file from the brml-file - with zipfile.ZipFile(data['path'], 'r') as brml: + with zipfile.ZipFile(data['path'][index], 'r') as brml: for info in brml.infolist(): if "RawData" in info.filename: brml.extract(info.filename, options['extract_folder']) @@ -233,9 +236,10 @@ def read_brml(data, options={}): diffractogram.append({'2th': twotheta, 'I': intensity}) - if 'wavelength' not in data.keys(): - for chain in root.findall('./FixedInformation/Instrument/PrimaryTracks/TrackInfoData/MountedOptics/InfoData/Tube/WaveLengthAlpha1'): - data['wavelength'] = float(chain.attrib['Value']) + #if 'wavelength' not in data.keys(): + # Find wavelength + for chain in root.findall('./FixedInformation/Instrument/PrimaryTracks/TrackInfoData/MountedOptics/InfoData/Tube/WaveLengthAlpha1'): + wavelength = float(chain.attrib['Value']) diffractogram = pd.DataFrame(diffractogram) @@ -249,15 +253,16 @@ def read_brml(data, options={}): - return diffractogram + return diffractogram, wavelength -def read_xy(data, options={}): +def read_xy(data, options={}, index=0): - if 'wavelength' not in data.keys(): - find_wavelength_from_xy(data=data) + #if 'wavelength' not in data.keys(): + # Get wavelength from scan + wavelength = find_wavelength_from_xy(path=data['path'][index]) - with open(data['path'], 'r') as f: + with open(data['path'][index], 'r') as f: position = 0 current_line = f.readline() @@ -276,37 +281,37 @@ def read_xy(data, options={}): diffractogram.columns = ['2th', 'I', 'sigma'] - return diffractogram + return diffractogram, wavelength -def read_data(data, options={}): +def read_data(data, options={}, index=0): beamline_extensions = ['mar3450', 'edf', 'cbf'] - file_extension = data['path'].split('.')[-1] + file_extension = data['path'][index].split('.')[-1] if file_extension in beamline_extensions: - diffractogram = integrate_1d(data=data, options=options) + diffractogram, wavelength = integrate_1d(data=data, options=options, index=index) elif file_extension == 'brml': - diffractogram = read_brml(data=data, options=options) + diffractogram, wavelength = read_brml(data=data, options=options, index=index) elif file_extension in['xy', 'xye']: - diffractogram = read_xy(data=data, options=options) + diffractogram, wavelength = read_xy(data=data, options=options, index=index) - diffractogram = translate_wavelengths(data=diffractogram, wavelength=data['wavelength']) + diffractogram = translate_wavelengths(data=diffractogram, wavelength=wavelength) - return diffractogram + return diffractogram, wavelength def load_reflection_table(data, options={}): - required_options = ['wavelength', 'to_wavelength'] + required_options = ['ref_wavelength', 'to_wavelength'] default_options = { - 'wavelength': 1.54059, + 'ref_wavelength': 1.54059, 'to_wavelength': None } @@ -333,7 +338,7 @@ def load_reflection_table(data, options={}): # Set the new modified headers as the headers of reflections.columns = headers - reflections = translate_wavelengths(data=reflections, wavelength=options['wavelength'], to_wavelength=options['to_wavelength']) + reflections = translate_wavelengths(data=reflections, wavelength=options['ref_wavelength'], to_wavelength=options['to_wavelength']) #print(reflections) @@ -378,6 +383,7 @@ def translate_wavelengths(data, wavelength, to_wavelength=None): if to_wavelength: + if to_wavelength > cuka: max_2th = 2*np.arcsin(cuka/to_wavelength) * 180/np.pi @@ -395,19 +401,24 @@ def translate_wavelengths(data, wavelength, to_wavelength=None): -def find_wavelength_from_xy(data): +def find_wavelength_from_xy(path): wavelength_dict = {'Cu': 1.54059, 'Mo': 0.71073} - with open(data['path'], 'r') as f: + with open(path, 'r') as f: lines = f.readlines() for line in lines: + # For .xy-files output from EVA if 'Anode' in line: anode = line.split()[8].strip('"') - data['wavelength'] = wavelength_dict[anode] + wavelength = wavelength_dict[anode] + # For .xy-files output from pyFAI integration elif 'Wavelength' in line: - data['wavelength'] = float(line.split()[2])*10**10 + wavelength = float(line.split()[2])*10**10 + + + return wavelength diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index daa7eaf..cec2d1e 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -43,12 +43,25 @@ def plot_diffractogram(data, options={}): options = aux.update_options(options=options, required_options=required_options, default_options=default_options) + # Convert data['path'] to list to allow iteration over this to accommodate both single and multiple diffractograms + if not isinstance(data['path'], list): + data['path'] = [data['path']] + + if not 'diffractogram' in data.keys(): - diffractogram = xrd.io.read_data(data=data, options=options) - data['diffractogram'] = diffractogram + # Initialise empty list for diffractograms and wavelengths + data['diffractogram'] = [None for _ in range(len(data['path']))] + data['wavelength'] = [None for _ in range(len(data['path']))] + + for index in range(len(data['path'])): + diffractogram, wavelength = xrd.io.read_data(data=data, options=options, index=index) + data['diffractogram'][index] = diffractogram + data['wavelength'][index] = wavelength else: - diffractogram = data['diffractogram'] + if not isinstance(data['diffractogram'], list): + data['diffractogram'] = [data['diffractogram']] + data['wavelength'] = [data['wavelength']] # Sets the xlim if this has not bee specified if not options['xlim']: @@ -95,11 +108,12 @@ def plot_diffractogram(data, options={}): colours = btp.generate_colours(options['palettes']) - if options['line']: - diffractogram.plot(x=options['x_vals'], y=options['y_vals'], ax=ax, c=next(colours), zorder=1) + for diffractogram in data['diffractogram']: + if options['line']: + diffractogram.plot(x=options['x_vals'], y=options['y_vals'], ax=ax, c=next(colours), zorder=1) - if options['scatter']: - ax.scatter(x=diffractogram[options['x_vals']], y = diffractogram[options['y_vals']], c=[(1,1,1,0)], edgecolors=[next(colours)], linewidths=plt.rcParams['lines.markeredgewidth'], zorder=2) #, edgecolors=np.array([next(colours)])) + if options['scatter']: + ax.scatter(x=diffractogram[options['x_vals']], y = diffractogram[options['y_vals']], c=[(1,1,1,0)], edgecolors=[next(colours)], linewidths=plt.rcParams['lines.markeredgewidth'], zorder=2) #, edgecolors=np.array([next(colours)])) @@ -110,7 +124,7 @@ def plot_diffractogram(data, options={}): # Make the reflection plots if options['reflections_plot'] and options['reflections_data']: options['xlim'] = ax.get_xlim() - options['to_wavelength'] = data['wavelength'] + options['to_wavelength'] = data['wavelength'][0] for reference, axis in zip(options['reflections_data'], ref_axes): plot_reflection_table(data=reference, ax=axis, options=options) @@ -118,7 +132,7 @@ def plot_diffractogram(data, options={}): # Print the reflection indices if options['reflections_indices'] and options['reflections_data']: options['xlim'] = ax.get_xlim() - options['to_wavelength'] = data['wavelength'] + options['to_wavelength'] = data['wavelength'][0] for reference in options['reflections_data']: plot_reflection_indices(data=reference, ax=indices_ax, options=options) @@ -149,17 +163,54 @@ def determine_grid_layout(options): def plot_diffractogram_interactive(data, options): + + minmax = {'2th': [None, None], '2th_cuka': [None, None], '2th_moka': [None, None], 'd': [None, None], '1/d': [None, None], 'q': [None, None], 'q2': [None, None], 'q4': [None, None]} + + for index, diffractogram in enumerate(data['diffractogram']): + if not minmax['2th'][0] or diffractogram['2th'].min() < minmax['2th'][0]: + minmax['2th'][0] = diffractogram['2th'].min() + min_index = index + + if not minmax['2th'][1] or diffractogram['2th'].max() > minmax['2th'][1]: + minmax['2th'][1] = diffractogram['2th'].max() + max_index = index + + minmax['2th_cuka'][0], minmax['2th_cuka'][1] = data['diffractogram'][min_index]['2th_cuka'].min(), data['diffractogram'][max_index]['2th_cuka'].max() + minmax['2th_moka'][0], minmax['2th_moka'][1] = data['diffractogram'][min_index]['2th_moka'].min(), data['diffractogram'][max_index]['2th_moka'].max() + minmax['d'][0], minmax['d'][1] = data['diffractogram'][max_index]['d'].min(), data['diffractogram'][min_index]['d'].max() + minmax['1/d'][0], minmax['1/d'][1] = data['diffractogram'][min_index]['1/d'].min(), data['diffractogram'][max_index]['1/d'].max() + minmax['q'][0], minmax['q'][1] = data['diffractogram'][min_index]['q'].min(), data['diffractogram'][max_index]['q'].max() + minmax['q2'][0], minmax['q2'][1] = data['diffractogram'][min_index]['q2'].min(), data['diffractogram'][max_index]['q2'].max() + minmax['q4'][0], minmax['q4'][1] = data['diffractogram'][min_index]['q4'].min(), data['diffractogram'][max_index]['q4'].max() + + + + # options['widgets'] = { + # 'xlim': { + # 'w': widgets.FloatRangeSlider(value=[data['diffractogram']['2th'].min(), data['diffractogram']['2th'].max()], min=data['diffractogram']['2th'].min(), max=data['diffractogram']['2th'].max(), step=0.5, layout=widgets.Layout(width='95%')), + # '2th_default': {'min': data['diffractogram']['2th'].min(), 'max': data['diffractogram']['2th'].max(), 'value': [data['diffractogram']['2th'].min(), data['diffractogram']['2th'].max()], 'step': 0.5}, + # '2th_cuka_default': {'min': data['diffractogram']['2th_cuka'].min(), 'max': data['diffractogram']['2th_cuka'].max(), 'value': [data['diffractogram']['2th_cuka'].min(), data['diffractogram']['2th_cuka'].max()], 'step': 0.5}, + # '2th_moka_default': {'min': data['diffractogram']['2th_moka'].min(), 'max': data['diffractogram']['2th_moka'].max(), 'value': [data['diffractogram']['2th_moka'].min(), data['diffractogram']['2th_moka'].max()], 'step': 0.5}, + # 'd_default': {'min': data['diffractogram']['d'].min(), 'max': data['diffractogram']['d'].max(), 'value': [data['diffractogram']['d'].min(), data['diffractogram']['d'].max()], 'step': 0.5}, + # '1/d_default': {'min': data['diffractogram']['1/d'].min(), 'max': data['diffractogram']['1/d'].max(), 'value': [data['diffractogram']['1/d'].min(), data['diffractogram']['1/d'].max()], 'step': 0.5}, + # 'q_default': {'min': data['diffractogram']['q'].min(), 'max': data['diffractogram']['q'].max(), 'value': [data['diffractogram']['q'].min(), data['diffractogram']['q'].max()], 'step': 0.5}, + # 'q2_default': {'min': data['diffractogram']['q2'].min(), 'max': data['diffractogram']['q2'].max(), 'value': [data['diffractogram']['q2'].min(), data['diffractogram']['q2'].max()], 'step': 0.5}, + # 'q4_default': {'min': data['diffractogram']['q4'].min(), 'max': data['diffractogram']['q4'].max(), 'value': [data['diffractogram']['q4'].min(), data['diffractogram']['q4'].max()], 'step': 0.5}, + # 'state': '2th' + # } + # } + options['widgets'] = { 'xlim': { - 'w': widgets.FloatRangeSlider(value=[data['diffractogram']['2th'].min(), data['diffractogram']['2th'].max()], min=data['diffractogram']['2th'].min(), max=data['diffractogram']['2th'].max(), step=0.5, layout=widgets.Layout(width='95%')), - '2th_default': {'min': data['diffractogram']['2th'].min(), 'max': data['diffractogram']['2th'].max(), 'value': [data['diffractogram']['2th'].min(), data['diffractogram']['2th'].max()], 'step': 0.5}, - '2th_cuka_default': {'min': data['diffractogram']['2th_cuka'].min(), 'max': data['diffractogram']['2th_cuka'].max(), 'value': [data['diffractogram']['2th_cuka'].min(), data['diffractogram']['2th_cuka'].max()], 'step': 0.5}, - '2th_moka_default': {'min': data['diffractogram']['2th_moka'].min(), 'max': data['diffractogram']['2th_moka'].max(), 'value': [data['diffractogram']['2th_moka'].min(), data['diffractogram']['2th_moka'].max()], 'step': 0.5}, - 'd_default': {'min': data['diffractogram']['d'].min(), 'max': data['diffractogram']['d'].max(), 'value': [data['diffractogram']['d'].min(), data['diffractogram']['d'].max()], 'step': 0.5}, - '1/d_default': {'min': data['diffractogram']['1/d'].min(), 'max': data['diffractogram']['1/d'].max(), 'value': [data['diffractogram']['1/d'].min(), data['diffractogram']['1/d'].max()], 'step': 0.5}, - 'q_default': {'min': data['diffractogram']['q'].min(), 'max': data['diffractogram']['q'].max(), 'value': [data['diffractogram']['q'].min(), data['diffractogram']['q'].max()], 'step': 0.5}, - 'q2_default': {'min': data['diffractogram']['q2'].min(), 'max': data['diffractogram']['q2'].max(), 'value': [data['diffractogram']['q2'].min(), data['diffractogram']['q2'].max()], 'step': 0.5}, - 'q4_default': {'min': data['diffractogram']['q4'].min(), 'max': data['diffractogram']['q4'].max(), 'value': [data['diffractogram']['q4'].min(), data['diffractogram']['q4'].max()], 'step': 0.5}, + 'w': widgets.FloatRangeSlider(value=[minmax['2th'][0], minmax['2th'][1]], min=minmax['2th'][0], max=minmax['2th'][1], step=0.5, layout=widgets.Layout(width='95%')), + '2th_default': {'min': minmax['2th'][0], 'max': minmax['2th'][1], 'value': [minmax['2th'][0], minmax['2th'][1]], 'step': 0.5}, + '2th_cuka_default': {'min': minmax['2th_cuka'][0], 'max': minmax['2th_cuka'][1], 'value': [minmax['2th_cuka'][0], minmax['2th_cuka'][1]], 'step': 0.5}, + '2th_moka_default': {'min': minmax['2th_moka'][0], 'max': minmax['2th_moka'][1], 'value': [minmax['2th_moka'][0], minmax['2th_moka'][1]], 'step': 0.5}, + 'd_default': {'min': minmax['d'][0], 'max': minmax['d'][1], 'value': [minmax['d'][0], minmax['d'][1]], 'step': 0.5}, + '1/d_default': {'min': minmax['1/d'][0], 'max': minmax['1/d'][1], 'value': [minmax['1/d'][0], minmax['1/d'][1]], 'step': 0.5}, + 'q_default': {'min': minmax['q'][0], 'max': minmax['q'][1], 'value': [minmax['q'][0], minmax['q'][1]], 'step': 0.5}, + 'q2_default': {'min': minmax['q2'][0], 'max': minmax['q2'][1], 'value': [minmax['q2'][0], minmax['q2'][1]], 'step': 0.5}, + 'q4_default': {'min': minmax['q4'][0], 'max': minmax['q4'][1], 'value': [minmax['q4'][0], minmax['q4'][1]], 'step': 0.5}, 'state': '2th' } } From f26153757a9527449d6e082d72bcd25141328af4 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Tue, 22 Mar 2022 20:03:23 +0100 Subject: [PATCH 02/57] testing this branching stuff --- beamtime/test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 beamtime/test.txt diff --git a/beamtime/test.txt b/beamtime/test.txt new file mode 100644 index 0000000..30a1328 --- /dev/null +++ b/beamtime/test.txt @@ -0,0 +1 @@ +something something test From b2ee68859a93b41a3d0b85f1bc203896ccadaeb2 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Tue, 22 Mar 2022 20:08:11 +0100 Subject: [PATCH 03/57] removing test-file --- beamtime/test.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 beamtime/test.txt diff --git a/beamtime/test.txt b/beamtime/test.txt deleted file mode 100644 index 30a1328..0000000 --- a/beamtime/test.txt +++ /dev/null @@ -1 +0,0 @@ -something something test From 86a2ae2379dfcc71e5761a215b4ba2179a7b96e6 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Tue, 22 Mar 2022 20:25:53 +0100 Subject: [PATCH 04/57] Fix bug to iterate correctly through filenames --- beamtime/xrd/io.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index 3e29b80..16991a2 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -40,10 +40,11 @@ def integrate_1d(data, options={}, index=0): df: DataFrame contianing 1D diffractogram if option 'return' is True ''' - required_options = ['unit', 'save', 'save_filename', 'save_extension', 'save_folder', 'overwrite'] + required_options = ['unit', 'nbins', 'save', 'save_filename', 'save_extension', 'save_folder', 'overwrite'] default_options = { 'unit': '2th_deg', + 'nbins': 3000, 'save': False, 'save_filename': None, 'save_extension': '_integrated.xy', @@ -64,17 +65,17 @@ def integrate_1d(data, options={}, index=0): ai = pyFAI.load(data['calibrant']) # Determine filename - filename = make_filename(data=data, options=options) + filename = make_filename(options=options, path=data['path'][index]) # Make save_folder if this does not exist already if not os.path.isdir(options['save_folder']): os.makedirs(options['save_folder']) - res = ai.integrate1d(data['image'], data['nbins'], unit=options['unit'], filename=filename) + res = ai.integrate1d(data['image'], options['nbins'], unit=options['unit'], filename=filename) data['path'][index] = filename - diffractogram, wavelength = read_xy(data=data, options=options) + diffractogram, wavelength = read_xy(data=data, options=options, index=index) if not options['save']: os.remove(filename) @@ -98,7 +99,7 @@ def make_filename(options, path=None): # If a path is given instead of an image array, the path is taken as the trunk of the savename if path: # Make filename by joining the save_folder, the filename (with extension deleted) and adding the save_extension - filename = os.path.join(options['save_folder'], os.path.split(data['path'])[-1].split('.')[0] + options['save_extension']) + filename = os.path.join(options['save_folder'], os.path.split(path)[-1].split('.')[0] + options['save_extension']) else: # Make filename just "integrated.dat" in the save_folder filename = os.path.join(options['save_folder'], 'integrated.xy') @@ -403,6 +404,8 @@ def translate_wavelengths(data, wavelength, to_wavelength=None): def find_wavelength_from_xy(path): + print(path) + wavelength_dict = {'Cu': 1.54059, 'Mo': 0.71073} From d31adb9585e95400191d79ca0b2fa5ef441fe969 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Tue, 22 Mar 2022 20:26:38 +0100 Subject: [PATCH 05/57] Add feature list --- beamtime/feature_list.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 beamtime/feature_list.txt diff --git a/beamtime/feature_list.txt b/beamtime/feature_list.txt new file mode 100644 index 0000000..f4a0efd --- /dev/null +++ b/beamtime/feature_list.txt @@ -0,0 +1,2 @@ +- Must allow for automatic normalisation between different diffractograms, must only happen upon reading data +- From 06753ab6b2d0f685e21929f63dbb762b2008690a Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 23 Mar 2022 14:20:19 +0100 Subject: [PATCH 06/57] Move minmax-determiniation to own function --- beamtime/xrd/plot.py | 61 +++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index cec2d1e..173da03 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -166,43 +166,12 @@ def plot_diffractogram_interactive(data, options): minmax = {'2th': [None, None], '2th_cuka': [None, None], '2th_moka': [None, None], 'd': [None, None], '1/d': [None, None], 'q': [None, None], 'q2': [None, None], 'q4': [None, None]} - for index, diffractogram in enumerate(data['diffractogram']): - if not minmax['2th'][0] or diffractogram['2th'].min() < minmax['2th'][0]: - minmax['2th'][0] = diffractogram['2th'].min() - min_index = index - - if not minmax['2th'][1] or diffractogram['2th'].max() > minmax['2th'][1]: - minmax['2th'][1] = diffractogram['2th'].max() - max_index = index - - minmax['2th_cuka'][0], minmax['2th_cuka'][1] = data['diffractogram'][min_index]['2th_cuka'].min(), data['diffractogram'][max_index]['2th_cuka'].max() - minmax['2th_moka'][0], minmax['2th_moka'][1] = data['diffractogram'][min_index]['2th_moka'].min(), data['diffractogram'][max_index]['2th_moka'].max() - minmax['d'][0], minmax['d'][1] = data['diffractogram'][max_index]['d'].min(), data['diffractogram'][min_index]['d'].max() - minmax['1/d'][0], minmax['1/d'][1] = data['diffractogram'][min_index]['1/d'].min(), data['diffractogram'][max_index]['1/d'].max() - minmax['q'][0], minmax['q'][1] = data['diffractogram'][min_index]['q'].min(), data['diffractogram'][max_index]['q'].max() - minmax['q2'][0], minmax['q2'][1] = data['diffractogram'][min_index]['q2'].min(), data['diffractogram'][max_index]['q2'].max() - minmax['q4'][0], minmax['q4'][1] = data['diffractogram'][min_index]['q4'].min(), data['diffractogram'][max_index]['q4'].max() - - - - # options['widgets'] = { - # 'xlim': { - # 'w': widgets.FloatRangeSlider(value=[data['diffractogram']['2th'].min(), data['diffractogram']['2th'].max()], min=data['diffractogram']['2th'].min(), max=data['diffractogram']['2th'].max(), step=0.5, layout=widgets.Layout(width='95%')), - # '2th_default': {'min': data['diffractogram']['2th'].min(), 'max': data['diffractogram']['2th'].max(), 'value': [data['diffractogram']['2th'].min(), data['diffractogram']['2th'].max()], 'step': 0.5}, - # '2th_cuka_default': {'min': data['diffractogram']['2th_cuka'].min(), 'max': data['diffractogram']['2th_cuka'].max(), 'value': [data['diffractogram']['2th_cuka'].min(), data['diffractogram']['2th_cuka'].max()], 'step': 0.5}, - # '2th_moka_default': {'min': data['diffractogram']['2th_moka'].min(), 'max': data['diffractogram']['2th_moka'].max(), 'value': [data['diffractogram']['2th_moka'].min(), data['diffractogram']['2th_moka'].max()], 'step': 0.5}, - # 'd_default': {'min': data['diffractogram']['d'].min(), 'max': data['diffractogram']['d'].max(), 'value': [data['diffractogram']['d'].min(), data['diffractogram']['d'].max()], 'step': 0.5}, - # '1/d_default': {'min': data['diffractogram']['1/d'].min(), 'max': data['diffractogram']['1/d'].max(), 'value': [data['diffractogram']['1/d'].min(), data['diffractogram']['1/d'].max()], 'step': 0.5}, - # 'q_default': {'min': data['diffractogram']['q'].min(), 'max': data['diffractogram']['q'].max(), 'value': [data['diffractogram']['q'].min(), data['diffractogram']['q'].max()], 'step': 0.5}, - # 'q2_default': {'min': data['diffractogram']['q2'].min(), 'max': data['diffractogram']['q2'].max(), 'value': [data['diffractogram']['q2'].min(), data['diffractogram']['q2'].max()], 'step': 0.5}, - # 'q4_default': {'min': data['diffractogram']['q4'].min(), 'max': data['diffractogram']['q4'].max(), 'value': [data['diffractogram']['q4'].min(), data['diffractogram']['q4'].max()], 'step': 0.5}, - # 'state': '2th' - # } - # } + update_minmax(minmax, data) options['widgets'] = { 'xlim': { 'w': widgets.FloatRangeSlider(value=[minmax['2th'][0], minmax['2th'][1]], min=minmax['2th'][0], max=minmax['2th'][1], step=0.5, layout=widgets.Layout(width='95%')), + 'state': '2th', '2th_default': {'min': minmax['2th'][0], 'max': minmax['2th'][1], 'value': [minmax['2th'][0], minmax['2th'][1]], 'step': 0.5}, '2th_cuka_default': {'min': minmax['2th_cuka'][0], 'max': minmax['2th_cuka'][1], 'value': [minmax['2th_cuka'][0], minmax['2th_cuka'][1]], 'step': 0.5}, '2th_moka_default': {'min': minmax['2th_moka'][0], 'max': minmax['2th_moka'][1], 'value': [minmax['2th_moka'][0], minmax['2th_moka'][1]], 'step': 0.5}, @@ -210,8 +179,7 @@ def plot_diffractogram_interactive(data, options): '1/d_default': {'min': minmax['1/d'][0], 'max': minmax['1/d'][1], 'value': [minmax['1/d'][0], minmax['1/d'][1]], 'step': 0.5}, 'q_default': {'min': minmax['q'][0], 'max': minmax['q'][1], 'value': [minmax['q'][0], minmax['q'][1]], 'step': 0.5}, 'q2_default': {'min': minmax['q2'][0], 'max': minmax['q2'][1], 'value': [minmax['q2'][0], minmax['q2'][1]], 'step': 0.5}, - 'q4_default': {'min': minmax['q4'][0], 'max': minmax['q4'][1], 'value': [minmax['q4'][0], minmax['q4'][1]], 'step': 0.5}, - 'state': '2th' + 'q4_default': {'min': minmax['q4'][0], 'max': minmax['q4'][1], 'value': [minmax['q4'][0], minmax['q4'][1]], 'step': 0.5} } } @@ -235,6 +203,29 @@ def plot_diffractogram_interactive(data, options): display(w) +def update_minmax(minmax, data): + ''' Finds minimum and maximum values of each column and updates the minmax dictionary to contain the correct values. + + Input: + minmax (dict): contains ''' + + for index, diffractogram in enumerate(data['diffractogram']): + if not minmax['2th'][0] or diffractogram['2th'].min() < minmax['2th'][0]: + minmax['2th'][0] = diffractogram['2th'].min() + min_index = index + + if not minmax['2th'][1] or diffractogram['2th'].max() > minmax['2th'][1]: + minmax['2th'][1] = diffractogram['2th'].max() + max_index = index + + minmax['2th_cuka'][0], minmax['2th_cuka'][1] = data['diffractogram'][min_index]['2th_cuka'].min(), data['diffractogram'][max_index]['2th_cuka'].max() + minmax['2th_moka'][0], minmax['2th_moka'][1] = data['diffractogram'][min_index]['2th_moka'].min(), data['diffractogram'][max_index]['2th_moka'].max() + minmax['d'][0], minmax['d'][1] = data['diffractogram'][max_index]['d'].min(), data['diffractogram'][min_index]['d'].max() # swapped, intended + minmax['1/d'][0], minmax['1/d'][1] = data['diffractogram'][min_index]['1/d'].min(), data['diffractogram'][max_index]['1/d'].max() + minmax['q'][0], minmax['q'][1] = data['diffractogram'][min_index]['q'].min(), data['diffractogram'][max_index]['q'].max() + minmax['q2'][0], minmax['q2'][1] = data['diffractogram'][min_index]['q2'].min(), data['diffractogram'][max_index]['q2'].max() + minmax['q4'][0], minmax['q4'][1] = data['diffractogram'][min_index]['q4'].min(), data['diffractogram'][max_index]['q4'].max() + def update_widgets(options): for widget in options['widgets'].values(): From 0fb8883d198ac6d57ac9a6dde3f2a6ed32084731 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 23 Mar 2022 14:26:43 +0100 Subject: [PATCH 07/57] Add normalisation of diffractograms (default: True= --- beamtime/xrd/io.py | 4 ++++ beamtime/xrd/plot.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index 16991a2..fc05654 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -300,6 +300,10 @@ def read_data(data, options={}, index=0): diffractogram, wavelength = read_xy(data=data, options=options, index=index) + if options['normalise']: + diffractogram['I'] = diffractogram['I'] / diffractogram['I'].max() + + diffractogram = translate_wavelengths(data=diffractogram, wavelength=wavelength) return diffractogram, wavelength diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index 173da03..d196f2c 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -19,7 +19,7 @@ def plot_diffractogram(data, options={}): data (dict): Must include path = string to diffractogram data, and plot_kind = (recx, beamline, image)''' # Update options - required_options = ['x_vals', 'y_vals', 'ylabel', 'xlabel', 'xunit', 'yunit', 'line', 'scatter', 'xlim', 'ylim', + required_options = ['x_vals', 'y_vals', 'ylabel', 'xlabel', 'xunit', 'yunit', 'line', 'scatter', 'xlim', 'ylim', 'normalise', 'reflections_plot', 'reflections_indices', 'reflections_data', 'plot_kind', 'palettes', 'interactive', 'rc_params', 'format_params'] default_options = { @@ -28,6 +28,7 @@ def plot_diffractogram(data, options={}): 'ylabel': 'Intensity', 'xlabel': '2theta', 'xunit': 'deg', 'yunit': 'a.u.', 'xlim': None, 'ylim': None, + 'normalise': True, 'line': True, # whether or not to plot diffractogram as a line plot 'scatter': False, # whether or not to plot individual data points 'reflections_plot': False, # whether to plot reflections as a plot @@ -55,9 +56,12 @@ def plot_diffractogram(data, options={}): for index in range(len(data['path'])): diffractogram, wavelength = xrd.io.read_data(data=data, options=options, index=index) + data['diffractogram'][index] = diffractogram data['wavelength'][index] = wavelength + + else: if not isinstance(data['diffractogram'], list): data['diffractogram'] = [data['diffractogram']] From 2424d89156adc085a4fb5c2a82ee632469ccbedf Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 23 Mar 2022 15:31:47 +0100 Subject: [PATCH 08/57] Add offset of x- and y-values for stacked diffractograms --- beamtime/xrd/io.py | 50 +++++++++++++++++++++++++++++++++++++------- beamtime/xrd/plot.py | 14 ++++++++----- 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index fc05654..263eaae 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -45,6 +45,7 @@ def integrate_1d(data, options={}, index=0): default_options = { 'unit': '2th_deg', 'nbins': 3000, + 'extract_folder': 'tmp', 'save': False, 'save_filename': None, 'save_extension': '_integrated.xy', @@ -68,8 +69,8 @@ def integrate_1d(data, options={}, index=0): filename = make_filename(options=options, path=data['path'][index]) # Make save_folder if this does not exist already - if not os.path.isdir(options['save_folder']): - os.makedirs(options['save_folder']) + if not os.path.isdir(options['extract_folder']): + os.makedirs(options['extract_folder']) res = ai.integrate1d(data['image'], options['nbins'], unit=options['unit'], filename=filename) @@ -79,7 +80,11 @@ def integrate_1d(data, options={}, index=0): if not options['save']: os.remove(filename) - shutil.rmtree('tmp') + shutil.rmtree(f'tmp') + + + # Reset this option + options['save_folder'] = None return diffractogram, wavelength @@ -89,8 +94,7 @@ def make_filename(options, path=None): # Define save location for integrated diffractogram data if not options['save']: - options['save_folder'] = 'tmp' - filename = os.path.join(options['save_folder'], 'tmp_diff.dat') + filename = os.path.join(options['extract_folder'], 'tmp_diff.dat') elif options['save']: @@ -183,9 +187,12 @@ def view_integrator(calibrant): def read_brml(data, options={}, index=0): + # FIXME: Can't read RECX1-data, apparently must be formatted differently from RECX2. Check the RawData-files and compare between the two files. + + required_options = ['extract_folder', 'save_folder'] default_options = { - 'extract_folder': 'tmp/', + 'extract_folder': 'tmp', 'save_folder': None } @@ -304,12 +311,41 @@ def read_data(data, options={}, index=0): diffractogram['I'] = diffractogram['I'] / diffractogram['I'].max() + if options['offset']: + diffractogram = apply_offset(diffractogram, wavelength, index, options) + + diffractogram = translate_wavelengths(data=diffractogram, wavelength=wavelength) return diffractogram, wavelength - +def apply_offset(diffractogram, wavelength, index, options): + #Apply offset along y-axis + diffractogram['I_org'] = diffractogram['I'] # make copy of original intensities + diffractogram['I'] = diffractogram['I'] + index*options['offset_y'] + + # Apply offset along x-axis + relative_shift = (wavelength / 1.54059)*options['offset_x'] # Adjusts the offset-factor to account for wavelength, so that offset_x given is given in 2th_cuka-units + diffractogram['2th_org'] = diffractogram['2th'] + diffractogram['2th'] = diffractogram['2th'] + index*relative_shift + + + return diffractogram + +def revert_offset(diffractogram,which=None): + + if which == 'both': + diffractogram['2th'] = diffractogram['2th_org'] + diffractogram['I'] = diffractogram['I_org'] + + if which == 'y': + diffractogram['I'] = diffractogram['I_org'] + + if which == 'x': + diffractogram['2th'] = diffractogram['2th_org'] + + return diffractogram def load_reflection_table(data, options={}): diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index d196f2c..17ad70b 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -19,7 +19,7 @@ def plot_diffractogram(data, options={}): data (dict): Must include path = string to diffractogram data, and plot_kind = (recx, beamline, image)''' # Update options - required_options = ['x_vals', 'y_vals', 'ylabel', 'xlabel', 'xunit', 'yunit', 'line', 'scatter', 'xlim', 'ylim', 'normalise', + required_options = ['x_vals', 'y_vals', 'ylabel', 'xlabel', 'xunit', 'yunit', 'line', 'scatter', 'xlim', 'ylim', 'normalise', 'offset', 'offset_x', 'offset_y', 'reflections_plot', 'reflections_indices', 'reflections_data', 'plot_kind', 'palettes', 'interactive', 'rc_params', 'format_params'] default_options = { @@ -29,6 +29,9 @@ def plot_diffractogram(data, options={}): 'xunit': 'deg', 'yunit': 'a.u.', 'xlim': None, 'ylim': None, 'normalise': True, + 'offset': True, + 'offset_x': 0, + 'offset_y': 1, 'line': True, # whether or not to plot diffractogram as a line plot 'scatter': False, # whether or not to plot individual data points 'reflections_plot': False, # whether to plot reflections as a plot @@ -49,6 +52,8 @@ def plot_diffractogram(data, options={}): data['path'] = [data['path']] + + # Check if there is some data stored already, load in data if not. This speeds up replotting in interactive mode. if not 'diffractogram' in data.keys(): # Initialise empty list for diffractograms and wavelengths data['diffractogram'] = [None for _ in range(len(data['path']))] @@ -72,7 +77,7 @@ def plot_diffractogram(data, options={}): options['xlim'] = [diffractogram[options['x_vals']].min(), diffractogram[options['x_vals']].max()] - # Start inteactive session with ipywidgets + # Start inteactive session with ipywidgets. Disables options['interactive'] in order for the interactive loop to not start another interactive session if options['interactive']: options['interactive'] = False options['interactive_session_active'] = True @@ -91,7 +96,6 @@ def plot_diffractogram(data, options={}): # Prepare plot, and read and process data - fig, ax = btp.prepare_plot(options=options) @@ -125,7 +129,7 @@ def plot_diffractogram(data, options={}): - # Make the reflection plots + # Make the reflection plots. By default, the wavelength of the first diffractogram will be used for these. if options['reflections_plot'] and options['reflections_data']: options['xlim'] = ax.get_xlim() options['to_wavelength'] = data['wavelength'][0] @@ -133,7 +137,7 @@ def plot_diffractogram(data, options={}): for reference, axis in zip(options['reflections_data'], ref_axes): plot_reflection_table(data=reference, ax=axis, options=options) - # Print the reflection indices + # Print the reflection indices. By default, the wavelength of the first diffractogram will be used for this. if options['reflections_indices'] and options['reflections_data']: options['xlim'] = ax.get_xlim() options['to_wavelength'] = data['wavelength'][0] From 606bfc180d13e5a5df3436b3dc08c5368ac6b286 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 23 Mar 2022 16:03:34 +0100 Subject: [PATCH 09/57] Add first stab at ylim widget, should be improved --- beamtime/xrd/io.py | 6 +++--- beamtime/xrd/plot.py | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index 263eaae..612cc16 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -388,6 +388,8 @@ def load_reflection_table(data, options={}): def translate_wavelengths(data, wavelength, to_wavelength=None): + # FIXME Somewhere here there is an invalid arcsin-argument. Not sure where. + pd.options.mode.chained_assignment = None # Translate to CuKalpha @@ -424,9 +426,7 @@ def translate_wavelengths(data, wavelength, to_wavelength=None): if to_wavelength: - - - if to_wavelength > cuka: + if to_wavelength >= cuka: max_2th = 2*np.arcsin(cuka/to_wavelength) * 180/np.pi else: max_2th = data['2th_cuka'].max() diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index 17ad70b..770b5a8 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -176,6 +176,24 @@ def plot_diffractogram_interactive(data, options): update_minmax(minmax, data) + ymin, ymax = None, None + for index, diffractogram in enumerate(data['diffractogram']): + if not ymin or (ymin > (diffractogram['I'].min())): #+index*options['offset_y'])): + ymin = diffractogram['I'].min()#+index*options['offset_y'] + + if not ymax or (ymax < (diffractogram['I'].max())):#+index*options['offset_y'])): + ymax = diffractogram['I'].max()#+index*options['offset_y'] + print(ymax) + + + ymin_start = ymin - 0.1*ymax + ymax_start = ymax+0.2*ymax + ymin = ymin - 5*ymax + ymax = ymax*5 + + + + options['widgets'] = { 'xlim': { 'w': widgets.FloatRangeSlider(value=[minmax['2th'][0], minmax['2th'][1]], min=minmax['2th'][0], max=minmax['2th'][1], step=0.5, layout=widgets.Layout(width='95%')), @@ -199,7 +217,8 @@ def plot_diffractogram_interactive(data, options): reflections_plot=widgets.ToggleButton(value=True), reflections_indices=widgets.ToggleButton(value=False), x_vals=widgets.Dropdown(options=['2th', 'd', '1/d', 'q', 'q2', 'q4', '2th_cuka', '2th_moka'], value='2th', description='X-values'), - xlim=options['widgets']['xlim']['w']) + xlim=options['widgets']['xlim']['w'], + ylim=widgets.FloatRangeSlider(value=[ymin_start, ymax_start], min=ymin, max=ymax, step=0.5, layout=widgets.Layout(width='95%'))) else: w = widgets.interactive(btp.ipywidgets_update, func=widgets.fixed(plot_diffractogram), data=widgets.fixed(data), options=widgets.fixed(options), From 0fbfd20a74cebea5d14daaf207ff7ba51edae2b0 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 30 Mar 2022 16:11:34 +0200 Subject: [PATCH 10/57] Enable reading of CoupledTwoTheta-scans --- beamtime/xrd/io.py | 64 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index 612cc16..5aa2fb1 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -224,24 +224,56 @@ def read_brml(data, options={}, index=0): for chain in root.findall('./DataRoutes/DataRoute'): - for scantype in chain.findall('ScanInformation/ScanMode'): - if scantype.text == 'StillScan': - if chain.get('Description') == 'Originally measured data.': - for scandata in chain.findall('Datum'): - scandata = scandata.text.split(',') - scandata = [float(i) for i in scandata] - twotheta, intensity = float(scandata[2]), float(scandata[3]) + # Get the scan type to be able to handle different data formats + scantype = chain.findall('ScanInformation')[0].get('VisibleName') - - else: - if chain.get('Description') == 'Originally measured data.': - for scandata in chain.findall('Datum'): + # Check if the chain is the right one to extract the data from + if chain.get('Description') == 'Originally measured data.': + + + if scantype == 'TwoTheta': + for scandata in chain.findall('Datum'): + scandata = scandata.text.split(',') + twotheta, intensity = float(scandata[2]), float(scandata[3]) + + if twotheta > 0: + diffractogram.append({'2th': twotheta, 'I': intensity}) + + elif scantype == 'Coupled TwoTheta/Theta': + for scandata in chain.findall('Datum'): + scandata = scandata.text.split(',') + twotheta, intensity = float(scandata[2]), float(scandata[4]) + + if twotheta > 0: + diffractogram.append({'2th': twotheta, 'I': intensity}) + + elif scantype == 'Still (Eiger2R_500K (1D mode))': + + start = float(chain.findall('ScanInformation/ScaleAxes/ScaleAxisInfo/Start')[0].text) + stop = float(chain.findall('ScanInformation/ScaleAxes/ScaleAxisInfo/Stop')[0].text) + increment = float(chain.findall('ScanInformation/ScaleAxes/ScaleAxisInfo/Increment')[0].text) + + + + for scandata in chain.findall('Datum'): scandata = scandata.text.split(',') - twotheta, intensity = float(scandata[2]), float(scandata[3]) - - if twotheta > 0: - diffractogram.append({'2th': twotheta, 'I': intensity}) + raw = [float(i) for i in scandata] + + intensity = [] + for r in raw: + if r > 600: + intensity.append(r) + + intensity = np.array(intensity) + + + + + twotheta = np.linspace(start, stop, len(intensity)) + + diffractogram = {'2th': twotheta, 'I': intensity} + #if 'wavelength' not in data.keys(): @@ -249,7 +281,9 @@ def read_brml(data, options={}, index=0): for chain in root.findall('./FixedInformation/Instrument/PrimaryTracks/TrackInfoData/MountedOptics/InfoData/Tube/WaveLengthAlpha1'): wavelength = float(chain.attrib['Value']) + diffractogram = pd.DataFrame(diffractogram) + From 223be18c3e451b8be2a962bba126f44c9eab41db Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 30 Mar 2022 17:40:06 +0200 Subject: [PATCH 11/57] Change default behaviour with 10+ plots --- beamtime/plotting.py | 20 ++++++++++++-------- beamtime/xrd/io.py | 6 ++---- beamtime/xrd/plot.py | 13 ++++++++++--- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/beamtime/plotting.py b/beamtime/plotting.py index dd9a481..4e058ac 100644 --- a/beamtime/plotting.py +++ b/beamtime/plotting.py @@ -377,16 +377,20 @@ def update_rc_params(rc_params): plt.rcParams.update({key: rc_params[key]}) -def generate_colours(palettes): +def generate_colours(palettes, kind=None): - # Creates a list of all the colours that is passed in the colour_cycles argument. Then makes cyclic iterables of these. - colour_collection = [] - for palette in palettes: - mod = importlib.import_module("palettable.colorbrewer.%s" % palette[0]) - colour = getattr(mod, palette[1]).mpl_colors - colour_collection = colour_collection + colour + if kind == 'single': + colour_cycle = itertools.cycle(palettes) - colour_cycle = itertools.cycle(colour_collection) + else: + # Creates a list of all the colours that is passed in the colour_cycles argument. Then makes cyclic iterables of these. + colour_collection = [] + for palette in palettes: + mod = importlib.import_module("palettable.colorbrewer.%s" % palette[0]) + colour = getattr(mod, palette[1]).mpl_colors + colour_collection = colour_collection + colour + + colour_cycle = itertools.cycle(colour_collection) return colour_cycle \ No newline at end of file diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index 5aa2fb1..14c0f98 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -252,7 +252,7 @@ def read_brml(data, options={}, index=0): start = float(chain.findall('ScanInformation/ScaleAxes/ScaleAxisInfo/Start')[0].text) stop = float(chain.findall('ScanInformation/ScaleAxes/ScaleAxisInfo/Stop')[0].text) - increment = float(chain.findall('ScanInformation/ScaleAxes/ScaleAxisInfo/Increment')[0].text) + @@ -262,7 +262,7 @@ def read_brml(data, options={}, index=0): intensity = [] for r in raw: - if r > 600: + if r > 601: intensity.append(r) intensity = np.array(intensity) @@ -478,9 +478,7 @@ def translate_wavelengths(data, wavelength, to_wavelength=None): def find_wavelength_from_xy(path): - print(path) - wavelength_dict = {'Cu': 1.54059, 'Mo': 0.71073} with open(path, 'r') as f: diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index 770b5a8..1a9429c 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -20,7 +20,7 @@ def plot_diffractogram(data, options={}): # Update options required_options = ['x_vals', 'y_vals', 'ylabel', 'xlabel', 'xunit', 'yunit', 'line', 'scatter', 'xlim', 'ylim', 'normalise', 'offset', 'offset_x', 'offset_y', - 'reflections_plot', 'reflections_indices', 'reflections_data', 'plot_kind', 'palettes', 'interactive', 'rc_params', 'format_params'] + 'reflections_plot', 'reflections_indices', 'reflections_data', 'plot_kind', 'palettes', 'interactive', 'rc_params', 'format_params', 'interactive_session_active'] default_options = { 'x_vals': '2th', @@ -45,6 +45,10 @@ def plot_diffractogram(data, options={}): 'format_params': {}, } + if 'offset_y' not in options.keys(): + if len(data['path']) > 10: + default_options['offset_y'] = 0.05 + options = aux.update_options(options=options, required_options=required_options, default_options=default_options) # Convert data['path'] to list to allow iteration over this to accommodate both single and multiple diffractograms @@ -62,6 +66,7 @@ def plot_diffractogram(data, options={}): for index in range(len(data['path'])): diffractogram, wavelength = xrd.io.read_data(data=data, options=options, index=index) + data['diffractogram'][index] = diffractogram data['wavelength'][index] = wavelength @@ -113,7 +118,10 @@ def plot_diffractogram(data, options={}): ax = ax[-1] - colours = btp.generate_colours(options['palettes']) + if len(data['path']) < 10: + colours = btp.generate_colours(options['palettes']) + else: + colours = btp.generate_colours(['black'], kind='single') for diffractogram in data['diffractogram']: @@ -183,7 +191,6 @@ def plot_diffractogram_interactive(data, options): if not ymax or (ymax < (diffractogram['I'].max())):#+index*options['offset_y'])): ymax = diffractogram['I'].max()#+index*options['offset_y'] - print(ymax) ymin_start = ymin - 0.1*ymax From 3e4c0a9fc2bbc95b8b6525902727dd30863c30b7 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 30 Mar 2022 17:50:41 +0200 Subject: [PATCH 12/57] Add slider for offset_y (not working yet) --- beamtime/xrd/plot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index 1a9429c..78c3906 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -66,7 +66,6 @@ def plot_diffractogram(data, options={}): for index in range(len(data['path'])): diffractogram, wavelength = xrd.io.read_data(data=data, options=options, index=index) - data['diffractogram'][index] = diffractogram data['wavelength'][index] = wavelength @@ -157,6 +156,8 @@ def plot_diffractogram(data, options={}): if options['interactive_session_active']: btp.update_widgets(options=options) + xrd.io.up + return diffractogram, fig, ax @@ -225,7 +226,9 @@ def plot_diffractogram_interactive(data, options): reflections_indices=widgets.ToggleButton(value=False), x_vals=widgets.Dropdown(options=['2th', 'd', '1/d', 'q', 'q2', 'q4', '2th_cuka', '2th_moka'], value='2th', description='X-values'), xlim=options['widgets']['xlim']['w'], - ylim=widgets.FloatRangeSlider(value=[ymin_start, ymax_start], min=ymin, max=ymax, step=0.5, layout=widgets.Layout(width='95%'))) + ylim=widgets.FloatRangeSlider(value=[ymin_start, ymax_start], min=ymin, max=ymax, step=0.5, layout=widgets.Layout(width='95%')), + offset_y=widgets.FloatSlider(value=options['offset_y'], min=-5, max=5) + ) else: w = widgets.interactive(btp.ipywidgets_update, func=widgets.fixed(plot_diffractogram), data=widgets.fixed(data), options=widgets.fixed(options), From f504c7dd691fa7fa360680e7dbad58e218ec866f Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 31 Mar 2022 13:52:59 +0200 Subject: [PATCH 13/57] Add interactive offset_y --- beamtime/xrd/io.py | 20 +++++++++++++++----- beamtime/xrd/plot.py | 11 ++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index 14c0f98..dc53b29 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -341,11 +341,13 @@ def read_data(data, options={}, index=0): diffractogram, wavelength = read_xy(data=data, options=options, index=index) - if options['normalise']: - diffractogram['I'] = diffractogram['I'] / diffractogram['I'].max() - if options['offset']: + if options['offset'] or options['normalise']: + # Make copy of the original intensities before any changes are made through normalisation or offset, to easily revert back if need to update. + diffractogram['I_org'] = diffractogram['I'] + diffractogram['2th_org'] = diffractogram['2th'] + diffractogram = apply_offset(diffractogram, wavelength, index, options) @@ -355,13 +357,21 @@ def read_data(data, options={}, index=0): def apply_offset(diffractogram, wavelength, index, options): + + options['current_offset_y'] = options['offset_y'] + options['current_offset_x'] = options['offset_x'] + #Apply offset along y-axis - diffractogram['I_org'] = diffractogram['I'] # make copy of original intensities + diffractogram['I'] = diffractogram['I_org'] # Reset intensities + + if options['normalise']: + diffractogram['I'] = diffractogram['I'] / diffractogram['I'].max() + diffractogram['I'] = diffractogram['I'] + index*options['offset_y'] # Apply offset along x-axis relative_shift = (wavelength / 1.54059)*options['offset_x'] # Adjusts the offset-factor to account for wavelength, so that offset_x given is given in 2th_cuka-units - diffractogram['2th_org'] = diffractogram['2th'] + diffractogram['2th'] = diffractogram['2th_org'] diffractogram['2th'] = diffractogram['2th'] + index*relative_shift diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index 78c3906..d7a9a5c 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -81,6 +81,13 @@ def plot_diffractogram(data, options={}): options['xlim'] = [diffractogram[options['x_vals']].min(), diffractogram[options['x_vals']].max()] + if options['interactive_session_active']: + if options['offset']: + if (options['offset_x'] != options['current_offset_x']) or (options['offset_y'] != options['current_offset_y']): + for i, (diff, wl) in enumerate(zip(data['diffractogram'], data['wavelength'])): + xrd.io.apply_offset(diff, wl, i, options) + + # Start inteactive session with ipywidgets. Disables options['interactive'] in order for the interactive loop to not start another interactive session if options['interactive']: options['interactive'] = False @@ -156,7 +163,9 @@ def plot_diffractogram(data, options={}): if options['interactive_session_active']: btp.update_widgets(options=options) - xrd.io.up + + + return diffractogram, fig, ax From 6f9fefae086b6729e7b68379eb969ee10542e493 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 31 Mar 2022 14:02:04 +0200 Subject: [PATCH 14/57] Add interactive offset_x --- beamtime/xrd/plot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index d7a9a5c..012e9b8 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -236,7 +236,8 @@ def plot_diffractogram_interactive(data, options): x_vals=widgets.Dropdown(options=['2th', 'd', '1/d', 'q', 'q2', 'q4', '2th_cuka', '2th_moka'], value='2th', description='X-values'), xlim=options['widgets']['xlim']['w'], ylim=widgets.FloatRangeSlider(value=[ymin_start, ymax_start], min=ymin, max=ymax, step=0.5, layout=widgets.Layout(width='95%')), - offset_y=widgets.FloatSlider(value=options['offset_y'], min=-5, max=5) + offset_y=widgets.BoundedFloatText(value=options['offset_y'], min=-5, max=5, step=0.01), + offset_x=widgets.BoundedFloatText(value=options['offset_x'], min=-1, max=1, step=0.01) ) else: From 6e851b494b39f93b87dfde610542a942fc4bd327 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 31 Mar 2022 17:29:10 +0200 Subject: [PATCH 15/57] Add heatmap, lacks mapping between x-value and 2th --- beamtime/xrd/plot.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index 012e9b8..a073dd6 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -1,3 +1,4 @@ +import seaborn as sns import matplotlib.pyplot as plt from matplotlib.ticker import (MultipleLocator, FormatStrFormatter,AutoMinorLocator) @@ -20,7 +21,7 @@ def plot_diffractogram(data, options={}): # Update options required_options = ['x_vals', 'y_vals', 'ylabel', 'xlabel', 'xunit', 'yunit', 'line', 'scatter', 'xlim', 'ylim', 'normalise', 'offset', 'offset_x', 'offset_y', - 'reflections_plot', 'reflections_indices', 'reflections_data', 'plot_kind', 'palettes', 'interactive', 'rc_params', 'format_params', 'interactive_session_active'] + 'reflections_plot', 'reflections_indices', 'reflections_data', 'heatmap', 'cmap', 'plot_kind', 'palettes', 'interactive', 'rc_params', 'format_params', 'interactive_session_active'] default_options = { 'x_vals': '2th', @@ -37,6 +38,8 @@ def plot_diffractogram(data, options={}): 'reflections_plot': False, # whether to plot reflections as a plot 'reflections_indices': False, # whether to plot the reflection indices 'reflections_data': None, # Should be passed as a list of dictionaries on the form {path: rel_path, reflection_indices: number of indices, colour: [r,g,b], min_alpha: 0-1] + 'heatmap': False, + 'cmap': 'viridis', 'plot_kind': None, 'palettes': [('qualitative', 'Dark2_8')], 'interactive': False, @@ -69,13 +72,20 @@ def plot_diffractogram(data, options={}): data['diffractogram'][index] = diffractogram data['wavelength'][index] = wavelength - else: if not isinstance(data['diffractogram'], list): data['diffractogram'] = [data['diffractogram']] data['wavelength'] = [data['wavelength']] + if options['heatmap']: + data['heatmap'] = [] + for diff in data['diffractogram']: + data['heatmap'].append(np.array(diff['I'])) + + data['heatmap'] = np.array(data['heatmap']) + data['heatmap'] = np.flipud(data['heatmap']) + # Sets the xlim if this has not bee specified if not options['xlim']: options['xlim'] = [diffractogram[options['x_vals']].min(), diffractogram[options['x_vals']].max()] @@ -130,12 +140,17 @@ def plot_diffractogram(data, options={}): colours = btp.generate_colours(['black'], kind='single') - for diffractogram in data['diffractogram']: - if options['line']: - diffractogram.plot(x=options['x_vals'], y=options['y_vals'], ax=ax, c=next(colours), zorder=1) - - if options['scatter']: - ax.scatter(x=diffractogram[options['x_vals']], y = diffractogram[options['y_vals']], c=[(1,1,1,0)], edgecolors=[next(colours)], linewidths=plt.rcParams['lines.markeredgewidth'], zorder=2) #, edgecolors=np.array([next(colours)])) + # FIXME Must be changed to map the x-value to the 2th-value somehow + if options['heatmap']: + sns.heatmap(data['heatmap'], cmap=options['cmap']) + + else: + for diffractogram in data['diffractogram']: + if options['line']: + diffractogram.plot(x=options['x_vals'], y=options['y_vals'], ax=ax, c=next(colours), zorder=1) + + if options['scatter']: + ax.scatter(x=diffractogram[options['x_vals']], y = diffractogram[options['y_vals']], c=[(1,1,1,0)], edgecolors=[next(colours)], linewidths=plt.rcParams['lines.markeredgewidth'], zorder=2) #, edgecolors=np.array([next(colours)])) @@ -168,7 +183,7 @@ def plot_diffractogram(data, options={}): - return diffractogram, fig, ax + return data['diffractogram'], fig, ax def determine_grid_layout(options): From 567282b80b79d86892e62f144e465f20a5d6f528 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Mon, 4 Apr 2022 14:48:29 +0200 Subject: [PATCH 16/57] Fix bug where extract_folder had no default value --- beamtime/xrd/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index dc53b29..729b674 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -40,7 +40,7 @@ def integrate_1d(data, options={}, index=0): df: DataFrame contianing 1D diffractogram if option 'return' is True ''' - required_options = ['unit', 'nbins', 'save', 'save_filename', 'save_extension', 'save_folder', 'overwrite'] + required_options = ['unit', 'nbins', 'save', 'save_filename', 'save_extension', 'save_folder', 'overwrite', 'extract_folder'] default_options = { 'unit': '2th_deg', From b0629de9a3dd5e32e49ad59639d1f4ef21c35bf2 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Mon, 4 Apr 2022 14:48:59 +0200 Subject: [PATCH 17/57] Add functions to round up and down to nearest dec --- beamtime/auxillary.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/beamtime/auxillary.py b/beamtime/auxillary.py index 76ec551..68785f7 100644 --- a/beamtime/auxillary.py +++ b/beamtime/auxillary.py @@ -1,4 +1,5 @@ import json +import numpy as np def update_options(options, required_options, default_options): ''' Takes a dictionary of options along with a list of required options and dictionary of default options, and sets all keyval-pairs of options that is not already defined to the default values''' @@ -37,6 +38,18 @@ def swap_values(dict, key1, key2): -def hello_world2(a=1, b=2): +def ceil(a, roundto=1): - print(f'Halla, MAFAKKAS! a = {a} og b = {b}') \ No newline at end of file + fac = 1/roundto + + a = np.ceil(a*fac) / fac + + return a + +def floor(a, roundto=1): + + fac = 1/roundto + + a = np.floor(a*fac) / fac + + return a \ No newline at end of file From 59629fcb615a798a2ef13ad47d83394dfe859d95 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Mon, 4 Apr 2022 14:50:20 +0200 Subject: [PATCH 18/57] Add plotting of heatmaps with true xlim --- beamtime/plotting.py | 2 +- beamtime/xrd/plot.py | 88 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 77 insertions(+), 13 deletions(-) diff --git a/beamtime/plotting.py b/beamtime/plotting.py index 4e058ac..500f532 100644 --- a/beamtime/plotting.py +++ b/beamtime/plotting.py @@ -182,7 +182,7 @@ def adjust_plot(fig, ax, options): ax.xaxis.set_minor_locator(MultipleLocator(options['x_tick_locators'][1])) - # THIS NEEDS REWORK FOR IT TO FUNCTION PROPERLY! + # FIXME THIS NEEDS REWORK FOR IT TO FUNCTION PROPERLY! if options['xticks']: ax.set_xticks(np.arange(plot_data['start'], plot_data['end']+1)) ax.set_xticklabels(options['xticks']) diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index a073dd6..d2b7b51 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -72,23 +72,20 @@ def plot_diffractogram(data, options={}): data['diffractogram'][index] = diffractogram data['wavelength'][index] = wavelength + # Sets the xlim if this has not bee specified + if not options['xlim']: + options['xlim'] = [data['diffractogram'][0][options['x_vals']].min(), data['diffractogram'][0][options['x_vals']].max()] + + + if options['heatmap']: + data['heatmap'], data['heatmap_xticks'], data['heatmap_xticklabels'] = generate_heatmap(data=data, options=options) + options['xlim'] = options['heatmap_xlim'] else: if not isinstance(data['diffractogram'], list): data['diffractogram'] = [data['diffractogram']] data['wavelength'] = [data['wavelength']] - if options['heatmap']: - data['heatmap'] = [] - for diff in data['diffractogram']: - data['heatmap'].append(np.array(diff['I'])) - - data['heatmap'] = np.array(data['heatmap']) - data['heatmap'] = np.flipud(data['heatmap']) - - # Sets the xlim if this has not bee specified - if not options['xlim']: - options['xlim'] = [diffractogram[options['x_vals']].min(), diffractogram[options['x_vals']].max()] if options['interactive_session_active']: @@ -142,7 +139,10 @@ def plot_diffractogram(data, options={}): # FIXME Must be changed to map the x-value to the 2th-value somehow if options['heatmap']: - sns.heatmap(data['heatmap'], cmap=options['cmap']) + sns.heatmap(data['heatmap'], cmap=options['cmap'], cbar=False, ax=ax) + ax.set_xticks(data['heatmap_xticks']) + ax.set_xticklabels(data['heatmap_xticklabels']) + ax.tick_params(axis='x', which='minor', bottom=False, top=False) else: for diffractogram in data['diffractogram']: @@ -186,6 +186,68 @@ def plot_diffractogram(data, options={}): return data['diffractogram'], fig, ax + +def generate_heatmap(data, options={}): + + required_options = ['x_tick_locators'] + + default_options = { + 'x_tick_locators': [0.5, 0.1] + } + + options = aux.update_options(options=options, required_options=required_options, default_options=default_options) + + twotheta = [] + intensities = [] + scans = [] + + for i, d in enumerate(data['diffractogram']): + twotheta = np.append(twotheta, d['2th'].to_numpy()) + intensities = np.append(intensities, d['I'].to_numpy()) + scans = np.append(scans, np.full(len(d['2th'].to_numpy()), int(i))) + + + # Generate ticks and xtick-labels + twotheta_max = data['diffractogram'][0]['2th'].max() + twotheta_min = data['diffractogram'][0]['2th'].min() + twotheta_span = twotheta_max - twotheta_min + ndatapoints = len(data['diffractogram'][0]['2th']) + steps = twotheta_span / ndatapoints + + twotheta_label_max = aux.floor(twotheta_max, roundto=options['x_tick_locators'][0]) + twotheta_label_min = aux.ceil(twotheta_min, roundto=options['x_tick_locators'][0]) + label_steps = (twotheta_label_max - twotheta_label_min)/options['x_tick_locators'][0] + + + + xtick_labels = np.linspace(twotheta_label_min, twotheta_label_max, num=int(label_steps)+1) + + options['x_tick_locators'] = None + + xticks = [] + for tick in xtick_labels: + xticks.append((tick - twotheta_min)/steps) + + heatmap = pd.DataFrame({'2th': twotheta, 'scan': scans, 'I': intensities}) + heatmap = heatmap.reset_index().pivot_table(index='scan', columns='2th', values='I') + + options['heatmap_xlim'] = [(options['xlim'][0] - twotheta_min)/steps, (options['xlim'][1] - twotheta_min)/steps] + + + print(xticks, xtick_labels) + + + return heatmap, xticks, xtick_labels + + + + + + + +# #results = np.transpose(np.vstack([twotheta, scans, intensities])) + + def determine_grid_layout(options): @@ -202,6 +264,8 @@ def determine_grid_layout(options): + + def plot_diffractogram_interactive(data, options): From 5541f44a58b4cbc96ba2c55f3ce1b16fcc255bb4 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Mon, 4 Apr 2022 16:47:01 +0200 Subject: [PATCH 19/57] Add automatic change of xlim range with heatmaps --- beamtime/xrd/plot.py | 107 ++++++++++++++++++++++++++++--------------- 1 file changed, 71 insertions(+), 36 deletions(-) diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index d2b7b51..df17e8d 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -76,9 +76,9 @@ def plot_diffractogram(data, options={}): if not options['xlim']: options['xlim'] = [data['diffractogram'][0][options['x_vals']].min(), data['diffractogram'][0][options['x_vals']].max()] - - if options['heatmap']: - data['heatmap'], data['heatmap_xticks'], data['heatmap_xticklabels'] = generate_heatmap(data=data, options=options) + # Generate heatmap data + data['heatmap'], data['heatmap_xticks'], data['heatmap_xticklabels'] = generate_heatmap(data=data, options=options) + if options['heatmap']: options['xlim'] = options['heatmap_xlim'] else: @@ -136,12 +136,10 @@ def plot_diffractogram(data, options={}): else: colours = btp.generate_colours(['black'], kind='single') - - # FIXME Must be changed to map the x-value to the 2th-value somehow if options['heatmap']: sns.heatmap(data['heatmap'], cmap=options['cmap'], cbar=False, ax=ax) - ax.set_xticks(data['heatmap_xticks']) - ax.set_xticklabels(data['heatmap_xticklabels']) + ax.set_xticks(data['heatmap_xticks'][options['x_vals']]) + ax.set_xticklabels(data['heatmap_xticklabels'][options['x_vals']]) ax.tick_params(axis='x', which='minor', bottom=False, top=False) else: @@ -176,7 +174,7 @@ def plot_diffractogram(data, options={}): if options['interactive_session_active']: - btp.update_widgets(options=options) + update_widgets(options=options) @@ -207,37 +205,52 @@ def generate_heatmap(data, options={}): scans = np.append(scans, np.full(len(d['2th'].to_numpy()), int(i))) - # Generate ticks and xtick-labels - twotheta_max = data['diffractogram'][0]['2th'].max() - twotheta_min = data['diffractogram'][0]['2th'].min() - twotheta_span = twotheta_max - twotheta_min + heatmap = pd.DataFrame({'2th': twotheta, 'scan': scans, 'I': intensities}) + xrd.io.translate_wavelengths(data=heatmap, wavelength=data['wavelength'][0]) + min_dict = {'2th': heatmap['2th'].min(), '2th_cuka': heatmap['2th_cuka'].min(), '2th_moka': heatmap['2th_moka'].min(), + 'q': heatmap['q'].min(), 'q2': heatmap['q2'].min(), 'q4': heatmap['q4'].min(), '1/d': heatmap['1/d'].min()} + + max_dict = {'2th': heatmap['2th'].max(), '2th_cuka': heatmap['2th_cuka'].max(), '2th_moka': heatmap['2th_moka'].max(), + 'q': heatmap['q'].max(), 'q2': heatmap['q2'].max(), 'q4': heatmap['q4'].max(), '1/d': heatmap['1/d'].max()} + + ndatapoints = len(data['diffractogram'][0]['2th']) - steps = twotheta_span / ndatapoints - twotheta_label_max = aux.floor(twotheta_max, roundto=options['x_tick_locators'][0]) - twotheta_label_min = aux.ceil(twotheta_min, roundto=options['x_tick_locators'][0]) - label_steps = (twotheta_label_max - twotheta_label_min)/options['x_tick_locators'][0] + xlims = [0, ndatapoints] + xticks = {} + xticklabels = {} - + for xval in min_dict.keys(): + + # Add xticks labels + + label_max = aux.floor(max_dict[xval], roundto=options['x_tick_locators'][0]) + label_min = aux.ceil(min_dict[xval], roundto=options['x_tick_locators'][0]) + label_steps = (label_max - label_min)/options['x_tick_locators'][0] + + xticklabels[xval] = np.linspace(label_min, label_max, num=int(label_steps)+1) + + # Add xticks + xval_span = max_dict[xval] - min_dict[xval] + steps = xval_span / ndatapoints + + + xticks_xval = [] + + for tick in xticklabels[xval]: + xticks_xval.append((tick-min_dict[xval])/steps) + + xticks[xval] = xticks_xval - xtick_labels = np.linspace(twotheta_label_min, twotheta_label_max, num=int(label_steps)+1) options['x_tick_locators'] = None - xticks = [] - for tick in xtick_labels: - xticks.append((tick - twotheta_min)/steps) - - heatmap = pd.DataFrame({'2th': twotheta, 'scan': scans, 'I': intensities}) heatmap = heatmap.reset_index().pivot_table(index='scan', columns='2th', values='I') - options['heatmap_xlim'] = [(options['xlim'][0] - twotheta_min)/steps, (options['xlim'][1] - twotheta_min)/steps] + options['heatmap_xlim'] = xlims - print(xticks, xtick_labels) - - - return heatmap, xticks, xtick_labels + return heatmap, xticks, xticklabels @@ -269,9 +282,9 @@ def determine_grid_layout(options): def plot_diffractogram_interactive(data, options): - minmax = {'2th': [None, None], '2th_cuka': [None, None], '2th_moka': [None, None], 'd': [None, None], '1/d': [None, None], 'q': [None, None], 'q2': [None, None], 'q4': [None, None]} + minmax = {'2th': [None, None], '2th_cuka': [None, None], '2th_moka': [None, None], 'd': [None, None], '1/d': [None, None], 'q': [None, None], 'q2': [None, None], 'q4': [None, None], 'heatmap': [None, None]} - update_minmax(minmax, data) + update_minmax(minmax=minmax, data=data, options=options) ymin, ymax = None, None for index, diffractogram in enumerate(data['diffractogram']): @@ -288,8 +301,6 @@ def plot_diffractogram_interactive(data, options): ymax = ymax*5 - - options['widgets'] = { 'xlim': { 'w': widgets.FloatRangeSlider(value=[minmax['2th'][0], minmax['2th'][1]], min=minmax['2th'][0], max=minmax['2th'][1], step=0.5, layout=widgets.Layout(width='95%')), @@ -301,17 +312,18 @@ def plot_diffractogram_interactive(data, options): '1/d_default': {'min': minmax['1/d'][0], 'max': minmax['1/d'][1], 'value': [minmax['1/d'][0], minmax['1/d'][1]], 'step': 0.5}, 'q_default': {'min': minmax['q'][0], 'max': minmax['q'][1], 'value': [minmax['q'][0], minmax['q'][1]], 'step': 0.5}, 'q2_default': {'min': minmax['q2'][0], 'max': minmax['q2'][1], 'value': [minmax['q2'][0], minmax['q2'][1]], 'step': 0.5}, - 'q4_default': {'min': minmax['q4'][0], 'max': minmax['q4'][1], 'value': [minmax['q4'][0], minmax['q4'][1]], 'step': 0.5} + 'q4_default': {'min': minmax['q4'][0], 'max': minmax['q4'][1], 'value': [minmax['q4'][0], minmax['q4'][1]], 'step': 0.5}, + 'heatmap_default': {'min': minmax['heatmap'][0], 'max': minmax['heatmap'][1], 'value': [minmax['heatmap'][0], minmax['heatmap'][1]], 'step': 10} } } - if options['reflections_data']: w = widgets.interactive(btp.ipywidgets_update, func=widgets.fixed(plot_diffractogram), data=widgets.fixed(data), options=widgets.fixed(options), scatter=widgets.ToggleButton(value=False), line=widgets.ToggleButton(value=True), reflections_plot=widgets.ToggleButton(value=True), reflections_indices=widgets.ToggleButton(value=False), + heatmap=widgets.ToggleButton(value=options['heatmap']), x_vals=widgets.Dropdown(options=['2th', 'd', '1/d', 'q', 'q2', 'q4', '2th_cuka', '2th_moka'], value='2th', description='X-values'), xlim=options['widgets']['xlim']['w'], ylim=widgets.FloatRangeSlider(value=[ymin_start, ymax_start], min=ymin, max=ymax, step=0.5, layout=widgets.Layout(width='95%')), @@ -329,7 +341,7 @@ def plot_diffractogram_interactive(data, options): display(w) -def update_minmax(minmax, data): +def update_minmax(minmax, data, options={}): ''' Finds minimum and maximum values of each column and updates the minmax dictionary to contain the correct values. Input: @@ -351,15 +363,38 @@ def update_minmax(minmax, data): minmax['q'][0], minmax['q'][1] = data['diffractogram'][min_index]['q'].min(), data['diffractogram'][max_index]['q'].max() minmax['q2'][0], minmax['q2'][1] = data['diffractogram'][min_index]['q2'].min(), data['diffractogram'][max_index]['q2'].max() minmax['q4'][0], minmax['q4'][1] = data['diffractogram'][min_index]['q4'].min(), data['diffractogram'][max_index]['q4'].max() + minmax['heatmap'] = options['heatmap_xlim'] + + def update_widgets(options): for widget in options['widgets'].values(): - if widget['state'] != options['x_vals']: + if options['heatmap'] and (widget['state'] != 'heatmap'): + setattr(widget['w'], 'min', widget['heatmap_default']['min']) + setattr(widget['w'], 'max', widget['heatmap_default']['max']) + setattr(widget['w'], 'value', widget['heatmap_default']['value']) + setattr(widget['w'], 'step', widget['heatmap_default']['step']) + + widget['state'] = 'heatmap' + + elif not options['heatmap'] and (widget['state'] != options['x_vals']): for arg in widget[f'{options["x_vals"]}_default']: + + # If new min value is larger than previous max, or new max value is smaller than previous min, set the opposite first + if arg == 'min': + if widget[f'{options["x_vals"]}_default']['min'] > getattr(widget['w'], 'max'): + setattr(widget['w'], 'max', widget[f'{options["x_vals"]}_default']['max']) + + elif arg == 'max': + if widget[f'{options["x_vals"]}_default']['max'] < getattr(widget['w'], 'min'): + setattr(widget['w'], 'min', widget[f'{options["x_vals"]}_default']['min']) + + setattr(widget['w'], arg, widget[f'{options["x_vals"]}_default'][arg]) + widget['state'] = options['x_vals'] From c0449f2e183d17f684d0906791e9a2b9e82d52f7 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Tue, 5 Apr 2022 13:52:27 +0200 Subject: [PATCH 20/57] Correct switch of ylim between diff and heatmap --- beamtime/xrd/plot.py | 199 +++++++++++++++++++++++++++++-------------- 1 file changed, 135 insertions(+), 64 deletions(-) diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index df17e8d..c97dabe 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -176,9 +176,6 @@ def plot_diffractogram(data, options={}): if options['interactive_session_active']: update_widgets(options=options) - - - return data['diffractogram'], fig, ax @@ -282,38 +279,51 @@ def determine_grid_layout(options): def plot_diffractogram_interactive(data, options): - minmax = {'2th': [None, None], '2th_cuka': [None, None], '2th_moka': [None, None], 'd': [None, None], '1/d': [None, None], 'q': [None, None], 'q2': [None, None], 'q4': [None, None], 'heatmap': [None, None]} + xminmax = {'2th': [None, None], '2th_cuka': [None, None], '2th_moka': [None, None], 'd': [None, None], '1/d': [None, None], 'q': [None, None], 'q2': [None, None], 'q4': [None, None], 'heatmap': [None, None], 'start': [None, None, None, None]} + yminmax = {'diff': [None, None, None, None], 'heatmap': [None, None], 'start': [None, None, None, None]} - update_minmax(minmax=minmax, data=data, options=options) - - ymin, ymax = None, None - for index, diffractogram in enumerate(data['diffractogram']): - if not ymin or (ymin > (diffractogram['I'].min())): #+index*options['offset_y'])): - ymin = diffractogram['I'].min()#+index*options['offset_y'] - - if not ymax or (ymax < (diffractogram['I'].max())):#+index*options['offset_y'])): - ymax = diffractogram['I'].max()#+index*options['offset_y'] + update_xminmax(xminmax=xminmax, data=data, options=options) + update_yminmax(yminmax=yminmax, data=data, options=options) - ymin_start = ymin - 0.1*ymax - ymax_start = ymax+0.2*ymax - ymin = ymin - 5*ymax - ymax = ymax*5 + + # Get start values for ylim slider based on choice (FIXME This can be impleneted into update_yminmax). Can also make a 'start' item that stores the start values, instead of having 4 items in 'diff' as it is now. + if options['heatmap']: + ymin = yminmax['heatmap'][0] + ymax = yminmax['heatmap'][1] + ymin_start = yminmax['heatmap'][0] + ymax_start = yminmax['heatmap'][1] + + elif not options['heatmap']: + ymin = yminmax['diff'][0] + ymax = yminmax['diff'][1] + ymin_start = yminmax['diff'][2] + ymax_start = yminmax['diff'][3] + + + # FIXME The start values for xlim should probably also be decided by initial value of x_vals, and can likewise be implemented in update_xminmax() + options['widgets'] = { 'xlim': { - 'w': widgets.FloatRangeSlider(value=[minmax['2th'][0], minmax['2th'][1]], min=minmax['2th'][0], max=minmax['2th'][1], step=0.5, layout=widgets.Layout(width='95%')), - 'state': '2th', - '2th_default': {'min': minmax['2th'][0], 'max': minmax['2th'][1], 'value': [minmax['2th'][0], minmax['2th'][1]], 'step': 0.5}, - '2th_cuka_default': {'min': minmax['2th_cuka'][0], 'max': minmax['2th_cuka'][1], 'value': [minmax['2th_cuka'][0], minmax['2th_cuka'][1]], 'step': 0.5}, - '2th_moka_default': {'min': minmax['2th_moka'][0], 'max': minmax['2th_moka'][1], 'value': [minmax['2th_moka'][0], minmax['2th_moka'][1]], 'step': 0.5}, - 'd_default': {'min': minmax['d'][0], 'max': minmax['d'][1], 'value': [minmax['d'][0], minmax['d'][1]], 'step': 0.5}, - '1/d_default': {'min': minmax['1/d'][0], 'max': minmax['1/d'][1], 'value': [minmax['1/d'][0], minmax['1/d'][1]], 'step': 0.5}, - 'q_default': {'min': minmax['q'][0], 'max': minmax['q'][1], 'value': [minmax['q'][0], minmax['q'][1]], 'step': 0.5}, - 'q2_default': {'min': minmax['q2'][0], 'max': minmax['q2'][1], 'value': [minmax['q2'][0], minmax['q2'][1]], 'step': 0.5}, - 'q4_default': {'min': minmax['q4'][0], 'max': minmax['q4'][1], 'value': [minmax['q4'][0], minmax['q4'][1]], 'step': 0.5}, - 'heatmap_default': {'min': minmax['heatmap'][0], 'max': minmax['heatmap'][1], 'value': [minmax['heatmap'][0], minmax['heatmap'][1]], 'step': 10} + 'w': widgets.FloatRangeSlider(value=[xminmax['start'][2], xminmax['start'][3]], min=xminmax['start'][0], max=xminmax['start'][1], step=0.5, layout=widgets.Layout(width='95%')), + 'state': options['x_vals'], + '2th_default': {'min': xminmax['2th'][0], 'max': xminmax['2th'][1], 'value': [xminmax['2th'][0], xminmax['2th'][1]], 'step': 0.5}, + '2th_cuka_default': {'min': xminmax['2th_cuka'][0], 'max': xminmax['2th_cuka'][1], 'value': [xminmax['2th_cuka'][0], xminmax['2th_cuka'][1]], 'step': 0.5}, + '2th_moka_default': {'min': xminmax['2th_moka'][0], 'max': xminmax['2th_moka'][1], 'value': [xminmax['2th_moka'][0], xminmax['2th_moka'][1]], 'step': 0.5}, + 'd_default': {'min': xminmax['d'][0], 'max': xminmax['d'][1], 'value': [xminmax['d'][0], xminmax['d'][1]], 'step': 0.5}, + '1/d_default': {'min': xminmax['1/d'][0], 'max': xminmax['1/d'][1], 'value': [xminmax['1/d'][0], xminmax['1/d'][1]], 'step': 0.5}, + 'q_default': {'min': xminmax['q'][0], 'max': xminmax['q'][1], 'value': [xminmax['q'][0], xminmax['q'][1]], 'step': 0.5}, + 'q2_default': {'min': xminmax['q2'][0], 'max': xminmax['q2'][1], 'value': [xminmax['q2'][0], xminmax['q2'][1]], 'step': 0.5}, + 'q4_default': {'min': xminmax['q4'][0], 'max': xminmax['q4'][1], 'value': [xminmax['q4'][0], xminmax['q4'][1]], 'step': 0.5}, + 'heatmap_default': {'min': xminmax['heatmap'][0], 'max': xminmax['heatmap'][1], 'value': [xminmax['heatmap'][0], xminmax['heatmap'][1]], 'step': 10} + }, + 'ylim': { + 'w': widgets.FloatRangeSlider(value=[yminmax['start'][2], yminmax['start'][3]], min=yminmax['start'][0], max=yminmax['start'][1], step=0.5, layout=widgets.Layout(width='95%')), + 'state': 'heatmap' if options['heatmap'] else 'diff', + 'diff_default': {'min': yminmax['diff'][0], 'max': yminmax['diff'][1], 'value': [yminmax['diff'][2], yminmax['diff'][3]], 'step': 0.1}, + 'heatmap_default': {'min': yminmax['heatmap'][0], 'max': yminmax['heatmap'][1], 'value': [yminmax['heatmap'][0], yminmax['heatmap'][1]], 'step': 0.1} } } @@ -326,7 +336,7 @@ def plot_diffractogram_interactive(data, options): heatmap=widgets.ToggleButton(value=options['heatmap']), x_vals=widgets.Dropdown(options=['2th', 'd', '1/d', 'q', 'q2', 'q4', '2th_cuka', '2th_moka'], value='2th', description='X-values'), xlim=options['widgets']['xlim']['w'], - ylim=widgets.FloatRangeSlider(value=[ymin_start, ymax_start], min=ymin, max=ymax, step=0.5, layout=widgets.Layout(width='95%')), + ylim=options['widgets']['ylim']['w'], offset_y=widgets.BoundedFloatText(value=options['offset_y'], min=-5, max=5, step=0.01), offset_x=widgets.BoundedFloatText(value=options['offset_x'], min=-1, max=1, step=0.01) ) @@ -341,61 +351,122 @@ def plot_diffractogram_interactive(data, options): display(w) -def update_minmax(minmax, data, options={}): +def update_xminmax(xminmax, data, options={}): ''' Finds minimum and maximum values of each column and updates the minmax dictionary to contain the correct values. Input: minmax (dict): contains ''' for index, diffractogram in enumerate(data['diffractogram']): - if not minmax['2th'][0] or diffractogram['2th'].min() < minmax['2th'][0]: - minmax['2th'][0] = diffractogram['2th'].min() + if not xminmax['2th'][0] or diffractogram['2th'].min() < xminmax['2th'][0]: + xminmax['2th'][0] = diffractogram['2th'].min() min_index = index - if not minmax['2th'][1] or diffractogram['2th'].max() > minmax['2th'][1]: - minmax['2th'][1] = diffractogram['2th'].max() + if not xminmax['2th'][1] or diffractogram['2th'].max() > xminmax['2th'][1]: + xminmax['2th'][1] = diffractogram['2th'].max() max_index = index - minmax['2th_cuka'][0], minmax['2th_cuka'][1] = data['diffractogram'][min_index]['2th_cuka'].min(), data['diffractogram'][max_index]['2th_cuka'].max() - minmax['2th_moka'][0], minmax['2th_moka'][1] = data['diffractogram'][min_index]['2th_moka'].min(), data['diffractogram'][max_index]['2th_moka'].max() - minmax['d'][0], minmax['d'][1] = data['diffractogram'][max_index]['d'].min(), data['diffractogram'][min_index]['d'].max() # swapped, intended - minmax['1/d'][0], minmax['1/d'][1] = data['diffractogram'][min_index]['1/d'].min(), data['diffractogram'][max_index]['1/d'].max() - minmax['q'][0], minmax['q'][1] = data['diffractogram'][min_index]['q'].min(), data['diffractogram'][max_index]['q'].max() - minmax['q2'][0], minmax['q2'][1] = data['diffractogram'][min_index]['q2'].min(), data['diffractogram'][max_index]['q2'].max() - minmax['q4'][0], minmax['q4'][1] = data['diffractogram'][min_index]['q4'].min(), data['diffractogram'][max_index]['q4'].max() - minmax['heatmap'] = options['heatmap_xlim'] + xminmax['2th_cuka'][0], xminmax['2th_cuka'][1] = data['diffractogram'][min_index]['2th_cuka'].min(), data['diffractogram'][max_index]['2th_cuka'].max() + xminmax['2th_moka'][0], xminmax['2th_moka'][1] = data['diffractogram'][min_index]['2th_moka'].min(), data['diffractogram'][max_index]['2th_moka'].max() + xminmax['d'][0], xminmax['d'][1] = data['diffractogram'][max_index]['d'].min(), data['diffractogram'][min_index]['d'].max() # swapped, intended + xminmax['1/d'][0], xminmax['1/d'][1] = data['diffractogram'][min_index]['1/d'].min(), data['diffractogram'][max_index]['1/d'].max() + xminmax['q'][0], xminmax['q'][1] = data['diffractogram'][min_index]['q'].min(), data['diffractogram'][max_index]['q'].max() + xminmax['q2'][0], xminmax['q2'][1] = data['diffractogram'][min_index]['q2'].min(), data['diffractogram'][max_index]['q2'].max() + xminmax['q4'][0], xminmax['q4'][1] = data['diffractogram'][min_index]['q4'].min(), data['diffractogram'][max_index]['q4'].max() + xminmax['heatmap'] = options['heatmap_xlim'] + + + xminmax['start'][0], xminmax['start'][1] = xminmax[options['x_vals']][0], xminmax[options['x_vals']][1] + xminmax['start'][2], xminmax['start'][3] = xminmax[options['x_vals']][0], xminmax[options['x_vals']][1] + + +def update_yminmax(yminmax: dict, data, options={}): + + for index, diffractogram in enumerate(data['diffractogram']): + if not yminmax['diff'][0] or (yminmax['diff'][0] > (diffractogram['I'].min())): + yminmax['diff'][0] = diffractogram['I'].min() + + if not yminmax['diff'][1] or (yminmax['diff'][1] < (diffractogram['I'].max())): + yminmax['diff'][1] = diffractogram['I'].max() + + + # Set start values of ymin and ymax to be slightly below lowest data points and slightly above highest data points to give some whitespace around the plot + yminmax['diff'][2] = yminmax['diff'][0] - 0.1*yminmax['diff'][1] + yminmax['diff'][3] = yminmax['diff'][1] + 0.2*yminmax['diff'][1] + + # Allow for adjustment up to five times ymax above and below data + yminmax['diff'][0] = yminmax['diff'][0] - 5*yminmax['diff'][1] + yminmax['diff'][1] = yminmax['diff'][1]*5 + + + yminmax['heatmap'][0] = 0 + yminmax['heatmap'][1] = data['heatmap'].shape[0] + + + if options['heatmap']: + yminmax['start'][0], yminmax['start'][1] = yminmax['heatmap'][0], yminmax['heatmap'][1] + yminmax['start'][2], yminmax['start'][3] = yminmax['heatmap'][0], yminmax['heatmap'][1] + + else: + # The third and fourth index are different here to not be zoomed completely out to begin with. + yminmax['start'][0], yminmax['start'][1] = yminmax['diff'][0], yminmax['diff'][1] + yminmax['start'][2], yminmax['start'][3] = yminmax['diff'][2], yminmax['diff'][3] + def update_widgets(options): - for widget in options['widgets'].values(): + for widget, attr in options['widgets'].items(): - if options['heatmap'] and (widget['state'] != 'heatmap'): - setattr(widget['w'], 'min', widget['heatmap_default']['min']) - setattr(widget['w'], 'max', widget['heatmap_default']['max']) - setattr(widget['w'], 'value', widget['heatmap_default']['value']) - setattr(widget['w'], 'step', widget['heatmap_default']['step']) + if widget == 'xlim': + + if options['heatmap'] and (attr['state'] != 'heatmap'): + setattr(attr['w'], 'min', attr['heatmap_default']['min']) + setattr(attr['w'], 'max', attr['heatmap_default']['max']) + setattr(attr['w'], 'value', attr['heatmap_default']['value']) + setattr(attr['w'], 'step', attr['heatmap_default']['step']) + + attr['state'] = 'heatmap' + + elif not options['heatmap'] and (attr['state'] != options['x_vals']): + for arg in attr[f'{options["x_vals"]}_default']: + + # If new min value is larger than previous max, or new max value is smaller than previous min, set the opposite first + if arg == 'min': + if attr[f'{options["x_vals"]}_default']['min'] > getattr(attr['w'], 'max'): + setattr(attr['w'], 'max', attr[f'{options["x_vals"]}_default']['max']) + + elif arg == 'max': + if attr[f'{options["x_vals"]}_default']['max'] < getattr(attr['w'], 'min'): + setattr(attr['w'], 'min', attr[f'{options["x_vals"]}_default']['min']) - widget['state'] = 'heatmap' - - elif not options['heatmap'] and (widget['state'] != options['x_vals']): - for arg in widget[f'{options["x_vals"]}_default']: - # If new min value is larger than previous max, or new max value is smaller than previous min, set the opposite first - if arg == 'min': - if widget[f'{options["x_vals"]}_default']['min'] > getattr(widget['w'], 'max'): - setattr(widget['w'], 'max', widget[f'{options["x_vals"]}_default']['max']) + setattr(attr['w'], arg, attr[f'{options["x_vals"]}_default'][arg]) - elif arg == 'max': - if widget[f'{options["x_vals"]}_default']['max'] < getattr(widget['w'], 'min'): - setattr(widget['w'], 'min', widget[f'{options["x_vals"]}_default']['min']) + + attr['state'] = options['x_vals'] + + elif widget == 'ylim': + state = 'heatmap' if options['heatmap'] else 'diff' + + if attr['state'] != state: + + for arg in attr[f'{state}_default']: + # If new min value is larger than previous max, or new max value is smaller than previous min, set the opposite first + if arg == 'min': + if attr[f'{state}_default']['min'] > getattr(attr['w'], 'max'): + setattr(attr['w'], 'max', attr[f'{state}_default']['max']) + + elif arg == 'max': + if attr[f'{state}_default']['max'] < getattr(attr['w'], 'min'): + setattr(attr['w'], 'min', attr[f'{state}_default']['min']) + + + setattr(attr['w'], arg, attr[f'{state}_default'][arg]) + + attr['state'] = state - - setattr(widget['w'], arg, widget[f'{options["x_vals"]}_default'][arg]) - - - widget['state'] = options['x_vals'] From 876e0f8d3d2759a762dbaf58c317e41fbf50c4bc Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Tue, 5 Apr 2022 16:12:19 +0200 Subject: [PATCH 21/57] Allow rescaling ylim with interactive diff plot --- beamtime/xrd/io.py | 11 ++- beamtime/xrd/plot.py | 161 ++++++++++++++++++++++++++++++------------- 2 files changed, 122 insertions(+), 50 deletions(-) diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index 729b674..910811b 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -358,9 +358,18 @@ def read_data(data, options={}, index=0): def apply_offset(diffractogram, wavelength, index, options): - options['current_offset_y'] = options['offset_y'] + if 'current_offset_y' not in options.keys(): + options['current_offset_y'] = options['offset_y'] + else: + if options['current_offset_y'] != options['offset_y']: + options['offset_change'] = True + + options['current_offset_y'] = options['offset_y'] + options['current_offset_x'] = options['offset_x'] + + #Apply offset along y-axis diffractogram['I'] = diffractogram['I_org'] # Reset intensities diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index c97dabe..9012b4a 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -20,7 +20,7 @@ def plot_diffractogram(data, options={}): data (dict): Must include path = string to diffractogram data, and plot_kind = (recx, beamline, image)''' # Update options - required_options = ['x_vals', 'y_vals', 'ylabel', 'xlabel', 'xunit', 'yunit', 'line', 'scatter', 'xlim', 'ylim', 'normalise', 'offset', 'offset_x', 'offset_y', + required_options = ['x_vals', 'y_vals', 'ylabel', 'xlabel', 'xunit', 'yunit', 'line', 'scatter', 'xlim', 'ylim', 'normalise', 'offset', 'offset_x', 'offset_y', 'offset_change', 'reflections_plot', 'reflections_indices', 'reflections_data', 'heatmap', 'cmap', 'plot_kind', 'palettes', 'interactive', 'rc_params', 'format_params', 'interactive_session_active'] default_options = { @@ -33,6 +33,7 @@ def plot_diffractogram(data, options={}): 'offset': True, 'offset_x': 0, 'offset_y': 1, + 'offset_change': False, 'line': True, # whether or not to plot diffractogram as a line plot 'scatter': False, # whether or not to plot individual data points 'reflections_plot': False, # whether to plot reflections as a plot @@ -53,6 +54,7 @@ def plot_diffractogram(data, options={}): default_options['offset_y'] = 0.05 options = aux.update_options(options=options, required_options=required_options, default_options=default_options) + options['current_offset_y'] = options['offset_y'] # Convert data['path'] to list to allow iteration over this to accommodate both single and multiple diffractograms if not isinstance(data['path'], list): @@ -174,7 +176,8 @@ def plot_diffractogram(data, options={}): if options['interactive_session_active']: - update_widgets(options=options) + options['current_y_offset'] = options['widget'].kwargs['offset_y'] + update_widgets(data=data, options=options) @@ -213,7 +216,7 @@ def generate_heatmap(data, options={}): ndatapoints = len(data['diffractogram'][0]['2th']) - xlims = [0, ndatapoints] + xlims = [0, ndatapoints, 0, ndatapoints] # 0: xmin, 1: xmax, 2: xmin_start, 3: xmax_start xticks = {} xticklabels = {} @@ -279,13 +282,18 @@ def determine_grid_layout(options): def plot_diffractogram_interactive(data, options): - xminmax = {'2th': [None, None], '2th_cuka': [None, None], '2th_moka': [None, None], 'd': [None, None], '1/d': [None, None], 'q': [None, None], 'q2': [None, None], 'q4': [None, None], 'heatmap': [None, None], 'start': [None, None, None, None]} - yminmax = {'diff': [None, None, None, None], 'heatmap': [None, None], 'start': [None, None, None, None]} + # Format here is xminmax[0]: xmin, xminmax[1]: xmax, xminmax[2]: xmin_start, xminmax[3]: xmax_start, where "_start" denotes starting value of the slider + xminmax = { '2th': [None, None, None, None], '2th_cuka': [None, None, None, None], '2th_moka': [None, None, None, None], + 'd': [None, None, None, None], '1/d': [None, None, None, None], + 'q': [None, None, None, None], 'q2': [None, None, None, None], 'q4': [None, None, None, None], + 'heatmap': [None, None, None, None], 'start': [None, None, None, None]} + + yminmax = { 'diff': [None, None, None, None], 'heatmap': [None, None, None, None], 'start': [None, None, None, None]} update_xminmax(xminmax=xminmax, data=data, options=options) update_yminmax(yminmax=yminmax, data=data, options=options) - + options['xminmax'], options['yminmax'] = xminmax, yminmax # Get start values for ylim slider based on choice (FIXME This can be impleneted into update_yminmax). Can also make a 'start' item that stores the start values, instead of having 4 items in 'diff' as it is now. if options['heatmap']: @@ -337,8 +345,8 @@ def plot_diffractogram_interactive(data, options): x_vals=widgets.Dropdown(options=['2th', 'd', '1/d', 'q', 'q2', 'q4', '2th_cuka', '2th_moka'], value='2th', description='X-values'), xlim=options['widgets']['xlim']['w'], ylim=options['widgets']['ylim']['w'], - offset_y=widgets.BoundedFloatText(value=options['offset_y'], min=-5, max=5, step=0.01), - offset_x=widgets.BoundedFloatText(value=options['offset_x'], min=-1, max=1, step=0.01) + offset_y=widgets.BoundedFloatText(value=options['offset_y'], min=-5, max=5, step=0.01, description='offset_y'), + offset_x=widgets.BoundedFloatText(value=options['offset_x'], min=-1, max=1, step=0.01, description='offset_x') ) else: @@ -348,6 +356,8 @@ def plot_diffractogram_interactive(data, options): xlim=options['widgets']['xlim']['w']) + options['widget'] = w + display(w) @@ -357,7 +367,9 @@ def update_xminmax(xminmax, data, options={}): Input: minmax (dict): contains ''' + xminmax['2th'] = [None, None, None, None] for index, diffractogram in enumerate(data['diffractogram']): + if not xminmax['2th'][0] or diffractogram['2th'].min() < xminmax['2th'][0]: xminmax['2th'][0] = diffractogram['2th'].min() min_index = index @@ -366,23 +378,43 @@ def update_xminmax(xminmax, data, options={}): xminmax['2th'][1] = diffractogram['2th'].max() max_index = index - xminmax['2th_cuka'][0], xminmax['2th_cuka'][1] = data['diffractogram'][min_index]['2th_cuka'].min(), data['diffractogram'][max_index]['2th_cuka'].max() - xminmax['2th_moka'][0], xminmax['2th_moka'][1] = data['diffractogram'][min_index]['2th_moka'].min(), data['diffractogram'][max_index]['2th_moka'].max() - xminmax['d'][0], xminmax['d'][1] = data['diffractogram'][max_index]['d'].min(), data['diffractogram'][min_index]['d'].max() # swapped, intended - xminmax['1/d'][0], xminmax['1/d'][1] = data['diffractogram'][min_index]['1/d'].min(), data['diffractogram'][max_index]['1/d'].max() - xminmax['q'][0], xminmax['q'][1] = data['diffractogram'][min_index]['q'].min(), data['diffractogram'][max_index]['q'].max() - xminmax['q2'][0], xminmax['q2'][1] = data['diffractogram'][min_index]['q2'].min(), data['diffractogram'][max_index]['q2'].max() - xminmax['q4'][0], xminmax['q4'][1] = data['diffractogram'][min_index]['q4'].min(), data['diffractogram'][max_index]['q4'].max() - xminmax['heatmap'] = options['heatmap_xlim'] + + xminmax['2th'][2], xminmax['2th'][3] = xminmax['2th'][0], xminmax['2th'][1] + + xminmax['2th_cuka'][0], xminmax['2th_cuka'][1] = data['diffractogram'][min_index]['2th_cuka'].min(), data['diffractogram'][max_index]['2th_cuka'].max() + xminmax['2th_cuka'][2], xminmax['2th_cuka'][3] = xminmax['2th_cuka'][0], xminmax['2th_cuka'][1] + + xminmax['2th_moka'][0], xminmax['2th_moka'][1] = data['diffractogram'][min_index]['2th_moka'].min(), data['diffractogram'][max_index]['2th_moka'].max() + xminmax['2th_moka'][2], xminmax['2th_moka'][3] = xminmax['2th_moka'][0], xminmax['2th_moka'][1] + + xminmax['d'][0], xminmax['d'][1] = data['diffractogram'][max_index]['d'].min(), data['diffractogram'][min_index]['d'].max() # swapped, intended + xminmax['d'][2], xminmax['d'][3] = xminmax['d'][0], xminmax['d'][1] + + xminmax['1/d'][0], xminmax['1/d'][1] = data['diffractogram'][min_index]['1/d'].min(), data['diffractogram'][max_index]['1/d'].max() + xminmax['1/d'][2], xminmax['1/d'][3] = xminmax['1/d'][0], xminmax['1/d'][1] + + xminmax['q'][0], xminmax['q'][1] = data['diffractogram'][min_index]['q'].min(), data['diffractogram'][max_index]['q'].max() + xminmax['q'][2], xminmax['q'][3] = xminmax['q'][0], xminmax['q'][1] + + xminmax['q2'][0], xminmax['q2'][1] = data['diffractogram'][min_index]['q2'].min(), data['diffractogram'][max_index]['q2'].max() + xminmax['q2'][2], xminmax['q2'][3] = xminmax['q2'][0], xminmax['q2'][1] + + xminmax['q4'][0], xminmax['q4'][1] = data['diffractogram'][min_index]['q4'].min(), data['diffractogram'][max_index]['q4'].max() + xminmax['q4'][2], xminmax['q4'][3] = xminmax['q4'][0], xminmax['q4'][1] + + + xminmax['heatmap'] = options['heatmap_xlim'] # This value is set in the generate_heatmap()-function xminmax['start'][0], xminmax['start'][1] = xminmax[options['x_vals']][0], xminmax[options['x_vals']][1] - xminmax['start'][2], xminmax['start'][3] = xminmax[options['x_vals']][0], xminmax[options['x_vals']][1] + xminmax['start'][2], xminmax['start'][3] = xminmax[options['x_vals']][2], xminmax[options['x_vals']][3] -def update_yminmax(yminmax: dict, data, options={}): +def update_yminmax(yminmax: dict, data: dict, options={}) -> None: - for index, diffractogram in enumerate(data['diffractogram']): + yminmax['diff'] = [None, None, None, None] + # Go through diffractograms and find the minimum and maximum intensity values + for diffractogram in data['diffractogram']: if not yminmax['diff'][0] or (yminmax['diff'][0] > (diffractogram['I'].min())): yminmax['diff'][0] = diffractogram['I'].min() @@ -399,8 +431,9 @@ def update_yminmax(yminmax: dict, data, options={}): yminmax['diff'][1] = yminmax['diff'][1]*5 - yminmax['heatmap'][0] = 0 - yminmax['heatmap'][1] = data['heatmap'].shape[0] + # Set start values to the edges of the dataset + yminmax['heatmap'][0], yminmax['heatmap'][1] = 0, data['heatmap'].shape[0] + yminmax['heatmap'][2], yminmax['heatmap'][3] = yminmax['heatmap'][0], yminmax['heatmap'][1] if options['heatmap']: @@ -413,59 +446,89 @@ def update_yminmax(yminmax: dict, data, options={}): yminmax['start'][2], yminmax['start'][3] = yminmax['diff'][2], yminmax['diff'][3] +def update_defaults(widget: dict, minmax: dict) -> None: + ''' Updates the default x- or y-limits of a given widget. Refer to plot_diffractogram_interactive() to see the form of the widget that is passed in. An update of the min/max-values is done just prior to calling this function. + Changes dictionaries in place. + + Input: + widget (dict): A dictionary containing the widget itself (widget['w']) and all its default-values (e.g. widget['2th_default']) + minmax (dict): A dictionary containing min and max values, as well as min_start and max_start values. (e.g. minmax['2th'] is a list with four elements: [xmin, xmax, xmin_start, xmax_start]) + + Output: + None.''' + + for name, attr in widget.items(): + if name.endswith('default'): + attr['min'] = minmax[name.replace('_default', '')][0] + attr['max'] = minmax[name.replace('_default', '')][1] + attr['value'] = [minmax[name.replace('_default', '')][2], minmax[name.replace('_default', '')][3]] -def update_widgets(options): +def update_widgets(data, options): - for widget, attr in options['widgets'].items(): - if widget == 'xlim': + for widget_name, widget in options['widgets'].items(): - if options['heatmap'] and (attr['state'] != 'heatmap'): - setattr(attr['w'], 'min', attr['heatmap_default']['min']) - setattr(attr['w'], 'max', attr['heatmap_default']['max']) - setattr(attr['w'], 'value', attr['heatmap_default']['value']) - setattr(attr['w'], 'step', attr['heatmap_default']['step']) + # Make changes to xlim-widget + if widget_name == 'xlim': + # First update the min and max values + update_xminmax(xminmax=options['xminmax'], data=data, options=options) + update_defaults(widget=widget, minmax=options['xminmax']) + - attr['state'] = 'heatmap' + if options['heatmap'] and (widget['state'] != 'heatmap'): + + + setattr(widget['w'], 'min', widget['heatmap_default']['min']) + setattr(widget['w'], 'max', widget['heatmap_default']['max']) + setattr(widget['w'], 'value', widget['heatmap_default']['value']) + setattr(widget['w'], 'step', widget['heatmap_default']['step']) + + widget['state'] = 'heatmap' - elif not options['heatmap'] and (attr['state'] != options['x_vals']): - for arg in attr[f'{options["x_vals"]}_default']: + elif not options['heatmap'] and (widget['state'] != options['x_vals']): + # Then loop through all attributes in the widget and change to current mode. + for arg in widget[f'{options["x_vals"]}_default']: # If new min value is larger than previous max, or new max value is smaller than previous min, set the opposite first if arg == 'min': - if attr[f'{options["x_vals"]}_default']['min'] > getattr(attr['w'], 'max'): - setattr(attr['w'], 'max', attr[f'{options["x_vals"]}_default']['max']) + if widget[f'{options["x_vals"]}_default']['min'] > getattr(widget['w'], 'max'): + setattr(widget['w'], 'max', widget[f'{options["x_vals"]}_default']['max']) elif arg == 'max': - if attr[f'{options["x_vals"]}_default']['max'] < getattr(attr['w'], 'min'): - setattr(attr['w'], 'min', attr[f'{options["x_vals"]}_default']['min']) + if widget[f'{options["x_vals"]}_default']['max'] < getattr(widget['w'], 'min'): + setattr(widget['w'], 'min', widget[f'{options["x_vals"]}_default']['min']) - setattr(attr['w'], arg, attr[f'{options["x_vals"]}_default'][arg]) + setattr(widget['w'], arg, widget[f'{options["x_vals"]}_default'][arg]) - attr['state'] = options['x_vals'] + widget['state'] = options['x_vals'] - elif widget == 'ylim': - state = 'heatmap' if options['heatmap'] else 'diff' + # Make changes to ylim-widget + elif widget_name == 'ylim': + update_yminmax(yminmax=options['yminmax'], data=data, options=options) + update_defaults(widget=widget, minmax=options['yminmax']) + + state = 'heatmap' if options['heatmap'] else 'diff' - if attr['state'] != state: + if widget['state'] != state or options['offset_change']: - for arg in attr[f'{state}_default']: + for arg in widget[f'{state}_default']: # If new min value is larger than previous max, or new max value is smaller than previous min, set the opposite first if arg == 'min': - if attr[f'{state}_default']['min'] > getattr(attr['w'], 'max'): - setattr(attr['w'], 'max', attr[f'{state}_default']['max']) + if widget[f'{state}_default']['min'] > getattr(widget['w'], 'max'): + setattr(widget['w'], 'max', widget[f'{state}_default']['max']) elif arg == 'max': - if attr[f'{state}_default']['max'] < getattr(attr['w'], 'min'): - setattr(attr['w'], 'min', attr[f'{state}_default']['min']) + if widget[f'{state}_default']['max'] < getattr(widget['w'], 'min'): + setattr(widget['w'], 'min', widget[f'{state}_default']['min']) - setattr(attr['w'], arg, attr[f'{state}_default'][arg]) - - attr['state'] = state + setattr(widget['w'], arg, widget[f'{state}_default'][arg]) + + options['offset_change'] = False + widget['state'] = state From dd7f2d9dea4f91ea3758ab776d0ef5c01037fce3 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 6 Apr 2022 12:44:33 +0200 Subject: [PATCH 22/57] Fix bug making last commit not work as intended --- beamtime/xrd/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index 9012b4a..db60b1a 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -54,7 +54,7 @@ def plot_diffractogram(data, options={}): default_options['offset_y'] = 0.05 options = aux.update_options(options=options, required_options=required_options, default_options=default_options) - options['current_offset_y'] = options['offset_y'] + #options['current_offset_y'] = options['offset_y'] # Convert data['path'] to list to allow iteration over this to accommodate both single and multiple diffractograms if not isinstance(data['path'], list): From 63726033249475c45a897d45fb311f08feb7ce99 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 6 Apr 2022 13:42:34 +0200 Subject: [PATCH 23/57] Translate relfections to heatmap x-coords --- beamtime/xrd/io.py | 25 ++++++++++++++++---- beamtime/xrd/plot.py | 54 ++++++++++++++++++++++++-------------------- 2 files changed, 49 insertions(+), 30 deletions(-) diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index 910811b..c2447d8 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -400,7 +400,7 @@ def revert_offset(diffractogram,which=None): return diffractogram -def load_reflection_table(data, options={}): +def load_reflection_table(data: dict, reflections_params: dict, options={}): required_options = ['ref_wavelength', 'to_wavelength'] @@ -413,12 +413,12 @@ def load_reflection_table(data, options={}): # VESTA outputs the file with a header that has a space between the parameter and units - so there is some extra code to rectify the issue # that ensues from this formatting - reflections = pd.read_csv(data['path'], delim_whitespace=True) + reflections = pd.read_csv(reflections_params['path'], delim_whitespace=True) # Remove the extra column that appears from the headers issue reflections.drop(reflections.columns[-1], axis=1, inplace=True) - with open(data['path'], 'r') as f: + with open(reflections_params['path'], 'r') as f: line = f.readline() headers = line.split() @@ -434,13 +434,28 @@ def load_reflection_table(data, options={}): reflections = translate_wavelengths(data=reflections, wavelength=options['ref_wavelength'], to_wavelength=options['to_wavelength']) - #print(reflections) + if 'heatmap' in data.keys(): + + start_2th, stop_2th = data['diffractogram'][0]['2th'].min(), data['diffractogram'][0]['2th'].max() + len_2th = stop_2th - start_2th + #print(start_2th, stop_2th, len_2th) + + start_heatmap, stop_heatmap = 0, data['heatmap'].shape[1] + len_heatmap = stop_heatmap - start_heatmap + #print(start_heatmap, stop_heatmap, len_heatmap) + + scale = len_heatmap/len_2th + + #print(scale) + #print(stop_2th * scale) + + reflections['heatmap'] = (reflections['2th']-start_2th) * scale return reflections -def translate_wavelengths(data, wavelength, to_wavelength=None): +def translate_wavelengths(data: pd.DataFrame, wavelength: float, to_wavelength=None) -> pd.DataFrame: # FIXME Somewhere here there is an invalid arcsin-argument. Not sure where. pd.options.mode.chained_assignment = None diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index db60b1a..cc6baa3 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -80,6 +80,8 @@ def plot_diffractogram(data, options={}): # Generate heatmap data data['heatmap'], data['heatmap_xticks'], data['heatmap_xticklabels'] = generate_heatmap(data=data, options=options) + options['heatmap_loaded'] = True + if options['heatmap']: options['xlim'] = options['heatmap_xlim'] @@ -163,16 +165,16 @@ def plot_diffractogram(data, options={}): options['xlim'] = ax.get_xlim() options['to_wavelength'] = data['wavelength'][0] - for reference, axis in zip(options['reflections_data'], ref_axes): - plot_reflection_table(data=reference, ax=axis, options=options) + for reflections_params, axis in zip(options['reflections_data'], ref_axes): + plot_reflection_table(data=data, reflections_params=reflections_params, ax=axis, options=options) # Print the reflection indices. By default, the wavelength of the first diffractogram will be used for this. if options['reflections_indices'] and options['reflections_data']: options['xlim'] = ax.get_xlim() options['to_wavelength'] = data['wavelength'][0] - for reference in options['reflections_data']: - plot_reflection_indices(data=reference, ax=indices_ax, options=options) + for reflections_params in options['reflections_data']: + plot_reflection_indices(data=data, reflections_params=reflections_params, ax=indices_ax, options=options) if options['interactive_session_active']: @@ -533,7 +535,7 @@ def update_widgets(data, options): -def plot_reflection_indices(data, ax, options={}): +def plot_reflection_indices(data, reflections_params, ax, options={}): ''' Print reflection indices from output generated by VESTA. Required contents of data: @@ -547,20 +549,21 @@ def plot_reflection_indices(data, ax, options={}): 'hide_indices': False } - data = aux.update_options(options=data, required_options=required_options, default_options=default_options) + reflections_params = aux.update_options(options=reflections_params, required_options=required_options, default_options=default_options) - if not data['hide_indices']: - reflection_table = xrd.io.load_reflection_table(data=data, options=options) + if not reflections_params['hide_indices']: + reflection_table = xrd.io.load_reflection_table(data=data, reflections_params=reflections_params, options=options) - if data['reflection_indices'] > 0: + if reflections_params['reflection_indices'] > 0: # Get the data['reflection_indices'] number of highest reflections within the subrange options['xlim'] - reflection_indices = reflection_table.loc[(reflection_table[options['x_vals']] > options['xlim'][0]) & (reflection_table[options['x_vals']] < options['xlim'][1])].nlargest(options['reflection_indices'], 'I') + x_vals = 'heatmap' if options['heatmap'] else options['x_vals'] + reflection_indices = reflection_table.loc[(reflection_table[x_vals] > options['xlim'][0]) & (reflection_table[x_vals] < options['xlim'][1])].nlargest(options['reflection_indices'], 'I') # Plot the indices - for i in range(data['reflection_indices']): + for i in range(reflections_params['reflection_indices']): if reflection_indices.shape[0] > i: - ax.text(s=f'({reflection_indices["h"].iloc[i]} {reflection_indices["k"].iloc[i]} {reflection_indices["l"].iloc[i]})', x=reflection_indices[options['x_vals']].iloc[i], y=0, fontsize=2.5, rotation=90, va='bottom', ha='center', c=data['text_colour']) + ax.text(s=f'({reflection_indices["h"].iloc[i]} {reflection_indices["k"].iloc[i]} {reflection_indices["l"].iloc[i]})', x=reflection_indices[x_vals].iloc[i], y=0, fontsize=2.5, rotation=90, va='bottom', ha='center', c=reflections_params['text_colour']) if options['xlim']: @@ -571,7 +574,7 @@ def plot_reflection_indices(data, ax, options={}): return -def plot_reflection_table(data, ax=None, options={}): +def plot_reflection_table(data, reflections_params, ax=None, options={}): ''' Plots a reflection table from output generated by VESTA. Required contents of data: @@ -590,15 +593,15 @@ def plot_reflection_table(data, ax=None, options={}): } if 'colour' in data.keys(): - options['reflections_colour'] = data['colour'] - if 'min_alpha' in data.keys(): - options['min_alpha'] = data['min_alpha'] - if 'reflection_indices' in data.keys(): - options['reflection_indices'] = data['reflection_indices'] - if 'label' in data.keys(): - options['label'] = data['label'] - if 'wavelength' in data.keys(): - options['wavelength'] = data['wavelength'] + options['reflections_colour'] = reflections_params['colour'] + if 'min_alpha' in reflections_params.keys(): + options['min_alpha'] = reflections_params['min_alpha'] + if 'reflection_indices' in reflections_params.keys(): + options['reflection_indices'] = reflections_params['reflection_indices'] + if 'label' in reflections_params.keys(): + options['label'] = reflections_params['label'] + if 'wavelength' in reflections_params.keys(): + options['wavelength'] = reflections_params['wavelength'] options = aux.update_options(options=options, required_options=required_options, default_options=default_options) @@ -606,9 +609,10 @@ def plot_reflection_table(data, ax=None, options={}): if not ax: _, ax = btp.prepare_plot(options) - reflection_table = xrd.io.load_reflection_table(data=data, options=options) + x_vals = 'heatmap' if options['heatmap'] else options['x_vals'] - reflections, intensities = reflection_table[options['x_vals']], reflection_table['I'] + reflection_table = xrd.io.load_reflection_table(data=data, reflections_params=reflections_params, options=options) + reflections, intensities = reflection_table[x_vals], reflection_table['I'] @@ -638,7 +642,7 @@ def plot_reflection_table(data, ax=None, options={}): xlim_range = ax.get_xlim()[1] - ax.get_xlim()[0] ylim_avg = (ax.get_ylim()[0]+ax.get_ylim()[1])/2 - ax.text(s=data['label'], x=(ax.get_xlim()[0]-0.01*xlim_range), y=ylim_avg, ha = 'right', va = 'center') + ax.text(s=reflections_params['label'], x=(ax.get_xlim()[0]-0.01*xlim_range), y=ylim_avg, ha = 'right', va = 'center') From bdfc31901341309a725e5450615fc2823a2554ba Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 6 Apr 2022 14:43:07 +0200 Subject: [PATCH 24/57] Initial commit of test --- beamtime/test/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 beamtime/test/__init__.py diff --git a/beamtime/test/__init__.py b/beamtime/test/__init__.py new file mode 100644 index 0000000..e69de29 From 1146c04a383086fd41f4362c36de0e9a08a34298 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 6 Apr 2022 15:02:38 +0200 Subject: [PATCH 25/57] Add first tests --- beamtime/test/pytest.ini | 6 ++++++ beamtime/test/test_auxillary.py | 29 +++++++++++++++++++++++++++++ beamtime/test/test_plotting.py | 8 ++++++++ beamtime/test/xrd/test_io.py | 0 beamtime/test/xrd/test_plot.py | 0 5 files changed, 43 insertions(+) create mode 100644 beamtime/test/pytest.ini create mode 100644 beamtime/test/test_auxillary.py create mode 100644 beamtime/test/test_plotting.py create mode 100644 beamtime/test/xrd/test_io.py create mode 100644 beamtime/test/xrd/test_plot.py diff --git a/beamtime/test/pytest.ini b/beamtime/test/pytest.ini new file mode 100644 index 0000000..8108e29 --- /dev/null +++ b/beamtime/test/pytest.ini @@ -0,0 +1,6 @@ +# pytest.ini + +[pytest] +minversion = 6.0 +testpaths = + . diff --git a/beamtime/test/test_auxillary.py b/beamtime/test/test_auxillary.py new file mode 100644 index 0000000..5a9e85e --- /dev/null +++ b/beamtime/test/test_auxillary.py @@ -0,0 +1,29 @@ +import beamtime.auxillary as aux + +def test_swap_values(): + + + dict = {'test1': 1, 'test2': 2} + key1 = 'test1' + key2 = 'test2' + + oldval1 = dict[key1] + oldval2 = dict[key2] + + new_dict = aux.swap_values(dict=dict, key1=key1, key2=key2) + + assert (dict[key1] == oldval2) and (dict[key2] == oldval1) + + +def test_ceil() -> None: + + assert aux.ceil(1.05, 0.5) == 1.5 + assert aux.ceil(1.05, 1) == 2.0 + assert aux.ceil(1.1, 0.2) == 1.2 + + +def test_floor() -> None: + + assert aux.floor(2.02, 1) == 2.0 + assert aux.floor(2.02, 0.01) == 2.02 + assert aux.floor(2.013, 0.01) == 2.01 \ No newline at end of file diff --git a/beamtime/test/test_plotting.py b/beamtime/test/test_plotting.py new file mode 100644 index 0000000..1374778 --- /dev/null +++ b/beamtime/test/test_plotting.py @@ -0,0 +1,8 @@ +import beamtime.plotting as btp +from cycler import cycler +import itertools + + +def test_generate_colours() -> None: + + assert type(btp.generate_colours('black', kind='single')) == itertools.cycle \ No newline at end of file diff --git a/beamtime/test/xrd/test_io.py b/beamtime/test/xrd/test_io.py new file mode 100644 index 0000000..e69de29 diff --git a/beamtime/test/xrd/test_plot.py b/beamtime/test/xrd/test_plot.py new file mode 100644 index 0000000..e69de29 From e07acdb4bb839580b541777ebc8937a624aecec6 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 6 Apr 2022 15:06:03 +0200 Subject: [PATCH 26/57] Remove packages not used --- beamtime/plotting.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/beamtime/plotting.py b/beamtime/plotting.py index 500f532..946a4e4 100644 --- a/beamtime/plotting.py +++ b/beamtime/plotting.py @@ -1,13 +1,11 @@ import beamtime.auxillary as aux import matplotlib.pyplot as plt -from matplotlib.ticker import (MultipleLocator, FormatStrFormatter,AutoMinorLocator) -from mpl_toolkits.axes_grid.inset_locator import (inset_axes, InsetPosition, mark_inset) +from matplotlib.ticker import (MultipleLocator) import importlib import matplotlib.patches as mpatches from matplotlib.lines import Line2D import matplotlib.lines as mlines -from cycler import cycler import itertools From 657276eb9177669dc4e4bda468759ea64c93ee20 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 6 Apr 2022 15:57:30 +0200 Subject: [PATCH 27/57] Add tests for auxillary.py --- beamtime/test/test_auxillary.py | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/beamtime/test/test_auxillary.py b/beamtime/test/test_auxillary.py index 5a9e85e..668b792 100644 --- a/beamtime/test/test_auxillary.py +++ b/beamtime/test/test_auxillary.py @@ -1,4 +1,5 @@ import beamtime.auxillary as aux +import os def test_swap_values(): @@ -26,4 +27,52 @@ def test_floor() -> None: assert aux.floor(2.02, 1) == 2.0 assert aux.floor(2.02, 0.01) == 2.02 - assert aux.floor(2.013, 0.01) == 2.01 \ No newline at end of file + assert aux.floor(2.013, 0.01) == 2.01 + + + +def test_options() -> None: + + + options = {} + required_options = ['test1', 'test2', 'test3', 'test4'] + default_options = { + 'test1': 1, + 'test2': 2, + 'test3': 3, + 'test4': 4, + 'test5': 5, + } + + + options = aux.update_options(options=options, required_options=required_options, default_options=default_options) + + assert options['test1'] == default_options['test1'] + assert len(options.items()) == len(required_options) + assert 'test5' not in options.keys() + + +def test_save_options() -> None: + + options = {'test1': 1, 'test2': 2} + path = 'tmp.dat' + + aux.save_options(options, path) + + assert os.path.isfile(path) + + os.remove(path) + + +def test_load_options() -> None: + + options = {'test1': 1, 'test2': 2} + path = 'tmp.dat' + + aux.save_options(options, path) + + loaded_options = aux.load_options(path) + + assert (loaded_options['test1'] == 1) and (loaded_options['test2'] == 2) + + os.remove(path) \ No newline at end of file From 4587322a9b199016f443e03b459e5fa1a447ac4b Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 6 Apr 2022 17:25:46 +0200 Subject: [PATCH 28/57] Add tests for plotting.py --- beamtime/test/test_plotting.py | 126 ++++++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 1 deletion(-) diff --git a/beamtime/test/test_plotting.py b/beamtime/test/test_plotting.py index 1374778..3b9ccda 100644 --- a/beamtime/test/test_plotting.py +++ b/beamtime/test/test_plotting.py @@ -1,8 +1,132 @@ import beamtime.plotting as btp from cycler import cycler import itertools +import numpy as np + +import matplotlib.pyplot as plt def test_generate_colours() -> None: - assert type(btp.generate_colours('black', kind='single')) == itertools.cycle \ No newline at end of file + assert type(btp.generate_colours('black', kind='single')) == itertools.cycle + + palettes = [('qualitative', 'Dark2_8')] + colour_cycle = btp.generate_colours(palettes) + + assert type(colour_cycle) == itertools.cycle + + + # Test that it actually loaded 8 colours when given a set of 8 colours to + + same_colour = None + for i in range(10): + colour = next(colour_cycle) + if i == 0: + first_colour = colour + + if colour == first_colour: + repeat_colour_index = i + + + assert repeat_colour_index == 8 + + + + +def test_update_rc_params() -> None: + + rc_params = { + 'lines.linewidth': 100 + } + + prev_params = plt.rcParams['lines.linewidth'] + + # Update run commands if any is passed (will pass an empty dictionary if not passed) + btp.update_rc_params(rc_params) + + new_params = plt.rcParams['lines.linewidth'] + + assert new_params == 100 + assert prev_params != new_params + + + # Reset run commands + plt.rcdefaults() + + + +def test_scale_figure() -> None: + + width, height = 1, 1 + + format_params = { + 'upscaling_factor': 2, + 'compress_width': 1, + 'compress_height': 1 + } + + width1, height1 = btp.scale_figure(format_params=format_params, width=width, height=height) + + assert width1 == 2 and height1 == 2 + + format_params = { + 'upscaling_factor': 1, + 'compress_width': 0.5, + 'compress_height': 1 + } + + width2, height2 = btp.scale_figure(format_params=format_params, width=width, height=height) + + assert width2 == 0.5 and height2 == 1 + + format_params = { + 'upscaling_factor': 2, + 'compress_width': 0.5, + 'compress_height': 0.2 + } + + width2, height2 = btp.scale_figure(format_params=format_params, width=width, height=height) + + assert width2 == 1 and height2 == 0.4 + + +def test_determine_width() -> None: + + conversion_cm_inch = 0.3937008 # cm to inch + + format_params = { + 'column_type': 'single', + 'single_column_width': 5, + 'double_column_width': 10, + 'width_ratio': '1:1' + } + + assert np.round(btp.determine_width(format_params),6) == np.round(5*conversion_cm_inch,6) + + format_params['column_type'] = 'double' + + assert np.round(btp.determine_width(format_params), 6) == np.round(10*conversion_cm_inch, 6) + + + format_params['column_type'] = 'single' + format_params['width_ratio'] = '1:2' + + assert np.round(btp.determine_width(format_params), 6) == np.round(2.5*conversion_cm_inch, 6) + +def test_determine_height() -> None: + + + width = 1 + + format_params = { + 'aspect_ratio': '1:1' + } + + assert btp.determine_height(format_params=format_params, width=width) == 1 + + format_params['aspect_ratio'] = '3:1' + + assert (btp.determine_height(format_params=format_params, width=width) - 0.333333333333333) < 10e-7 + + assert True + From d702875ab6ff31aed76a2c4e5c75a3e32894ed8c Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 6 Apr 2022 17:28:04 +0200 Subject: [PATCH 29/57] Ignore DeprecationWarning --- beamtime/test/pytest.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/beamtime/test/pytest.ini b/beamtime/test/pytest.ini index 8108e29..c317621 100644 --- a/beamtime/test/pytest.ini +++ b/beamtime/test/pytest.ini @@ -4,3 +4,6 @@ minversion = 6.0 testpaths = . + +filterwarnings = + ignore::DeprecationWarning From e3b0e2bc14fee5733f87803254aa4fe2e614b9f6 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Wed, 6 Apr 2022 17:29:45 +0200 Subject: [PATCH 30/57] Move some files to root folder --- beamtime/README.md => README.md | 0 beamtime/feature_list.txt => feature_list.txt | 0 beamtime/reqirements2.txt => reqirements2.txt | 0 beamtime/requirements.txt => requirements.txt | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename beamtime/README.md => README.md (100%) rename beamtime/feature_list.txt => feature_list.txt (100%) rename beamtime/reqirements2.txt => reqirements2.txt (100%) rename beamtime/requirements.txt => requirements.txt (100%) diff --git a/beamtime/README.md b/README.md similarity index 100% rename from beamtime/README.md rename to README.md diff --git a/beamtime/feature_list.txt b/feature_list.txt similarity index 100% rename from beamtime/feature_list.txt rename to feature_list.txt diff --git a/beamtime/reqirements2.txt b/reqirements2.txt similarity index 100% rename from beamtime/reqirements2.txt rename to reqirements2.txt diff --git a/beamtime/requirements.txt b/requirements.txt similarity index 100% rename from beamtime/requirements.txt rename to requirements.txt From 1db489c21ddd0926b95ae617f56bb4f167201dbe Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 12:02:13 +0200 Subject: [PATCH 31/57] First commit on new repo --- beamtime/test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 beamtime/test.txt diff --git a/beamtime/test.txt b/beamtime/test.txt new file mode 100644 index 0000000..2bf4342 --- /dev/null +++ b/beamtime/test.txt @@ -0,0 +1 @@ +Testing new repository \ No newline at end of file From a84bd065b2bc1b6bd62277af160088982bc398fa Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 12:20:08 +0200 Subject: [PATCH 32/57] Testing push on new repo --- beamtime/test.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 beamtime/test.txt diff --git a/beamtime/test.txt b/beamtime/test.txt deleted file mode 100644 index 2bf4342..0000000 --- a/beamtime/test.txt +++ /dev/null @@ -1 +0,0 @@ -Testing new repository \ No newline at end of file From e8ae6ba1224450ef587eac25ea5289a53c36a768 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 12:21:43 +0200 Subject: [PATCH 33/57] Testing push on new repo again --- beamtime/test.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 beamtime/test.txt diff --git a/beamtime/test.txt b/beamtime/test.txt new file mode 100644 index 0000000..e69de29 From aafcc5a1ed5b432e1ab6e4b8ed7f0eeda71cb90d Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 12:25:31 +0200 Subject: [PATCH 34/57] Test of push in VS Code --- beamtime/test.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/beamtime/test.txt b/beamtime/test.txt index e69de29..85476a8 100644 --- a/beamtime/test.txt +++ b/beamtime/test.txt @@ -0,0 +1 @@ +sdfsdfsdfsdf \ No newline at end of file From ab6bf231001a82deb1e29048d43eedf6033d9443 Mon Sep 17 00:00:00 2001 From: halvorhv Date: Thu, 7 Apr 2022 12:30:32 +0200 Subject: [PATCH 35/57] testing from terminal --- beamtime/test2.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 beamtime/test2.txt diff --git a/beamtime/test2.txt b/beamtime/test2.txt new file mode 100644 index 0000000..e69de29 From bf689886659bb64be611d1d6441269a8db96222b Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 14:05:40 +0200 Subject: [PATCH 36/57] Add more tests for plotting.py and made more general --- beamtime/plotting.py | 78 ++++++---------------------------- beamtime/test/test_plotting.py | 49 +++++++++++++++++++++ 2 files changed, 62 insertions(+), 65 deletions(-) diff --git a/beamtime/plotting.py b/beamtime/plotting.py index 946a4e4..780a022 100644 --- a/beamtime/plotting.py +++ b/beamtime/plotting.py @@ -20,8 +20,15 @@ def prepare_plot(options={}): format_params will determine the size, aspect ratio, resolution etc. of the figure. Should be modified to conform with any requirements from a journal.''' - rc_params = options['rc_params'] - format_params = options['format_params'] + if 'rc_params' in options.keys(): + rc_params = options['rc_params'] + else: + rc_params = {} + + if 'format_params' in options.keys(): + format_params = options['format_params'] + else: + format_params = {} required_format_params = ['single_column_width', 'double_column_width', 'column_type', 'width_ratio', 'aspect_ratio', 'width', 'height', 'compress_width', 'compress_height', 'upscaling_factor', 'dpi', @@ -80,53 +87,14 @@ def prepare_plot(options={}): return fig, axes -def prepare_plots(options={}): - - rc_params = options['rc_params'] - format_params = options['format_params'] - - required_options = ['single_column_width', 'double_column_width', 'column_type', 'width_ratio', 'aspect_ratio', 'compress_width', 'compress_height', 'upscaling_factor', 'dpi'] - - default_options = { - 'single_column_width': 8.3, - 'double_column_width': 17.1, - 'column_type': 'single', - 'width_ratio': '1:1', - 'aspect_ratio': '1:1', - 'compress_width': 1, - 'compress_height': 1, - 'upscaling_factor': 1.0, - 'dpi': 600, - } - - format_params = aux.update_options(format_params, required_options, default_options) - - - # Reset run commands - plt.rcdefaults() - - # Update run commands if any is passed (will pass an empty dictionary if not passed) - update_rc_params(rc_params) - - width = determine_width(format_params) - height = determine_height(format_params, width) - width, height = scale_figure(options=format_params, width=width, height=height) - - - if options['plot_kind'] == 'relative': - fig, axes = plt.subplots(nrows=1, ncols=options['number_of_frames'], figsize=(width,height), facecolor='w', dpi=format_params['dpi']) - - elif options['plot_kind'] == 'absolute': - fig, axes = plt.subplots(nrows=2, ncols=options['number_of_frames'], figsize=(width,height), gridspec_kw={'height_ratios': [1,5]}, facecolor='w', dpi=format_params['dpi']) - - return fig, axes - def adjust_plot(fig, ax, options): ''' A general function to adjust plot according to contents of the options-dictionary ''' required_options = [ 'plot_kind', + 'xlabel', 'ylabel', + 'xunit', 'yunit', 'hide_x_labels', 'hide_y_labels', 'hide_x_ticklabels', 'hide_y_ticklabels', 'hide_x_ticks', 'hide_y_ticks', @@ -141,6 +109,8 @@ def adjust_plot(fig, ax, options): default_options = { 'plot_kind': None, # defaults to None, but should be utilised when requiring special formatting for a particular plot + 'xlabel': None, 'ylabel': None, + 'xunit': None, 'yunit': None, 'hide_x_labels': False, 'hide_y_labels': False, # Whether the main labels on the x- and/or y-axes should be hidden 'hide_x_ticklabels': False, 'hide_y_ticklabels': False, # Whether ticklabels on the x- and/or y-axes should be hidden 'hide_x_ticks': False, 'hide_y_ticks': False, # Whether the ticks on the x- and/or y-axes should be hidden @@ -305,28 +275,6 @@ def ipywidgets_update(func, data, options={}, **kwargs): func(data=data, options=options) -def update_widgets(options): - - for widget in options['widgets'].values(): - - if widget['state'] != options['x_vals']: - for arg in widget[f'{options["x_vals"]}_default']: - - # If new min value is larger than previous max, or new max value is smaller than previous min, set the opposite first - if arg == 'min': - if widget[f'{options["x_vals"]}_default']['min'] > getattr(widget['w'], 'max'): - setattr(widget['w'], 'max', widget[f'{options["x_vals"]}_default']['max']) - - elif arg == 'max': - if widget[f'{options["x_vals"]}_default']['max'] < getattr(widget['w'], 'min'): - setattr(widget['w'], 'min', widget[f'{options["x_vals"]}_default']['min']) - - - setattr(widget['w'], arg, widget[f'{options["x_vals"]}_default'][arg]) - - widget['state'] = options['x_vals'] - - def determine_width(format_params): ''' ''' diff --git a/beamtime/test/test_plotting.py b/beamtime/test/test_plotting.py index 3b9ccda..8979bc1 100644 --- a/beamtime/test/test_plotting.py +++ b/beamtime/test/test_plotting.py @@ -4,6 +4,7 @@ import itertools import numpy as np import matplotlib.pyplot as plt +import matplotlib as mpl def test_generate_colours() -> None: @@ -130,3 +131,51 @@ def test_determine_height() -> None: assert True + + +def test_prepare_plot() -> None: + + fig, ax = btp.prepare_plot() + + assert type(fig) == plt.Figure + assert fig.get_dpi() == 600 + assert ax.get_xlim() == (0.0, 1.0) + + + +def test_adjust_plot() -> None: + + fig, ax = btp.prepare_plot() + + options = { + 'xlim': (0.0, 2.0), + 'title': 'Test' + } + + fig, ax = btp.adjust_plot(fig, ax, options) + + + assert ax.get_xlim() == (0.0, 2.0) + assert ax.get_title() == 'Test' + + + +def test_ipywidgets_update() -> None: + + + + def test_func(data, options): + test1 = options['test1'] + test2 = options['test2'] + + assert type(data) == dict + assert test1 == 1 + assert test2 == 2 + + + + data = {} + options = {} + + btp.ipywidgets_update(func=test_func, data=data, options=options, test1=1, test2=2) + From 239ea9f61e5fd8d1db1e8fc2e8a4f15429bddd23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Vester=20Th=C3=B8gersen?= <34004462+rasmusthog@users.noreply.github.com> Date: Thu, 7 Apr 2022 14:10:25 +0200 Subject: [PATCH 37/57] Create automated testing --- .github/workflows/python-app.yml | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..2e8690d --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,39 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python application + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest From 5c9c93fbb60b6a6b28ba155d34206215d95dbb1c Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 14:14:38 +0200 Subject: [PATCH 38/57] Exporting new requirements and environment --- environment.yml | 154 +++++++++++++++++++++++++++++ reqirements2.txt | 141 -------------------------- requirements.txt | 253 +++++++++++++++++++++++++++-------------------- 3 files changed, 302 insertions(+), 246 deletions(-) create mode 100644 environment.yml delete mode 100644 reqirements2.txt diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..b80378b --- /dev/null +++ b/environment.yml @@ -0,0 +1,154 @@ +name: beamtime +channels: + - conda-forge + - diffpy + - defaults +dependencies: + - argon2-cffi=21.3.0=pyhd3eb1b0_0 + - argon2-cffi-bindings=21.2.0=py39h2bbff1b_0 + - atomicwrites=1.4.0=py_0 + - attrs=21.4.0=pyhd3eb1b0_0 + - backcall=0.2.0=pyhd3eb1b0_0 + - blas=1.0=mkl + - bleach=4.1.0=pyhd3eb1b0_0 + - bottleneck=1.3.2=py39h7cc1a96_1 + - ca-certificates=2022.3.29=haa95532_0 + - cached-property=1.5.2=hd8ed1ab_1 + - cached_property=1.5.2=pyha770c72_1 + - certifi=2021.10.8=py39haa95532_2 + - cffi=1.15.0=py39h2bbff1b_1 + - colorama=0.4.4=pyhd3eb1b0_0 + - cycler=0.10.0=py_2 + - debugpy=1.4.1=py39hd77b12b_0 + - decorator=5.1.0=pyhd3eb1b0_0 + - defusedxml=0.7.1=pyhd3eb1b0_0 + - entrypoints=0.3=py39haa95532_0 + - fabio=0.12.0=py39h5d4886f_0 + - freetype=2.10.4=h546665d_1 + - glymur=0.9.4=pyhd8ed1ab_0 + - h5py=3.2.1=nompi_py39hf27771d_100 + - hdf5=1.10.6=nompi_h5268f04_1114 + - hdf5plugin=3.1.1=py39h71586dd_0 + - icc_rt=2019.0.0=h0cc432a_1 + - icu=68.1=h6c2663c_0 + - importlib-metadata=4.8.2=py39haa95532_0 + - importlib_metadata=4.8.2=hd3eb1b0_0 + - iniconfig=1.1.1=pyhd3eb1b0_0 + - intel-openmp=2021.3.0=haa95532_3372 + - ipykernel=6.4.1=py39haa95532_1 + - ipython=7.27.0=py39hd4e2768_0 + - ipython_genutils=0.2.0=pyhd3eb1b0_1 + - ipywidgets=7.6.5=pyhd3eb1b0_1 + - jbig=2.1=h8d14728_2003 + - jedi=0.18.0=py39haa95532_1 + - jinja2=3.0.2=pyhd3eb1b0_0 + - jpeg=9d=h2bbff1b_0 + - jsonschema=3.2.0=pyhd3eb1b0_2 + - jupyter_client=7.0.1=pyhd3eb1b0_0 + - jupyter_core=4.8.1=py39haa95532_0 + - jupyterlab_pygments=0.1.2=py_0 + - jupyterlab_widgets=1.0.0=pyhd3eb1b0_1 + - kiwisolver=1.3.2=py39h2e07f2f_0 + - krb5=1.19.2=hbae68bd_2 + - lerc=3.0=h0e60522_0 + - libclang=11.1.0=default_h5c34c98_1 + - libcurl=7.79.1=h789b8ee_1 + - libdeflate=1.8=h2bbff1b_5 + - libiconv=1.16=he774522_0 + - libpng=1.6.37=h1d00b33_2 + - libssh2=1.10.0=h680486a_2 + - libtiff=4.3.0=hd413186_2 + - libwebp=1.2.0=h2bbff1b_0 + - libxml2=2.9.12=h0ad7f3c_0 + - libxslt=1.1.34=he774522_0 + - libzlib=1.2.11=h8ffe710_1013 + - lxml=4.6.3=py39h4fd7cdf_0 + - lz4-c=1.9.3=h8ffe710_1 + - mako=1.1.5=pyhd8ed1ab_0 + - markupsafe=2.0.1=py39h2bbff1b_0 + - matplotlib=3.4.3=py39hcbf5309_1 + - matplotlib-base=3.4.3=py39h581301d_1 + - matplotlib-inline=0.1.2=pyhd3eb1b0_2 + - mistune=0.8.4=py39h2bbff1b_1000 + - mkl=2021.3.0=haa95532_524 + - mkl-service=2.4.0=py39h2bbff1b_0 + - mkl_fft=1.3.1=py39h277e83a_0 + - mkl_random=1.2.2=py39hf11a4ad_0 + - mpmath=1.2.1=py39haa95532_0 + - nbclient=0.5.11=pyhd3eb1b0_0 + - nbconvert=6.1.0=py39haa95532_0 + - nbformat=5.1.3=pyhd3eb1b0_0 + - nest-asyncio=1.5.1=pyhd3eb1b0_0 + - notebook=6.4.8=py39haa95532_0 + - numexpr=2.7.3=py39hb80d3ca_1 + - numpy=1.21.2=py39hfca59bb_0 + - numpy-base=1.21.2=py39h0829f74_0 + - olefile=0.46=pyh9f0ad1d_1 + - openjpeg=2.4.0=hb211442_1 + - openssl=1.1.1n=h2bbff1b_0 + - packaging=21.3=pyhd3eb1b0_0 + - palettable=3.3.0=pyhd3eb1b0_0 + - pandas=1.3.3=py39h6214cd6_0 + - pandocfilters=1.5.0=pyhd3eb1b0_0 + - parso=0.8.2=pyhd3eb1b0_0 + - pickleshare=0.7.5=pyhd3eb1b0_1003 + - pillow=8.4.0=py39hd45dc43_0 + - pip=21.2.4=py39haa95532_0 + - pluggy=1.0.0=py39haa95532_1 + - prometheus_client=0.13.1=pyhd3eb1b0_0 + - prompt-toolkit=3.0.20=pyhd3eb1b0_0 + - py=1.11.0=pyhd3eb1b0_0 + - pycparser=2.21=pyhd3eb1b0_0 + - pyfai=0.20.0=hd8ed1ab_0 + - pyfai-base=0.20.0=py39h2e25243_0 + - pygments=2.10.0=pyhd3eb1b0_0 + - pyparsing=2.4.7=pyhd3eb1b0_0 + - pyqt=5.12.3=py39hcbf5309_7 + - pyqt-impl=5.12.3=py39h415ef7b_7 + - pyqt5-sip=4.19.18=py39h415ef7b_7 + - pyqtchart=5.12=py39h415ef7b_7 + - pyqtwebengine=5.12.1=py39h415ef7b_7 + - pyreadline=2.1=py39hcbf5309_1004 + - pyrsistent=0.18.0=py39h196d8e1_0 + - pytest=7.1.1=py39haa95532_0 + - python=3.9.7=h6244533_1 + - python-dateutil=2.8.2=pyhd3eb1b0_0 + - python_abi=3.9=2_cp39 + - pytz=2021.3=pyhd3eb1b0_0 + - pywin32=228=py39hbaba5e8_1 + - pywinpty=2.0.2=py39h5da7b33_0 + - pyzmq=22.2.1=py39hd77b12b_1 + - qt=5.12.9=h5909a2a_4 + - qtconsole=5.1.1=pyhd3eb1b0_0 + - qtpy=1.11.2=pyhd8ed1ab_0 + - scipy=1.7.1=py39hbe87c03_2 + - seaborn=0.11.2=pyhd3eb1b0_0 + - send2trash=1.8.0=pyhd3eb1b0_1 + - setuptools=58.0.4=py39haa95532_0 + - silx=0.15.2=hd8ed1ab_0 + - silx-base=0.15.2=py39h2e25243_0 + - six=1.16.0=pyhd3eb1b0_0 + - sqlite=3.36.0=h2bbff1b_0 + - sympy=1.9=py39haa95532_0 + - terminado=0.13.1=py39haa95532_0 + - testpath=0.5.0=pyhd3eb1b0_0 + - tk=8.6.11=h8ffe710_1 + - tomli=1.2.2=pyhd3eb1b0_0 + - tornado=6.1=py39h2bbff1b_0 + - traitlets=5.1.0=pyhd3eb1b0_0 + - typing-extensions=3.10.0.2=hd3eb1b0_0 + - typing_extensions=3.10.0.2=pyh06a4308_0 + - tzdata=2021a=h5d7bf9c_0 + - vc=14.2=h21ff451_1 + - vs2015_runtime=14.27.29016=h5e58377_2 + - wcwidth=0.2.5=pyhd3eb1b0_0 + - webencodings=0.5.1=py39haa95532_1 + - wheel=0.37.0=pyhd3eb1b0_1 + - widgetsnbextension=3.5.2=py39haa95532_0 + - wincertstore=0.2=py39haa95532_2 + - winpty=0.4.3=4 + - xz=5.2.5=h62dcd97_1 + - zipp=3.7.0=pyhd3eb1b0_0 + - zlib=1.2.11=h8ffe710_1013 + - zstd=1.5.0=h6255e5f_0 +prefix: C:\Users\rasmusvt\Anaconda3\envs\beamtime diff --git a/reqirements2.txt b/reqirements2.txt deleted file mode 100644 index 5cef354..0000000 --- a/reqirements2.txt +++ /dev/null @@ -1,141 +0,0 @@ -# This file may be used to create an environment using: -# $ conda create --name --file -# platform: win-64 -argon2-cffi=21.3.0=pyhd3eb1b0_0 -argon2-cffi-bindings=21.2.0=py39h2bbff1b_0 -attrs=21.4.0=pyhd3eb1b0_0 -backcall=0.2.0=pyhd3eb1b0_0 -beamtime=0.1=pypi_0 -blas=1.0=mkl -bleach=4.1.0=pyhd3eb1b0_0 -bottleneck=1.3.2=py39h7cc1a96_1 -ca-certificates=2022.2.1=haa95532_0 -cached-property=1.5.2=hd8ed1ab_1 -cached_property=1.5.2=pyha770c72_1 -certifi=2021.10.8=py39haa95532_2 -cffi=1.15.0=py39h2bbff1b_1 -colorama=0.4.4=pyhd3eb1b0_0 -cycler=0.10.0=py_2 -debugpy=1.4.1=py39hd77b12b_0 -decorator=5.1.0=pyhd3eb1b0_0 -defusedxml=0.7.1=pyhd3eb1b0_0 -entrypoints=0.3=py39haa95532_0 -fabio=0.12.0=py39h5d4886f_0 -freetype=2.10.4=h546665d_1 -glymur=0.9.4=pyhd8ed1ab_0 -h5py=3.2.1=nompi_py39hf27771d_100 -hdf5=1.10.6=nompi_h5268f04_1114 -hdf5plugin=3.1.1=py39h71586dd_0 -icc_rt=2019.0.0=h0cc432a_1 -icu=68.1=h6c2663c_0 -importlib-metadata=4.8.2=py39haa95532_0 -importlib_metadata=4.8.2=hd3eb1b0_0 -intel-openmp=2021.3.0=haa95532_3372 -ipykernel=6.4.1=py39haa95532_1 -ipython=7.27.0=py39hd4e2768_0 -ipython_genutils=0.2.0=pyhd3eb1b0_1 -ipywidgets=7.6.5=pyhd3eb1b0_1 -jbig=2.1=h8d14728_2003 -jedi=0.18.0=py39haa95532_1 -jinja2=3.0.2=pyhd3eb1b0_0 -jpeg=9d=h2bbff1b_0 -jsonschema=3.2.0=pyhd3eb1b0_2 -jupyter_client=7.0.1=pyhd3eb1b0_0 -jupyter_core=4.8.1=py39haa95532_0 -jupyterlab_pygments=0.1.2=py_0 -jupyterlab_widgets=1.0.0=pyhd3eb1b0_1 -kiwisolver=1.3.2=py39h2e07f2f_0 -krb5=1.19.2=hbae68bd_2 -lerc=3.0=h0e60522_0 -libclang=11.1.0=default_h5c34c98_1 -libcurl=7.79.1=h789b8ee_1 -libdeflate=1.8=h2bbff1b_5 -libiconv=1.16=he774522_0 -libpng=1.6.37=h1d00b33_2 -libssh2=1.10.0=h680486a_2 -libtiff=4.3.0=hd413186_2 -libwebp=1.2.0=h2bbff1b_0 -libxml2=2.9.12=h0ad7f3c_0 -libxslt=1.1.34=he774522_0 -libzlib=1.2.11=h8ffe710_1013 -lxml=4.6.3=py39h4fd7cdf_0 -lz4-c=1.9.3=h8ffe710_1 -mako=1.1.5=pyhd8ed1ab_0 -markupsafe=2.0.1=py39h2bbff1b_0 -matplotlib=3.4.3=py39hcbf5309_1 -matplotlib-base=3.4.3=py39h581301d_1 -matplotlib-inline=0.1.2=pyhd3eb1b0_2 -mistune=0.8.4=py39h2bbff1b_1000 -mkl=2021.3.0=haa95532_524 -mkl-service=2.4.0=py39h2bbff1b_0 -mkl_fft=1.3.1=py39h277e83a_0 -mkl_random=1.2.2=py39hf11a4ad_0 -nbclient=0.5.11=pyhd3eb1b0_0 -nbconvert=6.1.0=py39haa95532_0 -nbformat=5.1.3=pyhd3eb1b0_0 -nest-asyncio=1.5.1=pyhd3eb1b0_0 -notebook=6.4.8=py39haa95532_0 -numexpr=2.7.3=py39hb80d3ca_1 -numpy=1.21.2=py39hfca59bb_0 -numpy-base=1.21.2=py39h0829f74_0 -olefile=0.46=pyh9f0ad1d_1 -openjpeg=2.4.0=hb211442_1 -openssl=1.1.1m=h2bbff1b_0 -packaging=21.3=pyhd3eb1b0_0 -pandas=1.3.3=py39h6214cd6_0 -pandocfilters=1.5.0=pyhd3eb1b0_0 -parso=0.8.2=pyhd3eb1b0_0 -pickleshare=0.7.5=pyhd3eb1b0_1003 -pillow=8.4.0=py39hd45dc43_0 -pip=21.2.4=py39haa95532_0 -prometheus_client=0.13.1=pyhd3eb1b0_0 -prompt-toolkit=3.0.20=pyhd3eb1b0_0 -pycparser=2.21=pyhd3eb1b0_0 -pyfai=0.20.0=hd8ed1ab_0 -pyfai-base=0.20.0=py39h2e25243_0 -pygments=2.10.0=pyhd3eb1b0_0 -pyparsing=2.4.7=pyhd3eb1b0_0 -pyqt=5.12.3=py39hcbf5309_7 -pyqt-impl=5.12.3=py39h415ef7b_7 -pyqt5-sip=4.19.18=py39h415ef7b_7 -pyqtchart=5.12=py39h415ef7b_7 -pyqtwebengine=5.12.1=py39h415ef7b_7 -pyreadline=2.1=py39hcbf5309_1004 -pyrsistent=0.18.0=py39h196d8e1_0 -python=3.9.7=h6244533_1 -python-dateutil=2.8.2=pyhd3eb1b0_0 -python_abi=3.9=2_cp39 -pytz=2021.3=pyhd3eb1b0_0 -pywin32=228=py39hbaba5e8_1 -pywinpty=2.0.2=py39h5da7b33_0 -pyzmq=22.2.1=py39hd77b12b_1 -qt=5.12.9=h5909a2a_4 -qtconsole=5.1.1=pyhd3eb1b0_0 -qtpy=1.11.2=pyhd8ed1ab_0 -scipy=1.7.1=py39hbe87c03_2 -send2trash=1.8.0=pyhd3eb1b0_1 -setuptools=58.0.4=py39haa95532_0 -silx=0.15.2=hd8ed1ab_0 -silx-base=0.15.2=py39h2e25243_0 -six=1.16.0=pyhd3eb1b0_0 -sqlite=3.36.0=h2bbff1b_0 -terminado=0.13.1=py39haa95532_0 -testpath=0.5.0=pyhd3eb1b0_0 -tk=8.6.11=h8ffe710_1 -tornado=6.1=py39h2bbff1b_0 -traitlets=5.1.0=pyhd3eb1b0_0 -typing-extensions=3.10.0.2=hd3eb1b0_0 -typing_extensions=3.10.0.2=pyh06a4308_0 -tzdata=2021a=h5d7bf9c_0 -vc=14.2=h21ff451_1 -vs2015_runtime=14.27.29016=h5e58377_2 -wcwidth=0.2.5=pyhd3eb1b0_0 -webencodings=0.5.1=py39haa95532_1 -wheel=0.37.0=pyhd3eb1b0_1 -widgetsnbextension=3.5.2=py39haa95532_0 -wincertstore=0.2=py39haa95532_2 -winpty=0.4.3=4 -xz=5.2.5=h62dcd97_1 -zipp=3.7.0=pyhd3eb1b0_0 -zlib=1.2.11=h8ffe710_1013 -zstd=1.5.0=h6255e5f_0 diff --git a/requirements.txt b/requirements.txt index d8eeb75..8b428c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,108 +1,151 @@ # This file may be used to create an environment using: # $ conda create --name --file # platform: win-64 -@EXPLICIT -https://repo.anaconda.com/pkgs/main/win-64/blas-1.0-mkl.conda -https://conda.anaconda.org/conda-forge/win-64/ca-certificates-2021.10.8-h5b45459_0.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/icc_rt-2019.0.0-h0cc432a_1.conda -https://repo.anaconda.com/pkgs/main/win-64/intel-openmp-2021.3.0-haa95532_3372.conda -https://repo.anaconda.com/pkgs/main/noarch/tzdata-2021a-h5d7bf9c_0.conda -https://repo.anaconda.com/pkgs/main/win-64/vs2015_runtime-14.27.29016-h5e58377_2.conda -https://repo.anaconda.com/pkgs/main/win-64/mkl-2021.3.0-haa95532_524.conda -https://repo.anaconda.com/pkgs/main/win-64/vc-14.2-h21ff451_1.conda -https://repo.anaconda.com/pkgs/main/win-64/icu-68.1-h6c2663c_0.conda -https://conda.anaconda.org/conda-forge/win-64/jbig-2.1-h8d14728_2003.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/jpeg-9d-h2bbff1b_0.conda -https://conda.anaconda.org/conda-forge/win-64/lerc-3.0-h0e60522_0.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/libclang-11.1.0-default_h5c34c98_1.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/libdeflate-1.8-h2bbff1b_5.conda -https://conda.anaconda.org/conda-forge/win-64/libiconv-1.16-he774522_0.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/libwebp-1.2.0-h2bbff1b_0.conda -https://conda.anaconda.org/conda-forge/win-64/libzlib-1.2.11-h8ffe710_1013.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/lz4-c-1.9.3-h8ffe710_1.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/openssl-1.1.1l-h8ffe710_0.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/sqlite-3.36.0-h2bbff1b_0.conda -https://conda.anaconda.org/conda-forge/win-64/tk-8.6.11-h8ffe710_1.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/xz-5.2.5-h62dcd97_1.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/krb5-1.19.2-hbae68bd_2.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/python-3.9.7-h6244533_1.conda -https://conda.anaconda.org/conda-forge/win-64/zlib-1.2.11-h8ffe710_1013.tar.bz2 -https://repo.anaconda.com/pkgs/main/noarch/backcall-0.2.0-pyhd3eb1b0_0.tar.bz2 -https://conda.anaconda.org/conda-forge/noarch/cached_property-1.5.2-pyha770c72_1.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/certifi-2021.10.8-py39haa95532_0.conda -https://repo.anaconda.com/pkgs/main/noarch/colorama-0.4.4-pyhd3eb1b0_0.conda -https://repo.anaconda.com/pkgs/main/win-64/debugpy-1.4.1-py39hd77b12b_0.conda -https://repo.anaconda.com/pkgs/main/noarch/decorator-5.1.0-pyhd3eb1b0_0.conda -https://repo.anaconda.com/pkgs/main/win-64/entrypoints-0.3-py39haa95532_0.conda -https://repo.anaconda.com/pkgs/main/noarch/ipython_genutils-0.2.0-pyhd3eb1b0_1.conda -https://conda.anaconda.org/conda-forge/win-64/libpng-1.6.37-h1d00b33_2.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/libssh2-1.10.0-h680486a_2.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/libxml2-2.9.12-h0ad7f3c_0.conda -https://repo.anaconda.com/pkgs/main/win-64/markupsafe-2.0.1-py39h2bbff1b_0.conda -https://repo.anaconda.com/pkgs/main/noarch/nest-asyncio-1.5.1-pyhd3eb1b0_0.conda -https://conda.anaconda.org/conda-forge/noarch/olefile-0.46-pyh9f0ad1d_1.tar.bz2 -https://repo.anaconda.com/pkgs/main/noarch/parso-0.8.2-pyhd3eb1b0_0.conda -https://repo.anaconda.com/pkgs/main/noarch/pickleshare-0.7.5-pyhd3eb1b0_1003.conda -https://repo.anaconda.com/pkgs/main/noarch/pyparsing-2.4.7-pyhd3eb1b0_0.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/python_abi-3.9-2_cp39.tar.bz2 -https://repo.anaconda.com/pkgs/main/noarch/pytz-2021.3-pyhd3eb1b0_0.conda -https://repo.anaconda.com/pkgs/main/win-64/pywin32-228-py39hbaba5e8_1.conda -https://repo.anaconda.com/pkgs/main/win-64/pyzmq-22.2.1-py39hd77b12b_1.conda -https://conda.anaconda.org/conda-forge/noarch/qtpy-1.11.2-pyhd8ed1ab_0.tar.bz2 -https://repo.anaconda.com/pkgs/main/noarch/six-1.16.0-pyhd3eb1b0_0.conda -https://repo.anaconda.com/pkgs/main/win-64/tornado-6.1-py39h2bbff1b_0.conda -https://repo.anaconda.com/pkgs/main/noarch/traitlets-5.1.0-pyhd3eb1b0_0.conda -https://repo.anaconda.com/pkgs/main/noarch/wcwidth-0.2.5-pyhd3eb1b0_0.conda -https://repo.anaconda.com/pkgs/main/noarch/wheel-0.37.0-pyhd3eb1b0_1.conda -https://repo.anaconda.com/pkgs/main/win-64/wincertstore-0.2-py39haa95532_2.conda -https://conda.anaconda.org/conda-forge/win-64/zstd-1.5.0-h6255e5f_0.tar.bz2 -https://conda.anaconda.org/conda-forge/noarch/cached-property-1.5.2-hd8ed1ab_1.tar.bz2 -https://conda.anaconda.org/conda-forge/noarch/cycler-0.10.0-py_2.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/freetype-2.10.4-h546665d_1.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/jedi-0.18.0-py39haa95532_1.conda -https://repo.anaconda.com/pkgs/main/win-64/jupyter_core-4.8.1-py39haa95532_0.conda -https://conda.anaconda.org/conda-forge/win-64/kiwisolver-1.3.2-py39h2e07f2f_0.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/libcurl-7.79.1-h789b8ee_1.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/libtiff-4.3.0-hd413186_2.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/libxslt-1.1.34-he774522_0.conda -https://conda.anaconda.org/conda-forge/noarch/mako-1.1.5-pyhd8ed1ab_0.tar.bz2 -https://repo.anaconda.com/pkgs/main/noarch/matplotlib-inline-0.1.2-pyhd3eb1b0_2.conda -https://repo.anaconda.com/pkgs/main/win-64/mkl-service-2.4.0-py39h2bbff1b_0.conda -https://repo.anaconda.com/pkgs/main/noarch/prompt-toolkit-3.0.20-pyhd3eb1b0_0.conda -https://conda.anaconda.org/conda-forge/win-64/pyqt5-sip-4.19.18-py39h415ef7b_7.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/pyreadline-2.1-py39hcbf5309_1004.tar.bz2 -https://repo.anaconda.com/pkgs/main/noarch/python-dateutil-2.8.2-pyhd3eb1b0_0.conda -https://conda.anaconda.org/conda-forge/win-64/qt-5.12.9-h5909a2a_4.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/setuptools-58.0.4-py39haa95532_0.conda -https://conda.anaconda.org/conda-forge/win-64/hdf5-1.10.6-nompi_h5268f04_1114.tar.bz2 -https://repo.anaconda.com/pkgs/main/noarch/jupyter_client-7.0.1-pyhd3eb1b0_0.conda -https://conda.anaconda.org/conda-forge/win-64/lxml-4.6.3-py39h4fd7cdf_0.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/numpy-base-1.21.2-py39h0829f74_0.conda -https://conda.anaconda.org/conda-forge/win-64/openjpeg-2.4.0-hb211442_1.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/pillow-8.4.0-py39hd45dc43_0.conda -https://repo.anaconda.com/pkgs/main/win-64/pip-21.2.4-py39haa95532_0.conda -https://repo.anaconda.com/pkgs/main/noarch/pygments-2.10.0-pyhd3eb1b0_0.conda -https://conda.anaconda.org/conda-forge/win-64/pyqt-impl-5.12.3-py39h415ef7b_7.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/ipython-7.27.0-py39hd4e2768_0.conda -https://conda.anaconda.org/conda-forge/win-64/pyqtchart-5.12-py39h415ef7b_7.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/pyqtwebengine-5.12.1-py39h415ef7b_7.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/ipykernel-6.4.1-py39haa95532_1.conda -https://conda.anaconda.org/conda-forge/win-64/pyqt-5.12.3-py39hcbf5309_7.tar.bz2 -https://repo.anaconda.com/pkgs/main/noarch/qtconsole-5.1.1-pyhd3eb1b0_0.conda -https://conda.anaconda.org/conda-forge/noarch/glymur-0.9.4-pyhd8ed1ab_0.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/fabio-0.12.0-py39h5d4886f_0.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/h5py-3.2.1-nompi_py39hf27771d_100.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/hdf5plugin-3.1.1-py39h71586dd_0.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/matplotlib-3.4.3-py39hcbf5309_1.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/matplotlib-base-3.4.3-py39h581301d_1.tar.bz2 -https://conda.anaconda.org/conda-forge/win-64/silx-base-0.15.2-py39h2e25243_0.tar.bz2 -https://conda.anaconda.org/conda-forge/noarch/silx-0.15.2-hd8ed1ab_0.tar.bz2 -https://conda.anaconda.org/conda-forge/noarch/pyfai-0.20.0-hd8ed1ab_0.tar.bz2 -https://repo.anaconda.com/pkgs/main/win-64/bottleneck-1.3.2-py39h7cc1a96_1.conda -https://repo.anaconda.com/pkgs/main/win-64/mkl_fft-1.3.1-py39h277e83a_0.conda -https://repo.anaconda.com/pkgs/main/win-64/mkl_random-1.2.2-py39hf11a4ad_0.conda -https://repo.anaconda.com/pkgs/main/win-64/numpy-1.21.2-py39hfca59bb_0.conda -https://repo.anaconda.com/pkgs/main/win-64/numexpr-2.7.3-py39hb80d3ca_1.conda -https://repo.anaconda.com/pkgs/main/win-64/scipy-1.7.1-py39hbe87c03_2.conda -https://repo.anaconda.com/pkgs/main/win-64/pandas-1.3.3-py39h6214cd6_0.conda -https://conda.anaconda.org/conda-forge/win-64/pyfai-base-0.20.0-py39h2e25243_0.tar.bz2 +argon2-cffi=21.3.0=pyhd3eb1b0_0 +argon2-cffi-bindings=21.2.0=py39h2bbff1b_0 +atomicwrites=1.4.0=py_0 +attrs=21.4.0=pyhd3eb1b0_0 +backcall=0.2.0=pyhd3eb1b0_0 +beamtime=0.1=dev_0 +blas=1.0=mkl +bleach=4.1.0=pyhd3eb1b0_0 +bottleneck=1.3.2=py39h7cc1a96_1 +ca-certificates=2022.3.29=haa95532_0 +cached-property=1.5.2=hd8ed1ab_1 +cached_property=1.5.2=pyha770c72_1 +certifi=2021.10.8=py39haa95532_2 +cffi=1.15.0=py39h2bbff1b_1 +colorama=0.4.4=pyhd3eb1b0_0 +cycler=0.10.0=py_2 +debugpy=1.4.1=py39hd77b12b_0 +decorator=5.1.0=pyhd3eb1b0_0 +defusedxml=0.7.1=pyhd3eb1b0_0 +entrypoints=0.3=py39haa95532_0 +fabio=0.12.0=py39h5d4886f_0 +freetype=2.10.4=h546665d_1 +glymur=0.9.4=pyhd8ed1ab_0 +h5py=3.2.1=nompi_py39hf27771d_100 +hdf5=1.10.6=nompi_h5268f04_1114 +hdf5plugin=3.1.1=py39h71586dd_0 +icc_rt=2019.0.0=h0cc432a_1 +icu=68.1=h6c2663c_0 +importlib-metadata=4.8.2=py39haa95532_0 +importlib_metadata=4.8.2=hd3eb1b0_0 +iniconfig=1.1.1=pyhd3eb1b0_0 +intel-openmp=2021.3.0=haa95532_3372 +ipykernel=6.4.1=py39haa95532_1 +ipython=7.27.0=py39hd4e2768_0 +ipython_genutils=0.2.0=pyhd3eb1b0_1 +ipywidgets=7.6.5=pyhd3eb1b0_1 +jbig=2.1=h8d14728_2003 +jedi=0.18.0=py39haa95532_1 +jinja2=3.0.2=pyhd3eb1b0_0 +jpeg=9d=h2bbff1b_0 +jsonschema=3.2.0=pyhd3eb1b0_2 +jupyter_client=7.0.1=pyhd3eb1b0_0 +jupyter_core=4.8.1=py39haa95532_0 +jupyterlab_pygments=0.1.2=py_0 +jupyterlab_widgets=1.0.0=pyhd3eb1b0_1 +kiwisolver=1.3.2=py39h2e07f2f_0 +krb5=1.19.2=hbae68bd_2 +lerc=3.0=h0e60522_0 +libclang=11.1.0=default_h5c34c98_1 +libcurl=7.79.1=h789b8ee_1 +libdeflate=1.8=h2bbff1b_5 +libiconv=1.16=he774522_0 +libpng=1.6.37=h1d00b33_2 +libssh2=1.10.0=h680486a_2 +libtiff=4.3.0=hd413186_2 +libwebp=1.2.0=h2bbff1b_0 +libxml2=2.9.12=h0ad7f3c_0 +libxslt=1.1.34=he774522_0 +libzlib=1.2.11=h8ffe710_1013 +lxml=4.6.3=py39h4fd7cdf_0 +lz4-c=1.9.3=h8ffe710_1 +mako=1.1.5=pyhd8ed1ab_0 +markupsafe=2.0.1=py39h2bbff1b_0 +matplotlib=3.4.3=py39hcbf5309_1 +matplotlib-base=3.4.3=py39h581301d_1 +matplotlib-inline=0.1.2=pyhd3eb1b0_2 +mistune=0.8.4=py39h2bbff1b_1000 +mkl=2021.3.0=haa95532_524 +mkl-service=2.4.0=py39h2bbff1b_0 +mkl_fft=1.3.1=py39h277e83a_0 +mkl_random=1.2.2=py39hf11a4ad_0 +mpmath=1.2.1=py39haa95532_0 +nbclient=0.5.11=pyhd3eb1b0_0 +nbconvert=6.1.0=py39haa95532_0 +nbformat=5.1.3=pyhd3eb1b0_0 +nest-asyncio=1.5.1=pyhd3eb1b0_0 +notebook=6.4.8=py39haa95532_0 +numexpr=2.7.3=py39hb80d3ca_1 +numpy=1.21.2=py39hfca59bb_0 +numpy-base=1.21.2=py39h0829f74_0 +olefile=0.46=pyh9f0ad1d_1 +openjpeg=2.4.0=hb211442_1 +openssl=1.1.1n=h2bbff1b_0 +packaging=21.3=pyhd3eb1b0_0 +palettable=3.3.0=pyhd3eb1b0_0 +pandas=1.3.3=py39h6214cd6_0 +pandocfilters=1.5.0=pyhd3eb1b0_0 +parso=0.8.2=pyhd3eb1b0_0 +pickleshare=0.7.5=pyhd3eb1b0_1003 +pillow=8.4.0=py39hd45dc43_0 +pip=21.2.4=py39haa95532_0 +pluggy=1.0.0=py39haa95532_1 +prometheus_client=0.13.1=pyhd3eb1b0_0 +prompt-toolkit=3.0.20=pyhd3eb1b0_0 +py=1.11.0=pyhd3eb1b0_0 +pycparser=2.21=pyhd3eb1b0_0 +pyfai=0.20.0=hd8ed1ab_0 +pyfai-base=0.20.0=py39h2e25243_0 +pygments=2.10.0=pyhd3eb1b0_0 +pyparsing=2.4.7=pyhd3eb1b0_0 +pyqt=5.12.3=py39hcbf5309_7 +pyqt-impl=5.12.3=py39h415ef7b_7 +pyqt5-sip=4.19.18=py39h415ef7b_7 +pyqtchart=5.12=py39h415ef7b_7 +pyqtwebengine=5.12.1=py39h415ef7b_7 +pyreadline=2.1=py39hcbf5309_1004 +pyrsistent=0.18.0=py39h196d8e1_0 +pytest=7.1.1=py39haa95532_0 +python=3.9.7=h6244533_1 +python-dateutil=2.8.2=pyhd3eb1b0_0 +python_abi=3.9=2_cp39 +pytz=2021.3=pyhd3eb1b0_0 +pywin32=228=py39hbaba5e8_1 +pywinpty=2.0.2=py39h5da7b33_0 +pyzmq=22.2.1=py39hd77b12b_1 +qt=5.12.9=h5909a2a_4 +qtconsole=5.1.1=pyhd3eb1b0_0 +qtpy=1.11.2=pyhd8ed1ab_0 +scipy=1.7.1=py39hbe87c03_2 +seaborn=0.11.2=pyhd3eb1b0_0 +send2trash=1.8.0=pyhd3eb1b0_1 +setuptools=58.0.4=py39haa95532_0 +silx=0.15.2=hd8ed1ab_0 +silx-base=0.15.2=py39h2e25243_0 +six=1.16.0=pyhd3eb1b0_0 +sqlite=3.36.0=h2bbff1b_0 +sympy=1.9=py39haa95532_0 +terminado=0.13.1=py39haa95532_0 +testpath=0.5.0=pyhd3eb1b0_0 +tk=8.6.11=h8ffe710_1 +tomli=1.2.2=pyhd3eb1b0_0 +tornado=6.1=py39h2bbff1b_0 +traitlets=5.1.0=pyhd3eb1b0_0 +typing-extensions=3.10.0.2=hd3eb1b0_0 +typing_extensions=3.10.0.2=pyh06a4308_0 +tzdata=2021a=h5d7bf9c_0 +vc=14.2=h21ff451_1 +vs2015_runtime=14.27.29016=h5e58377_2 +wcwidth=0.2.5=pyhd3eb1b0_0 +webencodings=0.5.1=py39haa95532_1 +wheel=0.37.0=pyhd3eb1b0_1 +widgetsnbextension=3.5.2=py39haa95532_0 +wincertstore=0.2=py39haa95532_2 +winpty=0.4.3=4 +xz=5.2.5=h62dcd97_1 +zipp=3.7.0=pyhd3eb1b0_0 +zlib=1.2.11=h8ffe710_1013 +zstd=1.5.0=h6255e5f_0 From b5f4f98070dd30292f98b06f056d34a76526454d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Vester=20Th=C3=B8gersen?= <34004462+rasmusthog@users.noreply.github.com> Date: Thu, 7 Apr 2022 14:22:28 +0200 Subject: [PATCH 39/57] Delete first attempt at automated testing --- .github/workflows/python-app.yml | 39 -------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml deleted file mode 100644 index 2e8690d..0000000 --- a/.github/workflows/python-app.yml +++ /dev/null @@ -1,39 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Python application - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -permissions: - contents: read - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest From 739b197e9aca699af70dd5cb984417d155b1071f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Vester=20Th=C3=B8gersen?= <34004462+rasmusthog@users.noreply.github.com> Date: Thu, 7 Apr 2022 14:23:03 +0200 Subject: [PATCH 40/57] Set up automated testing with conda --- .github/workflows/python-package-conda.yml | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/python-package-conda.yml diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml new file mode 100644 index 0000000..57940bd --- /dev/null +++ b/.github/workflows/python-package-conda.yml @@ -0,0 +1,34 @@ +name: Python Package using Conda + +on: [push] + +jobs: + build-linux: + runs-on: ubuntu-latest + strategy: + max-parallel: 5 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: 3.10 + - name: Add conda to system path + run: | + # $CONDA is an environment variable pointing to the root of the miniconda directory + echo $CONDA/bin >> $GITHUB_PATH + - name: Install dependencies + run: | + conda env update --file environment.yml --name base + - name: Lint with flake8 + run: | + conda install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + conda install pytest + pytest From c9885976f6d9a71b8ca6ae79e7142e0197a0ac01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Vester=20Th=C3=B8gersen?= <34004462+rasmusthog@users.noreply.github.com> Date: Thu, 7 Apr 2022 14:24:57 +0200 Subject: [PATCH 41/57] Change python version in automated testing --- .github/workflows/python-package-conda.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml index 57940bd..6261945 100644 --- a/.github/workflows/python-package-conda.yml +++ b/.github/workflows/python-package-conda.yml @@ -10,10 +10,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.10 + - name: Set up Python 3.9 uses: actions/setup-python@v3 with: - python-version: 3.10 + python-version: 3.9.7 - name: Add conda to system path run: | # $CONDA is an environment variable pointing to the root of the miniconda directory From c10317c1d32df92724ffd802b6cdc7e50f9e3143 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 14:35:41 +0200 Subject: [PATCH 42/57] Update requirements with --no-build tag --- requirements.txt | 305 ++++++++++++++++++++++++----------------------- 1 file changed, 154 insertions(+), 151 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8b428c5..e7bc821 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,151 +1,154 @@ -# This file may be used to create an environment using: -# $ conda create --name --file -# platform: win-64 -argon2-cffi=21.3.0=pyhd3eb1b0_0 -argon2-cffi-bindings=21.2.0=py39h2bbff1b_0 -atomicwrites=1.4.0=py_0 -attrs=21.4.0=pyhd3eb1b0_0 -backcall=0.2.0=pyhd3eb1b0_0 -beamtime=0.1=dev_0 -blas=1.0=mkl -bleach=4.1.0=pyhd3eb1b0_0 -bottleneck=1.3.2=py39h7cc1a96_1 -ca-certificates=2022.3.29=haa95532_0 -cached-property=1.5.2=hd8ed1ab_1 -cached_property=1.5.2=pyha770c72_1 -certifi=2021.10.8=py39haa95532_2 -cffi=1.15.0=py39h2bbff1b_1 -colorama=0.4.4=pyhd3eb1b0_0 -cycler=0.10.0=py_2 -debugpy=1.4.1=py39hd77b12b_0 -decorator=5.1.0=pyhd3eb1b0_0 -defusedxml=0.7.1=pyhd3eb1b0_0 -entrypoints=0.3=py39haa95532_0 -fabio=0.12.0=py39h5d4886f_0 -freetype=2.10.4=h546665d_1 -glymur=0.9.4=pyhd8ed1ab_0 -h5py=3.2.1=nompi_py39hf27771d_100 -hdf5=1.10.6=nompi_h5268f04_1114 -hdf5plugin=3.1.1=py39h71586dd_0 -icc_rt=2019.0.0=h0cc432a_1 -icu=68.1=h6c2663c_0 -importlib-metadata=4.8.2=py39haa95532_0 -importlib_metadata=4.8.2=hd3eb1b0_0 -iniconfig=1.1.1=pyhd3eb1b0_0 -intel-openmp=2021.3.0=haa95532_3372 -ipykernel=6.4.1=py39haa95532_1 -ipython=7.27.0=py39hd4e2768_0 -ipython_genutils=0.2.0=pyhd3eb1b0_1 -ipywidgets=7.6.5=pyhd3eb1b0_1 -jbig=2.1=h8d14728_2003 -jedi=0.18.0=py39haa95532_1 -jinja2=3.0.2=pyhd3eb1b0_0 -jpeg=9d=h2bbff1b_0 -jsonschema=3.2.0=pyhd3eb1b0_2 -jupyter_client=7.0.1=pyhd3eb1b0_0 -jupyter_core=4.8.1=py39haa95532_0 -jupyterlab_pygments=0.1.2=py_0 -jupyterlab_widgets=1.0.0=pyhd3eb1b0_1 -kiwisolver=1.3.2=py39h2e07f2f_0 -krb5=1.19.2=hbae68bd_2 -lerc=3.0=h0e60522_0 -libclang=11.1.0=default_h5c34c98_1 -libcurl=7.79.1=h789b8ee_1 -libdeflate=1.8=h2bbff1b_5 -libiconv=1.16=he774522_0 -libpng=1.6.37=h1d00b33_2 -libssh2=1.10.0=h680486a_2 -libtiff=4.3.0=hd413186_2 -libwebp=1.2.0=h2bbff1b_0 -libxml2=2.9.12=h0ad7f3c_0 -libxslt=1.1.34=he774522_0 -libzlib=1.2.11=h8ffe710_1013 -lxml=4.6.3=py39h4fd7cdf_0 -lz4-c=1.9.3=h8ffe710_1 -mako=1.1.5=pyhd8ed1ab_0 -markupsafe=2.0.1=py39h2bbff1b_0 -matplotlib=3.4.3=py39hcbf5309_1 -matplotlib-base=3.4.3=py39h581301d_1 -matplotlib-inline=0.1.2=pyhd3eb1b0_2 -mistune=0.8.4=py39h2bbff1b_1000 -mkl=2021.3.0=haa95532_524 -mkl-service=2.4.0=py39h2bbff1b_0 -mkl_fft=1.3.1=py39h277e83a_0 -mkl_random=1.2.2=py39hf11a4ad_0 -mpmath=1.2.1=py39haa95532_0 -nbclient=0.5.11=pyhd3eb1b0_0 -nbconvert=6.1.0=py39haa95532_0 -nbformat=5.1.3=pyhd3eb1b0_0 -nest-asyncio=1.5.1=pyhd3eb1b0_0 -notebook=6.4.8=py39haa95532_0 -numexpr=2.7.3=py39hb80d3ca_1 -numpy=1.21.2=py39hfca59bb_0 -numpy-base=1.21.2=py39h0829f74_0 -olefile=0.46=pyh9f0ad1d_1 -openjpeg=2.4.0=hb211442_1 -openssl=1.1.1n=h2bbff1b_0 -packaging=21.3=pyhd3eb1b0_0 -palettable=3.3.0=pyhd3eb1b0_0 -pandas=1.3.3=py39h6214cd6_0 -pandocfilters=1.5.0=pyhd3eb1b0_0 -parso=0.8.2=pyhd3eb1b0_0 -pickleshare=0.7.5=pyhd3eb1b0_1003 -pillow=8.4.0=py39hd45dc43_0 -pip=21.2.4=py39haa95532_0 -pluggy=1.0.0=py39haa95532_1 -prometheus_client=0.13.1=pyhd3eb1b0_0 -prompt-toolkit=3.0.20=pyhd3eb1b0_0 -py=1.11.0=pyhd3eb1b0_0 -pycparser=2.21=pyhd3eb1b0_0 -pyfai=0.20.0=hd8ed1ab_0 -pyfai-base=0.20.0=py39h2e25243_0 -pygments=2.10.0=pyhd3eb1b0_0 -pyparsing=2.4.7=pyhd3eb1b0_0 -pyqt=5.12.3=py39hcbf5309_7 -pyqt-impl=5.12.3=py39h415ef7b_7 -pyqt5-sip=4.19.18=py39h415ef7b_7 -pyqtchart=5.12=py39h415ef7b_7 -pyqtwebengine=5.12.1=py39h415ef7b_7 -pyreadline=2.1=py39hcbf5309_1004 -pyrsistent=0.18.0=py39h196d8e1_0 -pytest=7.1.1=py39haa95532_0 -python=3.9.7=h6244533_1 -python-dateutil=2.8.2=pyhd3eb1b0_0 -python_abi=3.9=2_cp39 -pytz=2021.3=pyhd3eb1b0_0 -pywin32=228=py39hbaba5e8_1 -pywinpty=2.0.2=py39h5da7b33_0 -pyzmq=22.2.1=py39hd77b12b_1 -qt=5.12.9=h5909a2a_4 -qtconsole=5.1.1=pyhd3eb1b0_0 -qtpy=1.11.2=pyhd8ed1ab_0 -scipy=1.7.1=py39hbe87c03_2 -seaborn=0.11.2=pyhd3eb1b0_0 -send2trash=1.8.0=pyhd3eb1b0_1 -setuptools=58.0.4=py39haa95532_0 -silx=0.15.2=hd8ed1ab_0 -silx-base=0.15.2=py39h2e25243_0 -six=1.16.0=pyhd3eb1b0_0 -sqlite=3.36.0=h2bbff1b_0 -sympy=1.9=py39haa95532_0 -terminado=0.13.1=py39haa95532_0 -testpath=0.5.0=pyhd3eb1b0_0 -tk=8.6.11=h8ffe710_1 -tomli=1.2.2=pyhd3eb1b0_0 -tornado=6.1=py39h2bbff1b_0 -traitlets=5.1.0=pyhd3eb1b0_0 -typing-extensions=3.10.0.2=hd3eb1b0_0 -typing_extensions=3.10.0.2=pyh06a4308_0 -tzdata=2021a=h5d7bf9c_0 -vc=14.2=h21ff451_1 -vs2015_runtime=14.27.29016=h5e58377_2 -wcwidth=0.2.5=pyhd3eb1b0_0 -webencodings=0.5.1=py39haa95532_1 -wheel=0.37.0=pyhd3eb1b0_1 -widgetsnbextension=3.5.2=py39haa95532_0 -wincertstore=0.2=py39haa95532_2 -winpty=0.4.3=4 -xz=5.2.5=h62dcd97_1 -zipp=3.7.0=pyhd3eb1b0_0 -zlib=1.2.11=h8ffe710_1013 -zstd=1.5.0=h6255e5f_0 +name: beamtime +channels: + - conda-forge + - diffpy + - defaults +dependencies: + - argon2-cffi=21.3.0 + - argon2-cffi-bindings=21.2.0 + - atomicwrites=1.4.0 + - attrs=21.4.0 + - backcall=0.2.0 + - blas=1.0 + - bleach=4.1.0 + - bottleneck=1.3.2 + - ca-certificates=2022.3.29 + - cached-property=1.5.2 + - cached_property=1.5.2 + - certifi=2021.10.8 + - cffi=1.15.0 + - colorama=0.4.4 + - cycler=0.10.0 + - debugpy=1.4.1 + - decorator=5.1.0 + - defusedxml=0.7.1 + - entrypoints=0.3 + - fabio=0.12.0 + - freetype=2.10.4 + - glymur=0.9.4 + - h5py=3.2.1 + - hdf5=1.10.6 + - hdf5plugin=3.1.1 + - icc_rt=2019.0.0 + - icu=68.1 + - importlib-metadata=4.8.2 + - importlib_metadata=4.8.2 + - iniconfig=1.1.1 + - intel-openmp=2021.3.0 + - ipykernel=6.4.1 + - ipython=7.27.0 + - ipython_genutils=0.2.0 + - ipywidgets=7.6.5 + - jbig=2.1 + - jedi=0.18.0 + - jinja2=3.0.2 + - jpeg=9d + - jsonschema=3.2.0 + - jupyter_client=7.0.1 + - jupyter_core=4.8.1 + - jupyterlab_pygments=0.1.2 + - jupyterlab_widgets=1.0.0 + - kiwisolver=1.3.2 + - krb5=1.19.2 + - lerc=3.0 + - libclang=11.1.0 + - libcurl=7.79.1 + - libdeflate=1.8 + - libiconv=1.16 + - libpng=1.6.37 + - libssh2=1.10.0 + - libtiff=4.3.0 + - libwebp=1.2.0 + - libxml2=2.9.12 + - libxslt=1.1.34 + - libzlib=1.2.11 + - lxml=4.6.3 + - lz4-c=1.9.3 + - mako=1.1.5 + - markupsafe=2.0.1 + - matplotlib=3.4.3 + - matplotlib-base=3.4.3 + - matplotlib-inline=0.1.2 + - mistune=0.8.4 + - mkl=2021.3.0 + - mkl-service=2.4.0 + - mkl_fft=1.3.1 + - mkl_random=1.2.2 + - mpmath=1.2.1 + - nbclient=0.5.11 + - nbconvert=6.1.0 + - nbformat=5.1.3 + - nest-asyncio=1.5.1 + - notebook=6.4.8 + - numexpr=2.7.3 + - numpy=1.21.2 + - numpy-base=1.21.2 + - olefile=0.46 + - openjpeg=2.4.0 + - openssl=1.1.1n + - packaging=21.3 + - palettable=3.3.0 + - pandas=1.3.3 + - pandocfilters=1.5.0 + - parso=0.8.2 + - pickleshare=0.7.5 + - pillow=8.4.0 + - pip=21.2.4 + - pluggy=1.0.0 + - prometheus_client=0.13.1 + - prompt-toolkit=3.0.20 + - py=1.11.0 + - pycparser=2.21 + - pyfai=0.20.0 + - pyfai-base=0.20.0 + - pygments=2.10.0 + - pyparsing=2.4.7 + - pyqt=5.12.3 + - pyqt-impl=5.12.3 + - pyqt5-sip=4.19.18 + - pyqtchart=5.12 + - pyqtwebengine=5.12.1 + - pyreadline=2.1 + - pyrsistent=0.18.0 + - pytest=7.1.1 + - python=3.9.7 + - python-dateutil=2.8.2 + - python_abi=3.9 + - pytz=2021.3 + - pywin32=228 + - pywinpty=2.0.2 + - pyzmq=22.2.1 + - qt=5.12.9 + - qtconsole=5.1.1 + - qtpy=1.11.2 + - scipy=1.7.1 + - seaborn=0.11.2 + - send2trash=1.8.0 + - setuptools=58.0.4 + - silx=0.15.2 + - silx-base=0.15.2 + - six=1.16.0 + - sqlite=3.36.0 + - sympy=1.9 + - terminado=0.13.1 + - testpath=0.5.0 + - tk=8.6.11 + - tomli=1.2.2 + - tornado=6.1 + - traitlets=5.1.0 + - typing-extensions=3.10.0.2 + - typing_extensions=3.10.0.2 + - tzdata=2021a + - vc=14.2 + - vs2015_runtime=14.27.29016 + - wcwidth=0.2.5 + - webencodings=0.5.1 + - wheel=0.37.0 + - widgetsnbextension=3.5.2 + - wincertstore=0.2 + - winpty=0.4.3 + - xz=5.2.5 + - zipp=3.7.0 + - zlib=1.2.11 + - zstd=1.5.0 +prefix: C:\Users\rasmusvt\Anaconda3\envs\beamtime From e8bc4d4bc4f9615ee4f27cd7e83ee0ce41226031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Vester=20Th=C3=B8gersen?= <34004462+rasmusthog@users.noreply.github.com> Date: Thu, 7 Apr 2022 14:39:03 +0200 Subject: [PATCH 43/57] Delete second attempt at setting up automated testing --- .github/workflows/python-package-conda.yml | 34 ---------------------- 1 file changed, 34 deletions(-) delete mode 100644 .github/workflows/python-package-conda.yml diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml deleted file mode 100644 index 6261945..0000000 --- a/.github/workflows/python-package-conda.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Python Package using Conda - -on: [push] - -jobs: - build-linux: - runs-on: ubuntu-latest - strategy: - max-parallel: 5 - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.9 - uses: actions/setup-python@v3 - with: - python-version: 3.9.7 - - name: Add conda to system path - run: | - # $CONDA is an environment variable pointing to the root of the miniconda directory - echo $CONDA/bin >> $GITHUB_PATH - - name: Install dependencies - run: | - conda env update --file environment.yml --name base - - name: Lint with flake8 - run: | - conda install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - conda install pytest - pytest From c8f1f64af86d8c3060616b2e136921c955b562e6 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 14:40:38 +0200 Subject: [PATCH 44/57] Update environment.yml without build --- environment.yml | 294 +++++++++++++++++++++++------------------------ requirements.txt | 154 ------------------------- 2 files changed, 147 insertions(+), 301 deletions(-) delete mode 100644 requirements.txt diff --git a/environment.yml b/environment.yml index b80378b..e7bc821 100644 --- a/environment.yml +++ b/environment.yml @@ -4,151 +4,151 @@ channels: - diffpy - defaults dependencies: - - argon2-cffi=21.3.0=pyhd3eb1b0_0 - - argon2-cffi-bindings=21.2.0=py39h2bbff1b_0 - - atomicwrites=1.4.0=py_0 - - attrs=21.4.0=pyhd3eb1b0_0 - - backcall=0.2.0=pyhd3eb1b0_0 - - blas=1.0=mkl - - bleach=4.1.0=pyhd3eb1b0_0 - - bottleneck=1.3.2=py39h7cc1a96_1 - - ca-certificates=2022.3.29=haa95532_0 - - cached-property=1.5.2=hd8ed1ab_1 - - cached_property=1.5.2=pyha770c72_1 - - certifi=2021.10.8=py39haa95532_2 - - cffi=1.15.0=py39h2bbff1b_1 - - colorama=0.4.4=pyhd3eb1b0_0 - - cycler=0.10.0=py_2 - - debugpy=1.4.1=py39hd77b12b_0 - - decorator=5.1.0=pyhd3eb1b0_0 - - defusedxml=0.7.1=pyhd3eb1b0_0 - - entrypoints=0.3=py39haa95532_0 - - fabio=0.12.0=py39h5d4886f_0 - - freetype=2.10.4=h546665d_1 - - glymur=0.9.4=pyhd8ed1ab_0 - - h5py=3.2.1=nompi_py39hf27771d_100 - - hdf5=1.10.6=nompi_h5268f04_1114 - - hdf5plugin=3.1.1=py39h71586dd_0 - - icc_rt=2019.0.0=h0cc432a_1 - - icu=68.1=h6c2663c_0 - - importlib-metadata=4.8.2=py39haa95532_0 - - importlib_metadata=4.8.2=hd3eb1b0_0 - - iniconfig=1.1.1=pyhd3eb1b0_0 - - intel-openmp=2021.3.0=haa95532_3372 - - ipykernel=6.4.1=py39haa95532_1 - - ipython=7.27.0=py39hd4e2768_0 - - ipython_genutils=0.2.0=pyhd3eb1b0_1 - - ipywidgets=7.6.5=pyhd3eb1b0_1 - - jbig=2.1=h8d14728_2003 - - jedi=0.18.0=py39haa95532_1 - - jinja2=3.0.2=pyhd3eb1b0_0 - - jpeg=9d=h2bbff1b_0 - - jsonschema=3.2.0=pyhd3eb1b0_2 - - jupyter_client=7.0.1=pyhd3eb1b0_0 - - jupyter_core=4.8.1=py39haa95532_0 - - jupyterlab_pygments=0.1.2=py_0 - - jupyterlab_widgets=1.0.0=pyhd3eb1b0_1 - - kiwisolver=1.3.2=py39h2e07f2f_0 - - krb5=1.19.2=hbae68bd_2 - - lerc=3.0=h0e60522_0 - - libclang=11.1.0=default_h5c34c98_1 - - libcurl=7.79.1=h789b8ee_1 - - libdeflate=1.8=h2bbff1b_5 - - libiconv=1.16=he774522_0 - - libpng=1.6.37=h1d00b33_2 - - libssh2=1.10.0=h680486a_2 - - libtiff=4.3.0=hd413186_2 - - libwebp=1.2.0=h2bbff1b_0 - - libxml2=2.9.12=h0ad7f3c_0 - - libxslt=1.1.34=he774522_0 - - libzlib=1.2.11=h8ffe710_1013 - - lxml=4.6.3=py39h4fd7cdf_0 - - lz4-c=1.9.3=h8ffe710_1 - - mako=1.1.5=pyhd8ed1ab_0 - - markupsafe=2.0.1=py39h2bbff1b_0 - - matplotlib=3.4.3=py39hcbf5309_1 - - matplotlib-base=3.4.3=py39h581301d_1 - - matplotlib-inline=0.1.2=pyhd3eb1b0_2 - - mistune=0.8.4=py39h2bbff1b_1000 - - mkl=2021.3.0=haa95532_524 - - mkl-service=2.4.0=py39h2bbff1b_0 - - mkl_fft=1.3.1=py39h277e83a_0 - - mkl_random=1.2.2=py39hf11a4ad_0 - - mpmath=1.2.1=py39haa95532_0 - - nbclient=0.5.11=pyhd3eb1b0_0 - - nbconvert=6.1.0=py39haa95532_0 - - nbformat=5.1.3=pyhd3eb1b0_0 - - nest-asyncio=1.5.1=pyhd3eb1b0_0 - - notebook=6.4.8=py39haa95532_0 - - numexpr=2.7.3=py39hb80d3ca_1 - - numpy=1.21.2=py39hfca59bb_0 - - numpy-base=1.21.2=py39h0829f74_0 - - olefile=0.46=pyh9f0ad1d_1 - - openjpeg=2.4.0=hb211442_1 - - openssl=1.1.1n=h2bbff1b_0 - - packaging=21.3=pyhd3eb1b0_0 - - palettable=3.3.0=pyhd3eb1b0_0 - - pandas=1.3.3=py39h6214cd6_0 - - pandocfilters=1.5.0=pyhd3eb1b0_0 - - parso=0.8.2=pyhd3eb1b0_0 - - pickleshare=0.7.5=pyhd3eb1b0_1003 - - pillow=8.4.0=py39hd45dc43_0 - - pip=21.2.4=py39haa95532_0 - - pluggy=1.0.0=py39haa95532_1 - - prometheus_client=0.13.1=pyhd3eb1b0_0 - - prompt-toolkit=3.0.20=pyhd3eb1b0_0 - - py=1.11.0=pyhd3eb1b0_0 - - pycparser=2.21=pyhd3eb1b0_0 - - pyfai=0.20.0=hd8ed1ab_0 - - pyfai-base=0.20.0=py39h2e25243_0 - - pygments=2.10.0=pyhd3eb1b0_0 - - pyparsing=2.4.7=pyhd3eb1b0_0 - - pyqt=5.12.3=py39hcbf5309_7 - - pyqt-impl=5.12.3=py39h415ef7b_7 - - pyqt5-sip=4.19.18=py39h415ef7b_7 - - pyqtchart=5.12=py39h415ef7b_7 - - pyqtwebengine=5.12.1=py39h415ef7b_7 - - pyreadline=2.1=py39hcbf5309_1004 - - pyrsistent=0.18.0=py39h196d8e1_0 - - pytest=7.1.1=py39haa95532_0 - - python=3.9.7=h6244533_1 - - python-dateutil=2.8.2=pyhd3eb1b0_0 - - python_abi=3.9=2_cp39 - - pytz=2021.3=pyhd3eb1b0_0 - - pywin32=228=py39hbaba5e8_1 - - pywinpty=2.0.2=py39h5da7b33_0 - - pyzmq=22.2.1=py39hd77b12b_1 - - qt=5.12.9=h5909a2a_4 - - qtconsole=5.1.1=pyhd3eb1b0_0 - - qtpy=1.11.2=pyhd8ed1ab_0 - - scipy=1.7.1=py39hbe87c03_2 - - seaborn=0.11.2=pyhd3eb1b0_0 - - send2trash=1.8.0=pyhd3eb1b0_1 - - setuptools=58.0.4=py39haa95532_0 - - silx=0.15.2=hd8ed1ab_0 - - silx-base=0.15.2=py39h2e25243_0 - - six=1.16.0=pyhd3eb1b0_0 - - sqlite=3.36.0=h2bbff1b_0 - - sympy=1.9=py39haa95532_0 - - terminado=0.13.1=py39haa95532_0 - - testpath=0.5.0=pyhd3eb1b0_0 - - tk=8.6.11=h8ffe710_1 - - tomli=1.2.2=pyhd3eb1b0_0 - - tornado=6.1=py39h2bbff1b_0 - - traitlets=5.1.0=pyhd3eb1b0_0 - - typing-extensions=3.10.0.2=hd3eb1b0_0 - - typing_extensions=3.10.0.2=pyh06a4308_0 - - tzdata=2021a=h5d7bf9c_0 - - vc=14.2=h21ff451_1 - - vs2015_runtime=14.27.29016=h5e58377_2 - - wcwidth=0.2.5=pyhd3eb1b0_0 - - webencodings=0.5.1=py39haa95532_1 - - wheel=0.37.0=pyhd3eb1b0_1 - - widgetsnbextension=3.5.2=py39haa95532_0 - - wincertstore=0.2=py39haa95532_2 - - winpty=0.4.3=4 - - xz=5.2.5=h62dcd97_1 - - zipp=3.7.0=pyhd3eb1b0_0 - - zlib=1.2.11=h8ffe710_1013 - - zstd=1.5.0=h6255e5f_0 + - argon2-cffi=21.3.0 + - argon2-cffi-bindings=21.2.0 + - atomicwrites=1.4.0 + - attrs=21.4.0 + - backcall=0.2.0 + - blas=1.0 + - bleach=4.1.0 + - bottleneck=1.3.2 + - ca-certificates=2022.3.29 + - cached-property=1.5.2 + - cached_property=1.5.2 + - certifi=2021.10.8 + - cffi=1.15.0 + - colorama=0.4.4 + - cycler=0.10.0 + - debugpy=1.4.1 + - decorator=5.1.0 + - defusedxml=0.7.1 + - entrypoints=0.3 + - fabio=0.12.0 + - freetype=2.10.4 + - glymur=0.9.4 + - h5py=3.2.1 + - hdf5=1.10.6 + - hdf5plugin=3.1.1 + - icc_rt=2019.0.0 + - icu=68.1 + - importlib-metadata=4.8.2 + - importlib_metadata=4.8.2 + - iniconfig=1.1.1 + - intel-openmp=2021.3.0 + - ipykernel=6.4.1 + - ipython=7.27.0 + - ipython_genutils=0.2.0 + - ipywidgets=7.6.5 + - jbig=2.1 + - jedi=0.18.0 + - jinja2=3.0.2 + - jpeg=9d + - jsonschema=3.2.0 + - jupyter_client=7.0.1 + - jupyter_core=4.8.1 + - jupyterlab_pygments=0.1.2 + - jupyterlab_widgets=1.0.0 + - kiwisolver=1.3.2 + - krb5=1.19.2 + - lerc=3.0 + - libclang=11.1.0 + - libcurl=7.79.1 + - libdeflate=1.8 + - libiconv=1.16 + - libpng=1.6.37 + - libssh2=1.10.0 + - libtiff=4.3.0 + - libwebp=1.2.0 + - libxml2=2.9.12 + - libxslt=1.1.34 + - libzlib=1.2.11 + - lxml=4.6.3 + - lz4-c=1.9.3 + - mako=1.1.5 + - markupsafe=2.0.1 + - matplotlib=3.4.3 + - matplotlib-base=3.4.3 + - matplotlib-inline=0.1.2 + - mistune=0.8.4 + - mkl=2021.3.0 + - mkl-service=2.4.0 + - mkl_fft=1.3.1 + - mkl_random=1.2.2 + - mpmath=1.2.1 + - nbclient=0.5.11 + - nbconvert=6.1.0 + - nbformat=5.1.3 + - nest-asyncio=1.5.1 + - notebook=6.4.8 + - numexpr=2.7.3 + - numpy=1.21.2 + - numpy-base=1.21.2 + - olefile=0.46 + - openjpeg=2.4.0 + - openssl=1.1.1n + - packaging=21.3 + - palettable=3.3.0 + - pandas=1.3.3 + - pandocfilters=1.5.0 + - parso=0.8.2 + - pickleshare=0.7.5 + - pillow=8.4.0 + - pip=21.2.4 + - pluggy=1.0.0 + - prometheus_client=0.13.1 + - prompt-toolkit=3.0.20 + - py=1.11.0 + - pycparser=2.21 + - pyfai=0.20.0 + - pyfai-base=0.20.0 + - pygments=2.10.0 + - pyparsing=2.4.7 + - pyqt=5.12.3 + - pyqt-impl=5.12.3 + - pyqt5-sip=4.19.18 + - pyqtchart=5.12 + - pyqtwebengine=5.12.1 + - pyreadline=2.1 + - pyrsistent=0.18.0 + - pytest=7.1.1 + - python=3.9.7 + - python-dateutil=2.8.2 + - python_abi=3.9 + - pytz=2021.3 + - pywin32=228 + - pywinpty=2.0.2 + - pyzmq=22.2.1 + - qt=5.12.9 + - qtconsole=5.1.1 + - qtpy=1.11.2 + - scipy=1.7.1 + - seaborn=0.11.2 + - send2trash=1.8.0 + - setuptools=58.0.4 + - silx=0.15.2 + - silx-base=0.15.2 + - six=1.16.0 + - sqlite=3.36.0 + - sympy=1.9 + - terminado=0.13.1 + - testpath=0.5.0 + - tk=8.6.11 + - tomli=1.2.2 + - tornado=6.1 + - traitlets=5.1.0 + - typing-extensions=3.10.0.2 + - typing_extensions=3.10.0.2 + - tzdata=2021a + - vc=14.2 + - vs2015_runtime=14.27.29016 + - wcwidth=0.2.5 + - webencodings=0.5.1 + - wheel=0.37.0 + - widgetsnbextension=3.5.2 + - wincertstore=0.2 + - winpty=0.4.3 + - xz=5.2.5 + - zipp=3.7.0 + - zlib=1.2.11 + - zstd=1.5.0 prefix: C:\Users\rasmusvt\Anaconda3\envs\beamtime diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e7bc821..0000000 --- a/requirements.txt +++ /dev/null @@ -1,154 +0,0 @@ -name: beamtime -channels: - - conda-forge - - diffpy - - defaults -dependencies: - - argon2-cffi=21.3.0 - - argon2-cffi-bindings=21.2.0 - - atomicwrites=1.4.0 - - attrs=21.4.0 - - backcall=0.2.0 - - blas=1.0 - - bleach=4.1.0 - - bottleneck=1.3.2 - - ca-certificates=2022.3.29 - - cached-property=1.5.2 - - cached_property=1.5.2 - - certifi=2021.10.8 - - cffi=1.15.0 - - colorama=0.4.4 - - cycler=0.10.0 - - debugpy=1.4.1 - - decorator=5.1.0 - - defusedxml=0.7.1 - - entrypoints=0.3 - - fabio=0.12.0 - - freetype=2.10.4 - - glymur=0.9.4 - - h5py=3.2.1 - - hdf5=1.10.6 - - hdf5plugin=3.1.1 - - icc_rt=2019.0.0 - - icu=68.1 - - importlib-metadata=4.8.2 - - importlib_metadata=4.8.2 - - iniconfig=1.1.1 - - intel-openmp=2021.3.0 - - ipykernel=6.4.1 - - ipython=7.27.0 - - ipython_genutils=0.2.0 - - ipywidgets=7.6.5 - - jbig=2.1 - - jedi=0.18.0 - - jinja2=3.0.2 - - jpeg=9d - - jsonschema=3.2.0 - - jupyter_client=7.0.1 - - jupyter_core=4.8.1 - - jupyterlab_pygments=0.1.2 - - jupyterlab_widgets=1.0.0 - - kiwisolver=1.3.2 - - krb5=1.19.2 - - lerc=3.0 - - libclang=11.1.0 - - libcurl=7.79.1 - - libdeflate=1.8 - - libiconv=1.16 - - libpng=1.6.37 - - libssh2=1.10.0 - - libtiff=4.3.0 - - libwebp=1.2.0 - - libxml2=2.9.12 - - libxslt=1.1.34 - - libzlib=1.2.11 - - lxml=4.6.3 - - lz4-c=1.9.3 - - mako=1.1.5 - - markupsafe=2.0.1 - - matplotlib=3.4.3 - - matplotlib-base=3.4.3 - - matplotlib-inline=0.1.2 - - mistune=0.8.4 - - mkl=2021.3.0 - - mkl-service=2.4.0 - - mkl_fft=1.3.1 - - mkl_random=1.2.2 - - mpmath=1.2.1 - - nbclient=0.5.11 - - nbconvert=6.1.0 - - nbformat=5.1.3 - - nest-asyncio=1.5.1 - - notebook=6.4.8 - - numexpr=2.7.3 - - numpy=1.21.2 - - numpy-base=1.21.2 - - olefile=0.46 - - openjpeg=2.4.0 - - openssl=1.1.1n - - packaging=21.3 - - palettable=3.3.0 - - pandas=1.3.3 - - pandocfilters=1.5.0 - - parso=0.8.2 - - pickleshare=0.7.5 - - pillow=8.4.0 - - pip=21.2.4 - - pluggy=1.0.0 - - prometheus_client=0.13.1 - - prompt-toolkit=3.0.20 - - py=1.11.0 - - pycparser=2.21 - - pyfai=0.20.0 - - pyfai-base=0.20.0 - - pygments=2.10.0 - - pyparsing=2.4.7 - - pyqt=5.12.3 - - pyqt-impl=5.12.3 - - pyqt5-sip=4.19.18 - - pyqtchart=5.12 - - pyqtwebengine=5.12.1 - - pyreadline=2.1 - - pyrsistent=0.18.0 - - pytest=7.1.1 - - python=3.9.7 - - python-dateutil=2.8.2 - - python_abi=3.9 - - pytz=2021.3 - - pywin32=228 - - pywinpty=2.0.2 - - pyzmq=22.2.1 - - qt=5.12.9 - - qtconsole=5.1.1 - - qtpy=1.11.2 - - scipy=1.7.1 - - seaborn=0.11.2 - - send2trash=1.8.0 - - setuptools=58.0.4 - - silx=0.15.2 - - silx-base=0.15.2 - - six=1.16.0 - - sqlite=3.36.0 - - sympy=1.9 - - terminado=0.13.1 - - testpath=0.5.0 - - tk=8.6.11 - - tomli=1.2.2 - - tornado=6.1 - - traitlets=5.1.0 - - typing-extensions=3.10.0.2 - - typing_extensions=3.10.0.2 - - tzdata=2021a - - vc=14.2 - - vs2015_runtime=14.27.29016 - - wcwidth=0.2.5 - - webencodings=0.5.1 - - wheel=0.37.0 - - widgetsnbextension=3.5.2 - - wincertstore=0.2 - - winpty=0.4.3 - - xz=5.2.5 - - zipp=3.7.0 - - zlib=1.2.11 - - zstd=1.5.0 -prefix: C:\Users\rasmusvt\Anaconda3\envs\beamtime From bae40fcabdf6acae4f9a9c2a9550082e74479518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Vester=20Th=C3=B8gersen?= <34004462+rasmusthog@users.noreply.github.com> Date: Thu, 7 Apr 2022 14:41:29 +0200 Subject: [PATCH 45/57] Set up third attempt at autotesting --- .github/workflows/python-package-conda.yml | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/python-package-conda.yml diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml new file mode 100644 index 0000000..6261945 --- /dev/null +++ b/.github/workflows/python-package-conda.yml @@ -0,0 +1,34 @@ +name: Python Package using Conda + +on: [push] + +jobs: + build-linux: + runs-on: ubuntu-latest + strategy: + max-parallel: 5 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: 3.9.7 + - name: Add conda to system path + run: | + # $CONDA is an environment variable pointing to the root of the miniconda directory + echo $CONDA/bin >> $GITHUB_PATH + - name: Install dependencies + run: | + conda env update --file environment.yml --name base + - name: Lint with flake8 + run: | + conda install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + conda install pytest + pytest From 89ea45a9bf3aa5f8d7f137764df0ee3e34cef966 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 14:50:09 +0200 Subject: [PATCH 46/57] Make manual environment file --- environment.yml | 155 +++--------------------------------------------- 1 file changed, 8 insertions(+), 147 deletions(-) diff --git a/environment.yml b/environment.yml index e7bc821..9500050 100644 --- a/environment.yml +++ b/environment.yml @@ -4,151 +4,12 @@ channels: - diffpy - defaults dependencies: - - argon2-cffi=21.3.0 - - argon2-cffi-bindings=21.2.0 - - atomicwrites=1.4.0 - - attrs=21.4.0 - - backcall=0.2.0 - - blas=1.0 - - bleach=4.1.0 - - bottleneck=1.3.2 - - ca-certificates=2022.3.29 - - cached-property=1.5.2 - - cached_property=1.5.2 - - certifi=2021.10.8 - - cffi=1.15.0 - - colorama=0.4.4 - - cycler=0.10.0 - - debugpy=1.4.1 - - decorator=5.1.0 - - defusedxml=0.7.1 - - entrypoints=0.3 - - fabio=0.12.0 - - freetype=2.10.4 - - glymur=0.9.4 - - h5py=3.2.1 - - hdf5=1.10.6 - - hdf5plugin=3.1.1 - - icc_rt=2019.0.0 - - icu=68.1 - - importlib-metadata=4.8.2 - - importlib_metadata=4.8.2 - - iniconfig=1.1.1 - - intel-openmp=2021.3.0 - - ipykernel=6.4.1 - - ipython=7.27.0 - - ipython_genutils=0.2.0 - - ipywidgets=7.6.5 - - jbig=2.1 - - jedi=0.18.0 - - jinja2=3.0.2 - - jpeg=9d - - jsonschema=3.2.0 - - jupyter_client=7.0.1 - - jupyter_core=4.8.1 - - jupyterlab_pygments=0.1.2 - - jupyterlab_widgets=1.0.0 - - kiwisolver=1.3.2 - - krb5=1.19.2 - - lerc=3.0 - - libclang=11.1.0 - - libcurl=7.79.1 - - libdeflate=1.8 - - libiconv=1.16 - - libpng=1.6.37 - - libssh2=1.10.0 - - libtiff=4.3.0 - - libwebp=1.2.0 - - libxml2=2.9.12 - - libxslt=1.1.34 - - libzlib=1.2.11 - - lxml=4.6.3 - - lz4-c=1.9.3 - - mako=1.1.5 - - markupsafe=2.0.1 - - matplotlib=3.4.3 - - matplotlib-base=3.4.3 - - matplotlib-inline=0.1.2 - - mistune=0.8.4 - - mkl=2021.3.0 - - mkl-service=2.4.0 - - mkl_fft=1.3.1 - - mkl_random=1.2.2 - - mpmath=1.2.1 - - nbclient=0.5.11 - - nbconvert=6.1.0 - - nbformat=5.1.3 - - nest-asyncio=1.5.1 - - notebook=6.4.8 - - numexpr=2.7.3 - - numpy=1.21.2 - - numpy-base=1.21.2 - - olefile=0.46 - - openjpeg=2.4.0 - - openssl=1.1.1n - - packaging=21.3 - - palettable=3.3.0 - - pandas=1.3.3 - - pandocfilters=1.5.0 - - parso=0.8.2 - - pickleshare=0.7.5 - - pillow=8.4.0 - - pip=21.2.4 - - pluggy=1.0.0 - - prometheus_client=0.13.1 - - prompt-toolkit=3.0.20 - - py=1.11.0 - - pycparser=2.21 - - pyfai=0.20.0 - - pyfai-base=0.20.0 - - pygments=2.10.0 - - pyparsing=2.4.7 - - pyqt=5.12.3 - - pyqt-impl=5.12.3 - - pyqt5-sip=4.19.18 - - pyqtchart=5.12 - - pyqtwebengine=5.12.1 - - pyreadline=2.1 - - pyrsistent=0.18.0 - - pytest=7.1.1 - - python=3.9.7 - - python-dateutil=2.8.2 - - python_abi=3.9 - - pytz=2021.3 - - pywin32=228 - - pywinpty=2.0.2 - - pyzmq=22.2.1 - - qt=5.12.9 - - qtconsole=5.1.1 - - qtpy=1.11.2 - - scipy=1.7.1 - - seaborn=0.11.2 - - send2trash=1.8.0 - - setuptools=58.0.4 - - silx=0.15.2 - - silx-base=0.15.2 - - six=1.16.0 - - sqlite=3.36.0 - - sympy=1.9 - - terminado=0.13.1 - - testpath=0.5.0 - - tk=8.6.11 - - tomli=1.2.2 - - tornado=6.1 - - traitlets=5.1.0 - - typing-extensions=3.10.0.2 - - typing_extensions=3.10.0.2 - - tzdata=2021a - - vc=14.2 - - vs2015_runtime=14.27.29016 - - wcwidth=0.2.5 - - webencodings=0.5.1 - - wheel=0.37.0 - - widgetsnbextension=3.5.2 - - wincertstore=0.2 - - winpty=0.4.3 - - xz=5.2.5 - - zipp=3.7.0 - - zlib=1.2.11 - - zstd=1.5.0 + - pandas + - numpy + - matplotlib + - ipywidgets + - palettable + - sympy + - seaborn + - pytest prefix: C:\Users\rasmusvt\Anaconda3\envs\beamtime From ceb9d1ab462ecc4574cb2cde55fe7df1478fb344 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 15:15:12 +0200 Subject: [PATCH 47/57] Upload new environment --- environment.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/environment.yml b/environment.yml index 9500050..24ccf4d 100644 --- a/environment.yml +++ b/environment.yml @@ -1,15 +1,15 @@ -name: beamtime +name: nafuma channels: - - conda-forge - diffpy - defaults dependencies: - - pandas - - numpy - - matplotlib - ipywidgets - - palettable - - sympy - seaborn + - sympy + - matplotlib - pytest -prefix: C:\Users\rasmusvt\Anaconda3\envs\beamtime + - numpy + - pandas + - palettable + - pyfai +prefix: C:\Users\rasmusvt\Anaconda3\envs\nafuma From 19918b3207f791563814fff54600e0b68390b8da Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 15:17:39 +0200 Subject: [PATCH 48/57] Remove old workflow --- .github/workflows/python-package-conda.yml | 34 ---------------------- 1 file changed, 34 deletions(-) delete mode 100644 .github/workflows/python-package-conda.yml diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml deleted file mode 100644 index 6261945..0000000 --- a/.github/workflows/python-package-conda.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Python Package using Conda - -on: [push] - -jobs: - build-linux: - runs-on: ubuntu-latest - strategy: - max-parallel: 5 - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.9 - uses: actions/setup-python@v3 - with: - python-version: 3.9.7 - - name: Add conda to system path - run: | - # $CONDA is an environment variable pointing to the root of the miniconda directory - echo $CONDA/bin >> $GITHUB_PATH - - name: Install dependencies - run: | - conda env update --file environment.yml --name base - - name: Lint with flake8 - run: | - conda install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - conda install pytest - pytest From 2c697be9da6abd969b2846618eacaa246b864796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Vester=20Th=C3=B8gersen?= <34004462+rasmusthog@users.noreply.github.com> Date: Thu, 7 Apr 2022 15:18:17 +0200 Subject: [PATCH 49/57] New attempt at setting up workflow --- .github/workflows/python-package-conda.yml | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/python-package-conda.yml diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml new file mode 100644 index 0000000..2c3dce4 --- /dev/null +++ b/.github/workflows/python-package-conda.yml @@ -0,0 +1,34 @@ +name: Python Package using Conda + +on: [push] + +jobs: + build-linux: + runs-on: ubuntu-latest + strategy: + max-parallel: 5 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: 3.10.4 + - name: Add conda to system path + run: | + # $CONDA is an environment variable pointing to the root of the miniconda directory + echo $CONDA/bin >> $GITHUB_PATH + - name: Install dependencies + run: | + conda env update --file environment.yml --name base + - name: Lint with flake8 + run: | + conda install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + conda install pytest + pytest From 601a5b061911c6be8effcbe0f70dbf769bcda490 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 15:19:57 +0200 Subject: [PATCH 50/57] Add conda-forge to channels --- environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/environment.yml b/environment.yml index 24ccf4d..04c88d5 100644 --- a/environment.yml +++ b/environment.yml @@ -2,6 +2,7 @@ name: nafuma channels: - diffpy - defaults + - conda-forge dependencies: - ipywidgets - seaborn From de8c0ab8d5baada16e01adef6b08f21c864ff109 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 15:28:49 +0200 Subject: [PATCH 51/57] Add install of package to workflow --- .github/workflows/python-package-conda.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml index 2c3dce4..ebf95a8 100644 --- a/.github/workflows/python-package-conda.yml +++ b/.github/workflows/python-package-conda.yml @@ -21,6 +21,7 @@ jobs: - name: Install dependencies run: | conda env update --file environment.yml --name base + pip install . - name: Lint with flake8 run: | conda install flake8 From 3d99af9a7a8e7d64721ba63026cb4bfb08b5c34c Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 15:39:07 +0200 Subject: [PATCH 52/57] Fix linting issues --- beamtime/plotting.py | 6 ++--- beamtime/xanes/calib.py | 2 +- beamtime/xrd/plot.py | 49 +---------------------------------------- 3 files changed, 5 insertions(+), 52 deletions(-) diff --git a/beamtime/plotting.py b/beamtime/plotting.py index 780a022..e8c5457 100644 --- a/beamtime/plotting.py +++ b/beamtime/plotting.py @@ -151,9 +151,9 @@ def adjust_plot(fig, ax, options): # FIXME THIS NEEDS REWORK FOR IT TO FUNCTION PROPERLY! - if options['xticks']: - ax.set_xticks(np.arange(plot_data['start'], plot_data['end']+1)) - ax.set_xticklabels(options['xticks']) + #if options['xticks']: + # ax.set_xticks(np.arange(plot_data['start'], plot_data['end']+1)) + # ax.set_xticklabels(options['xticks']) # else: # ax.set_xticks(np.arange(plot_data['start'], plot_data['end']+1)) # ax.set_xticklabels([x/2 for x in np.arange(plot_data['start'], plot_data['end']+1)]) diff --git a/beamtime/xanes/calib.py b/beamtime/xanes/calib.py index 2ef6c4d..6a4c8f6 100644 --- a/beamtime/xanes/calib.py +++ b/beamtime/xanes/calib.py @@ -13,7 +13,7 @@ def rbkerbest(): ##Better to make a new function that loops through the files, and performing the split_xanes_scan on -def split_xanes_scan(root, destination=None, replace=False): +def split_xanes_scan(filename, destination=None, replace=False): #root is the path to the beamtime-folder #destination should be the path to the processed data diff --git a/beamtime/xrd/plot.py b/beamtime/xrd/plot.py index cc6baa3..950a27f 100644 --- a/beamtime/xrd/plot.py +++ b/beamtime/xrd/plot.py @@ -7,6 +7,7 @@ import numpy as np import math import ipywidgets as widgets +from IPython.display import display import beamtime.xrd as xrd import beamtime.auxillary as aux @@ -657,54 +658,6 @@ def prettify_labels(label): return labels_dict[label] -def plot_diffractograms(paths, kind, options=None): - - - fig, ax = prepare_diffractogram_plot(options=options) - - diffractograms = [] - - for path in paths: - diffractogram = xrd.io.read_data(path=path, kind=kind, options=options) - diffractograms.append(diffractogram) - - - required_options = ['type', 'xvals', 'yvals', 'x_offset', 'y_offset', 'normalise', 'normalise_around', 'reverse_order'] - default_options = { - 'type': 'stacked', - 'xvals': '2th', - 'yvals': 'I', - 'x_offset': 0, - 'y_offset': 0.2, - 'normalise': True, - 'normalise_around': None, - 'reverse_order': False - } - - - # If reverse_order is enabled, reverse the order - if options['reverse_order']: - diffractograms = reverse_diffractograms(diffractograms) - - - # If normalise is enbaled, normalise all the diffractograms - if options['normalise']: - if not options['normalise_around']: - for diffractogram in diffractograms: - diffractogram["I"] = diffractogram["I"]/diffractogram["I"].max() - else: - diffractogram["I"] = diffractogram["I"]/diffractogram["I"].loc[(diffractogram['2th'] > options['normalise_around'][0]) & (diffractogram['2th'] < options['normalise_around'][1])].max() - - - if options['type'] == 'stacked': - for diffractogram in diffractograms: - diffractogram.plot(x=options['xvals'], y=options['yvals'], ax=ax) - - - fig, ax = prettify_diffractogram_plot(fig=fig, ax=ax, options=options) - - - return diffractogram, fig, ax def reverse_diffractograms(diffractograms): From 049f30d96b492573a5e64e8e091b9b5d7c16fa16 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 15:47:26 +0200 Subject: [PATCH 53/57] Fix last remaining liniting issue --- beamtime/xrd/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beamtime/xrd/io.py b/beamtime/xrd/io.py index c2447d8..fc5c292 100644 --- a/beamtime/xrd/io.py +++ b/beamtime/xrd/io.py @@ -149,7 +149,7 @@ def average_images(images): image_arrays = [] for image in images: - image_array = xrd.io.get_image_array(image) + image_array = get_image_array(image) image_arrays.append(image_array) From 27c911cf5454ed48aab8cb90f8ca3691bb7d68a4 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 17:05:52 +0200 Subject: [PATCH 54/57] Rename package to nafuma from beamtime --- feature_list.txt | 2 -- {beamtime => nafuma}/__init__.py | 0 {beamtime => nafuma}/auxillary.py | 0 {beamtime => nafuma}/electrochemistry/__init__.py | 0 {beamtime => nafuma}/electrochemistry/io.py | 0 {beamtime => nafuma}/electrochemistry/plot.py | 0 {beamtime => nafuma}/electrochemistry/unit_tables.py | 0 {beamtime => nafuma}/pdf/__init__.py | 0 {beamtime => nafuma}/plotting.py | 0 {beamtime => nafuma}/test.txt | 0 {beamtime => nafuma}/test/__init__.py | 0 {beamtime => nafuma}/test/pytest.ini | 0 {beamtime => nafuma}/test/test_auxillary.py | 0 {beamtime => nafuma}/test/test_plotting.py | 0 {beamtime => nafuma}/test/xrd/test_io.py | 0 {beamtime => nafuma}/test/xrd/test_plot.py | 0 {beamtime => nafuma}/test2.txt | 0 {beamtime => nafuma}/xanes/__init__.py | 0 {beamtime => nafuma}/xanes/calib.py | 0 {beamtime => nafuma}/xanes/io.py | 0 {beamtime => nafuma}/xrd/__init__.py | 0 {beamtime => nafuma}/xrd/io.py | 0 {beamtime => nafuma}/xrd/plot.py | 0 {beamtime => nafuma}/xrd/test.txt | 0 setup.py | 10 +++++----- 25 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 feature_list.txt rename {beamtime => nafuma}/__init__.py (100%) rename {beamtime => nafuma}/auxillary.py (100%) rename {beamtime => nafuma}/electrochemistry/__init__.py (100%) rename {beamtime => nafuma}/electrochemistry/io.py (100%) rename {beamtime => nafuma}/electrochemistry/plot.py (100%) rename {beamtime => nafuma}/electrochemistry/unit_tables.py (100%) rename {beamtime => nafuma}/pdf/__init__.py (100%) rename {beamtime => nafuma}/plotting.py (100%) rename {beamtime => nafuma}/test.txt (100%) rename {beamtime => nafuma}/test/__init__.py (100%) rename {beamtime => nafuma}/test/pytest.ini (100%) rename {beamtime => nafuma}/test/test_auxillary.py (100%) rename {beamtime => nafuma}/test/test_plotting.py (100%) rename {beamtime => nafuma}/test/xrd/test_io.py (100%) rename {beamtime => nafuma}/test/xrd/test_plot.py (100%) rename {beamtime => nafuma}/test2.txt (100%) rename {beamtime => nafuma}/xanes/__init__.py (100%) rename {beamtime => nafuma}/xanes/calib.py (100%) rename {beamtime => nafuma}/xanes/io.py (100%) rename {beamtime => nafuma}/xrd/__init__.py (100%) rename {beamtime => nafuma}/xrd/io.py (100%) rename {beamtime => nafuma}/xrd/plot.py (100%) rename {beamtime => nafuma}/xrd/test.txt (100%) diff --git a/feature_list.txt b/feature_list.txt deleted file mode 100644 index f4a0efd..0000000 --- a/feature_list.txt +++ /dev/null @@ -1,2 +0,0 @@ -- Must allow for automatic normalisation between different diffractograms, must only happen upon reading data -- diff --git a/beamtime/__init__.py b/nafuma/__init__.py similarity index 100% rename from beamtime/__init__.py rename to nafuma/__init__.py diff --git a/beamtime/auxillary.py b/nafuma/auxillary.py similarity index 100% rename from beamtime/auxillary.py rename to nafuma/auxillary.py diff --git a/beamtime/electrochemistry/__init__.py b/nafuma/electrochemistry/__init__.py similarity index 100% rename from beamtime/electrochemistry/__init__.py rename to nafuma/electrochemistry/__init__.py diff --git a/beamtime/electrochemistry/io.py b/nafuma/electrochemistry/io.py similarity index 100% rename from beamtime/electrochemistry/io.py rename to nafuma/electrochemistry/io.py diff --git a/beamtime/electrochemistry/plot.py b/nafuma/electrochemistry/plot.py similarity index 100% rename from beamtime/electrochemistry/plot.py rename to nafuma/electrochemistry/plot.py diff --git a/beamtime/electrochemistry/unit_tables.py b/nafuma/electrochemistry/unit_tables.py similarity index 100% rename from beamtime/electrochemistry/unit_tables.py rename to nafuma/electrochemistry/unit_tables.py diff --git a/beamtime/pdf/__init__.py b/nafuma/pdf/__init__.py similarity index 100% rename from beamtime/pdf/__init__.py rename to nafuma/pdf/__init__.py diff --git a/beamtime/plotting.py b/nafuma/plotting.py similarity index 100% rename from beamtime/plotting.py rename to nafuma/plotting.py diff --git a/beamtime/test.txt b/nafuma/test.txt similarity index 100% rename from beamtime/test.txt rename to nafuma/test.txt diff --git a/beamtime/test/__init__.py b/nafuma/test/__init__.py similarity index 100% rename from beamtime/test/__init__.py rename to nafuma/test/__init__.py diff --git a/beamtime/test/pytest.ini b/nafuma/test/pytest.ini similarity index 100% rename from beamtime/test/pytest.ini rename to nafuma/test/pytest.ini diff --git a/beamtime/test/test_auxillary.py b/nafuma/test/test_auxillary.py similarity index 100% rename from beamtime/test/test_auxillary.py rename to nafuma/test/test_auxillary.py diff --git a/beamtime/test/test_plotting.py b/nafuma/test/test_plotting.py similarity index 100% rename from beamtime/test/test_plotting.py rename to nafuma/test/test_plotting.py diff --git a/beamtime/test/xrd/test_io.py b/nafuma/test/xrd/test_io.py similarity index 100% rename from beamtime/test/xrd/test_io.py rename to nafuma/test/xrd/test_io.py diff --git a/beamtime/test/xrd/test_plot.py b/nafuma/test/xrd/test_plot.py similarity index 100% rename from beamtime/test/xrd/test_plot.py rename to nafuma/test/xrd/test_plot.py diff --git a/beamtime/test2.txt b/nafuma/test2.txt similarity index 100% rename from beamtime/test2.txt rename to nafuma/test2.txt diff --git a/beamtime/xanes/__init__.py b/nafuma/xanes/__init__.py similarity index 100% rename from beamtime/xanes/__init__.py rename to nafuma/xanes/__init__.py diff --git a/beamtime/xanes/calib.py b/nafuma/xanes/calib.py similarity index 100% rename from beamtime/xanes/calib.py rename to nafuma/xanes/calib.py diff --git a/beamtime/xanes/io.py b/nafuma/xanes/io.py similarity index 100% rename from beamtime/xanes/io.py rename to nafuma/xanes/io.py diff --git a/beamtime/xrd/__init__.py b/nafuma/xrd/__init__.py similarity index 100% rename from beamtime/xrd/__init__.py rename to nafuma/xrd/__init__.py diff --git a/beamtime/xrd/io.py b/nafuma/xrd/io.py similarity index 100% rename from beamtime/xrd/io.py rename to nafuma/xrd/io.py diff --git a/beamtime/xrd/plot.py b/nafuma/xrd/plot.py similarity index 100% rename from beamtime/xrd/plot.py rename to nafuma/xrd/plot.py diff --git a/beamtime/xrd/test.txt b/nafuma/xrd/test.txt similarity index 100% rename from beamtime/xrd/test.txt rename to nafuma/xrd/test.txt diff --git a/setup.py b/setup.py index 4c93b78..b3f9f34 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,11 @@ from setuptools import setup, find_packages -setup(name='beamtime', - version='0.1', - description='Package for process and analysis of beamtime data from SNBL', - url='http://github.uio.no/rasmusvt/beamtime', +setup(name='nafuma', + version='0.2', + description='Analysis tools for inorganic materials chemistry at the NAFUMA-group at the University of Oslo', + url='https://github.com/rasmusthog/nafuma', author='Rasmus Vester Thøgersen, Halvor Høen Hval', - author_email='rasmusvt@smn.uio.no', + author_email='code@rasmusthog.me', license='MIT', packages=find_packages(), zip_safe=False) From 08276301f251e25eb66cce51c46edee6f19f9955 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 17:11:14 +0200 Subject: [PATCH 55/57] Update imports to match new package name --- nafuma/electrochemistry/plot.py | 2 +- nafuma/plotting.py | 2 +- nafuma/test/test_auxillary.py | 2 +- nafuma/test/test_plotting.py | 2 +- nafuma/xrd/io.py | 2 +- nafuma/xrd/plot.py | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nafuma/electrochemistry/plot.py b/nafuma/electrochemistry/plot.py index 64b7115..df977a5 100644 --- a/nafuma/electrochemistry/plot.py +++ b/nafuma/electrochemistry/plot.py @@ -5,7 +5,7 @@ import pandas as pd import numpy as np import math -import beamtime.electrochemistry as ec +import nafuma.electrochemistry as ec def plot_gc(path, kind, options=None): diff --git a/nafuma/plotting.py b/nafuma/plotting.py index e8c5457..2233ab7 100644 --- a/nafuma/plotting.py +++ b/nafuma/plotting.py @@ -1,4 +1,4 @@ -import beamtime.auxillary as aux +import nafuma.auxillary as aux import matplotlib.pyplot as plt from matplotlib.ticker import (MultipleLocator) diff --git a/nafuma/test/test_auxillary.py b/nafuma/test/test_auxillary.py index 668b792..4cb9cd1 100644 --- a/nafuma/test/test_auxillary.py +++ b/nafuma/test/test_auxillary.py @@ -1,4 +1,4 @@ -import beamtime.auxillary as aux +import nafuma.auxillary as aux import os def test_swap_values(): diff --git a/nafuma/test/test_plotting.py b/nafuma/test/test_plotting.py index 8979bc1..e1af0b8 100644 --- a/nafuma/test/test_plotting.py +++ b/nafuma/test/test_plotting.py @@ -1,4 +1,4 @@ -import beamtime.plotting as btp +import nafuma.plotting as btp from cycler import cycler import itertools import numpy as np diff --git a/nafuma/xrd/io.py b/nafuma/xrd/io.py index fc5c292..b3f3951 100644 --- a/nafuma/xrd/io.py +++ b/nafuma/xrd/io.py @@ -9,7 +9,7 @@ import zipfile import xml.etree.ElementTree as ET -import beamtime.auxillary as aux +import nafuma.auxillary as aux def get_image_array(path): diff --git a/nafuma/xrd/plot.py b/nafuma/xrd/plot.py index 950a27f..8dd6a27 100644 --- a/nafuma/xrd/plot.py +++ b/nafuma/xrd/plot.py @@ -9,9 +9,9 @@ import math import ipywidgets as widgets from IPython.display import display -import beamtime.xrd as xrd -import beamtime.auxillary as aux -import beamtime.plotting as btp +import nafuma.xrd as xrd +import nafuma.auxillary as aux +import nafuma.plotting as btp def plot_diffractogram(data, options={}): From f53527fe0b2f8bbc350d850154e1c9a6d811c3b3 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 17:17:28 +0200 Subject: [PATCH 56/57] Clean up test files --- nafuma/test.txt | 1 - nafuma/test2.txt | 0 nafuma/xrd/test.txt | 0 3 files changed, 1 deletion(-) delete mode 100644 nafuma/test.txt delete mode 100644 nafuma/test2.txt delete mode 100644 nafuma/xrd/test.txt diff --git a/nafuma/test.txt b/nafuma/test.txt deleted file mode 100644 index 85476a8..0000000 --- a/nafuma/test.txt +++ /dev/null @@ -1 +0,0 @@ -sdfsdfsdfsdf \ No newline at end of file diff --git a/nafuma/test2.txt b/nafuma/test2.txt deleted file mode 100644 index e69de29..0000000 diff --git a/nafuma/xrd/test.txt b/nafuma/xrd/test.txt deleted file mode 100644 index e69de29..0000000 From de2616067daf2ebc333a592f2729a2425b9b1e25 Mon Sep 17 00:00:00 2001 From: rasmusvt Date: Thu, 7 Apr 2022 17:19:26 +0200 Subject: [PATCH 57/57] Rename automated test workflow --- .../{python-package-conda.yml => automated-testing.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{python-package-conda.yml => automated-testing.yml} (96%) diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/automated-testing.yml similarity index 96% rename from .github/workflows/python-package-conda.yml rename to .github/workflows/automated-testing.yml index ebf95a8..5b553a3 100644 --- a/.github/workflows/python-package-conda.yml +++ b/.github/workflows/automated-testing.yml @@ -1,4 +1,4 @@ -name: Python Package using Conda +name: Automated testing on: [push]