source: palm/trunk/SCRIPTS/palmplot @ 555

Last change on this file since 555 was 549, checked in by heinze, 14 years ago

bugfix: had to be added in if-queries

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