IDL Save a Procedure that Restores Variable Data

  1. Create the program file. Create the following IDL program that first restores the image variable contained within the imagefile.sav file. This variable is used in the following program statements defining the size of the window and in the TV routine which displays the image. The ARROW routine then draws an arrow within the window. Enter the following lines in a text editor.

    PRO draw_arrow
     
    ; Restore image data.
    RESTORE, 'imagefile.sav'
     
    ; Get the dimensions of the image file.
    s = SIZE(image, /DIMENSIONS)
     
    ; Prepare display device and display image.
    DEVICE, DECOMPOSED = 0
    WINDOW, 0, XSIZE=s[0], YSIZE=s[1], TITLE="Point of Interest"
    TV, image
     
    ; Draw the arrow.
    ARROW, 40, 20, 165, 115
     
    ; The IDL Virtual Manchine exits IDL when the end of a
    ; program is reached if there are not internal events. The 
    ; WAIT statement here allows the user to view the .sav file 
    ; results for 10 seconds when executed through the IDL 
    ; Virtual Machine.
    WAIT, 10
     
    END
  2. Save the file. Name the saved file draw_arrow.pro.
  3. Reset the IDL session. Enter the following at the IDL prompt to ensure that no unwanted session information is saved along with the program:

    .FULL_RESET_SESSION
  4. Compile the program. Enter the following at the IDL prompt:

    .COMPILE draw_arrow
  5. Resolve dependencies. Use RESOLVE_ALL (or IRESOLVE if the routine has any dependencies on iTools components) to iteratively compile any uncompiled user-written or library procedures or functions that are called in any already-compiled procedure or function:

    RESOLVE_ALL

    Note: RESOLVE_ALL does not resolve procedures or functions that are called via quoted strings such as CALL_PROCEDURE, CALL_FUNCTION, or EXECUTE, or in keywords that can contain procedure names such as TICKFORMAT or EVENT_PRO. You must manually compile these routines.

  6. Create the SAVE file. Create a file called draw_arrow.sav that contains the user-defined draw_arrow procedure. When the SAVEprocedure is called with the ROUTINES keyword and no arguments, it create a SAVE file containing all currently compiled routines. Because the procedures within the draw_arrow procedure are the only routines that are currently compiled in the IDL session, create the SAVE file as follows:

    SAVE, /ROUTINES, FILENAME='draw_arrow.sav'

    Note: When the name of the SAVE file uses the .sav extension and has the same base name as the main level program, it can be automatically compiled by IDL. This means that it can be called from another routine or restored from the IDL command line using only the name of the saved routine.

  7. Test the SAVE file in the IDL Virtual Machine. Click on the splash screen and open draw_arrow.sav. You could also test the SAVE file from IDL, enter the following at the command prompt.

    RESTORE, 'draw_arrow.sav'
    draw_arrow 
       8. In command mode
         
   idl -vm='draw_arrow.sav'


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值