Tutorial
Home Index

Using IDL To Work With cFit Fitted ACF Data

Overview

The cFit format data is a highly compressed version of the fitted ACF data.

This tutorial shows you how to use the cfit.pro library to work with files stored in the cFit format.

The libraries consist of functions written both in native IDL and functions that act as wrappers and use theCALL_EXTERNAL function to call the C libraries. The native IDL functions are the most portable, but are considerably slower than using the C libraries. The libraries contain a third set of functions that automatically determine whether the native IDL or C library functions should be used; you don't need to worry about which set of functions to use.

Reading cFit Files

The example program presented below does the simple task of reading records from a cFit file and plots the velocity measurements of beam 8 as a surface.

pro readcfit

  ; Open input file for reading
 

  openr,inp,'test.cfit',/GET_LUN,/SWAP_IF_BIG_ENDIAN
  s=CFitSeek(inp,2002,12,19,0,30,10,atme=atme)

  c=0 
  vstore=fltarr(100,720)
  while  CFitRead(inp,prm,fit) ne -1 do begin
   print, prm.time.hr,prm.time.mt,prm.time.sc
   if (prm.bmnum eq 8) then begin
     vstore[0:prm.nrang-1,c]=fit.v[0:prm.nrang-1]
     c++
   endif
 endwhile
 surface,vstore[0:74,0:c-1]
 free_lun,inp
end
Download this program here:readcfit.pro

The read routine CFitRead returns two structures, the first is the radar parameter block and the second is the fitted ACF data. The contents of these structures are documented in RFC #0020 and RFC #0022

Writing cfit Files

The program presented below uses the CFitWrite function to writ data to a new file.The function returns the number of bytes required to store the data

pro writecfit

  ; Open input file for reading
 
  openr,inp,'test.cfit',/GET_LUN,/SWAP_IF_BIG_ENDIAN
  openw,out,'test2.cfit',/GET_LUN,/SWAP_IF_BIG_ENDIAN

  s=CFitSeek(inp,2002,12,19,0,30,10,atme=atme)

  c=0L 
  vstore=fltarr(100,720)
  while  CFitRead(inp,prm,fit) ne -1 do begin
   s=CFitWrite(out,prm,fit,minpwr=-1000.0)
   c=c+s
   print,c,prm.time.mt,prm.time.sc,prm.time.us
 endwhile
 free_lun,inp
end
Download this program here:writecfit.pro

Back