Changeset 4733
- Timestamp:
- Aug 9, 2005, 7:56:30 AM (21 years ago)
- Location:
- trunk/Ohana/doc/www/html
- Files:
-
- 2 edited
-
DVO/userguide.htm (modified) (1 diff)
-
Opihi-Programs/index.htm (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/doc/www/html/DVO/userguide.htm
r4726 r4733 2 2 <meta name=title content=DVO Examples> 3 3 <meta name=page content=DVO Examples> 4 5 <h3> User Interface </h3>6 7 The interface has an interaction similar to <tt>tcsh</tt>. The arrows8 allow editing of previous commands. You can also use emacs-like9 commands such as cntl-a to reach the beginning of the line and cntl-e10 to reach the end. There is command and file completion: if you type11 part of a command (as the first thing on a line) and then type tab, it12 will fill in as much as possible, until the word is not unique.13 Typing tab twice at that point will list the possible endings. For14 any but the first word on a line, the same thing will happen for the15 files in the current directory. It is also possible to type just a16 fraction of a command, as long as it is unique. An ambiguous command17 will list the possible alternatives. For example:18 19 <pre>20 dvo: c21 ambiguous command: c ( catalog cgrid clear create cursor )22 </pre>23 24 The shell is an interpretive programming language.25 Variables are set as follows:26 27 <pre>28 dvo: $fred = 1029 </pre>30 31 Any expression within curly brackets {} is assumed32 to be an arithmetical expression and is evaluated before the line is33 executed. For example:34 35 <pre>36 echo {$fred*dcos(45)}37 </pre>38 39 would give the response 7.07107. There are math functions cos, sin,40 and tan, which operate on radian expressions, and also dcos, dsin,41 dtan, which operate on degree expressions. There are also the42 equivalent inverse functions: eg., asin and dasin return radians and43 degrees, respectively. The help section on Math defines all of the44 available math functions.45 46 <h3> Miscellaneous Commands </h3>47 48 <pre>49 ! -- system call50 ? -- list commands51 ?? -- list variables52 echo -- type this line53 exec -- system call54 exit -- exit program55 help -- get help on a function56 output -- redirect output to file57 quit -- exit program58 scan -- scan line from keyboard or file to variable59 wait -- wait until return is typed60 which -- show command61 </pre>62 63 Most of these are self-explanatory. The command ?? prints the system64 variables. The <tt>help</tt> command will provide help on a single65 command or, without any arguments, will list all available help66 files (this includes general help not associated with a specific67 command).68 69 <h3> Shell Programing </h3>70 71 <pre>72 break -- escape from function73 for -- loops74 if -- logical cases75 input -- read command lines from a file76 macro -- deal with the macros77 </pre>78 79 <p>80 There are several options for programming in <tt>status</tt>. First,81 a file which contains a series of commands can be executed with82 <tt>input (filename)</tt>. It is also possible to define macros which83 will behave much like regular commands. A macro is defined by typing84 <tt>macro name</tt> or <tt>macro create name</tt> followed by the85 commands. Arguments to the macro are assigned to the variables $186 .. $N and the number of arguments is given by $0. Macros may be87 defined in <tt>input</tt> files, and in fact when <tt>status</tt> is88 started, it loads the file <tt>~/.statusrc</tt> which may contain89 default macros. Simple loops and if statements can be performed, and90 are quite useful for complex macros.91 92 <p>93 'If' statements are similar in syntax to C if statements. Math94 expresions in the if statement must be contained in curly braces, as95 elsewhere. Variables with string values may use the logical ==96 operator to test if two strings are the same. 'For' loops are quite97 simplistic. The form is:98 99 <pre>100 for var first last delta101 (commands)102 end103 </pre>104 105 <p>106 The value of <tt>$var</tt> will start at the value <tt>first</tt> and increment by107 <tt>delta</tt> after each loop. The loop will stop after <tt>$var</tt> is greater108 than <tt>stop</tt>. The value <tt>delta</tt> is optional, with 1 assumed.109 The value of <tt>$var</tt> may be changed during the loop, and if set110 beyong the value of <tt>last</tt> will end the loop early.111 112 <h3> Vector Plotting </h3>113 114 <pre>115 box -- draw a box on the plot116 clear -- erase plot117 create -- create a new vector118 cursor -- get coords from cursor119 grid -- plot cartesian grid120 hist -- create histogram from a vector121 labels -- define labels for plot122 limits -- define plot limits123 plot -- plot a pair of vectors124 print -- write vectors to file125 ps -- define labels for plot126 set -- vector math127 style -- set the style for graph plots128 vectors -- list vectors129 zplot -- plot scaled points130 </pre>131 132 <p>133 In addition to scalar variables, <tt>status</tt> can manipulate and134 display 1-D vector variables. Many of the commands which extract data135 from the photometry database place the data in vectors as well as136 plotting them. A vector can also be created based on a number137 sequence with the command <tt>create name Nelements start delta</tt>.138 The resulting vector has $Nelements$ entries, starting at a value of139 $start$ and running until $start + delta*Nelements$. If $delta$ is140 0.0, all elements will have the value of $start$. A histogram of a vector141 may be made with the command <tt>hist</tt>, which creates a new vector142 containing the histogram of the first vector. The data range and bin143 size of the histogram are defined in same way as with create. This144 makes it easy to create the index vector that goes with a histogram145 vector:146 147 <pre>148 hist y Ny 1 100 0.1149 create dx 1 100 0.1150 </pre>151 152 <p>153 The above will create a histogram of y in Ny and the index in dx.154 Plotting this with <tt>plot dx Ny</tt> will show the histogram.155 156 <p>157 Vector math is performed with a command of the form <tt>set new =158 (expression)</tt>. The expression is some math function employing159 vectors and scalars. A complete listing of the math operators160 available in <tt>set</tt> can be found in the help for <tt>set</tt>.161 162 <p>163 Once vectors are defined, they may be plotted. A pair of vectors can164 be plotted against each other if they have the same number of entries.165 The plotting is performed on the graphics window, Kapa. There are166 actually several graphics windows available to <tt>status</tt>, any of167 which may be used to plot at any time. Some of the more complex168 operations default to either graphics window 0 or 1, depending on the169 context. Except for those functions with a pre-defined window, all170 plotting functions apply to the current graphics window unless an171 option <tt>-n N</tt> is given to specify a different window. The172 plotting style is determined by the command <tt>style</tt> which can set173 the line width, the line type (solid, dashed, dotted, etc), the point174 type (box, cross, etc), the point size, the color, and whether a pair175 of vectors is plotted as a sequence of points, a set of connected176 lines, or a histogram. Some functions which make plots use their own177 styles, as discussed below. The function <tt>limits</tt> lets the user178 set the range of the plot axes, or check the current setting. The179 command <tt>plot</tt> will plot a pair of vectors on the current graphics180 window using the current plotting style for that window. The command181 <tt>zplot</tt> will plot a pair of vectors with the point size scaled by182 a third vector, with maximum and minimum point sizes representing183 specified values. The <tt>cursor</tt> command goes the other way: this184 command puts the Kapa window in cursor mode and waits for input from185 Kapa. The user can then type any alphanumeric key on the graphics186 windows and will be told both the pointer location (in the graphics187 coordinates) and will have the coordinates stored in <tt>status</tt>188 variables. For example, by typing ``1'' in the sky display window,189 the RA and DEC of the pointer are stored in the variables <tt>$R1</tt>190 and <tt>$D1</tt>. This command can be used to let the user define191 locations or regions of interest on the Kapa window. (Future addition:192 <tt>button</tt>, which does the same with the mouse buttons).193 4 194 5 <h3> Database Functions </h3> -
trunk/Ohana/doc/www/html/Opihi-Programs/index.htm
r4727 r4733 6 6 7 7 <p> 8 Opihi is a program to manipulate and display 1-D (vector) and 2-D9 (matrix) data. Opihi has a simple command-line interaction that10 resembles the UNIX tcsh, but with many additional useful features.11 Opihi consists of several, vaguely independant portions: the12 command-line interpreter language (Opihi), the image display tool13 (Kii), the graphing tool (Kapa), and the vector and matrix14 manipulation commands.15 16 <h3> User Interface -- Opihi </h3>17 18 <p>19 8 Opihi is a generic command-line interpreter which has been used as the 20 front-end for Opihi, as well as other programs in the Elixir system.21 The interpreter has a variety of features of shell-scripting9 front-end for Mana, DVO, and other high-level programs in the Elixir 10 system. The interpreter has a variety of features of shell-scripting 22 11 languages: if statements, for loops, macros with command-line 23 12 arguments, and so forth. The shell also allows for variables, 24 13 arithmetic on variables, input from source files, and a variety of 25 other useful tools. I have used the Opihi shell language for several 26 other user interface front ends, in addition to the Opihi data analysis 27 tool: a CCD controller interface and a variable star database in the 28 LONEOS project. The programming structure of the Opihi front-end 29 makes it very easy to add commands to the package; more about this 30 later. 14 other useful tools. Opihi has a simple command-line interaction that 15 resembles the UNIX tcsh, but with many additional useful features. It 16 can also be used as a scripting language much like #sh/# or perl. 17 18 <p> 19 Opihi includes tools to manipulate and display 1-D (vector) and 2-D 20 (matrix) data. Two external programs are used to graphical display. 21 These are the image display tool (Kii), the graphing tool (Kapa), and 22 the vector and matrix manipulation commands. Various functions are 23 available to perform math, statistical, and other operations on 24 vectors and images. 25 26 <h3> User Interface </h3> 31 27 32 28 <p> … … 36 32 generally be placed on one line with semi-colons as separators. 37 33 34 The interface has an interaction similar to <tt>tcsh</tt>. The arrows 35 allow editing of previous commands. You can also use emacs-like 36 commands such as cntl-a to reach the beginning of the line and cntl-e 37 to reach the end. There is command and file completion: if you type 38 part of a command (as the first thing on a line) and then type tab, it 39 will fill in as much as possible, until the word is not unique. 40 Typing tab twice at that point will list the possible endings. For 41 any but the first word on a line, the same thing will happen for the 42 files in the current directory. It is also possible to type just a 43 fraction of a command, as long as it is unique. An ambiguous command 44 will list the possible alternatives. For example: 45 46 <pre> 47 dvo: c 48 ambiguous command: c ( catalog cgrid clear create cursor ) 49 </pre> 50 51 The shell is an interpretive programming language. 52 53 <h3> Data Representations</h3> 54 55 <h4> Simple Scalar Variables </h4> 56 38 57 <p> 39 58 Scalar variables in Opihi are proceeded with a dollar sign ($). A … … 48 67 consist of the standard math operators (+,-,*,/) as well as any 49 68 already-defined variables and the functions log(), ln(), sqrt(), 50 exp(), ten() ($10^x$), sin(), cos(), etc. Also, if there is a pair of 51 curly brackets {} anywhere on a command line, whatever is inside is 52 assumed to be a math expression and evaluated as well. This later 53 feature allows functions of variables to be passed as arguments to 54 Opihi functions. Variables can be numeric or character strings. If 69 exp(), ten() ($10^x$), sin(), cos(), etc. Variables can be numeric or character strings. If 55 70 the shell does not understand the syntax of the line as a math 56 71 expression, it is assumed to be a string. 57 72 58 73 <p> 59 Some of the programming functions are for loops and if (if else) 60 statements. There are no delimiting characters; ends of program 61 blocks are defined by the word 'end'. Syntax is rather simplistic at 62 the moment. For example: 74 If there is a pair of curly brackets {} anywhere on a command line, 75 whatever is inside is assumed to be a math expression and evaluated as 76 well. This later feature allows functions of variables to be passed 77 as arguments to Opihi functions. (see also the discussion below about 78 temporary vectors and images). 79 80 Any expression within curly brackets {} is assumed 81 to be an arithmetical expression and is evaluated before the line is 82 executed. For example: 83 84 <pre> 85 echo {$fred*dcos(45)} 86 </pre> 87 88 would give the response 7.07107. There are math functions cos, sin, 89 and tan, which operate on radian expressions, and also dcos, dsin, 90 dtan, which operate on degree expressions. There are also the 91 equivalent inverse functions: eg., asin and dasin return radians and 92 degrees, respectively. The help section on Math defines all of the 93 available math functions. 94 95 <h4> Lists </h4> 96 97 Opihi lists are grouped sets of scalar variables (which may be 98 strings). A list consists of N variables with names of the form 99 <tt>name:i/#, where the value of i ranges from 0 to N-1. In addition, 100 the list length is defined as the value #name:n/#. Since these are 101 just informally grouped, a list may be defined by hand (ie, by 102 defining each element and the length). There is also the command 103 #list/# which builds a list from the following lines until reaching 104 a line consisting of the single word #end/#: 105 106 <pre> 107 list sample 108 value 0 109 value 1 110 test line 111 end 112 </pre> 113 114 will define the variables #$sample:0 - $sample:2/#, and #$sample:n/#, 115 with value of 3. 116 117 <p> 118 The list command may also construct a list from the output of a UNIX 119 command: 120 121 <pre> 122 list sample -x "ls /tmp" 123 </pre> 124 125 will result in a list consisting of one entry for each file in the 126 listing. 127 128 <p> 129 The list command may also be used to split a string by whitespace: 130 131 <pre> 132 list sample -split this is a test 133 </pre> 134 will result in a list with 4 elements, one for each word. 135 136 <h4> queues </h4> 137 138 A queue is a data construct consisting of a sequence of lines from 139 which simple selections can be made. Data items are added and removed 140 from the queue with #queuepush/# and #queuepop/# commands which push 141 entries on the end of the queue and pop them off the beginning. The 142 available queues may be obtained with the command #queuelist/#, and 143 the length of a specific queue may be determined with the #queuesize/# 144 command. The contents of a queue may be printed with #queueprint/#. 145 Pushing data onto a non-existent queue will create the queue. An 146 empty queue may be created with the command #queueinit/# and a queue 147 may be deleted with #queuedelete/#. 148 149 <p> 150 The #queuepush/# commands allows for additional options which modify 151 how the data is pushed on the queue. The #-uniq/# flag specifies that 152 the queue should be search for an existing match and not add the new 153 data item if a matching item already exists. The #-replace/# flag is 154 similar to the #-uniq/# flag, but instead the new item will replace 155 the existing match, if a match is found. These two options have 156 identical results if the match is made based on the entire line. 157 However, they may be more usefully distinguished by specifying a 158 restriction on the match with the #-key/# flag. This flag specified 159 which whitespace-separated element of the line to use for the match, 160 with the first element being element 0. 161 162 <p> 163 Numerical vectors and images (matrices) are discussed later in this 164 document. 165 166 <h3> Flow-control block </h3> 167 <h3> Shell Programing </h3> 168 169 <pre> 170 break -- escape from function 171 for -- loops 172 if -- logical cases 173 input -- read command lines from a file 174 macro -- deal with the macros 175 </pre> 176 177 <p> 178 There are several options for programming in <tt>status</tt>. First, 179 a file which contains a series of commands can be executed with 180 <tt>input (filename)</tt>. It is also possible to define macros which 181 will behave much like regular commands. A macro is defined by typing 182 <tt>macro name</tt> or <tt>macro create name</tt> followed by the 183 commands. Arguments to the macro are assigned to the variables $1 184 .. $N and the number of arguments is given by $0. Macros may be 185 defined in <tt>input</tt> files, and in fact when <tt>status</tt> is 186 started, it loads the file <tt>~/.statusrc</tt> which may contain 187 default macros. Simple loops and if statements can be performed, and 188 are quite useful for complex macros. 189 190 <p> 191 'If' statements are similar in syntax to C if statements. Math 192 expresions in the if statement must be contained in curly braces, as 193 elsewhere. Variables with string values may use the logical == 194 operator to test if two strings are the same. 'For' loops are quite 195 simplistic. The form is: 196 197 <pre> 198 for var first last delta 199 (commands) 200 end 201 </pre> 202 203 <p> 204 The value of <tt>$var</tt> will start at the value <tt>first</tt> and increment by 205 <tt>delta</tt> after each loop. The loop will stop after <tt>$var</tt> is greater 206 than <tt>stop</tt>. The value <tt>delta</tt> is optional, with 1 assumed. 207 The value of <tt>$var</tt> may be changed during the loop, and if set 208 beyong the value of <tt>last</tt> will end the loop early. 209 210 211 <p> 212 Opihi has several types of flow-control features. These include 213 for-loops, while-loops, if-else blocks. These blocks are defined by 214 the corresponding command (#for/#, #while/#, #if/#) and are terminated 215 with by a line with the single word #end/#. 216 217 <p> 218 The for loop syntax is simplistic. The #for/# command specifies the 219 loop variable, the starting value, the ending value, and optionally 220 the delta for each loop. The implicit loop test is always to check if 221 the loop variable is still less than the end value (or greater than if 222 the delta value is negative). The definitions of this loop syntax and 223 the value of the list length (#$list:n/#) and the vector length 224 (#vector[]/#) make for natural loops over all elements of a list or 225 vector. Below are a few examples: 63 226 64 227 <pre> … … 66 229 echo $i 67 230 end 231 </pre> 232 This runs the loop with the variable #$i/# running from 1.0, 1.1, up to 9.9 233 (inclusive). 234 235 <pre> 236 for i 0 $list:n 237 echo $list:$i 238 end 239 </pre> 240 This would print all the elements of the list. 241 242 <pre> 243 for i 0 vector[] 244 echo vector[$i] 245 end 246 </pre> 247 This would print all the elements of the vector. 248 249 <p> 250 The if-block begins with a line of the form: #if (condition)/# and 251 ends with a single #end/#. A line with a single #else/# specifies the 252 optional else portion of the block. The conditional expression is a 253 valid math inequality with approximately C-syntax: 254 255 ## 256 (($i < 10) && ($i > 4)) 257 /## 258 259 The elements of the inequality may also be string comparisons. The 260 only valid string comparisons are #==/# and #!=/#. 261 262 <p> 263 The while loop begins with a line of the form #while (condition)/# and 264 ends with a single #end/#. The conditions follow the same rules as 265 the if conditional statements. 266 267 <p> 268 *continue, break, auto-break concepts/* 269 270 68 271 69 272 macro test … … 82 285 performing unix system calls (<tt>exec (command)</tt>). 83 286 287 <h3> Miscellaneous Commands </h3> 288 289 <pre> 290 ! -- system call 291 ? -- list commands 292 ?? -- list variables 293 echo -- type this line 294 exec -- system call 295 exit -- exit program 296 help -- get help on a function 297 output -- redirect output to file 298 quit -- exit program 299 scan -- scan line from keyboard or file to variable 300 wait -- wait until return is typed 301 which -- show command 302 </pre> 303 304 Most of these are self-explanatory. The command ?? prints the system 305 variables. The <tt>help</tt> command will provide help on a single 306 command or, without any arguments, will list all available help 307 files (this includes general help not associated with a specific 308 command). 309 84 310 <h3> 1D Data and the Graphing Window </h3> 311 312 <h3> Vector Plotting </h3> 313 314 <pre> 315 box -- draw a box on the plot 316 clear -- erase plot 317 create -- create a new vector 318 cursor -- get coords from cursor 319 grid -- plot cartesian grid 320 hist -- create histogram from a vector 321 labels -- define labels for plot 322 limits -- define plot limits 323 plot -- plot a pair of vectors 324 print -- write vectors to file 325 ps -- define labels for plot 326 set -- vector math 327 style -- set the style for graph plots 328 vectors -- list vectors 329 zplot -- plot scaled points 330 </pre> 85 331 86 332 <p> … … 90 336 of other vectors. For example, we could create a sine wave with the 91 337 following two lines: 338 339 <p> 340 In addition to scalar variables, <tt>status</tt> can manipulate and 341 display 1-D vector variables. Many of the commands which extract data 342 from the photometry database place the data in vectors as well as 343 plotting them. A vector can also be created based on a number 344 sequence with the command <tt>create name Nelements start delta</tt>. 345 The resulting vector has $Nelements$ entries, starting at a value of 346 $start$ and running until $start + delta*Nelements$. If $delta$ is 347 0.0, all elements will have the value of $start$. A histogram of a vector 348 may be made with the command <tt>hist</tt>, which creates a new vector 349 containing the histogram of the first vector. The data range and bin 350 size of the histogram are defined in same way as with create. This 351 makes it easy to create the index vector that goes with a histogram 352 vector: 353 354 <pre> 355 hist y Ny 1 100 0.1 356 create dx 1 100 0.1 357 </pre> 358 359 <p> 360 The above will create a histogram of y in Ny and the index in dx. 361 Plotting this with <tt>plot dx Ny</tt> will show the histogram. 362 363 <p> 364 Vector math is performed with a command of the form <tt>set new = 365 (expression)</tt>. The expression is some math function employing 366 vectors and scalars. A complete listing of the math operators 367 available in <tt>set</tt> can be found in the help for <tt>set</tt>. 368 369 <p> 370 Once vectors are defined, they may be plotted. A pair of vectors can 371 be plotted against each other if they have the same number of entries. 372 The plotting is performed on the graphics window, Kapa. There are 373 actually several graphics windows available to <tt>status</tt>, any of 374 which may be used to plot at any time. Some of the more complex 375 operations default to either graphics window 0 or 1, depending on the 376 context. Except for those functions with a pre-defined window, all 377 plotting functions apply to the current graphics window unless an 378 option <tt>-n N</tt> is given to specify a different window. The 379 plotting style is determined by the command <tt>style</tt> which can set 380 the line width, the line type (solid, dashed, dotted, etc), the point 381 type (box, cross, etc), the point size, the color, and whether a pair 382 of vectors is plotted as a sequence of points, a set of connected 383 lines, or a histogram. Some functions which make plots use their own 384 styles, as discussed below. The function <tt>limits</tt> lets the user 385 set the range of the plot axes, or check the current setting. The 386 command <tt>plot</tt> will plot a pair of vectors on the current graphics 387 window using the current plotting style for that window. The command 388 <tt>zplot</tt> will plot a pair of vectors with the point size scaled by 389 a third vector, with maximum and minimum point sizes representing 390 specified values. The <tt>cursor</tt> command goes the other way: this 391 command puts the Kapa window in cursor mode and waits for input from 392 Kapa. The user can then type any alphanumeric key on the graphics 393 windows and will be told both the pointer location (in the graphics 394 coordinates) and will have the coordinates stored in <tt>status</tt> 395 variables. For example, by typing ``1'' in the sky display window, 396 the RA and DEC of the pointer are stored in the variables <tt>$R1</tt> 397 and <tt>$D1</tt>. This command can be used to let the user define 398 locations or regions of interest on the Kapa window. (Future addition: 399 <tt>button</tt>, which does the same with the mouse buttons). 92 400 93 401 <pre> … … 127 435 green, blue, and yellow overlays. 128 436 437 <h3> programming considerations </h3> 438 The programming structure of the Opihi front-end 439 makes it very easy to add commands to the package; more about this 440 later.
Note:
See TracChangeset
for help on using the changeset viewer.
