manipulations

sans.dataloader.manipulations

Data manipulations for 2D data sets. Using the meta data information, various types of averaging are performed in Q-space

class sans.dataloader.manipulations.Boxavg

Bases: sans.dataloader.manipulations.Boxsum

Perform the average of counts in a 2D region of interest.

__call__()

Perform the sum in the region of interest

Parameters:data2D – Data2D object
Returns:average counts, error on average counts
__class__

alias of type

__delattr__

x.__delattr__(‘name’) <==> del x.name

__dict__ = <dictproxy object at 0x028EE710>
__getattribute__

x.__getattribute__(‘name’) <==> x.name

__hash__

x.__hash__() <==> hash(x)

__init__()
__module__ = 'sans.dataloader.manipulations'
static __new__(S, ...) → a new object with type S, a subtype of T
__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

x.__repr__() <==> repr(x)

__setattr__

x.__setattr__(‘name’, value) <==> x.name = value

__str__

x.__str__() <==> str(x)

__weakref__

list of weak references to the object (if defined)

_sum()

Perform the sum in the region of interest

Parameters:data2D – Data2D object
Returns:number of counts, error on number of counts, number of entries summed
class sans.dataloader.manipulations.Boxcut

Bases: object

Find a rectangular 2D region of interest.

__call__()

Find a rectangular 2D region of interest.

Parameters:data2D – Data2D object
Returns:mask, 1d array (len = len(data)) with Trues where the data points are inside ROI, otherwise False
__class__

alias of type

__delattr__

x.__delattr__(‘name’) <==> del x.name

__dict__ = <dictproxy object at 0x028EE4B0>
__getattribute__

x.__getattribute__(‘name’) <==> x.name

__hash__

x.__hash__() <==> hash(x)

__init__()
__module__ = 'sans.dataloader.manipulations'
static __new__(S, ...) → a new object with type S, a subtype of T
__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

x.__repr__() <==> repr(x)

__setattr__

x.__setattr__(‘name’, value) <==> x.name = value

__str__

x.__str__() <==> str(x)

__weakref__

list of weak references to the object (if defined)

_find()

Find a rectangular 2D region of interest.

Parameters:data2D – Data2D object
Returns:out, 1d array (length = len(data)) with Trues where the data points are inside ROI, otherwise Falses
class sans.dataloader.manipulations.Boxsum

Bases: object

Perform the sum of counts in a 2D region of interest.

__call__()

Perform the sum in the region of interest

Parameters:data2D – Data2D object
Returns:number of counts, error on number of counts
__class__

alias of type

__delattr__

x.__delattr__(‘name’) <==> del x.name

__dict__ = <dictproxy object at 0x028EE970>
__getattribute__

x.__getattribute__(‘name’) <==> x.name

__hash__

x.__hash__() <==> hash(x)

__init__()
__module__ = 'sans.dataloader.manipulations'
static __new__(S, ...) → a new object with type S, a subtype of T
__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

x.__repr__() <==> repr(x)

__setattr__

x.__setattr__(‘name’, value) <==> x.name = value

__str__

x.__str__() <==> str(x)

__weakref__

list of weak references to the object (if defined)

_sum()

Perform the sum in the region of interest

Parameters:data2D – Data2D object
Returns:number of counts, error on number of counts, number of entries summed
class sans.dataloader.manipulations.CircularAverage

Bases: object

Perform circular averaging on 2D data

The data returned is the distribution of counts as a function of Q

__call__()

Perform circular averaging on the data

Parameters:data2D – Data2D object
Returns:Data1D object
__class__

alias of type

__delattr__

x.__delattr__(‘name’) <==> del x.name

__dict__ = <dictproxy object at 0x028EE530>
__getattribute__

x.__getattribute__(‘name’) <==> x.name

__hash__

x.__hash__() <==> hash(x)

__init__()
__module__ = 'sans.dataloader.manipulations'
static __new__(S, ...) → a new object with type S, a subtype of T
__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

x.__repr__() <==> repr(x)

__setattr__

x.__setattr__(‘name’, value) <==> x.name = value

__str__

x.__str__() <==> str(x)

__weakref__

list of weak references to the object (if defined)

class sans.dataloader.manipulations.Ring

Bases: object

Defines a ring on a 2D data set. The ring is defined by r_min, r_max, and the position of the center of the ring.

The data returned is the distribution of counts around the ring as a function of phi.

Phi_min and phi_max should be defined between 0 and 2*pi in anti-clockwise starting from the x- axis on the left-hand side

__call__()

Apply the ring to the data set. Returns the angular distribution for a given q range

Parameters:data2D – Data2D object
Returns:Data1D object
__class__

alias of type

__delattr__

x.__delattr__(‘name’) <==> del x.name

__dict__ = <dictproxy object at 0x028EEFD0>
__getattribute__

x.__getattribute__(‘name’) <==> x.name

__hash__

x.__hash__() <==> hash(x)

