mda2idd_report documentation

Many sectors of the APS use the EPICS [1] sscan record [2] from synApps [3] to collect their experimental data. The saveData process [4] runs in an EPICS IOC to store the sscan record data into binary files using the MDA [5] format.

This support provides a tool to read those MDA files and, for 1-D and 2-D scans, write the scan into ASCII text files according to the expected layout provided by a previous program (yca scanSee_report, support based on the open-source yorick software with extensions to communicate with EPICS using Channel Access).

main window view

Main window showing full summary of selected MDA file

[1]EPICS: http://www.aps.anl.gov/epics/
[2]EPICS sscan record: http://www.aps.anl.gov/bcda/synApps/sscan/sscanRecord.html
[3]synApps: http://www.aps.anl.gov/bcda/synApps/index.php
[4]more information on the saveData process: http://www.aps.anl.gov/bcda/synApps/sscan/sscanDoc.html
[5]MDA format specification: http://www.aps.anl.gov/bcda/synApps/sscan/saveData_fileFormat.txt

Contents

mda2idd_gui

Source code documentation

mda2idd_gui Module

GUI for mda2idd_report

Objectives

Provide GUI tools to browse a file system and select MDA files. Process them with mda2idd_report.

Instructions

Browse to a directory containing MDA files. Select one. A summary will be shown. Choose: * File –> Save (or ^S) to convert selected MDA file to an ASCII text file. * File –> Convert entire Directory (^D) to convert all MDA files

For now, only *.mda files may be browsed. ASCII text files will be written to directory: ../ASCII/ (relative to the MDA file directory)

Features

  • presents file system list
  • adds directory picker dialog and text entry box
  • preview brief header or full summary of MDA file (^B)
  • convert one selected MDA file to ASCII (^S)
  • convert entire directory of MDA files to ASCII (^D)

Source Code Documentation

MainWindow([parent, start_fresh]) Manage the application through the main window

class mda2idd_gui.MainWindow(parent=None, start_fresh=False)[source]

Bases: wx._windows.Frame

Manage the application through the main window

GetDefaultPreferencesFileName()[source]

return the name of the preferences file for this session

The preferences file, an XML file that contains recent program settings for specific program features, is saved in the HOME (or USERPROFILE on Windows) directory for the user account under the .mda2idd_gui_rc.xml file name. Here is an example from a Windows 7 system:

<?xml version="1.0" encoding="UTF-8"?>
<mda2idd_gui datetime="2013-03-06 13:09:17.593000" version="2013-02">
  <preferences_file>C:\Users\Pete\.mda2idd_gui_rc.xml</preferences_file>
  <written_by program="C:\Users\Pete\Documents\eclipse\mda2idd_report\src\mda2idd_gui.py"/>
  <subversion id="$Id$"/>
  <window>
    <size h="1212" v="561"/>
    <position h="114" v="232"/>
    <sash pos="300"/>
  </window>
  <file_filter>*.mda</file_filter>
  <starting_directory>C:\Users\Pete\Documents\eclipse\mda2idd_report\data\mda</starting_directory>
  <short_summary>False</short_summary>
  <mrud max_directories="9">
    <!--MRUD: Most-Recently-Used Directory-->
    <dir>C:\Users\Pete\Documents\eclipse\mda2idd_report\data\mda</dir>
    <dir>C:\Users\Pete\Apps\epics\synAppsSVN\support\sscan\documentation</dir>
    <dir>C:\Temp\mdalib</dir>
    <dir>C:\Users\Pete\Desktop\scanSee3.1\DATA</dir>
    <dir>C:\Users\Pete\Documents\eclipse\dc2mda\src</dir>
    <dir>C:\Users\Pete\Documents\eclipse\dc2mda\src opo</dir>
  </mrud>
</mda2idd_gui>

Items remembered between program sessions include:

  • window size and position
  • position of the sash thats plits the file list from the summary output
  • the list of most-recently-used directories (MRUD)
  • the first directory to show (the last directory from which an MDA file was selected)

Note

If more than one copy of this program is run by the same user at the same time, the content of the preferences file will be that of the latest action that forced an update to the file content.

OnAbout(event)[source]

show the “About” box

OnConvertAll(event)[source]

