The IDL procedure <tt>galcount</tt>



next up previous contents
Next: The IDL procedure Up: 3D Redshift Space Visualization Previous: The IDL procedure

The IDL procedure galcount

pro galcount, file_in, f_outpre, ndata, n_box,$
              z_low, z_high, a_low, a_high, d_low, d_high

;   Bo Milvang-Jensen, May 20, 1994.

    if n_params() eq (0) then begin
      print
      print, 'Procedure galcount'
      print
      print, 'Description:'
      print, 'This procedure counts the number of galaxies (datapoints) in a box'
      print, 'which encompasses the data, and which is of size n_box**3'
      print, 'The output is suitable for an Explorer isosurface'
      print
      print, 'Usage:'
      print, 'galcount, file_in, f_outpre, ndata, n_box,$
      print, '          z_low, z_high, a_low, a_high, d_low, d_high
      print
      print, 'file_in : name of data ascii input file with alpha, delta, redshift'
      print, 'f_outpre: prefix of output files -'
      print, '          binary output file will get suffix .dat'
      print, '          header output file will get suffix .idl'
      print, 'ndata   : number of datapoint in file_in'
      print, 'n_box   : size of 3D box (e.g. 128)'
      print, 'z_low   : minimum redshift value'
      print, 'z_high  : maximum redshift value'
      print, 'a_low   : minimum alpha    value'
      print, 'a_high  : maximum alpha    value'
      print, 'd_low   : mimimum delta    value'
      print, 'd_high  : maximum delta    value'
      print
      return
    end

    n_data_before = ndata

    calcdata, file_in, ndata, a, maxv,$
	      z_low, z_high, a_low, a_high, d_low, d_high, new_n

    box=fltarr(n_box,n_box,n_box) 
    
    L = 2 * max(maxv)
    dL = L/n_box

    for t=0L, ndata-1 do begin
        x = a(t,0)
	y = a(t,1)
	z = a(t,2)
	i = fix((x+L/2)/dL)
	j = fix((y+L/2)/dL)
	k = fix((z+L/2)/dL)
	if (i eq n_box) then i=i-1
	if (j eq n_box) then j=j-1
	if (k eq n_box) then k=k-1
	; print, t, x, y, z, i, j, k
	box(i,j,k) = box(i,j,k)+1.
    endfor
     
    dat_name = f_outpre + '.dat'    ; binary output file (.dat)
    openw,  lun, dat_name, /GET_LUN
    writeu, lun, box
    close,  lun
    free_lun, lun

    idl_name = f_outpre + '.idl'    ; header output file (.idl)
    openw,  lun, idl_name, /GET_LUN
    printf, lun, '# IDL field description file'
    printf, lun, '#'
    printf, lun, '#'
    printf, lun, '# Created by IDL procedure: galcount'
    spawn, 'date', date_result
    printf, lun, '#'
    printf, lun, '# Created date: ', date_result
    printf, lun, '#' 
    spawn, 'pwd', pwd_result
    printf, lun, '# IDL pwd was: ', pwd_result
    printf, lun, '#'
    printf, lun, '# Input ascii data file: ', file_in
    printf, lun, '# Number of data point herein: ', n_data_before
    printf, lun, '#'
    printf, lun, '# z     low  cut:', z_low
    printf, lun, '# z     high cut:', z_high
    printf, lun, '# alpha low  cut:', a_low
    printf, lun, '# alpha high cut:', a_high
    printf, lun, '# delta low  cut:', d_low
    printf, lun, '# delta high cut:', d_high
    printf, lun, '#'
    printf, lun, '# Number of data points left after cuts: ', new_n
    printf, lun, '# Maximum absolute values (x,y,z): ', maxv
    printf, lun, '#'
    printf, lun, '#'
    printf, lun, 'ndim=3'
    printf, lun, ''
    printf, lun, 'dim1=', n_box
    printf, lun, 'dim2=', n_box
    printf, lun, 'dim3=', n_box
    printf, lun, ''
    printf, lun, 'veclen=1'
    printf, lun, ''
    printf, lun, 'data=float'
    printf, lun, 'field=uniform'
    printf, lun, ''
    printf, lun, 'frames=1'
    printf, lun, 'file="', dat_name, '"'
    close,  lun
    free_lun, lun

end



Bo Milvang-Jensen
Wed Jan 18 05:44:35 MET 1995