Sophie

Sophie

distrib > Mageia > 5 > i586 > by-pkgid > 37ce2601040f8edc2329d4714238376a > files > 837

eso-midas-doc-13SEPpl1.2-3.mga5.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 98.1p1 release (March 2nd, 1998)
originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Running a Program within MIDAS</TITLE>
<META NAME="description" CONTENT="Running a Program within MIDAS">
<META NAME="keywords" CONTENT="vol1">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="vol1.css">
<LINK REL="next" HREF="node50.html">
<LINK REL="previous" HREF="node47.html">
<LINK REL="up" HREF="node22.html">
<LINK REL="next" HREF="node49.html">
</HEAD>
<BODY >
<!--Navigation Panel-->
<A NAME="tex2html1083"
 HREF="node49.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
 SRC="icons.gif/next_motif.gif"></A> 
<A NAME="tex2html1079"
 HREF="node22.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
 SRC="icons.gif/up_motif.gif"></A> 
<A NAME="tex2html1073"
 HREF="node47.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
 SRC="icons.gif/previous_motif.gif"></A> 
<A NAME="tex2html1081"
 HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
 SRC="icons.gif/contents_motif.gif"></A> 
<A NAME="tex2html1082"
 HREF="node216.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
 SRC="icons.gif/index_motif.gif"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html1084"
 HREF="node49.html">Debugging of Procedures and</A>
<B> Up:</B> <A NAME="tex2html1080"
 HREF="node22.html">Monitor and Command Language</A>
<B> Previous:</B> <A NAME="tex2html1074"
 HREF="node47.html">Context Levels</A>
<BR>
<BR>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION00680000000000000000">&#160;</A> 
<A NAME="running-a-program-within-midas">&#160;</A>
<BR>
Running a Program within MIDAS
</H1>

<P>
To execute a user-written MIDAS application program<A NAME="2472">&#160;</A> (coded in FORTRAN or C),
employ the
command <TT>RUN</TT>. The command <TT>RUN MYPROG</TT> or <TT>RUN myprog</TT>
will execute <TT>myprog.exe</TT> in a subprocess like any other MIDAS
command.
<BR>
It is better practice to embed the command <TT>RUN MYPROG</TT> 
in a MIDAS 
command procedure. Typical tasks of this procedure would be to provide
default values for all parameters<A NAME="2478">&#160;</A>, to check the validity of parameter values, 
and to store the parameters into the keywords your program will use.
&nbsp;&nbsp; <BR>
Let us assume you have written your special filter program and stored the
executable module as
<TT>bestfilt.exe</TT> on disk. Program <TT>bestfilt</TT> just needs the names of
the input and output image
which are obtained inside the program from the keywords IN_A and OUT_A .
&nbsp;&nbsp; <BR>
The following MIDAS procedure:<BLOCKQUOTE>
<TT>!+ <BR>
  ! MIDAS procedure bestfilt.prg <BR>
  !+ <BR>
CROSSREF INPUT RESULT <BR>
DEFINE/PARAMETER P1 ? IMA "Enter input frame: " <BR>
DEFINE/PARAMETER P2 ? IMA "Enter output frame: " <BR>
DEFINE/MAXPAR 2 </TT>! max. 2 parameters expected<TT>
<BR>
  !  <BR>
WRITE/KEYWORD IN_A </TT><IMG
 WIDTH="17" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img200.gif"
 ALT="$\{$"><TT>P1</TT><IMG
 WIDTH="16" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img201.gif"
 ALT="$\}$"><TT> <BR>
WRITE/KEYWORD OUT_A </TT><IMG
 WIDTH="17" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img202.gif"
 ALT="$\{$"><TT>P2</TT><IMG
 WIDTH="16" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img203.gif"
 ALT="$\}$"><TT> <BR>
RUN BESTFILT			</TT>! .exe is the default type <TT>
<BR></TT></BLOCKQUOTE>will check, that the two parameters are valid MIDAS file names and prompt
for input if any parameter is not given.
Together with the MIDAS command<BLOCKQUOTE>
<TT>CREATE/COMMAND BESTFILT/IMAGE @@ bestfilt</TT></BLOCKQUOTE>your application will then be integrated smoothly into MIDAS.
<BR>
Now, you can apply your own filtering algorithm to the image <TT>lobo.bdf</TT>
by typing e.g. <BR>
<TT>BESTFILT/IMAGE res=perrito in=lobo</TT>.
&nbsp;&nbsp; <BR>
As with data files you can specify a search path for executables via the
command
<BR>
<TT>SET/MIDAS_SYSTEM EPATH=directory</TT> which is then used by the 
<TT>RUN</TT> command. Furthermore, if your module is written in C you can pass
parameters to the executable in the usual way (<I>argc, arv</I> stuff) via, 
e.g.
<BR>
<TT>RUN BESTFILT par1 par2 ...</TT> <BR>