selected the “ConvertAll” menu item

OnMenuFileItemExit(event)[source]

User requested to quit the application

Parameters:event – wxPython event object
OnMenuFileItemPrefs(event)[source]

save the preferences to a file

OnMenuFileItemReportStyle(event)[source]
OnMenuFileItemSave(event)[source]

save the selected MDA file as ASCII

OnMrudItem(event)[source]

handle MRUD menu items

OnSashMoved(event)[source]

user moved the sash

OnSelectDirPicker(event)[source]

user changed the text or browsed to a directory in the picker

OnSelectTreeCtrlItem(event)[source]

user selected something in the directory list tree control

OnWindowGeometryChanged(event)[source]

user changed the window size or position

appendSummaryText(text)[source]

post new text to the summary TextCtrl, appending to any existing text

convertMdaDir(path)[source]

convert all MDA files in a given directory

getPreferences(start_fresh=False)[source]

set program preferences: default (start_fresh) and then optionally override from a file

listMdaFiles(path)[source]

return a list of all MDA files in the path directory

messageDialog(description, text)[source]

Present a dialog asking user to acknowledge something

Parameters:
  • description (str) – short description of message
  • text (str) – message to be shown
  • yes_and_no (bool) – if False (default), does not show a <No> button
readPreferences()[source]

read program prefs from a file

setCurrentDirectory(directory)[source]

set the current directory

setStatusText(text)[source]

post new text to the status bar

setSummaryText(text)[source]

post new text to the summary TextCtrl, clearing any existing text

update_mrud(newdir)[source]

MRUD: list of most-recently-used directories

update_mrud_menus()[source]

manage the MRUD menu items

writePreferences()[source]

save program prefs to a file

mda2idd_gui.main()[source]

presents the GUI

mda2idd_report

Source code documentation

mda2idd_report Module

Generate ASCII text files from MDA files for APS station 2-ID-D

Objectives

  • Replaces yviewer, asciiRpt.py and mdaRpt.py
  • Creates a GUI similar to that of asciiRpt.py (aka yviewer)

Different than the output from mdaAscii, this module converts 1-D and 2-D scans stored in MDA files [1] into the text file format produced by yca scanSee_report (a Yorick-based support).

[1]MDA format specification: http://www.aps.anl.gov/bcda/synApps/sscan/saveData_fileFormat.txt

Main Methods

  • report(): converts MDA file to 1 or more ASCII text files, based on the rank
  • report_list(): process a list of MDA files
  • summaryMda(): text summary of a single MDA file (name, rank, datetime, …)

Internal (but interesting) Methods

Dependencies

operating system

None. This software was developed on a Windows 7 system and tested on various Linux distributions (Ubuntu, mint, and RHEL Linux) and on MacOSX. It was also tested on solaris but the performance was too poor on that specific system to advocate its continued use.

>>> git clone https://github.com/BCDA-APS/mda2idd_report.git

Source Code Documentation

summaryMda(mdaFileName) text summary of a single MDA file (name, rank, datetime, …)
report(mdaFileName[, allowException]) converts MDA file to 1 or more ASCII text files, based on the rank
report_1d(data) report 1-D MDA scan data in this format:
report_2d(data) report 2-D MDA scan data in this format, one file for each detector:
columnsToText(columns) convert a list of column lists into rows of text
writeOutput(path, filename, output) write the output text buffer to the file
getAsciiFileName(data[, detNum]) return the proper text file name, based on the file name stored in the MDA data structure
getAsciiPath(mdaFileName) given the path to the MDA file, return the related ASCII file path
report_list(mdaFileList) process a list of MDA files

exception mda2idd_report.RankException[source]

Bases: exceptions.Exception

this report can only handle ranks 1 and 2

exception mda2idd_report.ReadMdaException[source]

Bases: exceptions.Exception

MDA files are all version 1.3 (+/- 0.01)

mda2idd_report.columnsToText(columns)[source]

convert a list of column lists into rows of text

column widths will be chosen from the maximum character width of each column

Parameters:columns ([[str]]) – list of column lists (all same length)
Returns str:text block, with line separators

Example:

