source: palm/trunk/SCRIPTS/palmplot @ 978

Last change on this file since 978 was 776, checked in by heinze, 12 years ago

Bugfixes: increase of binary_version due to output of lpt_av, palmplot: adjustment for DKRZ (ibmh)

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