next up previous 107
Next: Log Files
Up: ORAC-DR - Programmer's Guide
Previous: Primitives

Writing a Primitive

In order to write a valid primitive certain steps must be adhered to in order to ensure that subsequent primitives have the correct information.

It assumes knowledge of the following Perl concepts: using Perl objects, lexical variables, Perl data structures.

Here is an example primitive showing the basic principles:

 1  =head1 NAME
 2
 3  _PRIMITIVE_NAME_ - short description
 4
 5  =head1 DESCRIPTION
 6 
 7  Long description
 8
 9  =head1 ARGUMENTS
10
11  =over 4
12
13  =item ARG1
14
15  Description of possible values of ARG1
16
17  etc...
18
19  =back
20
21  =head1 TASKS
22
23  List of external tasks required by the primitive
24
25  =head1 OUTPUT FILES
26
27  Output suffix for the display system.
28
29  etc, AUTHORS, COPYRIGHT.....
30
31  =cut
32
33  # Read arguments or use default values
34  my $arg1 = ( exists $_PRIMITIVE_NAME{ARG1} ? 
35               $_PRIMITIVE_NAME{ARG1} : 5);
36
37  # Loop over all sub frames
38  foreach my $i (1..$Frm->nfiles) {
39
40    # Get the input and output filename
41    my ($in, $out) = $Frm->inout('_sfx', $i);
42
43    # Read some value from the frame FITS header
44    my $value = $Frm->hdr('KEYWORD');
45
46    # Combine the in, out and value into options for the task
47    # DEPENDS ON ALGORITHM ENGINE
48    my $options = "IN=$in OUT=$out SWITCH=$value";
49
50    # Run the algorithm engine
51    $Mon{'task'}->obeyw('TASK',$options);
52
53    # Retrieve an answer from a parameter
54    ($ORAC_STATUS, $result) = $Mon{'task'}->get('TASK','PARAMETER');
55
56    # Print the result
57    orac_print "Result from primitive $ORAC_PRIMITIVE = $result\n";
58
59    # Update the frame object so that the next primitive
60    # gets the correct input file name
61    $Frm->file($i, $out);
62
63  }
64
65  # Ask the display system to display the frame
66  $Display->display_data($Frm) if defined $Display
67
The following should be noted:





next up previous 107
Next: Log Files
Up: ORAC-DR - Programmer's Guide
Previous: Primitives

ORAC-DR -- Programmer's Guide
Starlink User Note 233
Tim Jenness, Frossie Economou, Brad Cavanagh
Joint Astronomy Centre, Hilo, Hawaii
June 2004
E-mail:ussc@star.rl.ac.uk

Copyright © 2004 Particle Physics and Astronomy Research Council