awips2/deltaScripts/unified_grid/update_saved_display.sh
Steve Harris 745f2c6409 13.1.2-2 baseline
Former-commit-id: e8f4a2f031 [formerly 51208e5515] [formerly c0c1d56f3a] [formerly e8f4a2f031 [formerly 51208e5515] [formerly c0c1d56f3a] [formerly 4ba416aeb3 [formerly c0c1d56f3a [formerly 221d0aaf0e19a054387134e72a76a278159bf4d0]]]]
Former-commit-id: 4ba416aeb3
Former-commit-id: 82cdde8491 [formerly cd4185ef5c] [formerly 413d9d9811179a10639f756b8b4f690d86be7a6a [formerly 941337c553]]
Former-commit-id: c69e1900269e630aefc061c2464bc8fea1c9776a [formerly b6fa9b4858]
Former-commit-id: f52ec0b0a0
2013-01-06 14:32:24 -06:00

55 lines
4.6 KiB
Bash

#!/bin/bash
# This script will update any saved displays from the grib format to the grid format
#
# This update needs to be performed with build ???.
# This update only needs to be run if there are saved displays being stored outside of localization.
if [ $# -eq 0 ]; then
echo "Please provide a list of saved displays to update."
fi
IFS=$'\n'
for f in "$@"; do
echo Updating $f
#bf=$f.bak.`date +%m%d%y`
#cp $f $bf
# its probably not efficient to execute sed 20 times but its not slow...
# replace perturbationNumbers with ensmble ids
sed -n '1h;1!H;${;g;s/\(<mapping\s\+key="\)modelInfo\.perturbationNumber\("\s*>\s*<\s*constraint\s\+constraintValue="\)1\("\s\+constraintType="EQUALS"\s*\/>\s*<\/mapping>\)/\1info.ensembleId\2ctl1\3/g;p;}' -i $f
sed -n '1h;1!H;${;g;s/\(<mapping\s\+key="\)modelInfo\.perturbationNumber\("\s*>\s*<\s*constraint\s\+constraintValue="\)2\("\s\+constraintType="EQUALS"\s*\/>\s*<\/mapping>\)/\1info.ensembleId\2ctl2\3/g;p;}' -i $f
sed -n '1h;1!H;${;g;s/\(<mapping\s\+key="\)modelInfo\.perturbationNumber\("\s*>\s*<\s*constraint\s\+constraintValue="\)3\("\s\+constraintType="EQUALS"\s*\/>\s*<\/mapping>\)/\1info.ensembleId\2n1\3/g;p;}' -i $f
sed -n '1h;1!H;${;g;s/\(<mapping\s\+key="\)modelInfo\.perturbationNumber\("\s*>\s*<\s*constraint\s\+constraintValue="\)4\("\s\+constraintType="EQUALS"\s*\/>\s*<\/mapping>\)/\1info.ensembleId\2p1\3/g;p;}' -i $f
sed -n '1h;1!H;${;g;s/\(<mapping\s\+key="\)modelInfo\.perturbationNumber\("\s*>\s*<\s*constraint\s\+constraintValue="\)5\("\s\+constraintType="EQUALS"\s*\/>\s*<\/mapping>\)/\1info.ensembleId\2n2\3/g;p;}' -i $f
sed -n '1h;1!H;${;g;s/\(<mapping\s\+key="\)modelInfo\.perturbationNumber\("\s*>\s*<\s*constraint\s\+constraintValue="\)6\("\s\+constraintType="EQUALS"\s*\/>\s*<\/mapping>\)/\1info.ensembleId\2p2\3/g;p;}' -i $f
sed -n '1h;1!H;${;g;s/\(<mapping\s\+key="\)modelInfo\.perturbationNumber\("\s*>\s*<\s*constraint\s\+constraintValue="\)7\("\s\+constraintType="EQUALS"\s*\/>\s*<\/mapping>\)/\1info.ensembleId\2n3\3/g;p;}' -i $f
sed -n '1h;1!H;${;g;s/\(<mapping\s\+key="\)modelInfo\.perturbationNumber\("\s*>\s*<\s*constraint\s\+constraintValue="\)8\("\s\+constraintType="EQUALS"\s*\/>\s*<\/mapping>\)/\1info.ensembleId\2p3\3/g;p;}' -i $f
sed -n '1h;1!H;${;g;s/\(<mapping\s\+key="\)modelInfo\.perturbationNumber\("\s*>\s*<\s*constraint\s\+constraintValue="\)9\("\s\+constraintType="EQUALS"\s*\/>\s*<\/mapping>\)/\1info.ensembleId\2n4\3/g;p;}' -i $f
sed -n '1h;1!H;${;g;s/\(<mapping\s\+key="\)modelInfo\.perturbationNumber\("\s*>\s*<\s*constraint\s\+constraintValue="\)10\("\s\+constraintType="EQUALS"\s*\/>\s*<\/mapping>\)/\1info.ensembleId\2p4\3/g;p;}' -i $f
sed -n '1h;1!H;${;g;s/\(<mapping\s\+key="\)modelInfo\.perturbationNumber\("\s*>\s*<\s*constraint\s\+constraintValue="\)11\("\s\+constraintType="EQUALS"\s*\/>\s*<\/mapping>\)/\1info.ensembleId\2n5\3/g;p;}' -i $f
sed -n '1h;1!H;${;g;s/\(<mapping\s\+key="\)modelInfo\.perturbationNumber\("\s*>\s*<\s*constraint\s\+constraintValue="\)12\("\s\+constraintType="EQUALS"\s*\/>\s*<\/mapping>\)/\1info.ensembleId\2p5\3/g;p;}' -i $f
# handle grid version
sed -n '1h;1!H;${;g;s/\(<mapping\s\+key="\)gridVersion\("\s*>\s*<\s*constraint\s\+constraintValue="\)\([0-9]\{1,2\}\)\("\s\+constraintType="EQUALS"\s*\/>\s*<\/mapping>\)/\1info.secondaryId\2Version\3\4/g;p;}' -i $f
# level
sed -n 's/key="modelInfo\.level\.levelonevalue"/key="info.level.levelonevalue"/g;p;' -i $f
sed -n 's/key="modelInfo\.level\.leveltwovalue"/key="info.level.leveltwovalue"/g;p;' -i $f
sed -n 's/key="modelInfo\.level\.masterLevel.name"/key="info.level.masterLevel.name"/g;p;' -i $f
# parameter
sed -n 's/key="modelInfo\.parameterAbbreviation"/key="info.parameter.abbreviation"/g;p;' -i $f
# dataset
sed -n 's/key="modelInfo\.modelName"/key="info.datasetId"/g;p;' -i $f
#plugin name
sed -n 's/constraintValue="grib"/constraintValue="grid"/g;p;' -i $f
#Also need to map the productIdentifierKey in best res resource data.
sed -n 's/productIdentifierKey="modelInfo\.level\.levelonevalue"/productIdentifierKey="info.level.levelonevalue"/g;p;' -i $f
sed -n 's/productIdentifierKey="modelInfo\.level\.leveltwovalue"/productIdentifierKey="info.level.leveltwovalue"/g;p;' -i $f
sed -n 's/productIdentifierKey="modelInfo\.level\.masterLevel.name"/productIdentifierKey="info.level.masterLevel.name"/g;p;' -i $f
sed -n 's/productIdentifierKey="modelInfo\.modelName"/productIdentifierKey="info.datasetId"/g;p;' -i $f
sed -n 's/productIdentifierKey="modelInfo\.parameterAbbreviation"/productIdentifierKey="info.parameter.abbreviation"/g;p;' -i $f
#diff $f $bf > /dev/null
#if [ $? -eq 0 ]; then rm $bf; echo "No Changes"; fi
done