gisans-X-plorer

Simple App that interactively helps in the reduction of NICOS files for GISA(N|X)S data.

Screenshot

Install - Windows, Mac, Linux; Python 3.6

Open a terminal and use pip:

$ pip install gisansexplorer

Run:

Once installed, open a terminal and simply call gisansexplorer:

$ gisansexplorer

How To…



How to…

Open a NICOS .dat file

  • By navigating to it on the bottom left panel:

    Only dat files are shown

  • By browsing to it using the open… button on the bottom rigth:

    Press to open a dialog Only dat files are selectable

Select the region of interest (ROI)

  • By using the ROI selector on the left plot:
    • Click a corner and drag to resize.

    • Click the center and drag to move.

    Click and drag the squre on the plot

  • By setting the limits on the information table on the right:
    • Set the pixel limit values x0, y0, xf, xf (left, bottom, right, top).

    • After they turn green –wrong entries will turn red, click Update.

    Hit enter so each value turns green

Pop up the ROI plots

  • By double clicking on any of the ROI plots, DoubleClickRegion, four pop-up windows will appear:

    • \(Q_z\) vs integration along \(Q_y\)

    IntegrationAlongQy

    • \(Q_y\) vs integration along \(Q_z\)

    IntegrationAlongQz

    • 2D Intensity map as function of \(Q_y, Q_z\)

    • 3D Intensity surface as function of \(Q_y, Q_z\)

    GisansSurface

Clicking the floppy disk icon will save individual figures.

Add or subtract intensities from different Gisans maps

  • After loading one or more files, click the corresponding maps on the gisans map list. To select several maps, hold the keys shift or ctrl while clicking on each entry. This will automatically show the addition of the intensities of the selected gisans maps. To open several .dat files, repeat the procedure to Open a NICOS .dat file.

Use 'ctrl' and 'shift' to select multiple files.

  • To show the subtraction of the intensities, select any two entries on the list and tick the checkbox Subtract intensities

When more than two entries are selected, the checkbox becomes inactive

N.B. While ddition is calculated in the obvious way, \(I = I_A + I_B\), subtraction is calculated as \(I = |I_A - I_B|\).

Save the ROI

SaveButtons

  • The button Save ROI as ascii columns opens a dialog asking for a location and a filename. After the filename is given (e.g. MyGivenFilename), three files are saved:

    • MyGivenFilename_xI_.txt - two columns: the first one, the \(x\) coordinate of the detector in \(Q\)-space (i.e. \(Q_z\)); the second one, \(I(Q_z)\), i.e. the intensity integrated along \(Q_y\).

    • MyGivenFilename_yI_.txt - two columns: the first one, the \(y\) coordinate of the detector in \(Q\)-space (i.e. \(Q_y\)); the second one, \(I(Q_y)\), i.e. the intensity integrated along \(Q_z\).

    • MyGivenFilename_xyI_.txt- three columns: analogously to the two previous files, each column represents \(Q_z, Q_y, I(Q_z, Q_y)\).

  • The button Save png or pdf also opens a dialog asking for a location and a filename. After the filename is given (e.g. MyGivenFilename), five files are saved:

    • MyGivenFilename.png (or .pdf)

    • MyGivenFilename-integration_qy.png (or .pdf)

    • MyGivenFilename-integration_qz.png (or .pdf)

    • MyGivenFilename-gisans_surface.png (or .pdf)

    • MyGivenFilename-gisans_map.png (or .pdf)

The first file is practically a screenshot of the plotting area,

MyGivenFilename.png

, and the other four files correspond to the figures described in Section Pop up the ROI plots.

Change instrument and detector parameters

ChangeInstrumentParameters

The name of the instrument, the pixel size (in mm) and the sample-detector distance (in mm) can be modified by double-clicking the corresponding entries in the Info table. Once the new entries turn green, the Update button must be clicked for the changes to take effect. the wavelength selector, the angle of incidence, the mean sensitivity, and the monitor counts are read from the NICOS .dat file and thus are not adjustable.