__init__()
__module__ = 'sans.dataloader.manipulations'
static __new__(S, ...) → a new object with type S, a subtype of T
__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

x.__repr__() <==> repr(x)

__setattr__

x.__setattr__(‘name’, value) <==> x.name = value

__str__

x.__str__() <==> str(x)

__weakref__

list of weak references to the object (if defined)

class sans.dataloader.manipulations.Ringcut

Bases: object

Defines a ring on a 2D data set. The ring is defined by r_min, r_max, and the position of the center of the ring.

The data returned is the region inside the ring

Phi_min and phi_max should be defined between 0 and 2*pi in anti-clockwise starting from the x- axis on the left-hand side

__call__()

Apply the ring to the data set. Returns the angular distribution for a given q range

Parameters:data2D – Data2D object
Returns:index array in the range
__class__

alias of type

__delattr__

x.__delattr__(‘name’) <==> del x.name

__dict__ = <dictproxy object at 0x02906210>
__getattribute__

x.__getattribute__(‘name’) <==> x.name

__hash__

x.__hash__() <==> hash(x)

__init__()
__module__ = 'sans.dataloader.manipulations'
static __new__(S, ...) → a new object with type S, a subtype of T
__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

x.__repr__() <==> repr(x)

__setattr__

x.__setattr__(‘name’, value) <==> x.name = value

__str__

x.__str__() <==> str(x)

__weakref__

list of weak references to the object (if defined)

class sans.dataloader.manipulations.SectorPhi

Bases: sans.dataloader.manipulations._Sector

Sector average as a function of phi. I(phi) is return and the data is averaged over Q.

A sector is defined by r_min, r_max, phi_min, phi_max. The number of bin in phi also has to be defined.

__call__()

Perform sector average and return I(phi).

Parameters:data2D – Data2D object
Returns:Data1D object
__init__()
__module__ = 'sans.dataloader.manipulations'
_agv()

Perform sector averaging.

Parameters:
  • data2D – Data2D object
  • run – define the varying parameter (‘phi’ , ‘q’ , or ‘q2’)
Returns:

Data1D object

class sans.dataloader.manipulations.SectorQ

Bases: sans.dataloader.manipulations._Sector

Sector average as a function of Q for both symatric wings. I(Q) is return and the data is averaged over phi.

A sector is defined by r_min, r_max, phi_min, phi_max. r_min, r_max, phi_min, phi_max >0. The number of bin in Q also has to be defined.

__call__()

Perform sector average and return I(Q).

Parameters:data2D – Data2D object
Returns:Data1D object
__init__()
__module__ = 'sans.dataloader.manipulations'
_agv()

Perform sector averaging.

Parameters:
  • data2D – Data2D object
  • run – define the varying parameter (‘phi’ , ‘q’ , or ‘q2’)
Returns:

Data1D object

class sans.dataloader.manipulations.Sectorcut

Bases: object

Defines a sector (major + minor) region on a 2D data set. The sector is defined by phi_min, phi_max, where phi_min and phi_max are defined by the right and left lines wrt central line.

Phi_min and phi_max are given in units of radian and (phi_max-phi_min) should not be larger than pi

__call__()

Find a rectangular 2D region of interest.

Parameters:data2D – Data2D object
Returns:mask, 1d array (len = len(data))

with Trues where the data points are inside ROI, otherwise False

__class__

alias of type

__delattr__

x.__delattr__(‘name’) <==> del x.name

__dict__ = <dictproxy object at 0x02906A10>
__getattribute__

x.__getattribute__(‘name’) <==> x.name

__hash__

x.__hash__() <==> hash(x)

__init__()
__module__ = 'sans.dataloader.manipulations'
static __new__(S, ...) → a new object with type S, a subtype of T
__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

x.__repr__() <==> repr(x)

__setattr__

x.__setattr__(‘name’, value) <==> x.name = value

__str__

x.__str__() <==> str(x)

__weakref__

list of weak references to the object (if defined)

_find()

Find a rectangular 2D region of interest.

Parameters:data2D – Data2D object
Returns:out, 1d array (length = len(data))

with Trues where the data points are inside ROI, otherwise Falses

class sans.dataloader.manipulations.SlabX

Bases: sans.dataloader.manipulations._Slab

Compute average I(Qx) for a region of interest

__call__()

Compute average I(Qx) for a region of interest

Parameters:data2D – Data2D object
Returns:Data1D object
__class__

alias of type

__delattr__

x.__delattr__(‘name’) <==> del x.name

__dict__ = <dictproxy object at 0x02906DB0>
__getattribute__

x.__getattribute__(‘name’) <==> x.name

__hash__

x.__hash__() <==> hash(x)

__init__()
__module__ = 'sans.dataloader.manipulations'
static __new__(S, ...) → a new object with type S, a subtype of T
__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

x.__repr__() <==> repr(x)

__setattr__

x.__setattr__(‘name’, value) <==> x.name = value

__str__

x.__str__() <==> str(x)

__weakref__

list of weak references to the object (if defined)