<P>
If you want to execute Midas commands from a shell script you can do so as
shown in the following example, where we use 
the procedure <TT>myproc.prg</TT> and Bourne shell script <TT>myscript</TT> to obtain
the median value of an image.<BLOCKQUOTE>
<TT>!  <BR>
! MIDAS procedure myproc.prg <BR>
! to return the median of an image in an ASCII file <BR>
! execute via  `@@ myproc image_name'  <BR>
!  <BR>
define/param p1 ? ima "Enter name of image:"  <BR>
!  <BR>
statistics/image </TT><IMG
 WIDTH="17" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img204.gif"
 ALT="$\{$"><TT>p1</TT><IMG
 WIDTH="16" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img205.gif"
 ALT="$\}$"><TT> <BR>
!  <BR>
! save median of statistics command (was stored in keyword OUTPUTR(8))  <BR>
!  <BR>
define/local value/r/1/1 </TT><IMG
 WIDTH="17" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img206.gif"
 ALT="$\{$"><TT>outputr(8)</TT><IMG
 WIDTH="16" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img207.gif"
 ALT="$\}$"><TT> <BR>
define/local fc/i/1/2 0,0  <BR>
!  <BR>
! create new ASCII file (named `info.asci') and store median in there  <BR>
!  <BR>
open/file info.asci write fc  <BR>
write/file </TT><IMG
 WIDTH="17" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img208.gif"
 ALT="$\{$"><TT>fc(1)</TT><IMG
 WIDTH="16" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img209.gif"
 ALT="$\}$"><TT> median = </TT><IMG
 WIDTH="17" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img210.gif"
 ALT="$\{$"><TT>value</TT><IMG
 WIDTH="16" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img211.gif"
 ALT="$\}$"><TT> <BR>
close/file </TT><IMG
 WIDTH="17" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img212.gif"
 ALT="$\{$"><TT>fc(1)</TT><IMG
 WIDTH="16" HEIGHT="44" ALIGN="MIDDLE" BORDER="0"
 SRC="img213.gif"
 ALT="$\}$"><TT> <BR>
!  <BR>
bye  </TT>! terminate Midas<TT>
<BR>
<BR>
<BR>
#! /bin/sh  <BR>
# Bourne shell script `myscript' - execute via: $ myscript parameter  <BR>
#  <BR>
# delete last file we got  <BR>
rm -f info.asci  <BR>
#  <BR>
# start up Midas in another xterm window <BR>
# and let it execute the procedure `myproc.prg'  <BR>
# shell parameter $1 will be passed as parameter P1 to Midas  <BR>
#  <BR>
xterm -e inmidas -j "@@ myproc $1" 33 -p <BR>
#  <BR>
# the info we want is now in file: info.asci  <BR>
#  <BR>
more info.asci  </TT></BLOCKQUOTE>
<P>
There is also the possibility to run any Midas command (procedure) directly
from the Unix command line via the <I>drs</I> command.
To have it available you must do once 

<P>
<TT>$ source /midas/<I>version</I>/system/unix/drs_config</TT> <BR>
or

<P>
<TT>$ sh /midas/<I>version</I>/system/unix/drs_config.sh</TT> <BR>
&nbsp;&nbsp;
<BR>
then, assuming you have a FITS file <TT>fors1data.fits</TT> in your directory, you
type

<P>
<TT>$drs read/descr fors1data.fits "eso.*"</TT>
<BR>
to get all the ESO hierarchical FITS keywords of the image 
<TT>fors1data.fits</TT>.
<BR>
Note, that the descriptor pattern `eso.*' has to be 
enclosed in double quotes to avoid expansion of this term by the shell.
<BR>
With

<P>
<TT>$ drs -h</TT>
<BR>
you get a short help about the command.

<P>
<BLOCKQUOTE>
<DIV ALIGN="CENTER">
<B>Note</DIV>
<I>The <TT>drs</TT> command is currently only implemented for Unix (Linux) systems,
furthermore, it cannot be applied to Midas commands which use a graphics or
display window.
Also, Midas keyword manipulations don't make much sense, since the keyword data
base is NOT saved...</I></B></BLOCKQUOTE>
<P>
<BR><HR>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS">&#160;</A>
<UL>
<LI><A NAME="tex2html1085"
 HREF="node49.html">Debugging of Procedures and Modules</A>
</UL>
<!--End of Table of Child-Links-->
<HR>
<!--Navigation Panel-->
<A NAME="tex2html1083"
 HREF="node49.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
 SRC="icons.gif/next_motif.gif"></A> 
<A NAME="tex2html1079"
 HREF="node22.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
 SRC="icons.gif/up_motif.gif"></A> 
<A NAME="tex2html1073"
 HREF="node47.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
 SRC="icons.gif/previous_motif.gif"></A> 
<A NAME="tex2html1081"
 HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
 SRC="icons.gif/contents_motif.gif"></A> 
<A NAME="tex2html1082"
 HREF="node216.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
 SRC="icons.gif/index_motif.gif"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html1084"
 HREF="node49.html">Debugging of Procedures and</A>
<B> Up:</B> <A NAME="tex2html1080"
 HREF="node22.html">Monitor and Command Language</A>
<B> Previous:</B> <A NAME="tex2html1074"
 HREF="node47.html">Context Levels</A>
<!--End of Navigation Panel-->
<ADDRESS>
<I>Petra Nass</I>
<BR><I>1999-06-09</I>
</ADDRESS>
</BODY>
</HTML>