The instrument_name parameter only affects the title of the figures and the header of the ascii file when saving; instead, sample_detector_distance_mm and pixel_size_mm affect also the way in which the \([Q_y, Q_z]\) map is computed for the ROI plot.

Default vaules for the sdd and the pixel size are 1990 and 0.5755 respectively.

Adjust the beam center position

The detector pixel corresponding to the beam center can be adjusted via the parameters qyc and qzc. By modifying this parameters on the info table, black crosshairs appear on the detector view (left plot) and, if they are inside the ROI, they appear also on the q-space view (right plot). Two additional lines are calculated: a red one, corresponding to the corrected beam center and a green one, corresponding to the specular reflection. For the changes to take effect, the Update button must be clicked after the parameters turn green after being edited.

The black crosshairs are the user defined detector centre. The red line corresponds to the correction and the green one to the specular reflection.

The location of the green and red lines are properties of the class Experiment and are calculated inside the class MyFrame according to:

experiment.qzc_corr = experiment.qzc + int( ( experiment.sample_detector_distance_mm * np.tan( np.pi * float(experiment.angle_of_incidence) / 180.0) ) / experiment.pixel_size_mm )
experiment.qzc_spec = experiment.qzc - int( ( experiment.sample_detector_distance_mm * np.tan( np.pi * float(experiment.angle_of_incidence) / 180.0) ) / experiment.pixel_size_mm )

Modify the intensity gradient range

The intensity gradient can be shown either in linear scale or in logarithmic scale (default). To switch between these two scales, press the Log/Linear button.

IntensityGradientRange

Changing the range of the colormap can be achieved in two ways:

  • By specifying the minumum and maximum intensity values of the colormap in the Info Table.

  • By using the mouse wheel while hovering over the detector view (left plot) color bar.

The default min- and max- intensity values are 1e-06 and 1e-03 respectively.

Open and close experiment tabs

Creating new experiments allows to analyse data using different instruments and different sets of parameters in general.

  • Clicking the left + button will open a new experiment tab.

  • Clicking the right - button will delete the current experiment tab.

ExperimentTabs

After a new experiment tab is opened, the previous tabs are renamed according to the experimental .dat file opened in them. The new tab will have the default name “New Experiment N”, with N increasing by 1 every time the + button is pressed. The names of experiment tabs are non-editable.

Save progress

Saving the partial progress is not possible. When the close button is pressed (Usually an X in a top corner of the window, depending on the Operating System), a pop-up dialog asks whether to quit the application. After clicking Yes, the application will close and all progress will be lost. Make sure that all the reduced ascii data and the figures required are correctly saved before closing the application –refer to sections Pop up the ROI plots and Save the ROI.

CloseApp

gisansexplorer package

Submodules

gisansexplorer.GUI module

class gisansexplorer.GUI.MyFrame

Bases: PyQt5.QtWidgets.QFrame, gisansexplorer.utils.Frozen

[summary]

Parameters
  • qtw ([type]) – [description]

  • Frozen ([type]) – [description]

addExperimentInfo()

[summary]

addFileTreeAndList(botSplitter)

[summary]

Parameters

botSplitter ([type]) – [description]

addFunctionalityButtons()

[summary]

addPanels()

[summary]

build_ascii_header()

[summary]

Returns

[description]

Return type

[type]

color_outdated()

[summary]

Returns

[description]

Return type

[type]

static color_validate(table_item, value_a, value_b)

[summary]

Parameters
  • table_item ([type]) – [description]

  • value_a ([type]) – [description]

  • value_b ([type]) – [description]

Returns

[description]

Return type

[type]

compute_Q()

[summary]

Returns

[description]

Return type

[type]

doStuff(datFilePath)

[summary]

Parameters

datFilePath ([type]) – [description]