_avg()

Compute average I(Q_maj) for a region of interest. The major axis is defined as the axis of Q_maj. The minor axis is the axis that we average over.

Parameters:
  • data2D – Data2D object
  • maj_min – min value on the major axis
Returns:

Data1D object

class sans.dataloader.manipulations.SlabY

Bases: sans.dataloader.manipulations._Slab

Compute average I(Qy) for a region of interest

__call__()

Compute average I(Qy) for a region of interest

Parameters:data2D – Data2D object
Returns:Data1D object
__class__

alias of type

__delattr__

x.__delattr__(‘name’) <==> del x.name

__dict__ = <dictproxy object at 0x0294E0F0>
__getattribute__

x.__getattribute__(‘name’) <==> x.name

__hash__

x.__hash__() <==> hash(x)

__init__()
__module__ = 'sans.dataloader.manipulations'
static __new__(S, ...) → a new object with type S, a subtype of T
__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

x.__repr__() <==> repr(x)

__setattr__

x.__setattr__(‘name’, value) <==> x.name = value

__str__

x.__str__() <==> str(x)

__weakref__

list of weak references to the object (if defined)

_avg()

Compute average I(Q_maj) for a region of interest. The major axis is defined as the axis of Q_maj. The minor axis is the axis that we average over.

Parameters:
  • data2D – Data2D object
  • maj_min – min value on the major axis
Returns:

Data1D object

class sans.dataloader.manipulations._Sector

Defines a sector region on a 2D data set. The sector is defined by r_min, r_max, phi_min, phi_max, and the position of the center of the ring where phi_min and phi_max are defined by the right and left lines wrt central line and phi_max could be less than phi_min.

Phi is defined between 0 and 2*pi in anti-clockwise starting from the x- axis on the left-hand side

__init__()
__module__ = 'sans.dataloader.manipulations'
_agv()

Perform sector averaging.

Parameters:
  • data2D – Data2D object
  • run – define the varying parameter (‘phi’ , ‘q’ , or ‘q2’)
Returns:

Data1D object

class sans.dataloader.manipulations._Slab

Bases: object

Compute average I(Q) for a region of interest

__call__()
__class__

alias of type

__delattr__

x.__delattr__(‘name’) <==> del x.name

__dict__ = <dictproxy object at 0x0294E670>
__getattribute__

x.__getattribute__(‘name’) <==> x.name

__hash__

x.__hash__() <==> hash(x)

__init__()
__module__ = 'sans.dataloader.manipulations'
static __new__(S, ...) → a new object with type S, a subtype of T
__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

x.__repr__() <==> repr(x)

__setattr__

x.__setattr__(‘name’, value) <==> x.name = value

__str__

x.__str__() <==> str(x)

__weakref__

list of weak references to the object (if defined)

_avg()

Compute average I(Q_maj) for a region of interest. The major axis is defined as the axis of Q_maj. The minor axis is the axis that we average over.

Parameters:
  • data2D – Data2D object
  • maj_min – min value on the major axis
Returns:

Data1D object

sans.dataloader.manipulations.flip_phi()

Correct phi to within the 0 <= to <= 2pi range

Returns:phi in >=0 and <=2Pi
sans.dataloader.manipulations.get_intercept()

Returns the fraction of the side at which the q-value intercept the pixel, None otherwise. The values returned is the fraction ON THE SIDE OF THE LOWEST Q.

    A           B    
+-----------+--------+    <--- pixel size
0                    1     
Q_0 -------- Q ----- Q_1   <--- equivalent Q range
if Q_1 > Q_0, A is returned
if Q_1 < Q_0, B is returned
if Q is outside the range of [Q_0, Q_1], None is returned
sans.dataloader.manipulations.get_pixel_fraction()

Returns the fraction of the pixel defined by the four corners (q_00, q_01, q_10, q_11) that has q < qmax.:

        q_01                q_11
y=1         +--------------+
            |              |
            |              |
            |              |
y=0         +--------------+
        q_00                q_10

            x=0            x=1
sans.dataloader.manipulations.get_pixel_fraction_square()

Return the fraction of the length from xmin to x.:

    A            B
+-----------+---------+
xmin        x         xmax
Parameters:
  • x – x-value
  • xmin – minimum x for the length considered
  • xmax – minimum x for the length considered
Returns:

(x-xmin)/(xmax-xmin) when xmin < x < xmax

sans.dataloader.manipulations.get_q()
Parameters:
  • dx – x-distance from beam center [mm]
  • dy – y-distance from beam center [mm]
Returns:

q-value at the given position

sans.dataloader.manipulations.get_q_compo()

This reduces tiny error at very large q. Implementation of this func is not started yet.<–ToDo

sans.dataloader.manipulations.reader2D_converter()

convert old 2d format opened by IhorReader or danse_reader to new Data2D format

Parameters:data2d – 2d array of Data2D object
Returns:1d arrays of Data2D object

Table Of Contents

Previous topic

loader

Next topic

Readers

This Page