To execute a user-written MIDAS application program (coded in FORTRAN or C),
command RUN. The command RUN MYPROG or RUN myprog
will execute myprog.exe in a subprocess like any other MIDAS
It is better practice to embed the command RUN MYPROG in a MIDAS command procedure. Typical tasks of this procedure would be to provide default values for all parameters , to check the validity of parameter values, and to store the parameters into the keywords your program will use.
Let us assume you have written your special filter program and stored the executable module as bestfilt.exe on disk. Program bestfilt just needs the names of the input and output image which are obtained inside the program from the keywords IN_A and OUT_A .
The following MIDAS procedure:
!+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
! MIDAS procedure bestfilt.prg
CROSSREF INPUT RESULT
DEFINE/PARAMETER P1 ? IMA "Enter input frame: "
DEFINE/PARAMETER P2 ? IMA "Enter output frame: "
DEFINE/MAXPAR 2 ! max. 2 parameters expected
WRITE/KEYWORD IN_A P1
WRITE/KEYWORD OUT_A P2
RUN BESTFILT ! .exe is the default type
CREATE/COMMAND BESTFILT/IMAGE @@ bestfiltyour application will then be integrated smoothly into MIDAS.
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 myproc.prg and Bourne shell script myscript to obtain the median value of an image.
! MIDAS procedure myproc.prg
! to return the median of an image in an ASCII file
! execute via `@@ myproc image_name'
define/param p1 ? ima "Enter name of image:"
! save median of statistics command (was stored in keyword OUTPUTR(8))
define/local value/r/1/1 outputr(8)
define/local fc/i/1/2 0,0
! create new ASCII file (named `info.asci') and store median in there
open/file info.asci write fc
write/file fc(1) median = value
bye ! terminate Midas
# Bourne shell script `myscript' - execute via: $ myscript parameter
# delete last file we got
rm -f info.asci
# start up Midas in another xterm window
# and let it execute the procedure `myproc.prg'
# shell parameter $1 will be passed as parameter P1 to Midas
xterm -e inmidas -j "@@ myproc $1" 33 -p
# the info we want is now in file: info.asci
There is also the possibility to run any Midas command (procedure) directly from the Unix command line via the drs command. To have it available you must do once
$ source /midas/version/system/unix/drs_config
$ sh /midas/version/system/unix/drs_config.sh
then, assuming you have a FITS file fors1data.fits in your directory, you type
$drs read/descr fors1data.fits "eso.*"
to get all the ESO hierarchical FITS keywords of the image fors1data.fits.
Note, that the descriptor pattern `eso.*' has to be enclosed in double quotes to avoid expansion of this term by the shell.
$ drs -h
you get a short help about the command.
NoteThe drs 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...