Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
import numpy as np

def run(xaxis, data, **kwargs):
	#generate random noise the same shape as the data
	noise = np.random.rand(*data.shape)
	#add it to the output dictionary
	script_outputs = {"data":noise}
	#also return the x-axis
	script_outputs["xaxis"] = xaxis
	return script_outputs

 

 

2) Take XY data and return XY data of random noise of the same length, overwriting axes, data and titles (click here to download)

...

3) Take small angle scattering

Mathinline
bodyI
vs
Mathinline
bodyq
data and transform this to produce a Guinier plot (click here to download)

 

 

Code Block
languagepy
# Example script for use with the 'Python Script - XY to XY [Scripting]' processing plug-in.
# 
# Last updated 2016-11-02 - For DAWN 2.3
#
# Copyright (c) 2016 Diamond Light Source Ltd.
#
#
# The DAWN Python PyDev actor will execute this script, invoking a 'run' method in this file.
# This actor will pass the data and any associated variables from the dataset, which we will
# catch as a dictionary.
#
# Below is a simple example where reduced SAXS data is taken in and converted to display a Guinier plot

# Always handy to have numpy
import numpy as np


# The method the the PyDev actor will call, we'll catch any and all arguements as a dictionary
def run(**kwargs):

    # Extract out the data and xaxis from the dictionary
    data = kwargs['data']
    xaxis = kwargs['xaxis']

    # Do some 'error' handling
    if 'error' in kwargs:
        del kwargs['error']

    # Do the required mathematics on the data
    guinier = np.log(data)
    guinier_x = np.power(xaxis,2)

    # Set the plot titles and data values
    kwargs['data_title'] = 'ln(I)'
    kwargs['data'] = guinier
    kwargs['xaxis_title'] = 'q^2'
    kwargs['xaxis'] = guinier_x

    return kwargs

...

4) Take small angle scattering

Mathinline
bodyI
vs
Mathinline
bodyq
data and transform this to produce a Kratky plot (click here to download)

 

 

Code Block
languagepy
# Example script for use with the 'Python Script - XY to XY [Scripting]' processing plug-in.
# 
# Last updated 2016-11-02 - For DAWN 2.3
#
# Copyright (c) 2016 Diamond Light Source Ltd.
#
#
# The DAWN Python PyDev actor will execute this script, invoking a 'run' method in this file.
# This actor will pass the data and any associated variables from the dataset, which we will
# catch as a dictionary.
#
# Below is a simple example where reduced SAXS data is taken in and converted to display a Kratky plot

# Always handy to have numpy
import numpy as np


# The method the the PyDev actor will call, we'll catch any and all arguements as a dictionary
def run(**kwargs):

 # Extract out the data and xaxis from the dictionary
 data = kwargs['data']
 xaxis = kwargs['xaxis']

 # Do some 'error' handling
 if 'error' in kwargs:
 del kwargs['error']

 # Do the required mathematics on the data
 kratky = np.power(xaxis,2)*data

 # Set the plot titles and data values
 kwargs['data_title'] = 'I*q^2'
 kwargs['data'] = kratky
 kwargs['xaxis_title'] = 'q'

 return kwargs

...