sddscombine issue

Moderators: cyao, michael_borland

Post Reply
dpe
Posts: 29
Joined: 21 Mar 2012, 05:35

sddscombine issue

Post by dpe » 08 May 2012, 10:08

I have two different elegant programs which run on a transfer line and on a linac. Both produces the .sig output.
Now I'd like to combine the two .sig in an only file to be able to check the variables along the full complex.
The "s" column in the second file should be incremented by the last "s" value in the first file.

I'm now doing this with an awful script like this:

Code: Select all

cp ../Linac/linac.sig linac.sig
sddsprocess linac.sig -redefine=column,s,"s 5.895795e+01 +"
sddscombine ../Compressor/run.sig linac.sig all.sig -overwrite
rm linac.sig
I was wondering if there is a more straightforward way to do this, in particular I would like to be able to read the s value in the first file without have to enter it manually (but also not to have to make and delete copies of the files..)

Thank you!

michael_borland
Posts: 1933
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: sddscombine issue

Post by michael_borland » 08 May 2012, 11:31

Try the following:

sddscombine one.sig two.sig -pipe=out | sddsprocess -pipe -define=col,Page,i_page -process=s,max,sMax |
sddscombine -pipe -merge | sddsprocess -pipe=in both.sig -redefine=col,s,"s sMax Page 1 - * +",units=m

You can put this in a script with argument passing so you don't have to type it every time.

--Michael

dpe
Posts: 29
Joined: 21 Mar 2012, 05:35

Re: sddscombine issue

Post by dpe » 09 May 2012, 06:28

Dear Michael,

I red and understood your command. For just two file it's ok, if I have more I can call it recursively.
But there is a thing that puzzle me: using sdds do I really need to search for the max if I already know that the max is in the last position? I would never thought about that way to get the last s value. Anyway thank you very much for your always prompt assistance!

michael_borland
Posts: 1933
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: sddscombine issue

Post by michael_borland » 09 May 2012, 08:24

The reason you need to search for the maximum value is that SDDS doesn't provide a way to transfer data between pages. So when you combine the files in the first step, SDDS treats the data from the two files (now on two pages of the same file) as 100% independent. When sddsprocess is used to find the maximum value of s, the values are put into parameters, one value for each page. The second sddscombine command merges the two pages into one, which discards the parameters from the second page. Now I have access to the sMax value from the first file in a context where all the s values are available.

Hope that makes it more clear.

I suppose we could add an option to sddsprocess or sddscombine to somehow offset values by the last values in the columns of a previous page, but it's a very specialized requirement.

--Michael

dpe
Posts: 29
Joined: 21 Mar 2012, 05:35

Concatenating more files

Post by dpe » 06 Sep 2012, 04:06

As I expected now I need to concatenate three files.
I modified the command putting it in a bash script which concatenate any number of files in a single page file with continuous s coordinate.
The output file is named: "concat.ext" where ext is the extension of the first file.

Here it is, If anyone else needs ;)

Code: Select all

#!/bin/bash

#Concatenates the column of listed files in a new single page file. 
#The s coordinate is continuous from the start to the end

if [ $# -lt 2 ]; then
  echo "Usage: SDDS_concat filename1 filename2 [filename3 ...]"
  exit 0
fi

for f in "$@"
do
  if [ ! -f "$f" ]
  then
    echo "Error: file $f does not exist"
    exit 1
  fi
done

ext=${1##*.}
cp $1 "SDDS_concat.$ext.temp"

args=("$@")
for ((i=1; i < $#; i++)) {
   sddscombine "SDDS_concat.$ext.temp" "${args[$i]}" -pipe=out | sddsprocess -pipe -define=col,Page,i_page -process=s,last,last_s \
     | sddscombine -pipe -merge | sddsprocess -pipe -redefine=col,s,"s last_s Page 1 - * +",units=m \
     | sddsconvert -pipe=in "SDDS_concat.$ext.temp" -delete=column,Page -delete=parameter,last_s
}

mv "SDDS_concat.$ext.temp" "concat.$ext"

michael_borland
Posts: 1933
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: sddscombine issue

Post by michael_borland » 11 Sep 2012, 08:10

Thanks for posting this.

--Michael

Post Reply