source: palm/trunk/SCRIPTS/palmplot @ 529

Last change on this file since 529 was 529, checked in by heinze, 15 years ago

palmplot expects lists which are separated by blanks. The lists have to be enclosed in single quotes in the prompt.

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 4.6 KB
Line 
1#!/bin/ksh
2# palmplot - script for running the NCL scripts
3# $Id: palmplot 529 2010-03-31 10:36:23Z heinze $
4
5    # Using the available NCL scripts via the shell script palmplot
6
7    # Last changes
8    # 16/03/10 - Rieke - initial revision
9    # 30/03/10 - Rieke - substituting double quotes (") with a character
10    #                    variable (dq) containing double quotes
11    # 31/03/10 - Rieke - list of variable names can be specified using
12    #                    blank separated lists instead of comma
13    #                    separated lists
14
15
16 # SHORT INTRODUCTION FOR USING THIS SCRIPT
17 if [[ "$1" = "?"  || "$1" = "--help" || "$1" = "-h" ]]
18  then
19    (printf "\n   palmplot is designed to run the NCL scripts of PALM \n"
20     printf "\n   palmplot can be called as follows:"
21     printf "\n   palmplot script_identifier file_1=OUTPUT/test.nc file_out=test format_out=pdf var='pt w\"pt\" w*pt* u' no_rows=2 ...\n"
22     printf "\n   script_identifier has to be one of the following:"
23     printf "\n    xy, xz, yz, pr, ts, sp"
24     printf "\n   in dependence of the data that wants to be plotted\n"
25     printf "\n   the further arguments control the plot"
26     printf "\n   they can also be set in the configuration file .ncl.config"
27     printf "\n   a documentation is available at $PALM_BIN/\NCL\/UserGuide_for_NCLscripts.pdf\n\n")
28     exit
29 fi
30
31
32 # DEFINITION OF VARIABLES
33 a=""
34 arg=""
35 b=""
36 key=""
37 script=""
38 value=""
39 CMDLINE=""
40 STRINGPARAMS=""
41 STRINGPARAMS_CO=""
42 STRINGPARAMS_CS=""
43 STRINGPARAMS_PR="" 
44 STRINGPARAMS_SP=""
45 STRINGPARAMS_TS=""
46 STRINGPARAMS_VA=""
47
48
49 # LIST OF THE PARAMETERS OF THE NCL SCRIPTS WHICH NCL EXPECTED TO BE STRINGS
50 # CO: PARAMETERS WHICH ARE COMMON FOR ALL NCL SCRIPTS
51 # CS: cross_sections.ncl PR: profiles.ncl SP: spectra.ncl TS: timeseries.ncl
52 # VA: PARAMETERS WHICH CONTAIN LISTS OF VARIABLE NAMES
53 STRINGPARAMS_CO="file_1 format_out file_out var "
54 STRINGPARAMS_CS="sort mode fill_mode unit_x unit_y unit_z vec1 vec2 plotvec"
55 STRINGPARAMS_PR="file_2 file_3 file_4 file_5 file_6 name_legend_1 name_legend_2 name_legend_3 name_legend_4 name_legend_5 name_legend_6 c_var"
56 STRINGPARAMS_SP="sort unit_x unit_y"
57 STRINGPARAMS_TS="unit_t"
58 STRINGPARAMS_VA="var c_var vec1 vec2 plotvec"
59
60
61 # CHOICE OF THE PARTICULAR NCL SCRIPT
62 if [[ "$1" == "xy" ]]
63  then
64    script="cross_sections.ncl"
65    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS
66    CMDLINE="xyc=1 "
67  elif [[ "$1" == "xz" ]]
68    then
69    script="cross_sections.ncl"
70    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS
71    CMDLINE="xzc=1 "
72  elif [[ "$1" == "yz" ]]
73    then
74    script="cross_sections.ncl"
75    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS
76    CMDLINE="yzc=1 "
77  elif [[ "$1" == "pr" ]]
78    then
79    script="profiles.ncl"
80    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_PR
81  elif [[ "$1" == "ts" ]]
82    then
83    script="timeseries.ncl"
84    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_TS
85  elif [[ "$1" == "sp" ]]
86    then
87    script="spectra.ncl"
88    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_SP
89   else
90     (printf "\n  first argument has to be one of the following:"
91      printf "\n   xy, xz, yz, pr, ts or sp \n" 
92      printf "\n  type \"palmplot ?\" for information about the usage of this script\n")
93     exit
94 fi
95
96 # SHIFTING THE FIRST COMMAND LINE ARGUMENT
97 shift 
98
99 # PROCESSING THE COMMAND LINE ARGUMENTS
100 while [ $# -gt 0 ] 
101 do
102    arg=$1
103    key=${arg%%=*}
104    value=${arg#*=}
105
106    # ALLOWING RELATIVE AND ABSOLUTE FILE PATHS
107    if [[ "$key" ==  @(file_*) && "$value" != @(~/*|/*) ]]
108    then
109       value=$PWD/$value
110    fi
111     
112    # PROCESSING STRINGS
113    for a in $STRINGPARAMS
114    do
115      if [ "$key" = "$a" ]
116      then
117
118         # PROCESSING STRINGS CONTAINING LISTS OF VARIABLES
119         for b in $STRINGPARAMS_VA
120         do
121           if [ "$key" = "$b" ]
122           then
123              if [[ "$value" != "all" ]]
124              then
125                 # SUBSTITUTING BLANKS WITH COMMAS IN
126                 # PARAMETERS CONTAINING LISTS OF VARIABLES
127                 value=`echo $value | sed 's/ /,/g'`           
128                 if [[ "$value" == ${value#,} ]]
129                 then
130                    value=,$value
131                 fi
132                 if [[ "$value" == ${value%,} ]]
133                 then
134                    value=$value,
135                 fi
136                 break
137              fi
138           fi
139         done
140
141         # SUBSTITUTING DOUBLE QUOTES - REQUIRED BY NCL
142         value=`echo $value | sed 's/\"/\"+dq+\"/g'`
143         # SETTING ENTIRE STRING IN DOUBLE QUOTES - REQUIRED BY NCL
144         value=\"$value\"
145      fi
146    done
147
148    CMDLINE+="$key=$value "
149    shift
150 done
151
152 # EXECUTING THE PARTICULAR NCL SCRIPT
153 cd $PALM_BIN/NCL
154 ncl 'dq=str_get_dq()' $script $CMDLINE 
155
156
157
158
159
160
Note: See TracBrowser for help on using the repository browser.