source: palm/trunk/SCRIPTS/palmplot @ 669

Last change on this file since 669 was 566, checked in by heinze, 14 years ago

Formatting of all NCL scripts.
Items of .ncl.config are re-sorted and xyc, xzc and yzc are no parameters any more.
Parameters start_f_1/end_f_1 are renamed to start_f/end_f in profiles.ncl.
Bugfix in cross_sections: enable vector plot if var is set explicitly.
Deletion of NCL user guide because guide is no available online.

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