initFrame()

[summary]

on_cell_changed()

[summary]

on_click_loglinear()

[summary]

on_click_open_file()
on_click_save_ascii()

[summary]

on_click_save_png()

[summary]

Returns

[description]

Return type

[type]

on_click_update()

[summary]

on_file_double_clicked()

[summary]

on_file_selection_changed()

[summary]

on_graph_updated()

[summary]

on_progress_emited(value)

[summary]

Parameters

value ([type]) – [description]

on_subtract_checkbox_changed()

[summary]

openFileNameDialog()

[summary]

Returns

[description]

Return type

[type]

parse_dat(file)

[summary]

Parameters

file ([type]) – [description]

Returns

[description]

Return type

[type]

parse_intensity_map(inputd)

[summary]

Parameters

inputd ([type]) – [description]

Returns

[description]

Return type

[type]

parse_sensitivity_map(sens)

[summary]

Parameters

sens ([type]) – [description]

Returns

[description]

Return type

[type]

parse_yaml(fp)

[summary]

Parameters

fp ([type]) – [description]

Returns

[description]

Return type

[type]

read_dat_file(datFilePath=None)

[summary]

Parameters

datFilePath ([type], optional) – [description], by default None

Returns

[description]

Return type

[type]

read_intensity_file()

[summary]

Returns

[description]

Return type

[type]

read_sensitivity_file()

[summary]

Returns

[description]

Return type

[type]

read_yaml_file()

[summary]

Returns

[description]

Return type

[type]

safe_parse(parse_func, file_path)

[summary]

Parameters
  • parse_func ([type]) – [description]

  • file_path ([type]) – [description]

Returns

[description]

Return type

[type]

safe_parse_numpy(parse_func, file_path, dtype='i', delimiter=' ')

[summary]

Parameters
  • parse_func ([type]) – [description]

  • file_path ([type]) – [description]

  • dtype (str, optional) – [description], by default ‘i’

  • delimiter (str, optional) – [description], by default ‘ ‘

Returns

[description]

Return type

[type]

saveFileNameDialog()

[summary]

Returns

[description]

Return type

[type]

save_gisans_map_filepath(inputd)

[summary]

Parameters

inputd ([type]) – [description]

Raises

NotImplementedError – [description]

subtract_intensities_from_selected_files()

[summary]

Returns

[description]

Return type

[type]

Raises

ValueError – [description]

sum_intensities_from_selected_files()

[summary]

Returns

[description]

Return type

[type]

update_from_info_table()

[summary]

Returns

[description]

Return type

[type]

update_from_selection_list()

[summary]

update_gui()

[summary]

Returns

[description]

Return type

[type]

Raises

Exception – [description]

update_multi_experiment_values()

[summary]

Returns

[description]

Return type

[type]

update_single_experiment_values(experiment)

[summary]

Parameters

experiment ([type]) – [description]

Returns

[description]

Return type

[type]

update_table()

[summary]

Returns

[description]

Return type

[type]

class gisansexplorer.GUI.MyTabs

Bases: PyQt5.QtWidgets.QTabWidget, gisansexplorer.utils.Frozen

Collection of tabs hosting gisans data frames

tabButton_add

Adds a new tab

Type

QToolButton

tabButton_rmv

Removes the current tab

Type

QToolButton

frameList

List of gisans frames

Type

List

last_num

index of last tab created

Type

int

addTab()

Adds a new tab

initCornerButton()

Adds and creates connections for the add/rmv tab buttons

removeTab()

Removes the current tab

gisansexplorer.experiment_data_handling module

class gisansexplorer.experiment_data_handling.Experiment(instrument=<gisansexplorer.experiment_data_handling.Instrument object>)

Bases: gisansexplorer.utils.Frozen

cos_alpha_f(pixel_j)
property cos_alpha_i
sin_2theta_f(pixel_i)
sin_alpha_f(pixel_j)
property sin_alpha_i
property two_pi_over_lambda
class gisansexplorer.experiment_data_handling.FileReadingThread(myframe)