>>> columns = [ ['1A', '2A'], ['1B is long', '2B'], ['1C', '2C'] ]
>>> print columnsToText( columns )
1A  1B is long  1C
2A  2B          2C
mda2idd_report.developer_test()[source]

only for use in code development and testing

mda2idd_report.getAsciiFileName(data, detNum=None)[source]

return the proper text file name, based on the file name stored in the MDA data structure

Parameters:
  • data (obj) – MDA data structure returned by mda.readMDA()
  • detNum (int) – (2-D only)
mda2idd_report.getAsciiPath(mdaFileName)[source]

given the path to the MDA file, return the related ASCII file path

Create the path to the ASCII directory if it does not exist. If we cannot create the ASCII dir path, return the MDA file path instead.

The default expectation is that the files are stored in this type of directory structure:

some/path/to/data/
  ./MDA/
     scan_0001.mda
  ./ASCII/
     scan_0001.1d.txt
mda2idd_report.main()[source]

handles command-line input

mda2idd_report.report(mdaFileName, allowException=False)[source]

converts MDA file to 1 or more ASCII text files, based on the rank

Parameters:mdaFileName (str) – includes absolute or relative path to MDA file
Returns dict:{mdaFileName: [asciiFileName]}
mda2idd_report.report_1d(data)[source]

report 1-D MDA scan data in this format:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
; 
; ========================================================
; Filename: /home/2-iddf/data12c3/Alix_NWU/mda/2iddf_0001.mda
; 1D Scanno # =        1
; title= (Scan # 1)
; xtitle= PI_sample1_X(micron)
; ytitle= 
; timeStamp= OCT 30, 2012 12:03:41
; comment= 
; 
; 
; DIS:             P1                 D1                 D2                 ...
; Name:            2iddf:m38.VAL      S:SRcurrentAI      2idd:scaler1_cts1. ...
; Desc:            PI_sample1_X       SR Current                            ...
; Unit:            micron             mA                                    ...
  1               1197.47            122.374            169.800             ...
  2               1198.97            122.347            169.400             ...
  3               1200.47            122.318            171.000             ...
  4               1201.97            122.289            173.600             ...
  5               1203.47            122.777            169.000             ...
mda2idd_report.report_2d(data)[source]

report 2-D MDA scan data in this format, one file for each detector:

1
2
3
4
5
6
7
8
9
; FILE:  /home/2-iddf/data12c3/Alix_NWU/mda/2iddf_0012.mda
; Title:  Image#16 (2iddf:mca1.R9) - D01
; Scan # =       12 ,  Detector # =       16 ,   col=       51 ,   row=       51
;            Yvalue:        -1712.03        -1711.53        -1711.03        -1710.53        ...
;             Yindex               1               2               3               4        ...
; Xindex,    Xvalue,        Image(I,J) Array                                                ...
  1          1289.55         0.00000         0.00000         0.00000         0.00000        ...
  2          1290.05         0.00000         0.00000         0.00000         0.00000        ...
  3          1290.55         0.00000         0.00000         0.00000         0.00000        ...
mda2idd_report.report_list(mdaFileList)[source]

process a list of MDA files

mda2idd_report.summaryMda(mdaFileName)[source]

text summary of a single MDA file (name, rank, datetime, …)

Developed for the GUI to give the user a preview of the file before saving its data as ASCII to a text file.

mda2idd_report.writeOutput(path, filename, output)[source]

write the output text buffer to the file

Parameters:
  • path (str) – absolute or relative path to directory where file should be written
  • filename (str) – name of file to be written, existing file will be overwritten without warning
  • output (str) – text buffer to write to file

mda2idd_summary

Source code documentation

mda2idd_summary Module

Generate ASCII text summaries of MDA files for APS station 2-ID-D


Source Code Documentation

summaryMda(mdaFileName[, shortReport]) text summary of a single MDA file (name, rank, datetime, …)
summary_list(mdaFileList) process a list of MDA files

mda2idd_summary.main()[source]

handles command-line input

mda2idd_summary.summaryMda(mdaFileName, shortReport=True)[source]

text summary of a single MDA file (name, rank, datetime, …)

Developed for the GUI to give the user a preview of the file before saving its data as ASCII to a text file.

mda2idd_summary.summary_list(mdaFileList)[source]

process a list of MDA files

Indices and tables