Page 1 of 2

2D Array

Posted: 28 Jan 2009, 20:07
by tennant
Hi,

I have a digitized image of a beam on a profile monitor in the form of a 2D array. Is there a way I can modify in a way that I can use the suite of sdds tools on it (in particular, I would like to use sddshist to get the various projections).

Thanks,
chris

Re: 2D Array

Posted: 29 Jan 2009, 09:32
by michael_borland
Chris,

How you do this depends on how the data is arranged in the file. Do you have a 2D array stored in multiple columns, or in a single column?

--Michael

Re: 2D Array

Posted: 29 Jan 2009, 10:00
by tennant
Hi Michael,

The array is stored in multiple columns. I've attached a sample file.

--chris

Re: 2D Array

Posted: 29 Jan 2009, 18:00
by michael_borland
Chris,

Here's a script that converts your image file to two SDDS files.
% convertImage 2Darray.txt 2Darray1.sdds 2Darray2.sdds
The first output file is organized into rows and columns just as in the input file. Each column VLine??? is a vertical line from the image. There's also a column VLineProfile that's the sum of the VLine's.

The second output file is the transpose of the first output file. Each column HLine??? is a horizontal line from the image. There's also a column HLineProfile that's the sum of the HLine's.

Suggested plotting commands:
% sddscontour -shade 2Darray1.sdds -column=Index,VLine???
% sddscontour -shade 2Darray2.sdds -column=Index,HLine???
% sddsplot -column=Index,VLineProfile 2Darray1.sdds
% sddsplot -column=Index,HLineProfile 2Darray2.sdds

You may want to use sddsbaseline for baseline removal and sddscliptails to remove halo. Also, sddsspotanalysis can be used to perform processing to get x and y image parameters.
% sddsspotanalysis 2Darray.sdds1 sa.sdds -image=VLine??? -levels=intensity=1024,sat=1023 -background=halfwidth=30,symmetric,antihalo,antiloner -spotimage=si.sdds -spotROI=xval=200,yval=200
% sddscontour -shade si.sdds
Look in sa.sdds for the spot analysis results.

The attached plots show the image before and after spotanalysis.
original.png
spot.png
--Michael

Re: 2D Array

Posted: 30 Jan 2009, 06:38
by tennant
Hi Michael,

Thanks so much for your help. Unfortunately I get the following error when trying to run your script (both on Vista and XP). Any suggestions?

$ convertImage 2Darray.txt array1.sdds array2.sdds
child process exited abnormally
while executing
"exec plaindata2sdds 2Darray.txt -inputMode=ascii -outputMode=binary "-separator= " -pipe=out -column=VLine000,short -column=VLine001,short -column=VLi..."
("eval" body line 1)
invoked from within
"eval exec plaindata2sdds $input -inputMode=ascii -outputMode=binary {"-separator= "} -pipe=out $optionList \
-skiplines=1 -noRowCount \
| sddsproc..."
(file "./convertImage" line 43)[/quote]

Re: 2D Array

Posted: 30 Jan 2009, 09:19
by michael_borland
Chris,

Perhaps plaindata2sdds is not installed? Is it accessible from the commandline.

Sorry I can't provide much help with Windows platforms. I'll forward this to someone who might be able to help.

--Michael

Re: 2D Array

Posted: 30 Jan 2009, 09:26
by tennant
Michael,

I can't say that I've ever used "plaindata2sdds" but it is installed:

$ plaindata2sdds
usage: plaindata2sdds <input> <output>
[-pipe=[input][,output]]
[-inputMode=<ascii|binary>]
[-outputMode=<ascii|binary>]
[-separator=<char>]
[-noRowCount]
[-order=<rowMajor|columnMajor>]
[-parameter=<name>,<type>[,units=<string>][,description=<string>][,symbol=<string>][,count=<integer>]...]
[-column=<name>,<type>[,units=<string>][,description=<string>][,symbol=<string>][,count=<integer>]...]
[-nowarnings] [-fillin]
[-skiplines=<integer>]

-inputMode The plain data file can be read in ascii or binary format.
-outputMode The SDDS data file can be written in ascii or binary format.
-separator In ascii mode the columns of the plain data file are
separated by the given character. Be default it uses any
combination of whitespace characters.
-noRowCount The number of rows is not included in the plain data file.
If the plain data file is a binary file then the row count must be included.
-order Row major order is the default. Here each row of the plain data file
consists of one element from each column. In column major order
each column is located entirely on one row.
-parameter Add this option for each parameter in the plain data file.
-fillin fill in blank for string column or 0 for numeric column when there
is no data for it.
-column Add this option for each column in the plain data file.
-skiplines Add this option to skip header lines.

Program by Robert Soliday. (Jun 3 2008)

Re: 2D Array

Posted: 30 Jan 2009, 09:30
by tennant
P.S. I would be interested to see if someone running Windows runs into the same problem...

Re: 2D Array

Posted: 30 Jan 2009, 09:32
by michael_borland
Chris,

I've asked Bob Soliday to check into this, since he has a Windows installation.

Unfortunately, I think Windows doesn't do well with scripts and pipes. It doesn't seem to have the same ability as Linux to have subprocesses of subprocesses of subprocesses...

--Michael

Re: 2D Array

Posted: 30 Jan 2009, 12:35
by soliday
There appears to be two problems.
First the plaindata2sdds command is too long for Windows to handle. I think I have found a workaround for this.
Second the plaindata2sdds is not working on Windows with text files that have very long lines. I am still trying to figure out why this is happening. Once I figure it out I will post a solution.

--Bob