Bases: PyQt5.QtCore.QThread

progress_signal
run(self)
class gisansexplorer.experiment_data_handling.Instrument(name, pixel_size_mm=None, sample_detector_distance_mm=None, data_root_dir='/')

Bases: gisansexplorer.utils.Frozen

class gisansexplorer.experiment_data_handling.Settings

Bases: gisansexplorer.utils.Frozen

basename()
datFilePath()
gisans_cut_filepath(y_or_z='z')
gisans_map_filepath()
gzFilePaths()
sensFilePath()
yamlFilePaths()

gisansexplorer.main_app module

class gisansexplorer.main_app.App

Bases: PyQt5.QtWidgets.QMainWindow, gisansexplorer.utils.Frozen

addTab()
closeEvent(self, QCloseEvent)
gisansexplorer.main_app.icon_file()

gisansexplorer.plotting module

class gisansexplorer.plotting.AreaSelector(ax, line_select_callback)

Bases: gisansexplorer.utils.Frozen

class gisansexplorer.plotting.MyGraphView(graph_title, parent=None)

Bases: PyQt5.QtWidgets.QWidget

build_cbar()
build_norm(**kwargs)
define_axes()
define_layout()
finishedUpdating
init_canvas_connections()
init_data_and_parameters()
init_xyzLabel()
line_select_callback(eclick, erelease)
on_mouse_click(event)
on_mouse_move(event)
on_mouse_wheel(event)
save(**kwargs)
save_figures(filePath)
save_gisans_map(filePath=None)
save_gisans_surface(filePath=None)
save_qy_integration(filePath=None)
save_qz_integration(filePath=None)
show_figures()
take_care_of_negative_values()
test_show()
update_area_selector(**kwargs)
update_ax(**kwargs)
update_axes(**kwargs)
update_cax()
update_data(**kwargs)
update_graph(**kwargs)
update_xax()
update_yax()
update_zoom_ax()
class gisansexplorer.plotting.PlotData

Bases: gisansexplorer.utils.Frozen

class gisansexplorer.plotting.PlotStyle

Bases: object

classmethod apply_style(ax)
axisLabelFontSize = 30.0
borderWidth = 3
figSize = (12, 9)
fontSize = 20
lineWidth = 4.0
majorTickLength = 20
minorTickLength = 6.0
titleFontSize = 10.0
gisansexplorer.plotting.create_gisans_figure(data, cnorm, draw_surface_plot=False)
gisansexplorer.plotting.create_qy_integration_figure(data)
gisansexplorer.plotting.create_qz_integration_figure(data)

gisansexplorer.utils module

class gisansexplorer.utils.FloatValidator(*args, **kwargs)

Bases: PyQt5.QtGui.QValidator

fixup(self, str) → str
validate(self, str, int) → Tuple[QValidator.State, str, int]
class gisansexplorer.utils.Frozen

Bases: object

gisansexplorer.utils.enable_high_dpi_scaling()
gisansexplorer.utils.format_float(value)

Modified form of the ‘g’ format specifier.

gisansexplorer.utils.handle_exception(e)
gisansexplorer.utils.is_file(path)
class gisansexplorer.utils.mySciSpinBox(*args, **kwargs)

Bases: PyQt5.QtWidgets.QDoubleSpinBox

fixup(self, str) → str
stepBy(self, int)
textFromValue(self, float) → str
validate(self, str, int) → Tuple[QValidator.State, str, int]
valueFromText(self, str) → float
gisansexplorer.utils.profile_dec(fnc)

A decorator that uses cProfile to profile a function

gisansexplorer.utils.profile_function_with_arguments(*args, **kwargs)
gisansexplorer.utils.valid_float_string(string)

Module contents

gisansexplorer.entry_point()

gisansexplorer