; Creates ref projections
 ;
 ; SOURCE:   spider/docs/techs/recon1/Procs/make-ref-views.spi
 ;
 ; PURPOSE:  Sets angles for reference projections.
 ;           Creates reference projections from a reference volume.
 ;
 ;
 ; USAGE:    ./spider spi/dat @make-ref-views
 ;
 ;  ------------ Parameters ---------------------------------------
 ;
 ; INPUT FILES: ([win_dir] denotes input directory)
 ;   [ref_vol]        [win_dir]/ref_vol       Current reference volume    (one) 
 ;
 ; OUTPUT FILES: ('[rec_dir] denotes output directory)
 ;   [iter_refangs]   [rec_dir]/ref_angs_00   Reference angles doc file   (one)                  
 ;   [ref_projs]      [rec_dir]/ref_projs_00  Reference projections       (one) 
 ;   [ref_view_list]  [rec_dir]/sel_proj      View list doc file          (one)
 ; 
 ; -------------- END BATCH HEADER ---------------------------------

 MD
   TR OFF                  ; Decrease results file output
 MD
   VB OFF                  ; Decrease results file output
 MD 
   SET MP 
   0                       ; Use all available processors  
 
 ; Get reconstruction parameters & file names
 [steptype] = 0            ; Alignment step
 @recon-settings([steptype],[num-grps],[pixsiz],[ang-step],[r2],[alignsh],[prj-radius],[winsiz],[incore-yn],[bp-type],[qsub])

 SYS
    mkdir -p [rec_dir]

 [iter] = 0

 DE                        ; Delete 
   [iter_refangs]          ; Reference projection angles doc file   (deleted)
 DE                        ; Delete 
   [ref_view_list]         ; Selection doc file                     (deleted)

 ; List angles for reference projections in doc file.
 VO EA [num-angs]          ; Sets [num-ang] to number of reference projections
   [ang-step]              ; Theta angular step            (varies with iteration)
   0, 90                   ; Theta range, 90 is for use with 'Check Mirrored Positions'
   0, 359.9                ; Phi range
   [iter_refangs]          ; Reference projection angles doc file   (output)

 ![num-angs] = [num-angs] -1 ; Skip duplicated angle
 [num-angs]  

 ; Create ('PJ 3F') stack holding reference projections. 

 SYS
   echo  '  Creating: {%I0%[num-angs]} reference projections with radius: {%I0%[prj-radius]}' ; echo

 PJ 3F                     ; Projection operation
   [ref_vol]               ; Current reference volume             (input) 
   [prj-radius]            ; Radius of projection
   1-[num-angs]            ; Reference angles used    
   [iter_refangs]          ; Reference angles doc file            (input)
   [ref_projs]@*****       ; Reference projection stack template  (output) 

 ; Generate view-list (projection selection file)
 SYS
   mkdir -p ../Averages

 DOC CREATE
   [ref_view_list]         ; View list doc file    (output)
   1                       ; Column to be filled
   1-[num-angs]            ; Numbers to put in column

 SYS
   echo  '  Created view list doc file: [ref_view_list]' ; echo

 EN 
 ;