Added the possibility to create a simple-column-ASCII-file instead of a db-file as output of the script. Not yet tested extensively.
This commit is contained in:
140
src/external/scripts/mlog2db
vendored
140
src/external/scripts/mlog2db
vendored
@ -11,13 +11,13 @@ if [ "$#" -lt 2 ] ; then
|
||||
|
||||
"musrfit-mlog to db converter"
|
||||
|
||||
USAGE: mlog2db FIRSTRUN# LASTRUN# EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oDB_OUTPUT_FILE | -k | -s]
|
||||
USAGE: mlog2db FIRSTRUN# LASTRUN# EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oOUTPUT_FILE | data | -k | -s]
|
||||
OR
|
||||
mlog2db \[SPACE SEPARATED LIST OF RUNS\] EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oDB_OUTPUT_FILE | -k | -s]
|
||||
mlog2db \[SPACE SEPARATED LIST OF RUNS\] EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oOUTPUT_FILE | data | -k | -s ]
|
||||
OR
|
||||
mlog2db RUNLISTFILE EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oDB_OUTPUT_FILE | -k | -s]
|
||||
mlog2db RUNLISTFILE EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oOUTPUT_FILE | data | -k | -s]
|
||||
|
||||
This small script converts subsequent musrfit output files (mlog) into one db file using bash/awk.
|
||||
This small script converts subsequent musrfit output files (mlog or msr) into one db- or column-ASCII-file using bash/awk.
|
||||
|
||||
Example 1:
|
||||
mlog2db 1423 1425 _tf_h13
|
||||
@ -67,6 +67,8 @@ If your musrfit output files do not have an extension as specified above like "2
|
||||
Example 5:
|
||||
mlog2db 200 220 "" -oABC.db fit-199
|
||||
|
||||
As an alternative to the db-format as output-format of the script it is possible to choose an ASCII file with simple data columns by invoking the script with the option "data". All features described above are available also for that case!
|
||||
|
||||
CAUTION:
|
||||
The "indexing number" of the .mlog has to be at the begin of the filename.
|
||||
Furthermore the data files that were fitted have to have the name "XXX_RUN#[_YYY]", where XXX,YYY are strings without whitespaces ("/" is OK).
|
||||
@ -399,8 +401,18 @@ else
|
||||
fi
|
||||
done
|
||||
|
||||
# determine the output file-format, default: db
|
||||
FORMAT=db
|
||||
for PAR in "$@"
|
||||
do
|
||||
if [ "$PAR" == "data" ]; then
|
||||
FORMAT=dat
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# put together all data to db-format and write it to the file
|
||||
awk -v outfile=$OUTFILE -v noheader=$NOHEADER -v runList=$RUNLIST_USED -v numIndVar=$NUM_OF_IND_VAR '{
|
||||
awk -v outfile=$OUTFILE -v noheader=$NOHEADER -v runList=$RUNLIST_USED -v numIndVar=$NUM_OF_IND_VAR -v format=$FORMAT '{
|
||||
|
||||
FS = " "
|
||||
OFS = " "
|
||||
@ -467,8 +479,9 @@ else
|
||||
split(line, indVar, " ")
|
||||
}
|
||||
|
||||
# Output to file in the case, the LEM summary file is accessible and the option "nosummary" is not set
|
||||
# Output to db-file in the case, the LEM summary file is accessible and the option "nosummary" is not set
|
||||
|
||||
if(format != "dat") {
|
||||
if("'"$TEMPERATURE"'" != "") {
|
||||
|
||||
# Write the db-header
|
||||
@ -592,6 +605,121 @@ else
|
||||
if("'"$q"'" == "'"$LASTRUN"'") print "\n" >> outfile
|
||||
}
|
||||
}
|
||||
|
||||
# output to a data-file with simple column-structure
|
||||
# first if the LEM-summary files are present and "nosummary" has not been set
|
||||
else {
|
||||
if("'"$TEMPERATURE"'" != "") {
|
||||
|
||||
# Write the dat-header
|
||||
if("'"$q"'" == 0 && noheader != 1){
|
||||
|
||||
$1 = "T"
|
||||
$2 = "Tr"
|
||||
$3 = "E"
|
||||
$4 = "RALRAR"
|
||||
$5 = "RATRAB"
|
||||
|
||||
for(k=1;k<numIndVar;k++){
|
||||
$(k+5)=indVar[k+1]
|
||||
}
|
||||
|
||||
for(k=1;k<i;k++){ # musrfit parameters
|
||||
$(3*k-2+5+numIndVar-1)=parArray[k]
|
||||
$(3*k-2+5+numIndVar)="PosErr"
|
||||
$(3*k-2+5+numIndVar+1)="NegErr"
|
||||
}
|
||||
|
||||
for(k=0;k<4;k++){ # CHI2, NDF, CHI2red, RUN (without errors)
|
||||
$(3*i-2+5+numIndVar-1+k)=parArray[i+k]
|
||||
}
|
||||
|
||||
print $0 >> outfile
|
||||
}
|
||||
|
||||
# Write the data-block
|
||||
$1 = "'"$TEMPERATURE"'"
|
||||
$2 = "'"$TRANSPORT"'"
|
||||
if ("'"$ENERGY"'" != "") { $3 = "'"$ENERGY"'" } else { $3 = "-999" }
|
||||
if ("'"$RALRAR"'" != "") { $4 = "'"$RALRAR"'" } else { $4 = "-999" }
|
||||
if ("'"$RATRAB"'" != "") { $5 = "'"$RATRAB"'" } else { $5 = "-999" }
|
||||
|
||||
if(runList == 1) { # process the "independent variables" from the file
|
||||
while((getline line < "'"$1"'") > 0){
|
||||
split(line, indVarValue, " ")
|
||||
if (indVarValue[1] == "'"$COUNT"'"){
|
||||
for(k=2;k<=numIndVar;k++){ $(k+4) = indVarValue[k] }
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(l=1;l<i;l++){ # musrfit parameters
|
||||
$(3*l-2+5+numIndVar-1)=dataArray[l]
|
||||
$(3*l-2+5+numIndVar)=posErrArray[l]
|
||||
$(3*l-2+5+numIndVar+1)=negErrArray[l]
|
||||
}
|
||||
|
||||
for(l=0;l<4;l++){ # CHI2, NDF, CHI2red, RUN (without errors)
|
||||
$(3*i-2+5+numIndVar-1+l)=dataArray[i+l]
|
||||
}
|
||||
|
||||
print $0 >> outfile
|
||||
|
||||
if("'"$q"'" == "'"$LASTRUN"'") print "\n" >> outfile
|
||||
}
|
||||
|
||||
# If we do not have the information from the summary file or "nosummary" is set
|
||||
# Writing to column-data file
|
||||
else {
|
||||
if("'"$q"'" == 0 && noheader != 1){
|
||||
|
||||
for(k=1;k<numIndVar;k++){
|
||||
$(k)=indVar[k+1]
|
||||
}
|
||||
|
||||
for(k=1;k<i;k++){ # musrfit parameters
|
||||
$(3*k-2+numIndVar-1)=parArray[k]
|
||||
$(3*k-2+numIndVar)="PosErr"
|
||||
$(3*k-2+numIndVar+1)="NegErr"
|
||||
}
|
||||
|
||||
for(k=0;k<4;k++){ # CHI2, NDF, CHI2red, RUN (without errors)
|
||||
$(3*i-2+numIndVar-1+k)=parArray[i+k]
|
||||
}
|
||||
|
||||
print $0 >> outfile
|
||||
}
|
||||
|
||||
# Write the data-block
|
||||
|
||||
if(runList == 1) { # process the "independent variables" from the file
|
||||
while((getline line < "'"$1"'") > 0){
|
||||
split(line, indVarValue, " ")
|
||||
if (indVarValue[1] == "'"$COUNT"'"){
|
||||
for(k=2;k<=numIndVar;k++){ $(k-1) = indVarValue[k] }
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(l=1;l<i;l++){ # musrfit parameters
|
||||
$(3*l-2+numIndVar-1)=dataArray[l]
|
||||
$(3*l-2+numIndVar)=posErrArray[l]
|
||||
$(3*l-2+numIndVar+1)=negErrArray[l]
|
||||
}
|
||||
|
||||
for(l=0;l<4;l++){ # CHI2, NDF, CHI2red, RUN (without errors)
|
||||
$(3*i-2+numIndVar-1+l)=dataArray[i+l]
|
||||
}
|
||||
|
||||
print $0 >> outfile
|
||||
|
||||
if("'"$q"'" == "'"$LASTRUN"'") print "\n" >> outfile
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}' $COUNT$EXTENSION.$OUTPUTEXT
|
||||
done
|
||||
fi
|
||||
|
Reference in New Issue
Block a user