source: palm/trunk/SCRIPTS/palmplot @ 513

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

Using the NCL scripts by means of the shell script palmplot

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1#!/bin/ksh
2# palmplot - script for running the NCL scripts
3# $Id: palmplot 513 2010-03-16 13:37:48Z 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
10
11 # SHORT INTRODUCTION FOR USING THIS SCRIPT
12 if [[ "$1" = "?"  || "$1" = "--help" || "$1" = "-h" ]]
13  then
14    (printf "\n   palmplot is designed to run the NCL scripts of PALM \n"
15     printf "\n   palmplot can be called as follows:"
16     printf "\n   palmplot script_identifier file_1=OUTPUT/test.nc file_out=test format_out=pdf var=,pt,u, no_rows=2 ...\n"
17     printf "\n   script_identifier has to be one of the following:"
18     printf "\n    xy, xz, yz, pr, ts, sp"
19     printf "\n   in dependence of the data that wants to be plotted\n"
20     printf "\n   the further arguments control the plot"
21     printf "\n   they can also be set in the configuration file .ncl.config"
22     printf "\n   a documentation is available at $PALM_BIN/\NCL\/UserGuide_for_NCLscripts.pdf\n\n")
23     exit
24 fi
25
26
27 # DEFINITION OF VARIABLES
28 a=""
29 arg=""
30 key=""
31 script=""
32 value=""
33 CMDLINE=""
34 STRINGPARAMS=""
35 STRINGPARAMS_CO=""
36 STRINGPARAMS_CS=""
37 STRINGPARAMS_PR="" 
38 STRINGPARAMS_SP=""
39 STRINGPARAMS_TS=""
40
41
42 # LIST OF THE PARAMETERS OF THE NCL SCRIPTS WHICH NCL EXPECTED TO BE STRINGS
43 # CO: PARAMETERS WHICH ARE COMMON FOR ALL NCL SCRIPTS
44 # CS: cross_sections.ncl PR: profiles.ncl SP: spectra.ncl TS: timeseries.ncl
45 STRINGPARAMS_CO="file_1 format_out file_out var "
46 STRINGPARAMS_CS="sort mode fill_mode unit_x unit_y unit_z vec1 vec2 plotvec"
47 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"
48 STRINGPARAMS_SP="sort unit_x unit_y"
49 STRINGPARAMS_TS="unit_t"
50
51
52 # CHOICE OF THE PARTICULAR NCL SCRIPT
53 if [[ "$1" == "xy" ]]
54  then
55    script="cross_sections.ncl"
56    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS
57    CMDLINE="xyc=1 "
58  elif [[ "$1" == "xz" ]]
59    then
60    script="cross_sections.ncl"
61    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS
62    CMDLINE="xzc=1 "
63  elif [[ "$1" == "yz" ]]
64    then
65    script="cross_sections.ncl"
66    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_CS
67    CMDLINE="yzc=1 "
68  elif [[ "$1" == "pr" ]]
69    then
70    script="profiles.ncl"
71    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_PR
72  elif [[ "$1" == "ts" ]]
73    then
74    script="timeseries.ncl"
75    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_TS
76  elif [[ "$1" == "sp" ]]
77    then
78    script="spectra.ncl"
79    STRINGPARAMS=$STRINGPARAMS_CO$STRINGPARAMS_SP
80   else
81     (printf "\n  first argument has to be one of the following:"
82      printf "\n   xy, xz, yz, pr, ts or sp \n" 
83      printf "\n  type \"palmplot ?\" for information about the usage of this script\n")
84     exit
85 fi
86
87 # SHIFTING THE FIRST COMMAND LINE ARGUMENT
88 shift 
89
90 # PROCESSING THE COMMAND LINE ARGUMENTS
91 while [ $# -gt 0 ] 
92 do
93    arg=$1
94    key=${arg%%=*}
95    value=${arg#*=}
96   
97    # ALLOWING RELATIVE AND ABSOLUTE FILE PATHS
98    if [[ "$key" ==  @(file_*) && "$value" != @(~/*|/*) ]]
99    then
100       value=$PWD/$value
101    fi
102     
103    # SETTING STRINGS IN QUOTATION MARKS - REQUIRED BY NCL
104    for a in $STRINGPARAMS
105    do
106      if [ "$key" = "$a" ]
107      then
108         value=\"$value\"
109         break
110      fi
111    done
112
113    CMDLINE+="$key=$value "
114    shift
115 done
116
117 # EXECUTING THE PARTICULAR NCL SCRIPT
118 cd $PALM_BIN/NCL
119 ncl $script $CMDLINE
120
121
122
123
124
125
Note: See TracBrowser for help on using the repository browser.