Sam Haimov's WCRTOOLS IDL LIBRARY HELP

Last modified: Fri Aug 21 11:10:13 2009.


List of Routines


Routine Descriptions

AC2GT

[Next Routine] [List of Routines]
 NAME:
      AC2GT

 PURPOSE:
      Returns single precision AC (aircraft) to EARTH or EARTH to AC 
      coordinate transformation matrix. AC coordinates (x',y',z'): along plane
      axis, right wing, down.  Earth(x,y,z): East, North, Up; positive angles
      are counterclockwise. 

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      res=ac2gt(attitude)
      res=ac2gt(roll,pitch,heading)

 INPUTS:
      Attitude: fltarr(3,m)
                attitude[0,m], AC roll in radians
                attitude[1,m], AC pitch in radians
                attitude[2,m], AC heading in radians

      Instead of attitude you can enter roll, pitch and heading as
      separate arrays:
     
      Roll:    fltarr(m), AC roll in radians 
      Pitch:   fltarr(m), AC pitch in radians 
      Heading: fltarr(m), AC heading in radians 

 KEYWORD PARAMETERS:
      DEG:  when set the attitude angles are given in degrees
      G2A:  when set ac2gt returns ground to aircraft trans. matrix
            otherwise returns aircraft to ground trans. matrix (default)
      HELP: show this text

 OUTPUTS:
      Res:  fltarr(3,3,m), array of transform. matrices for m sets of angles

 PROCEDURE:
      The transformation matrix is given by:
      AC to Earth:  Ta2g=Tz##(Th##(Tp##Tr)) and since T is a orthonormal matrix
      Earth to AC transformation matrix is Tg2a=transpose(Ta2g)
      Where Tr is the AC roll(phi) matrix, Tp - pitch(theta) matrix,
      Th - heading(psi) matrix, and Tz - down to up (z) rotation :

      Tr=[[1,0,0],[0,cos(phi),-sin(phi)],[0,sin(phi),cos(phi)]]
      Tp=[[cos(theta),0,sin(theta)],[0,1,0],[-sin(theta),0,cos(theta)]]
      Th=[[sin(psi),cos(psi),0],[-cos(psi),sin(psi),0],[0,0,1]]
      Tz=[[1,0,0],[0,-1,0],[0,0,-1]] 

 NOTES:
      AC coordinate system:  x' -> AC axis toward the nose
                             y' -> right wing
                             z' -> AC down
      AC heading, psi,   (North=0, N->E positive)      -> rotate z' 
      AC pitch,   theta, (AC nose up is positive)      -> rotate y'
      AC roll,    phi,   (right wing down is positive) -> rotate x'  

 SIDE EFFECTS:
      The function returns -1 if the usage is incorrect

(See /tools/idl/wcrtools/ac2gt.pro)


AC2WCR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       AC2WCR

 PURPOSE:
       Returns a KingAir(KA) or NCAR C130 variable with the time dimension 
       matching WCR time dimension (profiles) or vice versa.
       KA or WCR variables could be 1-D, 2-D or 3-D arrays with the last
       dimension being the time(profile). The match is achieved by linearly 
       interpolating KA (ac2wcr) or WCR (wcr2ac) data variable time dimension.

       There is no lowpass filtering of the result and thus frequency
       aliasing is possible in cases where the resampled data is also
       downsampled.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       result=ac2wcr(var,actime,wcrtime,sps,timehack=timehack  $
                     errorm=errorm,wcr2ac=wcr2ac,help=help)

 INPUTS:
       Var:      numerical array, AC variable (or WCR var if wcr2ac is set)
                 AC var must have one time dim only (sps dim should be merged
                 with time dim - see acloadnc function)  
       Actime:   long/double array, AC time vector (UNIX seconds)
       Wcrtime:  double array, WCR time vector (UNIX seconds)
       Sps:      input, AC variable sampling rate (default 1, see NOTES)

 KEYWORD PARAMETERS:
       ERRORM:   when set prints error messages
       TIMEHACK: input,float, WCR time correction in seconds  (default 0.0)
       WCR2AC:   when set match WCR variable (var) to AC sps 
       HELP:     shows this text

 OUTPUTS:
      
 SIDE EFFECTS:
       The function returns an empty string if the usage is incorrect, 
       -1 if var is not defined or has more than 3 dimensions, 
       -2 if wcrtime is not subset of actime, or
       -3 if actime is not subset of wcrtime when wcr2ac is set     

 NOTES:
       AC vars are equaly spaced in time.  WCR vars are non-equaly spaced
       (varying number of profiles per second and a small variation in the
       time interval between the profiles).  Thus ac2wcr returns 
       irregularly gridded data.  If wcr2ac is set the returned WCR var is
       regularly gridded matching AC netcdf sps dimension.

       The timehack, if given, serves to sync WCR and AC time.
       The time hack is applied to the WCR time (it should be small if any).
       The input wcrtime is not changed.

       If actime is a double precision array and includes the fractional 
       seconds corresponding to the AC var sampling rate (sps), the sps input
       parameter could be omitted or must be set to 1.

       actime and wcrtime must match the AC and WCR data vars

       ATTN: This function has not been tested for 3-D arrays yet
        
 EXAMPLES:

 ******* 1) Interpolate KA data to sync with WCR time *************************
 
 .run commonwcrset                     ; Install WCR data common blocks
 openwcrf,'Wpp00-04-13-18-51-54',data  ; Open WCR raw data file
 wcrtime=1                             ; Initilize wcrtime as scalar to force
                                       ; loading WCR raw time by readwcrdata 
 readwcrdata,0,2000,rawtime=wcrtime    ; Load segment of WCR data and full raw
 wcrtime=wcrtime-86400.                ; time (UNIX format). WCR time for this
                                       ; file was 24 hours ahead; so correct it
 timehack=0.0                          ; Assume no time sync problem between
                                       ; the AC and WCR (GPS to UTC correction
                                       ; is applied within readwcrdata)

 Extract the indices for desired UTC interval from the loaded wcr data segment.
 In this case readwcrdata loaded data by given start/stop record numbers.
 To check what times corresponds to this numbers one can print the following:
 print,sec2time([time[0],time[1999]), which will print start and stop time
 as hhmmss.ss double precision numbers.
 
 ind=where(sec2time(time+timehack) gt 185416 and  $
           sec2time(time+timehack) lt 185500)

 Load the AC UNIX time variable (time).  If there is no such variable in the
 AC netcdf data file one can use acloadnc routine with TIME keyword to construct
 AC UNIX time vector (this assume that netcdf file is NCAR/RAF Nimbus format
 compliant).  

 katime=acloadnc(ncid,'time','20000413.c25.nc',sps=sps,start=185400,stopt=185510)

 'time' vector represents whole seconds. Thus expand it to sps (in this case
 sps=25). Use rebin but take care to expand last second

 katime25=rebin(double(katime),25*n_elements(katime))
 katime25[n_elements(katime25)-25:*]=katime25[n_elements(katime25)-25:*]+ $
                                     findgen(25)/25.  

 Load the AC var to be interpolated. Make sure it is for the same time
 interval as katime.  Also make sure this time interval encloses the WCR
 time interval, which allows interpolation (no extrapolation) for all data
 points of the output.

 karoll=acloadnc(ncid,'hroll',sps=sps,start=185400,stopt=185510)

 Interpolate the KA roll to match WCR sampling times

 wcrroll=ac2wcr(karoll,katime25,wcrtime[ind],1,timehack=timehack)

 Plot the results

 plot,katime25-katime25[0],karoll,lin=1
 oplot,wcrtime[ind]+timehack-katime25[0],wcrroll

 aximage,10.*alog10(hh[*,ind]),time[ind],radrng,/tr,/timeax,setw=[-1,41]
 plot,time[ind],wcrroll,/noerase,xsty=5,ysty=5

 ******* 2) Interpolate WCR data to sync with KA time *************************

 .run commonwcrset
 openwcrf,'Wpp00-04-13-18-51-54',data
 wcrtime=1 & readwcrdata,0,2000,rawtime=wcrtime
 wcrtime=wcrtime-86400. ; WCR unix time for this file was 24 hours ahead
 timehack=0.0

 katime=acloadnc(ncid,'time','20000413.c25.nc',sps=sps,start=185417,stopt=185500)
 if sec2time(katime[0] mod 86400) ne 185417 or $
    sec2time(katime[n_elements(katime)-1] mod 86400) ne 185510 then $
    print, 'Requested time interval is not valid.'
 rebin but take care to expand last second
 katime25=rebin(double(katime),25*n_elements(katime))
 katime25[n_elements(katime25)-25:*]=katime25[n_elements(katime25)-25:*]+ $
                                     findgen(25)/25.  
 
 ; Interpolate the noise channel
 kahhnoise=ac2wcr(hhnoise,katime25,wcrtime,1,timehack=timehack,/wcr2ac)

 ; Interpolate the H-reflectivity
 kahh=ac2wcr(hh,katime25,wcrtime,1,timehack=timehack,/wcr2ac)

 ; Plot the results
 plot,wcrtime+timehack-katime25[0],10.*alog10(hhnoise),lin=1
 oplot,katime25-katime25[0],10.*alog10(kahhnoise)

 aximage,10.*alog10(kahh),(katime25 mod 86400),radrng,/tr,/timeax,setw=[-1,41]
 aximage,10.*alog10(hh),time,radrng,/tr,/timeax,setw=[-1,41]

 ******************************************************************************

(See /tools/idl/wcrtools/ac2wcr.pro)


ACLOADINS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       ACLOADINS

 PURPOSE:
       Returns UW_KingAir/NCAR_C130 selected INS and other AC data variables
       from a netCDF file. There is only one time dimension in the loaded
       variables. See the notes.  Time variable is resampled to match data
       sampling rate (sps).

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       acdata = acloadins(cdfid,startt=startt,stopt=stopt,close=close,$
                deg=deg,filename=filename,ncnames=ncnames,sps=sps,    $
                wcrdvc=wcrdvc,help=help)

 INPUTS:
       Cdfid:     netCDF file ID (if defined), returned from a previous call
                  to ncdf_open, ncdf_create, ncdf_varload or ncdf_fcopy or
                  other routine

 KEYWORD PARAMETERS:
       CLOSE:     when set AC netcdf file will be closed.
       DEG:       input, when set the attitude angles in acdata are in degrees
       FILENAME:  input, string, KA(N2UW) or NCAR 130 (N130AR) netCDF file
                  name; if given will open netCDF file first. In this case
                  Cdfid is an output parameter
       NCNAMES:   input, string array, AC netcdf varnames to be used (if not 
                         defined N2UW or N130AR default var names are used; 
                         see Notes for the default variable names)
                  ncnames[0] - AC time (seconds in UNIX format)
                  ncnames[1] - AC true air speed in m/s
                  ncnames[2] - AC roll [deg or rad]
                  ncnames[3] - AC pitch [deg or rad]
                  ncnames[4] - AC true heading [deg or rad]
                  ncnames[5] - AC east-west(EW) ground velocity [m/s]
                  ncnames[6] - AC north-south(NS) ground velocity [m/s]
                  ncnames[7] - AC vertical velocity [m/s]
                  ncnames[8] - AC East component of the wind [m/s]
                  ncnames[9] - AC North component of the wind [m/s]
                  ncnames[10]- AC vertical wind [m/s]

                  ncnames[11]- AC roll rate [rad/s] (use '' if N/A)
                  ncnames[12]- AC pitch rate [rad/s](use '' if N/A)
                  ncnames[13]- AC heading rate [rad/s] (use '' if N/A)

                  ncnames[14]- AC EW ground vel. GPS correction(use '' if N/A)
                  ncnames[15]- AC NS ground vel. GPS correction(use '' if N/A)

                  ncnames[16]- AC longitude [deg](use '' if N/A)
                  ncnames[17]- AC latitude [deg] (use '' if N/A)
                  ncnames[18]- AC altitude MSL [m](use '' if N/A)

                  ncnames[19]- AC geometric altitude [m](use '' if N/A)
                  ncnames[20]- AC sideslip angle [deg or rad] (use '' if N/A)

                  Note: a) at least the first 11 var names must be defined;
                           the other allowed sets are 14, 16, 19, 21 var names;
                        b) if any of the vars beyond the first 11 are not
                           needed or do not exist use empty string('') to
                           skip those variables
                        c) if wcrdvc is set the last 5 vars are not loaded
                        
       SPS:       output, integer; samples per second (1,10,25; 25 is expected)
       STARTT:    input, long, start time in hhmmss
       STOPT:     input, long, stop time in hhmmss including last second record
       WCRDVC:    when set acdata contains the first 18 fields only (see,acdata
                  structure description below; needed for WCR Doppler velocity
                  correction)
       HELP:      shows this text

 OUTPUTS:
       Cdfid:  netCDF file ID, returned if Filename is given and CLOSE not set
       Acdata: structure, return AC IRS/INS data matching AC time
               acdata.time   -> double(n), AC time in Unix sec (see Notes)
             ; Following angles are in radians or degrees if deg keyword set
               acdata.roll   -> fltarr(n), AC roll angle
               acdata.pitch  -> fltarr(n), AC pitch angle
               acdata.heading-> fltarr(n), AC true heading from North
             ; AC ground velocities in [m/s]
               acdata.ug     -> fltarr(n), East-West AC ground velocity
               acdata.vg     -> fltarr(n), North-South AC ground velocity
               acdata.wg     -> fltarr(n), AC vertical velocity
             ; UWKA GPS corrections of ins AC velocities (ignore for C130)
               acdata.uerr   -> fltarr(n), E-W vel correction in m/s
               acdata.verr   -> fltarr(n), N-S vel correction in m/s
             ; AC measured winds in [m/s]
               acdata.uw     -> fltarr(n), East wind velocity component
               acdata.vw     -> fltarr(n), North wind velocity component
               acdata.ww     -> fltarr(n), vertical wind velocity component
             ; AC attitude rates in rad/sec or deg/sec (if deg keyword is set)
               acdata.rollr  -> fltarr(n,3), roll rate
               acdata.pitchr -> fltarr(n,3), pitch rate
               acdata.yawr   -> fltarr(n,3), yaw rate
             ;
               acdata.tas    -> fltarr(n), true air speed in m/s

             ; AC data info: aircraft ID (N2UW or N130AR)
               acdata.info   -> string, aircraft ID

             ; UWKA radar wing mirror position
               acdata.wcrmirror -> intarr(n), KA radar wing mirror position
                                   (0-side, 1-up, for side/up antenna)

             ; Fields used for Dual-Doppler analysis only
               acdata.lat    -> fltarr(n), latitude position of the AC [deg]
               acdata.lon    -> fltarr(n), longitude position of the AC [deg]
               acdata.alt    -> AC altitude MSL in meters
               acdata.ralt   -> AC radar altimeter altitude in meters
               acdata.beta   -> AC sideslip angle [rad, unless DEG is set]

             Note: 1) Lat, Lon and Alt are extracted from the variables
                      indicated in the AC data file global attribute 
                      'coordinates'; if 'coordinates' or the indicated var.
                      does not exists the default variables are used
                   2) If any of the non-critical data (e.g., attitude rate) is
                      not available, -1 is recorded


 SIDE EFFECTS:

 NOTES:
       KingAir netCDF files follow the NCAR-RAF/nimbus convention.  This
       convention requires that the time dimension, 'time' (unlimited or not),
       is the first (last for idl, which uses fortran/row order) and the next
       dimension, if exists, is always samples per second, 'sps'.

       Acdata.time time vector is extracted from time(time) variable and
       represents seconds since 00:00:00 Jan 1 1970. If sps is greater than 1
       acdata.time is resampled to match sps. If time variable does not exist
       it is  assembled from two variables:
       'base_time' - seconds since 00:00:00 Jan 1 1970,
       'time_offset' - seconds since base_time, a sequence w/ 1 sec step;
       both, 'base_time' and 'time_offset' are obsolete and may not be
       recorded in the AC files in the future. 

       This routine loads the requested variables with the 'sps' dimension,
       if exists, merged with the 'time' dimension.  Thus the output always
       has only one time dimension.

       If startt and stopt are given netcdf variables are extracted within the
       specified time. If stopt is not defined the variables are read untill
       the end of the file.  And if both, startt and stopt are not defined or
       are invalid the complete data set for the variables are read.

       ________________________________________

       Default KA (N2UW) netcdf variable names:
       ________________________________________

       Time

         'time'

       True Air Sppeed

         'TASX' or 'tas'

       Attitude angles and their rates

         roll -> 'hroll',    (kfroll);    roll rate  ->'hrollr'
         pitch -> 'hpitch',  (kfpitch);   pitch rate ->'hpitchr'
         heading -> 'hthead',(kfthead);   yaw rate   ->'hyawr'

       Attitude vars have attribute 'units' with values 'deg', 'rad', 'deg/sec'
       or 'rad/sec'.  All variables are converted according to deg keyword

       AC ground velocity and its GPS correction (not applied to acvel)

         E-W vel ->  'hewvel',(kfewvel); E-W GPS vel correction ->  'uerr'('')
         N-S vel ->  'hnsvel',(kfnsvel); N-S GPS vel correction ->  'verr'('')

       Vertical velocity

         'hwp3'   - use baro-loop output  (kfzvel)
                    other possible vars are
                         'hivs' - use direct ins output or
                         'wnb'  - use UW adaptive filter

       AC derived wind

         'hu'  ; East component      (kfuwind  - from GPS Kalman processing)
         'hv'  ; North component     (kfvwind  - from GPS Kalman processing)
         'hw'  ; vertical component  (kfwwind  - from GPS Kalman processing)

       AC LAT and LON position

         'LAT', GPS-Corrected Inertial Latitude  (kflat-from GPS Kalman processing)
                    other possible variable:
                       'GLAT'- GPS Latitude or 'LATC' - GPS corrected LAT
         'LON', GPS-Corrected Inertial Longitude (kflon-from GPS Kalman processing)
                    other possible variable:
                       'GLON'- GPS Longitude or 'LONC' - GPS corrected LON
          which var is used is determined by the 'coordinates' global attribute

       AC pressure altitude
         'PALT'  - pressure altitude in meters (default)
            or
         'ztrue' - hydrostatic corrected pressure altitude in meters
            or 
         other variable, as determined by the 'coordinates' global attribute

       AC geometric altitude
         'ralt2' - radar altimeter altitude in meters (before Nov 2005)
         'ralt3' - radar altimeter altitude in meters

       AC side slip angle

         'beta' - side slip angle in deg or rad

       Radar mirror position is extracted from 25th bit of lo_events

       __________________________________________________

       Default NCAR C-130 (N130AR) netcdf variable names:
       __________________________________________________

       Time

         'Time'

       True Air Speed

        'TASX' or 'TASHC'

       Attitude angles and their rates

         roll -> 'ROLL',     roll rate  -> 'BROLLR'
         pitch -> 'PITCH',   pitch rate -> 'BPITCHR'
         heading -> 'THDG',  yaw rate   -> 'BYAWR'

       Attitude vars have attribute 'units' with values 'deg', 'rad', 'deg/sec'
       or 'rad/sec'.  All variables are converted according to deg keyword

       AC ground velocity

         'VEWC', East ground velocity (GPS corrected)
                 other possible variables:
                 'GVEW', East ground velocity (GPS) or
                 'VEW',  East ground velocity (INS) or

         'VNSC', North ground velocity (GPS corrected)
                 other possible variables:
                 'GVNS', North ground velocity (GPS) or
                 'VNS',  North ground velocity (INS) or

       Vertical velocity

         'VSPD', baro-loop IRS vertical speed
                 other possible variables:
                 'WP3',  Vertical Speed (post-processed with inertial baro-loop)

       AC wind

         'UIC', East component (GPS corrected)
                other possible variable:
                'UI',  East component

         'VIC', North component (GPS corrected)
                other possible variable:
                'VI',  North component

         'WIC', vertical component (GPS corrected)
                other possible variable:
                'WI',  vertical component

       AC LAT and LON position

         'LATC', GPS-Corrected Inertial Latitude
                 other possible variable:
                 'GLAT', GPS Latitude
         'LONC', GPS-Corrected Inertial Longitude
                 other possible variable:
                 'GLON', GPS Longitude
          which var is used is determined by the 'coordinates' global attribute

       AC altitude

         'PALT', 'GGALT', 'ALTX'
            or 
         other variable, as determined by the 'coordinates' global attribute

       AC geometric altitude

         'HGM232' - radar altimeter altitude in meters

       AC side slip angle

         'SSLIP' - side slip angle in deg or rad
       _________________________________

       All variable units are defined in attribute 'units' and should be
       'm/s' for velocity vars, and 'rad', 'deg', /rad/sec', or 'deg/sec' for
       attitude variables.

 EXAMPLES:

(See /tools/idl/wcrtools/acloadins.pro)


ACLOADNC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       ACLOADNC

 PURPOSE:
       Returns KingAir or NCAR C130 aircraft data variable from a netCDF file.
       There is only one time dimension in the returned variable.  
       See the notes.  

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       result=acloadnc(Cdfid,varname [,filename],close=close,sps=sps, $
              startt=startt,stopt=stopt,stime=stime,help=help)

 INPUTS:
       Cdfid:    netCDF file ID, returned from a previous call to 
                 ncdf_open, ncdf_create, ncdf_varload or ncdf_fcopy
       Varname:  string, netCDF variable name
                 ATTN: See STIME keyword and NOTES/EXAMPLES on how to load
                 the time vector
       Filename: string, optional netCDF file name; if given will open netCDF 
                 file first. In this case Cdfid is an output parameter

 KEYWORD PARAMETERS:
       CLOSE:  when set AC netcdf file will be closed.
       SPS:    output, integer; samples per second for the loaded variable
               input, integer; samples per second for the time variable only,
                      requires STIME keyword to be set (time variable does not
                      have sps dimension and SPS as input can be used to
                      resample time to include fractional seconds)
       STARTT: input, long, start time in hhmmss
       STOPT:  input, long, stop time in hhmmss including last second record
       STIME:  input, when set identifies varname as a time variable; this is
                      needed if 'base_time' and 'time_offset' variables are
                      used (for both N2UW and N130AR) or time in unix seconds
                      is desired from N130AR data, given the current definition
                      of N130AR netcdf file 'Time' variable (for more see NOTES
                      and EXAMPLES)

       HELP:   shows this text

 OUTPUTS:
       Cdfid:  netCDF file ID (if defined), if filename given or returned from
               a previous call to ncdf_open, ncdf_create, ncdf_varload, 
               ncdf_fcopy or other routine

 SIDE EFFECTS:
       The function returns -1 if the variable is not found or an empty string
       if the usage is incorrect.
       Variables cannot have more than 4 dimensions.

 NOTES:
       KingAir netCDF files follow the NCAR-RAF/nimbus convention.  This
       convention requires that the time dimension, 'time' (unlimited or not), 
       is the first (last for idl, which uses column/fortran order) and the 
       next dimension, if exists, is always samples per second, 'sps'.

       This function returns the requested variable with the 'sps' dimension,
       when exists, merged with the 'time' dimension.  Thus the output always
       has only one time dimension and is sampled at the rate that can be 
       extracted using the SPS keyword

       If startt and stopt are given netcdf variable is extracted within the
       specified time. If stopt is not defined the variable is read untill
       the end of the file.  And if both, startt and stopt are not defined or
       are invalid the complete data set for the variable is read.
       
       Loading a time variable:
         The following basic time variables are available from the UWKA and
         the NCAR C130 data files:
           base_time   - recording start time in unix seconds (obsolete after
                         2007 and may be removed in the future)
           time_offset - long array of whole seconds from base_time (obsolete)
           time        - long array of unix seconds (UWKA only)
           Time        - same as time_offset (NCAR C130 only)
         See the examples below on how to get time in unix seconds from 
         base_time and time_offset or from Time (NCAR C130 only)
        
       It is expected that the N2UW 'time' format is UNIX seconds (this may
       change in the future), and the N130AR 'Time' format is whole seconds 
       (long integer) starting from 0.
       For N130AR 'Time' variable, 'units' attribute is expected in the the 
       following format: 'seconds since 20YY-MM-DD HH:MM:SS +0000'
        
 EXAMPLES:

      1) The following example assumes that a netcdf file was previously opened,
         hroll variable exists and 121915/122252 is a legitimate time (hhmmss)
         subinterval.

         roll=acloadnc(ncid,'hroll',sps=sps,start=121915,stop=122252)

         Note that sps is an output in this call and any input value for sps
         would be ignored.
      
      2) Read the default time var for the whole data file. If 'time' does not 
         exist the routine will make attempt to assemble time from 'base_time'
         and 'time_offset'. Note that the output inlcudes whole seconds only.

         time=acloadnc(ncid,'',/stime) 
         time=acloadnc(ncid,'time')  ; the same as above but if 'time' does
                                       not exist the routine will return -1

      3) As 2) but resample time to include fractional seconds based on sps

         time=acloadnc(ncid,'time',sps=25,/stime)  
         time=acloadnc(ncid,'time',sps=25) ; no resampling, sps input ignored

      4) Load 'Time' from NCAR C130 data set (nimbus revision 1.3 or later)

         time=acloadnc(ncid,'',/stime)     ; load time in UNIX seconds starting
                                           ; from the 'units' starting time
         time=acloadnc(ncid,'Time')        ; load time in sec starting from 0.
         time=acloadnc(ncid,'Time',/stime) ; load time in sec; if Time starts
                                           ; from 0 in whole seconds it is
                                           ; converted to UNIX seconds using
                                           ; 'units' attribute

(See /tools/idl/wcrtools/acloadnc.pro)


CLEARWCR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CLEARWCR

 PURPOSE:
       Initilize wcr common blocks, wcrparams and wcrdata

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       CLEARWCR

 INPUTS:

 KEYWORD PARAMETERS:
       HELP:  Show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata 

 SIDE EFFECTS:

 EXAMPLES:

(See /tools/idl/wcrtools/clearwcr.pro)


CLOSEWCRF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       CLOSEWCRF

 PURPOSE:
       Closes WCR file.  If WCRLUN exists takes lun1 as an actual lun
       otherwise uses 31 for lun1

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       CLOSEWCR

 INPUTS:

 KEYWORD PARAMETERS:
      HELP:  Show this text

 OUTPUTS:

 COMMON BLOCKS:

(See /tools/idl/wcrtools/closewcrf.pro)


COMMONWCRINCLUDE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       COMMONWCRINCLUDE

 PURPOSE:
       Set wcr common blocks as include file in other wcrtools routines

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       This is only an include file.  Attempt to run it will return an error.

 COMMON BLOCKS:
       wcrparams, wcrdata 

(See /tools/idl/wcrtools/commonwcrinclude.pro)


COMMONWCRSET

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       COMMONWCRSET

 PURPOSE:
       Set wcr common blocks

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       .run COMMONWCRSET

 COMMON BLOCKS:
       wcrparams, wcrdata 

 NOTES:
       Normally this program runs before any other wcr routine. 
       It is not needed if openwcrm is used or there is no need of access to
       the common block variables

(See /tools/idl/wcrtools/commonwcrset.pro)


H2OMWIR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      H2OMWIR

 PURPOSE:
      Returns complex refraction index of pure water/ice for a given
      microwave frequency in GHz and temperature in degree Celsius

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      m=h2omwir(freq,temperature,ice=ice,kflag=kflag); m=n'-j*n"

 INPUTS:
      Freq:         float/double, radio frequency in GHz (default 94.92GHz)
      Temperature:  float, water temperature in degree Celsius (default  0C)

 KEYWORD PARAMETERS:
      ICE:    if set, the function returns refraction index for ice
              for temperatures <= 0 deg C
      KFLAG:  input ,byte flag determining the return quantity(ies) 
                1 - the function returns m (default)
                2 - the function returns K=(m^2-1)/(m^2+2)
                3 - the function returns [m,K]
                4 - the function returns |K|^2=abs((m^2-1)/(m^2+2))^2
      HELP:   show this text

 SIDE EFFECTS:
      The function returns an empty string if the usage is incorrect
      If no input parameters are given the refraction index of
      water or ice for 0 degree and 94.92GHz is returned.

      The return is in double precision even though the approximations
      do not provide double precision accuracy. This is to maintain 
      double precision for other calculations.

 PROCEDURE:
      For water:
        [1] Ulaby,Moore,Fung, Microwave Remote Sensing, v.1, 1981, pp.298-303
            and v.3, 1986, pp.2020-2021 
      For ice:
        [2] Radiative Transfer Models for Microwave Radiometry, Ed. C.Matzler,
            IEE Press (expected to be published in 2005)
            Improved approximation equations(in comparison to the ones in [3])
            discussed in [2, Ch.5.3] were provided by C.Matzler in private
            communication.
        [3] Liebe H.,T.Manabe,G.Hufford, Millimeter-Wave Attenuation and
            Delay rates Due to Fog/Cloud Conditions, IEEE Trans.on Antennas
            and Propagation, v.37, 1989, p.1618

      The approximations used for pure water and ice from the above references
      give somewhat different results than the ones reported by Lhermitte (IEEE
      Trans.on Geoscience and Remote Sensing, v.26,1988, p.211)

 EXAMPLES:

(See /tools/idl/wcrtools/h2omwri.pro)


KAWCRMIRROR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      KAWCRMIRROR

 PURPOSE:
      Returns time array for the KA (N2UW) radar wing mirror position 
      (0-side, 1-up, single antenna configuration)

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
   res=kawcrmirror(ncf)
   res=kawcrmirror(ncf,timem=timem,sps=sps,startt=startt,stopt=stopt, $
                    date=fdate,leapsec=leapsec)

 INPUTS:
      Ncf:  string, KA processed data netcdf file name or
            long, netcdf file id

 KEYWORD PARAMETERS:
      SPS:     input, KA variable sampling rate (default 1); use with timem=0
               (e.g., sps=25 will force 25 Hz sampling of the function return) 
      STARTT:  input, start time in hhmmss (default, the beginning of the file)
               (can be coded as hhmmss.1, see timem)
      STOPT:   input, stop time in hhmmss (default, the end of the file)
      TIMEM:   1, kawcrmirror returns fltarr(n,3): n - number of mirror changes
                  res[*,0] - start times, hhmmss
                  res[*,1] - stop times, hhmmss
                  res[*,2] - mirror position (0-side, 1-up)
               0, kawcrmirror returns intarr(ntime*sps) w/ 
                  radar position(default) (ntime - number of seconds)
               fltarr(ntime), netcdf var TIME (previously read)
                  will skip reading TIME netcdf var and is equivalent to
                  input 1 if startt=hhmmss or input 0 if startt=hhmmss.1  
      DATE:    output, string, KA flight date YYYYMMDD
      LEAPSEC: output, long, loads leap seconds from KA data file
      HELP:    show this text

 OUTPUT
      Ncf:  long, netcdf file id  (if the input Ncf was a netcdf file name)

 SIDE EFFECTS:
      Require netcdf file for the KA data.
      Mirror position must be the 25th bit in var 'lo_events' (1Hz rate only)
      Time in hhmmss is read from netcdf var 'TIME'
      Flight date is read from var 'FlightDate'
      The function returns -1 if startt and/or stopt are not within TIME
      and an empty string if the usage is incorrect

(See /tools/idl/wcrtools/kawcrmirror.pro)


KAWCRMIRRORPRINT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     KAWCRMIRRORPRINT

 PURPOSE:
     Create an ascii file containing times of radar mirror position changes
     for a given flight

 CATEGORY:
     wcrtools

 CALLING SEQUENCE:
     KAWCRMIRRORPRINT, Ncf

 INPUTS:
     Ncf:  KA processed data netcdf file name

 KEYWORD PARAMETERS:
     HELP: show this text

 OUTPUTS:

 SIDE EFFECTS:
     Create file  

(See /tools/idl/wcrtools/kawcrmirrorprint.pro)


KAWCRREFORM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       KAWCRREFORM

 PURPOSE:
       Reforms a WCR variable from a merged KA/WCR netcdf file by merging
       'profile' and 'time' dimensions.
       The resultant array has one less dimension and the 'time' is a new 
       dimension which represents all profiles. This new time dimension is
       not regularly spaced. 

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       result=kawcrreform(ncid,varname [,filename],startt=startt,stopt=stopt)

 INPUTS:
       ncid:     netCDF variable ID, returned from a previous call to 
                 ncdf_open, ncdf_create, ncdf_varload or ncdf_fcopy
       Varname:  string, netCDF variable name
       Filename: string, optional netCDF file name; if given will open netCDF 
                 file first. In this case ncid is an output var

 KEYWORD PARAMETERS:
       STARTT:   input, long, start time in hhmmss; (default is base_time,
                   see Notes); if beyond the time interval of the file, starts
                   from the biginning
       STOPT:    input, long, stop time in hhmmss (see Notes); (default is the
                   end if the file time, see Notes); if beyond the time interval 
                   of the file, use the default end of the file time
       HELP:     show this text ( use print,kawcrreform(/help) )

 OUTPUTS:
       ncid:     netCDF variable ID, returned if Filename is given

 SIDE EFFECTS:
       The function returns an empty string if the usage is incorrect or 
       -1 if the variable is not found or
       -2 if var 'profiles' does not exist or
       -3 if 'base_time' and/or 'time_offset' do not exist.
       -4 if STARTT and STOPT are not valid for this file
       -5 if varname has more than 3 dimensions

 NOTES:
       This routine assumes that there is a dimension called 'profile'
       (representing the max. profiles in a second) in the netCDF file as well
       as variable 'profiles' with the actual number of radar profiles
       for each second.

       varname netcdf variable can have no more than 3 dimesnions
       and time dimension is always the last one

       The data are read from KA/WCR merged netcdf file without any checkings
       and modifications.

       The use of STARTT and STOPT requires the existence of netcdf variables
       'base_time' and 'time_offset', where base_time is the start time of the
       data in the file given in seconds after 00:00:00 Jan 1, 1970 and 
       time_offset is offset in seconds from base_time.

 EXAMPLES:

       hh=kawcrreform(ncid,'hh')

       This will load hh(range,profile,time) and reform to hh(range,new_time)
       where new_time_size=n_elements(time)*total(profiles)

(See /tools/idl/wcrtools/kawcrreform.pro)


OPENWCRF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       OPENWCRF

 PURPOSE:
       Open SPPMAG, PPMAG4, PPMAG6 or FFT WCR file and load several
       radar/data parameters (see showwcrprms)

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       OPENWCRF, Fn, Data

 INPUTS:
       Fn:      string, wcr file name

 KEYWORD PARAMETERS:
       ACSPEED:       input, float; average aircraft speed in m/s (default 90.)
       WCRLUN:        lun, default is 31
       TIMECOR:       if defined gives UTC time correction of the wcr time
                      After June 1998, IRIG card is used to set the time.
                      Normal use of the card is to get the time from a master
                      IRIG card with GPS time.  Thus the default value is 
                      -15 s, which are the current leap seconds (Jan 2009)
       BIG_ENDIAN:    when set, assumes that the file data are in big endian
                      order.  The default is LITTLE_ENDIAN (after Mar 2001) and
                      For data before Mar 2002 it is ignored.  
       HELP:  Show this text

 OUTPUTS:
       Data:    wcr file structure
       WcrFlag:  wcrflag[0] - file size doesn't match 
                              (data file did not close properly)
                 wcrflag[1] - # of bad profiles at the file end
                 wcrflag[2] - WCR computer date and timestamps date don't match
                              or IRIG connection/data was lost/corrupted

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:
       radar parameters loaded in wcrparams common block (see showwcrprms)
       radrng[rangegates] and velo[fftbins] are loaded in wcrdata by this 
       routine

(See /tools/idl/wcrtools/openwcrf.pro)


OPENWCRM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       OPENWCRM

 PURPOSE:
       Main program that sets common wcr blocks and open a wcr file
       It assumes logical unit (lun) 31 and default GPS time correction
       (to see default leap seconds, check tcorrection after opening a file)
       If different setting is needed run directly openwcrf with desired
       parameters.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       .run OPENWCRM

 COMMON BLOCKS:
       wcrparams, wcrdata 

(See /tools/idl/wcrtools/openwcrm.pro)


PLOTWCRCALM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PLOTWCRCALM

 PURPOSE:
       Make calibration/test plots for data or corner reflector

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       PLOTWCRCALM,dir
 
 INPUTS:
         Dir: string, wcr file directory to process all wcr files; must end
                with directory separator (/); if undefined use pickfile to
                acquire the data directory;
              'select': use pickfile with an option to select desired file(s)
              strarr(n), full path and names for n files to be processed

 KEYWORD PARAMETERS:
        CRmax: output, fltarr(2,n), max returns in dBm for H- and V-ch
       CRmean: output, fltarr(2,n), mean returns in dBm for the range
               gate where the max values (CRmax) occur 
       FILEID: string, file search string (default '*20??-??-??-*')
         HCOR: when set correct h channel w.r.t. v channel using 0.95 slope
         VCOR: when set correct v channel w.r.t. v channel using default vals
   BIG_ENDIAN: when set, assumes that the input file data are in big endian
               order.  The default is LITTLE_ENDIAN.
      INDJUMP: input string
               'all'  - uses all profiles (default)
               'even' - uses even profiles for calplot and stat
               'odd'  - uses odd profiles for calplot and stat
     NOSAVEPS: when set does not save the ps files(ignored if plotps not set)
       PLOTPS: when set creates a ps file,(default is x device)
               2 creates a ps file and skip cross-channel plots for ppmag
               -1 uses x device and skip cross-channel plots for ppmag 
      PRINTER: printer name (e.g.,'lj5local','lj4_gv','qms')
               '': suppress printing (default)
        PSDIR: string, directory for postscript file(s)
               Default save ps files in subdir 'ps/', which is created
               if non-existant.  When dir='select', ps directory is always
               sub directory of the home directory, otherwise it is sub
               of dir
      TIMECOR: if defined gives UTC time correction of the wcr time
               After June 1998, IRIG card is used to set the time.
               Normal use of the card is to get the time from a master
               IRIG card with GPS time.  The default value is set to
               the leap seconds in openwcrf. 
       TLABEL: string, page title at the bottom of the page
               undefined - Experiment .... / Data
               'cr' - will add Corner Reflector to the label
               '' - prompt for a label
               strarr(2), 1st string 'cr' or '', 2nd string: additonal text
                          to be added before tlabel[0]
               strarr(n), titles for each file to be processed
                          (used usually for calibration titles)     
         HELP: Show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:
       four plots + three plots (2 pages)

 EXAMPLES:
       Corner Reflector calibration plot

       dir     = '/orel3/data99/cs99/'+d+'/'
       psdir   = dir+d+'ps/'
       fileid  = 'pp01-'
       printer = 'lj5local'
       tlabel  = "Coastal II '99 Data"
       hcor    = 0
       plotwcrcalm,dir,pri=printer,/plotps,fil=fileid,ind='all', $
                   tlabel=['cr',tlabel],psdir=psdir,hcor=hcor

(See /tools/idl/wcrtools/plotwcrcalm.pro)


PLOTWCRCALM1

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PLOTWCRCALM1

 PURPOSE:
       Make isolation plots (plotwcrcocr) only

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       PLOTWCRCALM1,dir

 INPUTS:
          Dir: string, wcr file directory to process all wcr files
               undefined: use pickfile
               'select': use pickfile with an option to select file(s)
                         full path and name; process the given wcr file(s)

 KEYWORD PARAMETERS:
        PSDIR: string, directory for postscript file(s)
               Default save ps files in subdir 'ps/', which is created
               if non-existant.  When dir='select', ps directory is always
               sub directory of the home directory, otherwise it is sub
                 of dir
      PRINTER: printer name (e.g.,'lj5local')
               '': suppress printing (default)
       TLABEL: string, page title at the bottom of the page
               undefined - Experiment .... / Data
               'cr' - will print Experiment ... /Corner Reflector
               '' - prompt for a label
               strarr(2), 1st string as above, 2nd string is appended
         HCOR: when set correct h channel w.r.t. v channel using 0.95 slope
         VCOR: when set correct v channel w.r.t. v channel using default vals
       PLOTPS: when set creates ps files (default is x device)
     NOSAVEPS: when set does not save the ps files(ignored if plotps not set)
      INDJUMP: input string
               'all'  - uses all profiles (default)
               'even' - uses even profiles for calplot and stat
               'odd'  - uses odd profiles for calplot and stat

       FILEID: identification string for wcr file: '200' (default)
       TIMECOR: if defined gives UTC time correction of the wcr time
                After June 1998, IRIG card is used to set the time.
                Normal use of the card is to get the time from a master
                IRIG card with GPS time.  The default value is set to
                the leap seconds in openwcrf. 
    BIG_ENDIAN: when set, assumes that the input file data are in big endian
                order.  The default is LITTLE_ENDIAN.
         HELP: Show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:
       three plots
       does not handle FFT wcr files

 EXAMPLES:
       Corner Reflector calibration plot ("isolation", gain imbalance plots)

       dir     = '/orel3/data99/cs99/'+d+'/'
       psdir   = dir+d+'ps/'
       fileid  = 'pp01-'
       printer = 'lj5local'
       tlabel  = "Coastal II '99 Data"
       hcor    = 0
       plotwcrcalm1,dir,pri=printer,/plotps,fil=fileid,ind='all', $
                tlabel=['cr',tlabel],psdir=psdir,hcor=hcor,vcor=vcor

(See /tools/idl/wcrtools/plotwcrcalm1.pro)


PLOTWCRCOCR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PLOTWCRCOCR

 PURPOSE:
       This program uses calibration data already in the common block to plot
       hh/vv, vh/hh, hv/vv. This program is normally used by running 
       plotwcrtestm, plotwcrcalm, plotwcrcalm1 or plotwcrcrm.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       PLOTWCRCOCR

 INPUTS:

 KEYWORD PARAMETERS:
       SMOOTH:   number of smoothing points (0, default)
       ZOOM:     input array [ readmode, str, stp ]
                 readmode: 0  - str/stp, start/stop record numbers
                           1  - str/stp, start/stop profile numbers
                           2  - str/stp, start/stop UTC in hhmmss
       INDJUMP:  input string
                 'all'  - uses even and odd profiles (default)
                 'even' - uses even profiles only
                 'odd'  - uses odd profiles only
       RANGE:    input array [begin_rg, end_rg], (default [3,rangegates-1])
       PPMAG:    when set works for ppmag files only
       PLOTFLAG: output status, 0 - ok
                                1 - no plots produced 
       HELP:     show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata 

 SIDE EFFECTS:
       three plots
       This routine works with PPMAG and SPPMAG.  In plotwcrnoise.pro vh/hh or
       hv/hh is plotted for sppmag.  Thus to avoid doublication when both,
       plotwcrnoise and plotwcrcocr are used, set the ppmag keyword

 EXAMPLES:

(See /tools/idl/wcrtools/plotwcrcocr.pro)


PLOTWCRCR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PLOTWCRCR

 PURPOSE:
       This program uses corner reflector power measurements already in the 
       common block to plot hh, vv, hv, vh at the range gate of maximum
       reflection. This program is normally used by running plotwcrcalm,  
       plotwcrcalm1 or plotwcrcrm.

       This routine is inteded for CR calibration files only (after 1999)

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       PLOTWCRCR,firstrg,lastrg

 INPUTS:
       Firstrg:  first range gate in meters for the expected
                 location of the corner reflector (default, 100 m)
       Lastrg:   last range gate in meters for the expected
                 location of the corner reflector (default, 300 m)

 KEYWORD PARAMETERS:
       CRmax:   output, [CRmaxH,CRmaxV], max returns in dBm for H- and V-ch
       CRmean:  output, [CRmeanH,CRmeanV], mean returns in dBm for the range
                gate where the max values (CRmax) occur 
       SMOOTH:  number of smoothing points (0, default)
       ZOOM:    input array [ readmode, str, stp ]
                readmode: 0  - str/stp, start/stop record numbers
                          1  - str/stp, start/stop profile numbers
                          2  - str/stp, start/stop UTC in hhmmss
       HELP:    show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata 

 SIDE EFFECTS:
       two plots

 EXAMPLES:

(See /tools/idl/wcrtools/plotwcrcr.pro)


PLOTWCRCRM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PLOTWCRCRM

 PURPOSE:
       Make calibration/test plots for data or corner reflector 
       using a single wcr file or data in the common blocks

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       PLOTWCRCRM

 INPUTS:

 KEYWORD PARAMETERS:
       HCOR:    when set correct h channel w.r.t. v channel using 0.95 slope  
       VCOR:    when set correct v channel w.r.t. v channel using default vals 
       INDJUMP: input string
                'all'  - uses even and odd profiles (default)
                'even' - uses even profiles only
                'odd'  - uses odd profiles only
       NOSAVEPS:when set does not save the ps files(ignored if plotps not set) 
       PLOTPS:  when set creates a ps file,(default is x device)
                2 creates a ps file and skip cross-channel plots for ppmag
                -1 uses x device and skip cross-channel plots for ppmag 
       PRINTER: string for the printer (e.g., 'lj5local');
                printer='' will supress printing (default)
       RANGE:   [firstrg, lastrg], search between firstrg  and lastrg range
                gates  in meters for the return from the corner reflector 
                (default [120,350])
       READWCR: when set reads data from common block otherwise from a file
                (default, 0)
       SETXWIN: set window manager (default, 0)
       SMOOTH:  number of smoothing points (0, default)
                when input [sm1,sm2] performes corresponding different 
                smoothings for calplot (noise and cal signal) and calcrplot
                (received signal)
       TIMECOR: if defined gives UTC time correction of the wcr time
                After June 1998, IRIG card is used to set the time.
                Normal use of the card is to get the time from a master
                IRIG card with GPS time.  The default value is set to
                the leap seconds in openwcrf. 
       TLABEL:  string for graphics title (default, 'CORNER REFLECTOR')
       ZOOMPROF:input array [ rmode, str, stp ]
                rmode:    0  - str/stp, start/stop record numbers
                          1  - str/stp, start/stop profile numbers
                          2  - str/stp, start/stop UTC in hhmmss
     BIG_ENDIAN:when set, assumes that the input file data are in big endian
                order.  The default is LITTLE_ENDIAN.
       HELP:    Show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata 

 SIDE EFFECTS:
       four plots + three plots (2 pages)

 EXAMPLES:
       Corner Reflector calibration plot

       .run openwcrm
       readwcrdata,data
       tlabel  = "Coastal II '99 Data/Corner Reflector"
       plotwcrcrm,range=[120,250],pri=printer,plotps=0,ind='all', $
                  tlabel=tlabel,/readwcr,setx=1

(See /tools/idl/wcrtools/plotwcrcrm.pro)


PLOTWCRFFT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PLOTWCRFFT

 PURPOSE:
       This program uses wcr data already in the common block to plot, fftps
       at given range gate, fftTx and fftnoise. This program is normally used 
       by running plotwcrfftm or plotwcrtestm. (fftTx plot has been disabled)

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       PLOTWCRFFT

 INPUTS:

 KEYWORD PARAMETERS:
       PLOTPS:  99 - creates a ps file,(0 to 31 is x device)
       RGATE:   input integer, when given plots corresponding range gate
                default is 10 (0 is the first range gate) 
       SMOOTH:  number of smoothing points (0, default)
                [sm1,sm2], sm1 - vel. smoothing points, sm2 - profile smoothing
       TLABEL:  string, page title at the bottom of the page
                ( default 'Experiment Data')
       ZOOM:    input array [ startvel, stopvel ] for velocity plots only
       PROFILE: when set determines record number to be plotted for vel. plots
                (default is the average of all)
       HELP:    Show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata 

 SIDE EFFECTS:
       two pages w/ 3 plots each

 EXAMPLES:

(See /tools/idl/wcrtools/plotwcrfft.pro)


PLOTWCRFFTM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PLOTWCRFFTM

 PURPOSE:
       Plots fft data for test purposes of a fft wcr file (the file is 
       processed w/o segmentation; use plotwcrtestm for large files)

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       PLOTWCRFFTM

 INPUTS:

 KEYWORD PARAMETERS:
      NOSAVEPS: when set does not save the ps files(ignored if plotps not set) 
        PLOTPS: when set creates a ps file,(default is x device)
       PRINTER: string for the printer, (default, 'lj5local')
                printer='' will supress printing
       READVXI: when set reads data from common block otherwise from a file
                (default, 0)
       RGATE:   input integer, when given plots corresponding range gate
                default is 10 (0 is the first range gate) 
                (default [120,350])
       SETXWIN: set ploting window (default, 0; ignored for ps device)
       SMOOTH:  number of smoothing points (0, default)
       TIMECOR: if defined gives UTC time correction of the wcr time
                After June 1998, IRIG card is used to set the time.
                Normal use of the card is to get the time from a master
                IRIG card with GPS time.  The default value is set to
                the leap seconds in openwcrf. 
        TLABEL: string for graphics title (default, 'Experiment Data')
    BIG_ENDIAN: when set, assumes that the input file data are in big endian
                order.  The default is LITTLE_ENDIAN.
        HELP:   show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata 

 SIDE EFFECTS:
       two plots

 EXAMPLES:
       Corner Reflector calibration plot

       .run openwcrm
       readwcrdata
       tlabel  = "Coastal II '99 Data"
       plotwcrfftm,rgate=15,tlabel=tlabel,/readwcr,setx=1

(See /tools/idl/wcrtools/plotwcrfftm.pro)


PLOTWCRNOISE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PLOTWCRNOISE

 PURPOSE:
       This program uses calibration data already in the common block to plot
       noise and Tx leakage channels and calculate correlation coeffs.
       This program is normally used by running plotwcrcalm,  
       plotwcrcalm1 or plotwcrcrm.

       This routine is inteded for CR calibration files only (after 1999)

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       PLOTWCRNOISE

 INPUTS:

 KEYWORD PARAMETERS:
       SMOOTH:  number of smoothing points (0, default)
       ZOOM:    input array [ readmode, str, stp ]
                readmode: 0  - str/stp, start/stop record numbers
                          1  - str/stp, start/stop profile numbers
                          2  - str/stp, start/stop UTC in hhmmss
       INDJUMP: input string
                'all'  - uses even and odd profiles (default)
                'even' - uses even profiles only
                'odd'  - uses odd profiles only
      HELP:  Show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata 

 SIDE EFFECTS:
       create two plots using the current device (ususally x or ps)

 EXAMPLES:

(See /tools/idl/wcrtools/plotwcrnoise.pro)


PLOTWCRTEST

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PLOTWCRTEST

 PURPOSE:
       This program makes plots of noise, leakage, 0 and last range gate
       data for data quality checks. The data must be already loaded into
       the wcr common block and the time vector has to be in seconds or
       hhmmss. This program works for non-FFT files. For FFT files use 
       plotwcrfftm or plotwcrfft.pro.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       PLOTWCRTEST

 INPUTS:

 KEYWORD PARAMETERS:
       INDJUMP: input string
                'all'  - uses even and odd profiles (default)
                'even' - uses even profiles only
                'odd'  - uses odd profiles only
       LPAGE:   input, integer, leading page number (e.g., 1 in page 1-3)
                (default, no leading number, e.g., page 3)
       NOISO:   when set does not plot co/cross ratios
       NOLEAK:  when set does not plot Tx pulse leakage
       NONOISE: when set does not plot noise channels and time
       NORG:    when set does not plot data for range gates
       RANGEG:  input, intarr of up to 3 elements with range gates
                (default [0,1,rangegates-1])
       SETWIN:  input integer, X window display (0-31) (default is 0)
                99 - postscript device
       SMOOTH:  number of smoothing points (0, default)
       TLABEL:  string, page title at the bottom of the page
                ( default 'Experiment Data')
       ZOOM:    input array [ readmode, str, stp ]
                readmode: 0  - str/stp, start/stop record numbers
                          1  - str/stp, start/stop profile numbers
                          2  - str/stp, start/stop UTC in hhmmss
       HELP:    show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:
       Creates plots using the current graphics device (usually x or ps)
       Time vector is allowed in two formats:  seconds or hhmmss.dd

 EXAMPLES:

(See /tools/idl/wcrtools/plotwcrtest.pro)


PLOTWCRTESTM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PLOTWCRTESTM

 PURPOSE:
       Make test plots for multiple file data

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       PLOTWCRTESTM,dfsel

 INPUTS:
       Dfsel: string, wcr file directory to process all wcr files; must end
                with directory separator (/); if undefined use pickfile to
                acquire the data directory;
              string, full path and name for a wcr file to be processed;
              'select': use pickfile with an option to select desired file(s)
              strarr(n), full path and names for n files to be processed

 KEYWORD PARAMETERS:
      FILEID:   string, file search string (default '*20??-??-??-*')
      INDJUMP:  input string
                'all'  - uses even and odd profiles (default)
                'even' - uses even profiles only
                'odd'  - uses odd profiles only
      HCOR:     when set correct h channel w.r.t. v channel using 0.95 slope
      VCOR:     when set correct v channel w.r.t. v channel using default vals
      NOISO:    when set does not plot co/cross ratios
      NOLEAK:   when set does not plot Tx pulse leakage
      NONOISE:  when set does not plot noise channels
      NORG:     when set does not plot data for range gates
      RANGEG:   input, intarr of up to 3 elements with range gates
                (default [0,1,rangegates-1])
      SMOOTH:   number of smoothing points (0, default)
      TIMECOR:  if defined gives UTC time correction of the wcr time
                After June 1998, IRIG card is used to set the time.
                Normal use of the card is to get the time from a master
                IRIG card with GPS time.  The default value is set to
                the leap seconds in openwcrf. 
      TLABEL:   string, page title at the bottom of the page
                default (undefined): 'Experiment Data'
                '' - prompt for an input title
      ZOOM:     input array [ readmode, str, stp ]
                readmode: 0  - str/stp, start/stop record numbers
                          1  - str/stp, start/stop profile numbers
                          2  - str/stp, start/stop UTC in hhmmss

      NOSAVEPS: when set does not save the ps files(ignored if plotps not set)
      PLOTPS:   when set creates ps files (default is x device)
      PRINTER:  printer name (e.g.,'lj5local')
                '': suppress printing (default)
      PSDIR:    string, directory for postscript file(s)
                Default save ps files in subdir 'ps/', which is created
                if non-existent.  ps directory is sub directory of dfsel
    BIG_ENDIAN: when set, assumes that the input file data are in big endian
                order.  The default is LITTLE_ENDIAN.
      HELP:     Show this text

 OUTPUTS:
       Dfsel:   strarr(n), full path and file name of the n processed files
                when dfsel='select' as an input

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:
       plot 3 pages

 EXAMPLES:
       Corner Reflector calibration plot

       dir     = '/orel3/data99/cs99/'+d+'/'
       psdir   = dir+d+'ps/'
       fileid  = 'pp01-'
       printer = 'lj5local'
       tlabel  = "Coastal II '99 Data"
       hcor    = 0
       plotwcrtestm,dir,pri=printer,/plotps,fil=fileid,ind='all', $
                    tlabel=tlabel,psdir=psdir

(See /tools/idl/wcrtools/plotwcrtestm.pro)


PRINTWCRPRMS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PRINTWCRPRMS

 PURPOSE:
       Prints radar parameters for a given data file
        - file name and algorithm
        - start/stop time, duration
        - approx. time series length and sampling interval in seconds
        - time correction if any and DSPs clock difference statistics
        - profs per second statistics, ignoring first and last second
        - profiles/time-segment loaded
        - data rate in KB/s
        - data flags [1,999,1]: file size doesn't match,
                              # of bad profiles at the file end ,
                              WCR computer date and timestamps date don't match
                              or IRIG connection/data was lost/corrupted 
        - Tx pulse width, IF filter, pulse pair sequence
        - Tx pulses polarization, prf
        - range gate delay, range resolution, # range gates
        - # averaged pulses
        - range-to-profile (R/P) aspect ratio for 90 m/s A/C speed
        - interrupt (data off) profile numbers or # of interrupts 
          (for mode=2 only); interrupts were elliminated after 1998
        - max. velocity and vel. resolution (FFT only), fftwindow used

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       PRINTWCRPRMS,Mode,Inprm

 INPUTS:
       Mode:   0 : displays the information 
               1 : saves the info in ascii file
               2 : prints WCR params. at a given position (normal units)
                   using the current device 
       Inprm:  for mode = 0  - ignore
                          1  - string, file name
                          2  - fltarr(3), paper position in normal units and
                               charsize; [0.15,0.15,0.85] default
 KEYWORD PARAMETERS:
       PROFSTAT: output, lonarr(n), returns an array with the number of 
                 profiles per each whole second of time.  If time array is not
                 available (data were not read, readwcrdata) returns -999
       HELP:     Show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata 

 SIDE EFFECTS:

 EXAMPLES:

(See /tools/idl/wcrtools/printwcrprms.pro)


PRINTWCRSTAMP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PRINTWCRSTAMP

 PURPOSE:
       Print wcrfile parameters and statistics at the bottom of a page.
       Print a date stamp at the upper left corner of a page.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       PRINTWCRSTAMP, Tlabel

 INPUTS:
       TLABEL: title text (default is none)

 KEYWORD PARAMETERS:
       MODE:    0 : displays the information 
                1 : saves the info in ascii file
                2 : prints WCR params. at a given position (normal units)
                    using the current device (default)
       PAGE:    page number (could be number or string, e.g., 1 or '1-1')

       INDJUMP: 'all'  - uses even and odd profiles (default)               
                'even' - uses even profiles only
                'odd'  - uses odd profiles only

       RANGE:   [begin_rg, end_rg], (default [3,rangegates-1])
                range gate zoom for co/cross channel statistics

       STATTEXT: string array with stat information.  Works only with mode 2.
       HELP:  Show this text

 OUTPUTS:

 COMMON BLOCKS:

 SIDE EFFECTS:
       print/plot radar information 

(See /tools/idl/wcrtools/printwcrstamp.pro)


PRINTWCRSTAT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       PRINTWCRSTAT

 PURPOSE:
       Prints min, max, mean, std (in dBm) and varc=std/mean (%) for noise,
       internal calibration measurements, hh/vv, cross_ch/co_ch and DSP jumps
       in the noise channels of a given data file.  
       Note: Internal calibration stat is disabled.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       PRINTWCRSTAT, Mode, Inprm

 INPUTS:
       Mode:    0 : displays the information 
                1 : saves the info in ascii file
                2 : prints WCR params. at a given position (normal units)
                    using the current device 
       Inprm:   for mode = 0  - ignore
                           1  - string, output file name, default is the
                                first 11 chars from wcrfile plus '.stat'
                                this mode is intended for multiple file proc.
                           2  - fltarr(3), paper position in normal units and
                                charsize; [0.45,0.15,0.85] default

 KEYWORD PARAMETERS:
       INDJUMP: 'all'  - uses even and odd profiles (default)               
                'even' - uses even profiles only
                'odd'  - uses odd profiles only

       RANGE:    [begin_rg, end_rg], (default [3,rangegates-1])
                 range gate zoom for co/cross channel statistics

       STATTEXT: string array with stat information.  Works only with mode 2.
       HELP:     show this text

 OUTPUTS:        

 COMMON BLOCKS:
       wcrparams, wcrdata 

 SIDE EFFECTS:
       print radar data statistics to the current device
       if stattext is empty ('') then it is an output string array
       if stattext is not empty printwcrstat prints it to the graphics device  

(See /tools/idl/wcrtools/printwcrstat.pro)


READWCRALL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READWCRALL

 PURPOSE:
       Load into the wcrdata common block all radar data from a WCR file 
       If strt/stp exist loads data according to readmode.
       Note:  Run OPENWCRM program before running this routine.
       This program is obsolete.  Use readwcrdata.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       READWCRALL, Data, Strt, Stp

 INPUTS:
       Data:  wcr file structure
       Strt:  start reading point
              For rmode = 0  -  strt/stp record in the wcr file
                          1  -  input:  strt/stp profile numbers
                                output: strt/stp corresponding wcr file records
                          2  -  input:  strt/stp UTC in hhmmss, long
                                output: strt/stp corresponding wcr file records
       Stp:   stop reading point (see above)

 KEYWORD PARAMETERS:
       TIMEMODE: 1 : [sec,microsec]; lonarr(stp-strt+1) 
                 2 : hhmmss.dd     ; dblarr(stp-strt+1)   
                 3 : sssss.dd      ; dblarr(stp-strt+1) (default)
       READMODE: 0 : reads profs given strt/stp record number(default)
                 1 : reads profiles between strt/stp profile numbers
                 2 : reads profiles within strt/stp UTC    
       HCOR:     when set correct all H-channel data. 
                 Use hcor=-1 to suppress H correction info print
       PPMNOAV:  when set, same pol pulses in the burst are not averaged for
                 PPMAG alg.  The consequence of this is that hh, vv, hv and vh 
                 become 3-D arrays, and hhnoise, vvnoise, 2-D arrays
       BADPROF:  output, array with profile numbers of potentially bad profiles
       CLOSEWCR: when set closes the wcr file using defaull lun=31
                 integer > 1 gives the wcr file lun
     BIG_ENDIAN: when set, assumes that the input file data are in big endian
                 order.  The default is LITTLE_ENDIAN.
       HELP:     show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams 

 SIDE EFFECTS:
       HCOR is ignored for fft wcr files

 EXAMPLES:

(See /tools/idl/wcrtools/readwcrall.pro)


READWCRDATA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READWCRDATA
 
 PURPOSE:
       Load into the wcrdata common block radar data from a WCR file (see 
       showwcrprms). The routine also determines numrec, begtime, endtime,
       basetime, noiseflag, and dspsync.
       
 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       READWCRDATA, Startrec, Stoprec

 INPUTS:
       Startrec:  long, start record (0 to tnumrec-2, default, 0) or
                  long, start time in hhmmss (when timein keyword is set)
       Stoprec:   long, stop record (1 to tnumrec-1, default, tnumrec-1)
                  long, stop time in hhmmss (when timein keyword is set)

 KEYWORD PARAMETERS:
       CLOSEWCR: if set closes the wcr file
       NOCROSS:  when set cross-channel data are not loaded
       FFTP:     when set, calculate returned power and noise power in mW
                 and load them in hh (and/or vv) and hhnoise (and/or vvnoise)
                 (FFT and DPFFT modes only)  
       FILENAME: string, input wcr file name;
                 use 'load' to get a file selction;
                 if not given assumes the file is already open 
       HCOR:     when set correct all H-channel data. 
                 Use hcor=-1 to suppress H correction info print
       NOLEAK:   When set transmitter leakage data are not loaded
       PPMNOAV:  0, all noise measurements for same Rx pulses in the burst are 
                    averaged; if less than the burst size use needed number of
                    noise meas. with the minimum mean (default)
                 1, same ch. pulses in the burst for all data are not averaged.
                    The consequence of this is that hh, vv, hv and vh become 
                    3-D arrays, and hhnoise,vvnoise, hhtx,vvtx,hhlk,vvlk - 2-D
                 For data before July 2004:
                   2, use one (match ch.)pulse noise meas.with the minimum mean
                   3, as 2 for h-ch noise and 0 for v-ch noise
                   4, as 2 for v-ch noise and 0 for h-ch noise
                 Note: after Jul 2004 the ppmnoav=2,3,4 are ignored                
       PPONLY:   when set load pulse pairs data only (does not load co-power,
                 cross-power, noise and leak data channels). Valid for SPPMAG
                 and PPMAG algorithms only. PPMNOAV, NOLEAK, NOCROSS, FFTP, 
                 HCOR and VCOR keywords are ignored
       PPP:      output, fltarr(rangegates,npulse-1,profs); received power 
                 calculated from pulse pairs (see Notes) 
       RAWTIME:  input, integer,load UNIX time
                  -1 - return unix time in the named variable and this is the 
                       only action by the readwcrdata
                 output, dblarr(numrec-1), raw UNIX time (includes fract. secs)
                       rawtime is corrected if tcorrection > 0
       TIMEIN:   when set, inputs are times in hhmmss (see Notes)
       TIMECOR:  float, if given defines UTC time correction (tcorrection).
                 This time correction, if defined, overrides the time  
                 correction used (the default is leap seconds) in openwcrf 
                 After June 1998, IRIG card is used to set the time.
                 Normal use of the card is to get the time from a master
                 IRIG card with GPS time.  Thus the default value is the leap 
                 seconds(to see default leap seconds, check tcorrection after 
                 opening a file).

       TIMEMODE: 2 : hhmmss.dd          ; dblarr(stoprec-startrec+1)
                 3 : sssss.dd           ; seconds starting from 0.dd   
                 4 : sssss.dd  (default); seconds after midnight
                 If tcorrection exists time will be corrected

       VCOR:     when set correct all V-channel data. 
                 Use vcor=-1 to suppress V correction info print
     BIG_ENDIAN: when set, assumes that the file data are in big endian order.
                 The default is LITTLE_ENDIAN. Ignored for data before 03/2002  
       WCRLUN:   lun, default is 31
       HELP:     show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:
       This routine will not work properly with WCR files before 1998

 NOTES:
       When using TIMEIN keyword keep in mind the following possible problem.
       I use the time median interval between wcr profiles to find which 
       portion of the data to read (this is to make it more efficient).
       However there is a KA data system problem during IRIG slewing time  
       which causes time jumps in the wcr IRIG time (not fixed yet, Dec 2000).
       When this jumps are present extracted data may not match the desired 
       time range.

       PPP power represents the product of the returned amplitudes from the 
       pulses forming the pulse pair. 
       For example if Tx pulse sequence is HHVV then:
         ppp[*,0,*]=1/averages*sum(abs(H1)exp(i*angle(H1))*abs(H2)exp(-i*angle(H2)) 
       while returned powers for H1 and H2 are:
         hh[*,0,*]=1/averages*sum(abs(H1)^2)   ; PPMNOAV keyword is set to 1
         hh[*,1.*]=1/averages*sum(abs(H2)^2)
       As you can see PPP is coherently averaged for all the averaged pulse
       pairs while the regular returned power is non-coherently averaged. 
       

(See /tools/idl/wcrtools/readwcrdata.pro)


READWCRFFTSPEC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READWCRFFTSPEC

 PURPOSE:
       Read wcr file fft data between 'strt' and 'stp' profiles

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       READWCRFFTSPEC, Data, Strt, Stp

 INPUTS:
       Data:  wcr file structure
       Strt:  start reading point
              For rmode = 0  -  strt/stp record in the wcr file
                          1  -  input:  strt/stp profile numbers
                                output: strt/stp corresponding wcr file records
                          2  -  input:  strt/stp UTC in hhmmss, long
                                output: strt/stp corresponding wcr file records
       Stp:   stop reading point (see above)

 KEYWORD PARAMETERS:
       BIG_ENDIAN:    when set, assumes that the file data are in big
                      endian order.  The default is LITTLE_ENDIAN.  
       HELP:          Show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata 

 SIDE EFFECTS:
       Load into wcrdata block, fftps: fltarr(fftbins,rangegates,n)

 NOTES:
       1) 'strt' and 'stp' are not necessarily associated with the actual
          profile numbers; just determine the start/stop of the data segment.
          In order to load data for desired start/stop profile set or UTC frame
          use READWCRTB routine first
       2) n=strt-stp+1
       3) fftbins = number of spectral line
       4) common blocks wcrparams and wcrdata must be set first
       5) Raw data are calibrated in Watts instead of mW.  Coorection
          factor of 1000 (30dB) is applied to convert to mW
 
 EXAMPLES:

(See /tools/idl/wcrtools/readwcrfftspec.pro)


READWCRNOISE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READWCRNOISE

 PURPOSE:
       Read wcr file noise and leakage data between 'strt' and 'stp' profs

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       READWCRNOISE, Data, Strt, Stp

 INPUTS:
       Data:  wcr file structure
       Strt:  start reading point
              For rmode = 0  -  strt/stp record in the wcr file
                          1  -  input:  strt/stp profile numbers
                                output: strt/stp corresponding wcr file records
                          2  -  input:  strt/stp UTC in hhmmss, long
                                output: strt/stp corresponding wcr file records
       Stp:   stop reading point (see above)

 KEYWORD PARAMETERS:
       PPMNOAV:     when set, same pol pulses in the burst are not averaged for
                    PPMAG alg.  The consequence of this is that hhnoise,  
                    vvnoise,hhtx, vvtx, hhlk, vvlk become 2-D arrays 
       BIG_ENDIAN:  when set, assumes that the file data are in big
                    endian order.  The default is LITTLE_ENDIAN.  
       HELP:        Show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata 

 SIDE EFFECTS:
       Load into wcrdata block:
       vvnoise    - fltarr(n), V noise measurements
       hhnoise    - fltarr(n), H noise measurements
       vvtx       - fltarr(n), co-leak from V trnsmt pulse (after 1996)
       hhtx       - fltarr(n), co-leak from H trnsmt pulse (after 1996)
       vvlk       - fltarr(n), cross-leak from H trnsmt pulse (after 1996)
       hhlk       - fltarr(n), cross-leak from V trnsmt pulse (after 1996)
       ppnoise    - complexarr(n), pulse pair noise (SPPMAG)
                  - complexarr(3,n), pulse pair noise  (PPMAG4)
                  - complexarr(5,n), pulse pair noise  (PPMAG6)
       pptx       - complexarr(n), pulse pair tx leak (SPPMAG)(DISABLED)
                  - complexarr(3,n), pulse pair tx leak (PPMAG4)(DISABLED)
                  - complexarr(5,n), pulse pair tx leak (PPMAG6)(DISABLED)
       fftnoise   - fltarr(averages,n), noise spectrum
       ffttx      - fltarr(averages,n), tx pulse leak spectrum

 NOTES:
       1) 'strt' and 'stp' are not necessarily associated with the actual
          profile numbers; just determine the start/stop of the data segment.
          In order to load data for desired start/stop profile set or UTC frame
          use READWCRTB routine first
       2) n=strt-stp+1
       3) common blocks wcrparams and wcrdata must be set first
       4) FFT raw data are calibrated in Watts instead of mW.  Coorection
          factor of 1000 (30dB) is applied to convert to mW
 
 EXAMPLES:

(See /tools/idl/wcrtools/readwcrnoise.pro)


READWCRPOWERPP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READWCRPOWERPP

 PURPOSE:
       Read wcr file returned power and pulse pair data from 'strt' to 'stp'

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       READWCRPOWERPP, Data, Strt, Stp

 INPUTS:
       Data:  wcr file structure
       Strt:  start reading point
              For rmode = 0  -  strt/stp record in the wcr file
                          1  -  input:  strt/stp profile numbers
                                output: strt/stp corresponding wcr file records
                          2  -  input:  strt/stp UTC in hhmmss, long
                                output: strt/stp corresponding wcr file records
       Stp:   stop reading point (see above)

 KEYWORD PARAMETERS:
       PPMNOAV:       when set, same pol pulses in the burst are not averaged
                      for PPMAG alg.  The consequence of this is that hh,vv,hv 
                      and vh become 3-D arrays 
       BIG_ENDIAN:    when set, assumes that the file data are in big
                      endian order.  The default is LITTLE_ENDIAN.  
       HELP:          show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata 

 SIDE EFFECTS:
       Load into wcrdata block:
       vv          - fltarr(rangeGates,n), copol V power measurements
       hh          - fltarr(rangeGates,n), copol H power measurements
       vh          - fltarr(rangeGates,n), crosspol V power measurements
       hv          - fltarr(rangeGates,n), crosspol H power measurements
       vh          - fltarr(rangeGates,n), crosspol V power measurements
       pp          - complexarr(rangeGates,n), pulse pair meas. (SPPMAG)
                   - complexarr(rangeGates,3,n), pulse pair meas. (PPMAG4)
                   - complexarr(rangeGates,5,n), pulse pair meas. (PPMAG6)

 NOTES:
       1) 'strt' and 'stp' are not necessarily associated with the actual
          profile numbers; just determine the start/stop of the data segment.
          In order to load data for desired start/stop profile set or UTC frame
          use READWCRTB routine first
       2) n=strt-stp+1
       3) common blocks wcrparams and wcrdata must be set first
       4) For SPPMAG the output is either hh, vh or vv, hv. 
 
 EXAMPLES:

(See /tools/idl/wcrtools/readwcrpowerpp.pro)


READWCRRAW

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READWCRRAW

 PURPOSE:
       Open and Load into the memory raw data from a WCR file 
       
 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       READWCRRAW, Recraw, Startrec, Stoprec

 INPUTS:
       Startrec:  long, start record (0 to tnumrec-2, default, 0)
       Stoprec:   long, stop record (1 to tnumrec-1, default, tnumrec-1)

 KEYWORD PARAMETERS:
       FILEHEADER:    output, structure containing the file header
                      This keyword is ignored for data before April 2002
       FILENAME:      string, input wcr file name; 
                      if not given assumes the file is already open 
                      use 'load' to get a file selction;
       BIG_ENDIAN:    when set, assumes that the file data are in big endian
                      order.  The default is LITTLE_ENDIAN. For data files
                      before Mar 2002 this keyword is ignored.  
       WCRLUN:        lun, default is 30 if FILENAME is given and 31 if not
       CLOSEWCR:      if set closes the wcr file  
       HELP:          show this text

 OUTPUTS:
       Recraw:  Nr-element array of structures
                {header: lonarr(headervars),data:fltarr(Nch,Nn+Ntx+Nrg,Nmode)}
                headervars= 25 after Oct 96, 40 after May 99, 5 after Mar 02
                Nch   = 2       ; real & imag for pulse pairs and V & H 
                                  for magnitudes ; SPPMAG and PPMAG modes
                        fftbins ; for FFT mode
                Nn    = noise samples (always 1 before May 1999)
                Ntx   = 1, Tx pulse leakage; internal cal. pulse (before 1997)
                Nrg   = # of range gates
                Nmode =  2 - for SPPMAG (1 pps, 1 mags)
                         7 - for PPMAG4 (3 pps, 4 mags)
                        11 - for PPMAG6 (5 pps, 6 mags)
                        15 - for PPMAG8 (7 pps, 8 mags)
                         1 - for FFT
                         2 - for DPFFT (co- and cross- spectra)
                Nr    = # of records read (max Nr=tnumrec)

 COMMON BLOCKS:
       wcrparams

 SIDE EFFECTS:
       This routine will not work with WCR files before 1997 
       Use readwcrall for data before Oct 1996

       When using the routine to read equal size blocks of data
       it is most time efficient (as long as the structure is not deleted 
       from the memory it is initilized only the first time and then
       just checks if the new data block has the same size)

(See /tools/idl/wcrtools/readwcrraw.pro)


READWCRTB

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       READWCRTB

 PURPOSE:
       Read wcr file time and prof recordings between 'strt' and 'stp' 
       and correct the time according to tcorrection variable.
       Determine the interruptions (data on/data off, obsolete after 
       May 1999) if any.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       READWCRTB, Data, Strt, Stp

 INPUTS:
       Data:  wcr file structure
       Strt:  start reading point
              For rmode = 0  -  strt/stp record in the wcr file
                          1  -  input:  strt/stp profile numbers
                                output: strt/stp corresponding wcr file records
                          2  -  input:  strt/stp UTC in hhmmss, long
                                output: strt/stp corresponding wcr file records
       Stp:   stop reading point (see above)

 KEYWORD PARAMETERS:
       TIMEMODE: 1 : [sec,microsec]; lonarr(stp-strt+1)
                 2 : hhmmss.dd     ; dblarr(stp-strt+1)   
                 3 : sssss.dd      ; dblarr(stp-strt+1) (default)
       READMODE: 0 : reads profs given strt/stp record number(default)
                 1 : reads profiles between strt/stp profile numbers
                 2 : reads profiles within strt/stp UTC    
        BADPROF: output, array with profile numbers of potentially bad profiles
        RAWTIME: input, integer,load UNIX time
                  1 - return unix time in the named variable
                 -1 - return unix time in the named variable and this is the 
                      only action by the readwcrtb
                 output, dblarr(numrec-1), raw UNIX time based on timemode = 1
                         and readmode = 0; it is corrected if tcorrection > 0
     BIG_ENDIAN: when set, assumes that the file data are in big endian
                 order.  The default is BIG_ENDIAN.  
       HELP:     show this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams 

 SIDE EFFECTS:
       Load into wcrdata block:
       time      - (see tmode), UTC time for every profile in 'mode' format
       begtime   - (see rmode=2), UTC desired data segment beginning time
       endtime   - (see rmode=2), UTC desired data segment end time 
       prof      - lonarr(numRec-1), profile numbers
       interrupts- lonarr(numIntr,2), (first,last) profiles for interrupts
       dspsync   - fltarr(3) mean,std and max-min of DSPs' time diff.

       tcorrection is applied to time data if tcorrection ne -999.
       and timemode is 1 or 2. For timemode=3 time is corrected for
       fractional seconds in tcorrection (if any) only.  The whole seconds
       correction is applied to starttime/begtime and stoptime/endtime. 
       In this case time[0] could be negative number but gt -1.

 NOTES:
       1) READMODE 2 and 3 are slower than 1. It reads all the data
          to find the desired actual profile or time range 
       2) For data before May 1999:  TIMEMODE 2 and 3 calculate time using the 
          clock reading from the odd DSP profiles only and interpolate for the
          even. 
          ATTN: The 2 DSPs were not syncronized and therefore the 
                time is not consistent (small offset, 0.5 to 1.0 sec).
                This has been fixed after May 1999.
       3) TIMEMODE 1 gives the raw time readings from the 2 DSPs.  
          TIMEMODE 1 is not allowed for READMODE 1 and 2.
       4) See openwcrf.pro for wcrdata and wcrparams structure descriptions.
       5) interrupts is a 2-d aray with first and last profile numbers for 
          data on/data off WCR DAQ mode.  If there is no interrupts its value
          is 0.  For rmode=0, interrupts are between strt and stp; for all
          other modes interrupts are for the whole wcr file. Interrupts are
          obsolete after May 1999.

(See /tools/idl/wcrtools/readwcrtb.pro)


SETCOMMONWCR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SETCOMMONWCR

 PURPOSE:
       Set wcr common blocks

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       .run SETCOMMONWCR

 COMMON BLOCKS:
       wcrparams, wcrdata 

 NOTES:
       Normally this program runs before any other wcr routine. 
       It is not needed if openwcrm is used or there is no need of access to
       the common block variables

(See /tools/idl/wcrtools/setcommonwcr.pro)


SHOWWCRPRG

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       SHOWWCRPRG

 PURPOSE:
       Show WCR wcr IDL routines

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       showwcrprms

 KEYWORD PARAMETERS:
       PRMS:  when set show WCR param. variables only (wcrparams common block)
       DATA:  when set show WCR data variables only (wcrdata common block) 
       HELP:  show this text

(See /tools/idl/wcrtools/showwcrprms.pro)


WCRACVEL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRACVEL

 PURPOSE:
      Returns aircraft (AC) velocity contribution (fltarr(m) in m/s) into the 
      WCR beam w.r.t. ground. Positive contribution means away from the radar.

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      res=wcracvel(acvel,roll,pitch,heading,beaminit,gpscor=gpscor,rmcor=rmcor,$
                   rmv=rmv,radarm=radarm,wcrb=wcrb,wcrt=wcrt,acv=acv,deg=deg, $
                   help=help)

      res=wcracvel(acvel,trnsm,beaminit)

 INPUTS:
      Acvel:   fltarr(m,3),   AC velocity [m/s] in Earth coordinates 
                              [[east-west vel],[north-south vel],[vert. vel]]
      Roll:    fltarr(m),     AC roll in radians                  or
               fltarr(3,3,m), AC to Earth transformation matrix   or
               fltarr(3,m),   WCR beam in Earth coordinate system 
 
      Pitch:   fltarr(m), AC pitch in radians 
      Heading: fltarr(m), AC heading in radians

      Instead of roll,pitch,heading the AC to Earth coordinate systems 
      transformation matrix, trnsm, fltarr(3,3,n) can be given

      Beaminit: Initialize antenna beam; 
                Default beams:
                 0         - side-looking KingAir, KA, (main) 12"antenna
                 1         - up-looking KA (main+mirror) 12" antenna
                 2         - KA nadir 18" antenna
                 3         - KA side-fore antenna(~35 deg)
                 4         - KA down-fore 15" antenna(~30 deg)
                 5         - NCAR C130 nadir 12" antenna (7/16/01)
                 6         - NCAR C130 down-aft 12" antenna(7/16/01)
                 7         - NRC CV580 side looking 12" antenna
                 8         - NRC CV580 nadir looking 12" antenna
                 fltarr(m) - side/up antenna for KA determined by the KA mirror 
                             (0-side, 1-up), m > 3
                Antenna beam pointing vector:
                 fltarr(3)  - beam unit vector in AC coordinate system
                              [AC along axis, right wing, down]
                 fltarr(3,m)- beam unit vectors for all data points

 KEYWORD PARAMETERS:
      GPSCOR:  input, [[uerr],[verr]], E-W and N-S velocity corrections
               (default - keyword not defined; correction is not applied)
      RMCOR:   input, [[rollr],[pitchr],[yawr]], AC attitude rates in rad/sec
                      (default - not defined; correction is not applied)
               output, if input is defined as above the output is radar moment
                       correction
      RMV:     output, fltarr(m), radar arm velocity correction vector into
                       the WCR beam w.r.t. groud in m/s
      RADARM:  wcr antenna position in meters (AC coords) w.r.t INS;
               default is [-1.88,0.,-0.79] for UWKA side/up antenna; antenna 
               installations on other aircraft are described in wcracvelm.pro  
      WCRT:    output, fltarr(3,3,n), AC-to-Earth transformation matrix
      WCRB:    output, fltarr(3,n), WCR beam in Earth coordinate system  
      ACV:     output, fltarr(n,3), Acvel(GPS/RMCOR corrected if requested)
                       in AC corrdinates.
      DEG:     when set the attitude params are given in degrees
      HELP:    show this text

 SIDE EFFECTS:
       The function returns an empty string if the usage is incorrect

 NOTES:
       Vertical velocity component of acvel could be chosen from several 
       calculated in KA processing:  inertial baro (hwp3), ins component 
       (hivs), UW adaptive filter (wnb). 

 EXAMPLES:

(See /tools/idl/wcrtools/wcracvel.pro)


WCRACVELM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRACVELM

 PURPOSE:
      Returns aircraft (AC) velocity contribution (fltarr(m) in m/s) into the
      WCR beam w.r.t. ground. Wcracvel is called to calculate the velocity
      contribution. Positive contribution means away from the radar.
      
      This routine calls acloadins to load the appropriate data if acdata
      is not given. AC data files from UWKA (N2UW) or NCAR/C130 (N130AR)
      only are allowed.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
      res=wcracvelm(acdata,cdfid,beaminit=beaminit,startt=startt,stopt=stopt, $
                  gpsc=gpsc,rmcor=rmcor,rmv=rmv,radbeam=radbeam,acv=acv,$
                  wcracw=wcracw,filename=filename,ncnames=ncnames,close=close,$
                  help=help)

 INPUTS:
       Acdata: structure, AC IRS/INS data matching AC time
               ATTN: If defined cdfid and filename inputs are ignores  
                     otherwise acdata is output
               acdata.time   -> double(m), AC unix time in sec (see Notes)
             ; Following angles are in radians or degrees if deg keyword set
               acdata.roll   -> fltarr(m), AC roll angle
               acdata.pitch  -> fltarr(m), AC pitch angle
               acdata.heading-> fltarr(m), AC true heading from North
             ; AC ground velocities in [m/s]
               acdata.ug     -> fltarr(m), East-West AC ground velocity
               acdata.vg     -> fltarr(m), North-South AC ground velocity
               acdata.wg     -> fltarr(m), AC vertical velocity
             ; UWKA GPS corrections of ins AC velocities (ignore for C130)
               acdata.uerr   -> fltarr(m), E-W vel correction in m/s
               acdata.verr   -> fltarr(m), N-S vel correction in m/s
             ; AC measured winds in [m/s]
               acdata.uw     -> fltarr(m), East wind velocity component
               acdata.vw     -> fltarr(m), North wind velocity component
               acdata.ww     -> fltarr(m), vertical wind velocity component
             ; AC attitude rates in rad/sec or deg/sec (if deg keyword is set)
               acdata.rollr  -> fltarr(m,3), roll rate
               acdata.pitchr -> fltarr(m,3), pitch rate
               acdata.yawr   -> fltarr(m,3), yaw rate
             ;
               acdata.tas    -> fltarr(m), true air speed in m/s
             ;
             ; UWKA radar wing mirror position 
               acdata.wcrmirror -> intarr(m), KA radar wing mirror position
                                   (0-side, 1-up, for side/up antenna)

             ; AC data info: aircraft id (N2UW, N130AR or NRC-CV580)
               acdata.info   -> string, aircraft ID

             Note: If any of the non-critical data (e.g., attitude rate) is
                   not available, -1 is recorded

       Cdfid:  netCDF file ID, returned from a previous call to
               ncdf_open, ncdf_create, ncdf_varload or ncdf_fcopy
               (ignored if acdata exist)

 KEYWORD PARAMETERS:
       ACV:      output, fltarr(m,3) matching ACTIME, AC velocity (GPS/RMCOR 
                         corrected if requested) in AC corrdinates.
       BEAMINIT: input, Initialize antenna beam; 
                 Default beams:
                  -1(default)- dual-polarization side/up antenna, use UWKA 
                               radar mirror variable for pointing direction
                   0         - side-looking KingAir, KA, (main) 12"antenna
                   1         - up-looking KA (main+mirror) 12" antenna
                   2         - KA nadir 18" antenna
                   3         - KA side-fore antenna(~35 deg)
                   4         - KA down-fore 15" antenna(~30 deg)
                   5         - NCAR C130 nadir 12" antenna (7/16/01)
                   6         - NCAR C130 down-aft 12" antenna(7/16/01)
                   7         - NRC CV580 side looking 12" antenna
                   8         - NRC CV580 nadir looking 12" antenna
                   fltarr(m) - side/up antenna for KA determined by the  
                               KA mirror (0-side, 1-up), m > 3
                 Antenna beam pointing vector:
                   fltarr(3)  - beam unit vector in AC coordinate system
                                [AC along axis, right wing, down]
                   fltarr(3,m)- beam unit vectors for all data points

       CLOSE:    when set AC netcdf file will be closed(ignored if acdata exist).
       GPSC:     when set does NOT apply GPS correction to AC E-W and N-S
                 velocity for UWKA only (ignored for NCAR C130)
                 NCAR C130 AC E-W and N-S ground speed are GPS corrected.
       FILENAME: input, string, AC netCDF file name; if given will open netCDF
                 file first. In this case Cdfid is an output parameter
                 (IGNORED if acdata is defined)
       NCNAMES:   input, string array, AC netcdf varnames to be used (if not 
                         defined N2UW or N130AR default var names are used; 
                         ignored if acdata exist 
                  ncnames[0] - AC time (seconds in UNIX format)
                  ncnames[1] - AC true air speed in m/s
                  ncnames[2] - AC roll [deg or rad]
                  ncnames[3] - AC pitch [deg or rad]
                  ncnames[4] - AC true heading [deg or rad]
                  ncnames[5] - AC east-west(EW) ground velocity [m/s]
                  ncnames[6] - AC north-south(NS) ground velocity [m/s]
                  ncnames[7] - AC vertical velocity [m/s]
                  ncnames[8] - AC East component of the wind [m/s]
                  ncnames[9] - AC North component of the wind [m/s]
                  ncnames[10]- AC vertical wind [m/s]

                  ncnames[11]- AC roll rate [rad/s] (use '' if N/A)
                  ncnames[12]- AC pitch rate [rad/s](use '' if N/A)
                  ncnames[13]- AC heading rate [rad/s] (use '' if N/A)

                  ncnames[14]- AC EW ground vel. GPS correction(use '' if N/A)
                  ncnames[15]- AC NS ground vel. GPS correction(use '' if N/A)

                  Note: a) at least the first 11 var names must be defined;
                        b) if any of the vars beyond the first 11 are not
                           needed or do not exist use empty string('') to
                           skip those variables
                        c) see ACLOADINS.PRO help for default variable names
       RADBEAM:  output, fltarr(3,m), WCR beam in Earth coordinate system
       RMCOR:    input, integer/fltarr(3), applies antenna moment correction
                   0 - antenna moment correction NOT applied  
                   1 - antenna moment correction applied (use default position)
                   [x,y,x] - ant. position in aircraft coord w.r.t IRS in meters
                 Default: for UWKA or NRC Convair not applied (0) 
                          for NCAR C130 applied(1)
                 Default antenna positions w.r.t. INS/IRS in meters:
                          N2UW side/up antenna:    [-1.88,0.,  -0.79]
                          NCAR C130 down antennas: [-16.5,-0.33,-2.0] 
                          NRC CV580 antennas:      [-7.04,0.75, 0.00]
                 All N2UW antenna positions in AC coordinates(meters from INS):
                          side/up antenna   [-1.88,0.,-0.79]
                          side_fore antenna [-1.22,0.,-0.79]
                          down antenna      [-1.88,0., 0.  ]
                          done-fore antenna [-2.00,0., 0.  ]
       RMV:      output, fltarr(m), radar arm velocity correction vector into
                        the WCR beam w.r.t. groud in m/s
       STARTT:   input, long, start time in hhmmss (ignored if acdata exist)
       STOPT:    input, long, stop time in hhmmss including last second record
                 (ignored if acdata exist)
       WCRACW:   output, fltarr(m) matching ACTIME, AC measured wind contribution
                 into the WCR beam
       HELP:     shows this text

 OUTPUTS:
       Acdata: structure, return AC IRS/INS data matching AC time
               (for discription see INPUTS)
       Cdfid:  netCDF file ID, returned if Filename is given

 SIDE EFFECTS:
       The function returns an empty string for help and if the usage is
       incorrect

 NOTES:
       KingAir netCDF files follow the NCAR-RAF/nimbus convention.  This
       convention requires that the time dimension, 'time' (unlimited or not),
       is the first (last for idl, which uses fortran order) and the next
       dimension, if exists, is always samples per second, 'sps'.

       Actime time vector is assembled from two variables:
       'base_time' - seconds since 00:00:00 Jan 1 1970
       'time_offset' - seconds since base_time, a sequence w/ 1 sec step
       The result is a vector representing seconds since 00:00:00 Jan 1 1970.
       actime is resampled according to the input file INS data sps dimension.

       If startt and stopt are given netcdf variables are extracted within the
       specified time. If stopt is not defined the variables are read untill
       the end of the file.  And if both, startt and stopt are not defined or
       are invalid the complete data set for the variables are read.

 EXAMPLES:

(See /tools/idl/wcrtools/wcracvelm.pro)


WCRACWIND

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRACWIND

 PURPOSE:
      Returns aircraft (AC) measured wind contribution (fltarr(n) in m/s) into 
      the WCR beam. Positive contribution means away from the radar.

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      res=wcracwind(acwind,roll,pitch,heading,beaminit, $
                    wcrb=wcrb,wcrt=wcrt,deg=deg,help=help)

      res=wcracwind(acwind,trnsm,beaminit)

      res=wcracwind(acwind,wcrbeam)

 INPUTS:
      Acwind:  fltarr(n,3),   AC measured wind in [m/s] 
                              [[wind East comp],[wind North comp],[vert.wind]]
      Roll:    fltarr(n),     AC roll in radians                  or
      Trnsm:   fltarr(3,3,n), AC to Earth transformation matrix   or
      Wcrbeam: fltarr(3,n),   WCR beam in Earth coordinate system 
 
      Pitch:   fltarr(n), AC pitch in radians 
      Heading: fltarr(n), AC heading in radians

      Instead of roll,pitch,heading the AC to Earth coordinate systems 
      transformation matrix, trnsm, fltarr(3,3,n), or already calculated
      WCR beam, wcrbeam, fltarr(3,n), in Earth corrdinates can be given

      Beaminit: input, Initialize antenna beam; 
                Default beams:
                  0         - side-looking KingAir, KA, (main) 12"antenna
                  1         - up-looking KA (main+mirror) 12" antenna
                  2         - KA nadir 18" antenna
                  3         - KA side-fore antenna(~35 deg)
                  4         - KA down-fore 15" antenna(~30 deg)
                  5         - NCAR C130 nadir 12" antenna (7/16/01)
                  6         - NCAR C130 down-aft 12" antenna(7/16/01)
                  7         - NRC CV580 side looking 12" antenna
                  8         - NRC CV580 nadir looking 12" antenna
                  fltarr(n) - side/up antenna for KA determined by the  
                              KA mirror (0-side, 1-up), m > 3
                Antenna beam pointing vector:
                  fltarr(3)  - beam unit vector in AC coordinate system
                               [AC along axis, right wing, down]
                  fltarr(3,n)- beam unit vectors for all data points

 KEYWORD PARAMETERS:
      WCRT:     output, fltarr(3,3,n), AC-to-Earth transformation matrix
      WCRB:     output, fltarr(3,n), WCR beam in Earth coordinate system  
      DEG:      when set the attitude params are given in degrees
      HELP:     show this text

 SIDE EFFECTS:
      The function returns an empty string if the usage is incorrect

 NOTES:
       

 EXAMPLES:

(See /tools/idl/wcrtools/wcracwind.pro)


WCRBEAM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRBEAM

 PURPOSE:
      Returns WCR antenna beam coordinates in Earth or aircraft (AC) 
      coordinate system; fltarr(3,m) unit vectors in AC time

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      res=wcrbeam(roll,pitch,heading,beaminit,deg=deg,acbeam=acbeam,help=help)
      res=wcrbeam(trnsm,beaminit,acbeam=acbeam,help=help)

 INPUTS:
      Roll:    fltarr(m), AC roll in radians 
      Pitch:   fltarr(m), AC pitch in radians 
      Heading: fltarr(m), AC heading in radians

      Instead of roll,pitch,heading the AC to Earth coordinate systems 
      transformation matrix can be given.

      Trnsm:   fltarr(3,3,m)

      Beaminit: Initialize antenna beam position
                Default beam pointing angles:
                 0          - side-looking KingAir, KA, (main) 12"antenna
                              default vector: [-0.01221,0.999898,0.00317781]
                 1          - up-looking KA (main) 12" antenna
                              default vector: [ 0.052336, 0.,-0.99862951]
                 2          - KA nadir 18" antenna
                              default vector: [-0.05547,0.0019240,0.998436]
                 3          - KA side-fore looking antenna (~35 deg)
                              default vector: [0.591778,0.805532,0.024110]
                 4          - KA down-fore looking 15" antenna (~30 deg)
                              default vector: [0.4408,0.00613254,0.897537]
                 5          - NCAR C130 nadir 12" antenna (7/16/01)
                              default vector:[-0.0426, 0., 0.999092]
                 6          - NCAR C130 down-aft looking 12" antenna(7/16/01)
                              default vector:[-0.5745, 0., 0.818153]
                 7          - NRC CV580 side looking 12" antenna
                              default vector: [-0.004593,0.999717,0.023354]
                 8          - NRC CV580 nadir 12" antenna
                              default vector:[-0.0448,0.,0.999]
                 fltarr(m)  - side/up antenna for KA determined by the  
                              KA mirror (0-side, 1-up), m > 3

                Antenna beam pointing angles:
                 fltarr(3)  - beam unit vector in AC coordinate system
                              [AC along axis, right wing, down]
                 fltarr(3,m)- beam unit vectors for all data points 

 KEYWORD PARAMETERS:
      DEG:      when set the attitude angles are given in degrees
      ACBEAM:   when set wcrbeam returns beam coordinates in AC coord. system
                (identical to beaminit input fltarr(3,m))
      HELP:     show this text

 SIDE EFFECTS:
       The function returns an empty string if the usage is incorrect

 NOTES:
       
 EXAMPLES:

(See /tools/idl/wcrtools/wcrbeam.pro)


WCRBEAMCAL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRBEAMCAL

 PURPOSE:
       Analyze wcr antenna beam angles in aircraft reference frame 
       The results are used to establish (calibrate) the beam angles
       for all 4 wcr antennas

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrbeamcal, beam,ground,wcrt,timeoff=t,comm=comm,epstop=epstop, $
                   averg=averg,ppsel=ppsel,beamrng=beamrng,rmcor=rmcor,$
                   checkcor=checkcor,checktime=checktime,checkdv=checkdv,$
                   dbg=dbg,help=help

 INPUTS:
       Beam:      initial guess for the beam unit vector:
                  fltarr(3), [ac_along_axis,right_wing,down]; requires ppselect
                         keyword to be defined or
                  0    - side-looking KingAir, N2UW, (main) 12"antenna
                         default guess: [0.0, 1.0, 0.0]
                  2    - KA nadir 18" antenna
                         default guess: [0.0, 0.0, 1.0]
                  3    - KA side-fore looking antenna (~35 deg)
                         default guess: [0.6, 0.8, 0.0]
                  4    - KA down-fore looking 15" antenna (~30 deg)
                         default guess: [0.4, 0.0, 0.9]
                  5    - NCAR C130 nadir 12" antenna
                         default guess: [0.0, 0.0, 1.0]
                  6    - NCAR C130 down-aft looking 12" antenna (~36 deg)
                         default guess: [-0.6,0.0, 0.8]
                  7    - NRC CV580 side looking 12" antenna
                         default guess: [0.0, 1.0, 0.0]
                  8    - NRC CV580 nadir 12" antenna
                         default guess :[0.0, 0.0, 1.0]
       Ground:    input, float; surface return threshold in dBm;
                  Default (not defined) is no thresholding; surface is
                  determined as the max returnf for every profile
       Wcrt:      input, dblarr, wcr unix time matching the wcr loaded data

 KEYWORD PARAMETERS:
       AVERG:     input, when set averages all range gates (if more than one)
                  that are considered surface return (above GROUND threshold)
                  for every profile
       BEAMRNG:   output, float, wcr range to the surface
       CHECKCOR:  input, when set, use correlation analysis
       CHECKTIME: input, when set, perform time offset optimization analysis
       CHECKDV:   input, when set, perform hsitogram analysis of the surface 
                  velocity calculated using calculated beam angles
       COMM:      input, info string added to the printed out results
       DBG:       input, when set, does not exit the routine
       EPSTOP:    input,float; specify the constained minimization procedure
                  (see constrained_min) convergence criterium (fractional
                  change of obj. function less than EPSTOP for 2 consecutive
                  iterations); default 1.e-3
       RMCOR:     integer/fltarr(3), applies antenna moment correction
                  0 - antenna moment correction NOT applied  
                  1 - antenna moment correction applied (use default position)
                  [x,y,x] - ant. position in aircraft coord w.r.t IRS in meters
       PPSEL:     input, string (e.g., 'H1H1') matching wcr pulse-pair to the
                  Beam (use only if Beam is given as unit vector,fltarr(3))
       TIMEOFF:   input/output, float; timeoffset between WCR and AC clocks
                  (wcrtime+timeoffset=actime);
                  input: 0 or not defined - clocks are synched (default)
                        -1.0 to 1.0       - the value is used for time synch
                        +-9.xx            - the routine uses +-0.xx as initial
                                            guess and makes an attempt to
                                            determine the optimal time offset
                  output: optimal timeoffset in sec (only for +-9.xx input)

 OUTPUTS:
       Beam:      fltarr(3), [ac_along_axis,right_wing,down], beam unit vector

 SIDE EFFECTS:
       Print a lot of analysis data

 PROCEDURE:
       Uses wcrbeamfind, wcrtimeoff and other analysis tools to calibrate 
       the wcr antenna beam angles

 NOTES:

 EXAMPLES:
           beam=0      & epstop=9.e-4 
           ground=-30. & comm='5000 ft, 45 deg roll'  
           wcrbeamcal,beam,ground,wcrt,comm=comm,epstop=epstop, $
                      checkcor=0,checktime=1,checkdv=1

(See /tools/idl/wcrtools/wcrbeamcal.pro)


WCRBEAMFIND

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRBEAMFIND

 PURPOSE:
       Finds unit vector (pointing angles in aircraft, AC,coordinate system) 
       of a wcr antenna beam from wcr surface returns

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrbeamfind,beaminit,drng,dprof,status=status,timeoffset=timeoffset, $
                   ground=ground,acncf=acncf,wcrfn=wcrfn,ppselect=ppselect, $
                   nowcrread=nowcrread,epstop=epstop,limser=limser,         $
                   rmcor=rmcor,averg=averg,report=report,dispfun=dispfun,   $
                   help=help

 INPUTS:
       Beaminit:  initial guess for the beam unit vector:
                  fltarr(3), [ac_along_axis,right_wing,down]; requires ppselect
                         keyword to be defined or
                  0    - side-looking KingAir, N2UW, (main) 12"antenna
                         default guess: [0.0, 1.0, 0.0]
                  2    - KA nadir 18" antenna
                         default guess: [0.0, 0.0, 1.0]
                  3    - KA side-fore looking antenna (~35 deg)
                         default guess: [0.6, 0.8, 0.0]
                  4    - KA down-fore looking 15" antenna (~30 deg)
                         default guess: [0.4, 0.0, 0.9]
                  5    - NCAR C130 nadir 12" antenna
                         default guess: [0.0, 0.0, 1.0]
                  6    - NCAR C130 down-aft looking 12" antenna (~36 deg)
                         default guess: [-0.6,0.0, 0.8]
                  7    - NRC CV580 side looking 12" antenna
                         default guess: [0.0, 1.0, 0.0]
                  8    - NRC CV580 nadir 12" antenna
                         default guess :[0.0, 0.0, 1.0]
                
       Drng:      [first,last] range of wcr data range gates to be used
                  default is all range gates
       Dprof:     [first,last] wcr data profile range to be used; default is 
                  all  profiles; to input Dprof, Drng must exists (use 0 for default)
           
 KEYWORD PARAMETERS:
       AVERG:     input, when set averages all range gates (if more than one)
                  that are considered surface return (above GROUND threshold)
                  for every profile
       ACNCF:     input,string; AC 25 HZ netcdf data file name or netcdf ID;
                  If not defined the program uses AC data loaded in a previous
                  call to this routine
       DISPFUN:   when set displays obj. function and parameters evaluation 
                  during the minimization search                  
       EPSTOP:    input,float; specify the constained minimization procedure
                  (see constrained_min) convergence criterium (fractional
                  change of obj. function less than EPSTOP for 2 consecutive
                  iterations); default 1.e-3
       GROUND:    input, float; surface return threshold in dBm (negative
                   number is expected (see below when using positive value).
                  Default (not defined) is no thresholding; surface is
                   determined as the max return for every profile.
       LIMSER:    input, integer, maximum number of 1-d minimization searches
                  (see constrained_min); default is 20
       NOWCRREAD: when set does not read wcr raw data and use already loaded 
                  wcr  data. If drng and dprof are defined it uses the subset 
                  of the already loaded data.
       PPSELECT:  input, string; type of pulse pair to be used: 'H1H1',etc.
                  for the given beaminit vector (ignored if beaminit 0 to 8)
       REPORT:    input, string,path/name for the CONSTRAINED_MIN report file.
                  If the specified file does not exist, it will be created; if
                  existing it will be overwritten.  Default(not defined) does
                  not create a report file.
       RMCOR:     integer/fltarr(3), applies antenna moment correction
                  0 - antenna moment correction NOT applied  
                  1 - antenna moment correction applied
                  [x,y,x] - ant. position in aircraft coord w.r.t IRS in meters
       STATUS:    output, integer, solution status (see constrained_min, inform) 
                  0 - optimal solution was found
       TIMEOFFSET:input/output, float; timeoffset between WCR and AC clocks
                  (wcrtime+timeoffset=actime);
                  input: 0 or not defined - clocks are synched (default)
                        -1.0 to 1.0       - the value is used for time synch
                        +-9.xx            - the routine uses +-0.xx as initial
                                            guess and makes an attempt to
                                            determine the optimal time offset
                  output: optimal timeoffset in sec (only for +-9.xx input)
       WCRFN:     input string; WCR raw data file name.  If not given the
                  needed file is assumed open. The [drng,dprof] data is 
                  loaded unless NOWCRREAD keyword is set.
       HELP:      shows this text

 OUTPUTS:
       Beaminit:  fltarr(3), [ac_along_axis,right_wing,down], beam unit vector

 SIDE EFFECTS:

 PROCEDURE:

 NOTES:

 EXAMPLES:
       1) Side beam, IHOP02, May 16
       .run commonwcrset
       openwcrf,'/sova4/ihop02/may16/W2002-05-16-11-57-50'
       readwcrdata,120307,120348,/timein       
       ncf='/net/owl/data/kingair_data/ihop02/processed/20020516.c25.nc'
       beami=0 & beam=beami 
       wcrbeamfind,beam,timeoff=0.1,status=status,ground=-20.,/nowcr, $
          report='IHOP020516.sidebeam.txt',acncf=ncf,/dispfun

       2) Side beam, IHOP, June 19
       .run commonwcrset
       openwcrf,'/sova4/ihop02/jun19/W2002-06-19-20-36-21'
       readwcrdata,203600,203730,/timein
       ncf='/net/owl/data/kingair_data/ihop02/processed/20020619a.c25.nc'
       beami=0 & beam=beami 
       wcrbeamfind,beam,timeoff=9.00,status=status,ground=-25.,/nowcr, $
          report='IHOP020619.sidebeam.txt',acncf=ncf

(See /tools/idl/wcrtools/wcrbeamfind.pro)


WCRCALCOEFF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRCALCOEFF

 PURPOSE:
      Calculate HH calibration coeff. from corner reflector measurements.

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      WCRCALCOEFF,rCR,PcrdB,ccoeff,hhnoise_sigmadB,ZedBmin=ZedBmin
      WCRCALCOEFF [,ccoeff]  - prints out min detectable signal

 INPUTS:
      rCR:     scalar/array of distances to the corner reflector in meters
      PcrdB:   max received power from CR for every distance in dBm
      ccoeff:  scalar, cal. constant in dBZ (default, 31)

 KEYWORD PARAMETERS:
      hhnoise_sigmadB: averaged sigma for the noise in dB
      ZedBmin:         min detectable signal in dBZ for 0.06 to 15 km and 
                       2*sigma detection threshold
      HELP:            display this text

 OUTPUTS:
      ccoeff:  scalar/array of cal. constant(s) in dBZ

(See /tools/idl/wcrtools/wcrcalcoeff.pro)


WCRCALCOREF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	WCRCALCOREF

 PURPOSE:

	Calibrate co-pol reflectivity factor(hh,vv,abs(pp)) in equivalent dBZ or 
	mm^6/m^3. Allows additional pre-calibration profile/range gate averaging.

    ATTN: This routine does not work for PPMAG reflectivity data loaded
          with PPMNOAV=1 (same pol/beam pulses are not averaged). The work
          around is to use the input params instead of the data in the
          wcrdata common block 

 CATEGORY:

	wcrtools

 CALLING SEQUENCE:

	coref=wcrcalcoref(thresh,calcoef,wcrstr=wcrstr)

    or

	coref=wcrcalcoref(thresh,calcoef,refl,conoise,rrng)

 INPUT:

    Thresh:  float, detection threshold value above mean noise (in dB) or,
             fltarr(2), thresh[0]+10*alog(thresh[1]) is used as a threshold
               where thresh[0] is the threshold in dB and thresh[1]
               is a threshold factor (e.g.,[-70,2] -> -67 dB thresh)
               [-999,factor] will cause using 10.*alog10(factor*noise_sigma),
               where noise_sigma is evaluated from the noise for nswin
               profiles.(default threshold is one sigma of the noise,
               i.e., thresh=-999 or thresh=[-999,1.])

    Calcoef: float, calibration constant in dB

    Refl:    fltarr(nrg,nprof),received power in mW
                
    Conoise: fltarr(nprof), co-channel noise vector in mW

    Rrng:    fltarr(nrg), radar range vector in meters  

 KEYWORD PARAMETERS:

    ATT      - input,float, two-way attenuation coefficient in dB/km 
    LINZ     - when set the calibration is in mm^6/m^3 (default is dBZ)
    MNOISE   - output,fltarr(n,2); 
                 mnoise[*,0] for LINZ=0 (keyword not set):
                   mean noise subtracted from the received co-pol power
                 mnoise[*,0] for LINZ=1 (keyword set):
                   noise power matching the reflectivity being calibrated
                   (this does not match the mean noise for LINZ=0 subtarcted,
                    which is a smoothed one)
                 mnoise[*,1]-threshold level (in dBZ @ 1km);
                   If thresh=[-999,1] mnoise[*,1] is the noise standard  
                   deviation in dBZ @ 1km or mm^6/m^3 if LINZ=1 (see notes)
    NAN      - input: 
                 1 - assign NaN to all values below the threshold.
                 Any other value - used as missing value.
                 Maximum valid value for NAN is -150.
               Default(keyword not set) is -32767.
               Note: NAN keyword is ignored if both NOTRESH and LINZ are set.
                     If NOTHRESH only is set than all values below the mean
                     noise are set to the value of NAN
    NAV      - short integer, number of profiles to be avaraged
                 intarr(2), number of profiles and range gates to average 
                 default is no averaging               
    NOTHRESH - when set, only mean noise is subtracted (no thresholding) 
    NSWIN    - input,long, smoothing noise-window size(default 101); should be 
                 an odd number(1 is added for evens); it is recommended not to 
                 exceed 10% of the processed number of profiles;  values less
                 than 3 and greater than 50% of all profiles cause the use of
                 constant mean and stdev of the noise data
    SILENT   - when set suppress info print
    WCRSTR   - when set uses wcr common block for data (refl,noise,rng)
                 input, string, 'H1','H2','V1','V2','V3' - after 07/04
                                'hh','vv' - before 07/04
    HELP     - Show this text

 COMMON BLOCKS:
     wcrdata

 NOTES:
     For PPMAG modes calibration when received power threshold is based on the
     standard deviation of the measured noise, noiseflag and txsequence are 
     used to determine how the noise data were generated by readwcrdata 
     (ppmnoav keyword).  For PPMAG modes the noise can be assambled in
     different ways not necessarily matching the noise in the loaded H/V power
     which is always averaged (in readwcrdata) of all H/V pulses in a burst.
     In case of ppmnoav=2,3,4; the loaded hhnoise and/or vnoise are/is using 
     a single pulse noise measurements and therefore its standard deviation
     may be higher than the noise contribution into the averaged received power
     (e.g., if txstrpol=['H','H','V','V']) and ppmnoav=3 then std(hhnoise) 
     would be 1.4 dB higher than the std of the noise contribution in hh)
     In these cases the threshold is corrected by the needed factor.

     The above corection is performed only when wcrstr is defined

 EXAMPLES:
     hhc=wcrcalcoref([-999,2.],hhcal,hh,hhnoise,vvnoise,rrng)
     vvc=wcrcalcoref([-999,2.],vvcal,vv,vvnoise,hhnoise,rrng,nav=5)
     hhc=wcrcalcoref([-999,2.],hhcal,wcrstr='hh')
     hhc=wcrcalcoref([-999,2.],hhcal,wcrstr='hh',nswin=199) 
     hhc=wcrcalcoref(-75.,hhcal,wcrstr='hh'); threshold -75dB above smoothed noise

(See /tools/idl/wcrtools/wcrcalcoref.pro)


WCRCALCRREF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	WCRCALCRREF

 PURPOSE:

	Calibrate cross-pol reflectivity  factors vh, hv, in equivalent dBZ
       or mm^6/m^3, and LDRvh, LDRhv, ZDR in dB. 
	Allows additional pre-calibration profile/range gate averaging.

    ATTN: This routine does not work for multi-pulse reflectivity data
          which may occur for PPMAG (PPMNOAV=1 for data before July 2004 or
          any data from PPMAG after July 2004). The work around is to use the
          input params instead of the data in the wcrdata common block 

 CATEGORY:

	wcrtools

 CALLING SEQUENCE:

	crref=wcrcalcrref(thresh,calcoef,wcrstr=wcrstr)

    or

       crref=wcrcalcrref(thresh,calcoef,refl,noise,rrng)

 INPUT:

    Thresh:  float, detection threshold value above mean noise (in dB) or,
             fltarr(2), thresh[0]+10*alog(thresh[1]) is used as a threshold
               where thresh[0] is the threshold in dB and thresh[1]
               is a threshold factor (e.g.,[-70,2] -> -67 dB thresh)
               [-999,factor] will cause using 10.*alog10(factor*noise_sigma),
               where noise_sigma is evaluated from the noise for nswin
               profiles.(default threshold is one sigma of the noise,
               i.e., thresh=-999 or thresh=[-999,1.])

    Calcoef: fltarr(4),[crrefcal,corefcal,isodB]
               e.g., for vh:  [vvcal,   hhcal,   vhisodB]
                     for hv:  [hhcal,   vvcal,   hvisodB]
                     for zdr: [hhcal,   vvcal]

    Refl:    fltarr(3*nrg,nprof) or fltarr(2*nrg,nprof), received power[mW]
             [crref(nrg,nprof),coref1(nrg,nprof),coref2(nrg,nprof)]
               e.g., for PPMAG  vh:  [vh,hh,vv], or hv: [hv,vv,hh] 
                     for SPPMAG vh:  [vh,hh],    or hv: [hv,vv] 
                     for        zdr: [hh,vv]
                    
    Noise:   fltarr(2*nprof), [crnoise,conoise]
               e.g., for vh: [vvnoise,hhnoise], for hv: [hhnoise,vvnoise]

    Rrng:    fltarr(nrg), radar range vector in meters  

 KEYWORD PARAMETERS:
               
    ATT      - float, two-way attenuation coefficient (dB/km)
    LINZ     - when set the cross-ch  cal. is in Z mm^6/m^3 (default is dBZ)
               LINZ is ignored for LDR or ZDR .
    MNOISE   - output,fltarr(n,2); cross-channel noise data
                 mnoise[*,0] for LINZ=0 (keyword not set):
                   mean noise subtracted from the received co-pol power
                 mnoise[*,0] for LINZ=1 (keyword set):
                   noise power matching the reflectivity being calibrated
                   (this does not match the mean noisefor LINZ=0 subtarcted,
                    which is a smoothed one)
                 mnoise[*,1]-threshold level (in dBZ @ 1km);
                   If thresh=[-999,1] mnoise[*,1] is the noise standard  
                   deviation in dBZ @ 1km or mm^6/m^3 if LINZ=1 (see notes)
                 mnoise is not returned for wcrstr='zdr'
    NAN      - input: 
                 1 - assign NaN to all values below the threshold.
                 Any other value - used as missing value.
                 Maximum valid value for NAN is -150.
               Default(keyword not set) is -32767.
               Note: NAN keyword is ignored if both NOTRESH and LINZ are set.
                     If NOTHRESH only is set than all values below the mean
                     noise are set to the value of NAN
    NAV      - short integer, number of profiles to be avaraged
                  intarr(2), number of profiles and range gates to average 
                  default is no averaging   
    NOTHRESH - when set, only mean noise is subtracted (no thresholding) 
    NSWIN    - input,long, smoothing noise-window size(default 99); should be 
                 an odd number(1 is added for evens); it is recommended not to 
                 exceed 10% of the processed number of profiles;  values less
                 than 3 and greater than 50% of all profiles cause the use of
                 constant mean and stdev of the noise data
    SILENT   - when set suppress info print
    WCRSTR   - when set uses wcr common block for data (refl,noise,rng)
                  input, string, 'vh', 'hv','ldrhv','ldrvh','zdr'
    HELP     - Show this text

 COMMON BLOCKS:
    wcrdata

 NOTES:
    For PPMAG modes calibration and reflectivity threshold based on the
    standard deviation of the measured noise, noiseflag and txsequence are 
    used to determine how the noise data were generated by readwcrdata 
    (ppmnoav keyword).  For PPMAG modes the noise can be assambled in
    different ways not necessarily matching the noise in the loaded H/V power
    which is always averaged (in readwcrdata) of all H/V pulses in a burst.
    In case of ppmnoav=2,3,4; the loaded hhnoise and/or vnoise are/is using 
    a single pulse noise measurements and therefore its standard deviation
    may be higher than the noise contribution into the averaged received power
    (e.g., if txstrpol=['H','H','V','V']) and ppmnoav=3 then std(hhnoise) would
     be 1.4 dB higher than the std of the noise contribution in hh)
    In these cases the threshold is corrected by the needed factor.

    The above corection is performed only when wcrstr is defined and not for
    'ZDR'

 EXAMPLES:
    vhc=wcrcalcrref([-999,2.],[vvcal,hhcal,vhiso],[vh,hh], $
                    [vvnoise,hhnoise],rng)                      ; SPPMAG
    hvc=wcrcalcrref([-999,2.],[hhcal,vvcal,hviso],[hv,vv,hh], $
                    [hhnoise,vvnoise],rng)                      ; PPMAG
    vhc=wcrcalcrref([-999,2.],[vvcal,hhcal,vhiso],nav=5,wcrstr='vh')
    hvc=wcrcalcrref([-999,2.],[hhcal,vvcal,hviso],nav=5,wcrstr='hv')

    ldrhv=wcrcalcrref([-999,2.],[hhcal,vvcal,hviso],nav=5,wcrstr='ldrhv')

    zdr=wcrcalcrref(-80,[hhcal,vvcal],[hh,vv],[hhnoise,vvnoise], $
                    rng,wcrstr='zdr')
    zdr=wcrcalcrref([-999,2.],[hhcal,vvcal],wcrstr='zdr')

(See /tools/idl/wcrtools/wcrcalcrref.pro)


WCRCALINFO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRCALINFO

 PURPOSE:
      Calibration constants for WCR experiments.

      This routine has been modified to work with multi-beam configs
      after 2002. 
 
 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      WCRCALINFO,expstr,calconst

 INPUT:
      Expstr: input, string, experiment acronym
              If EXPSTR is not given or valid, calibration info for all 
              experiments is printed.
              If 'NAMES' returns all allowed experiment acronims

 KEYWORD PARAMETERS:
      HELP:   Show this text

 OUTPUTS:
      Calconst - output, fltarr(5), [hhcal1,vvcal1,vvcal2,vvcal3,hhcal4] 
                 for 250 ns pulse (subtract 3.5 dB for 500 ns pulse)
                 -999 is used when no cal. constant is available

                 hhcal1 - cal const for N2UW side/up antenna H-pol, 
                           or C130 nadir antenna (July 2001)
                 vvcal1 - cal const for N2UW side/up antenna V-pol,
                           or C130 down-aft antenna (July 2001)
                 vvcal2 - cal const for N2UW nadir antenna
                 vvcal3 - cal const for N2UW side-fore antenna
                 hhcal4 - cal const for N2UW down-fore antenna

                 ATTEN: only hhcal1 and vvcal1 are available untill 2002

(See /tools/idl/wcrtools/wcrcalinfo.pro)


WCRCALTHRESHNC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRCALTHRESHNC

 PURPOSE:
       Return thresholded reflectivity in dBZ
       Optionally it can also return thresholded Doppler velocity field

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       result=wcrcalthreshnc(rf,pnoise,radrng,sfactor,dvc)

 INPUTS:
       Rf:      fltarr(rg,np); rg-number of range gates, np-number of profiles;
                non-thresholded reflectivity factor in dBZ or mm^6/mm^3
       Pnoise:  fltarr(np);
                  for NAV[0]>1 and Rf in mm^6/m^3:
                             Noise power in mm^6/mm^3 at 1 km
                  otherwise: Standard deviation of the reflectivity noise
                             in equivalent dBZ or mm^6/m^3 at 1 km;
                ATTN: The value of NAV[1] does not matter here !
                      The units of Pnoise must match Rf units
       Radrng:  fltarr(rangegates) radar range gates in meters 
       Sfactor: float, factor applied to StDev of the noise to form the 
                       threshold (must be positive or 0.; default is 1)
       Dvc:     fltarr(rg,np); Doppler velocity field corrected for aircraft
                motion and matching Rf (this parameter is optional and should
                be used in conjuction with keyword variable DVT)  
                
 KEYWORD PARAMETERS:
       DVT:     output, fltarr(rg,np); tresholded Dvc in m/s
       LEAK:    input, lonarr(3), [prof0,prof1,slkf,rg1], when defined 
                calculates the Tx leak threshold (mean(leak)+slkf*std(leak)) 
                using prof0 to prof1 with no target in the first 15 range gates
                and then removes it from the data for range gates 0 to rg1 
       MISVAL:  input,float, missing value for Rf (default -32767.)
       NAN:     input, when set replaces all missing values with NaNs if 
                missing values are not NaNs
       NAV:     input, npa, short integer, number of profiles to be avaraged;
                            (default is 1)
                [npa,nrga], intarr(2), number of profiles and range gates 
                            to average (default is [1,1])
                [npa,nrga,nsw], npa,nrga, and smoothing profile window size 
                            to calculate StDev(Pnoise) if Pnoise in mm6/m3 
                            (default is [1,1,101])
                ATTN: nsw smoothing window is w.r.t. Rf input size; when NAV[0]
                      is greater than 1 it is reduced accordingly, but the
                      minimum for nsw is set to 3 independent on NAV[0] and
                      the maximum is 0.5*np, after which a constant threshold
                      is applied.
       UNITS:   input,string, units for Rf and Pnoise ('dBZ' or 'mm6/m3');
                default is 'mm6/m3'
       RRADRNG: output,fltarr((rg/nrga)*nrga), resampled range axis of Rf
                (Radrng) when nrga > 1, otherwise returns Radrng
       HELP:    show this text (use print,wcrcalthreshnc(/help) )

 OUTPUTS:

 SIDE EFFECTS:
       If Rf size is not exactly divisible by NAV Rf size is truncated
       to the maximum divisible integer lower than the input size. Thus
       it is possible that not all input profiles are used.
       
 NOTES:
       When NAV > 1 the averages are done in linear not in dB even
       when Rf is in dBZ.  This may cause IDL to issue error messages:
       '% Program caused arithmetic error: Floating underflow',and/or
       '% Program caused arithmetic error: Floating divide by 0'
       when values less than approximately -380 dBZ (machine min 
       value for single precision) are present in the input data. 
       The numerical errors caused are minimal and thus ignored.

       When NAV > 1 and the Rf is given in dBZ keep in mind that
       1) the averaged value may be biased (due to missing points:
           noise measurements below the removed mean noise), and
       2) the statistics of every resultant(averaged) reflectivity
          point may be changing due to the possible difference in 
          the number of the valid input reflectivity data points  
          available in every averaged interval.

 EXAMPLES:

   1) Using WCR netcdf file with reflectivity and noise in mm6/m3

   ncid=ncdf_open('WCR.CUPIDO06.20060718.174601_175904.PP8.Z.nc')
   vdown=reform((wcrloadnc(ncid,'vv'))[0,*,*])  ; reflectivity
   vmn=reform((wcrloadnc(ncid,'vmnoise'))[0,*]) ; receiver noise
   vsn=reform((wcrloadnc(ncid,'vsnoise'))[0,*]) ; StDev of the noise
   radrng=wcrloadnc(ncid,'range')               ; range axis
   time=wcrloadnc(ncid,'time')                  ; profile axis
   misval=ncdf_attload(ncid,'vv','missing_value')
   units=ncdf_attload(ncid,'vv','units')

   v1downc=wcrcalthreshnc(vdown,vsn,radrng,1.,units=units,misval=misval)
   v3downc=wcrcalthreshnc(vdown,vsn,radrng,3.,units=units,misval=misval)

 ; Note that the next call is using vsn (nav[0]=1) while the other 2 use vmn

   v3_2=wcrcalthreshnc(vdown,vsn,radrng,3.,units=units,nav=[1,2])
   v3_12=wcrcalthreshnc(vdown,vmn,radrng,3.,units=units,nav=12)
   v3_242=wcrcalthreshnc(vdown,vmn,radrng,3.,units='mm6/m3',nav=[24,2],rr=rr2)

 ; Plot the averaged(in profiles and range gates) and thresholded reflectivity

   ; prepare the time axis for the plot; the range axis is rr2
   tt24=rebin(time[0:(n_elements(time)/24)*24-1L],(n_elements(time)/24))

   aximage,v3_242,/tr,tt24 mod 86400.,reverse(rr2),setw=[-1,41],min=-60,/ord,$
     /timeax,tit='Nadir beam,nav=[24,1]',xtit=['UTC','dBZ'],ytit='Range [m]',$
     imgz=2

   2) Using WCR netcdf file with reflectivity and noise in dBZ

   ncid1=ncdf_open('WCR.CUPIDO06.20060718.174601_175904.PP8.dBZ.nc')
   vc=reform((wcrloadnc(ncid1,'vv'))[0,*,*])
   vs=reform((wcrloadnc(ncid1,'vsnoise'))[0,*])
   radrng=wcrloadnc(ncid1,'range')
   time=wcrloadnc(ncid1,'time')
   misval=ncdf_attload(ncid1,'vv','missing_value')
   units=ncdf_attload(ncid1,'vv','units')

 ; Note that both calls below use vs (StDev of the noise).
 ; If Rf is in dBZ Pnoise must always be the StDev.

   vv3_2=wcrcalthreshnc(vc,vs,radrng,3.,nav=[1,2],misval=misval,units=units)
   vv3_12=wcrcalthreshnc(vc,vs,radrng,3.,nav=12,misval=misval,units=units)
   vv3_242=wcrcalthreshnc(vc,vs,radrng,3.,nav=[24,2],rr=rr2)

 ; Plot non-thresholded reflectivity

   aximage,vc,/tr,time mod 86400.,reverse(radrng),setw=[-1,41],min=-60,/ord,$
         /timeax,tit='Nadir beam',xtit=['UTC','dBZ'],ytit='Range [m]',asp=12

 ; Plot averaged and thresholded reflectivity

   tt24=rebin(time[0:(n_elements(time)/24)*24-1L],(n_elements(time)/24))
   aximage,vv3_242,/tr,tt24 mod 86400.,reverse(rr2),setw=[-1,41],min=-60,$
          /timeax,/ord,tit='Nadir beam,nav=[12,2]',xtit=['UTC','dBZ'],$
          ytit='Range [m]',imgz=2

(See /tools/idl/wcrtools/wcrcalthreshnc.pro)


WCRCALTHRESHNC1

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRCALTHRESHNC1

 PURPOSE:
       Return thresholded reflectivity in dBZ
       Optionally it can also return thresholded Doppler velocity field

       The difference between WCRCALTHRESHNC and WCRCALTHRESHNC1 is in the
       way transmitter leak removal is handled.  This routine determines
       and removes the leak (if requested) after the noise thresholding.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       result=wcrcalthreshnc1(rf,pnoise,radrng,sfactor,dvc)

 INPUTS:
       Rf:      fltarr(rg,np); rg-number of range gates, np-number of profiles;
                non-thresholded reflectivity factor in dBZ or mm^6/mm^3
       Pnoise:  fltarr(np);
                  for NAV[0]>1 and Rf in mm^6/m^3:
                             Noise power in mm^6/mm^3 at 1 km
                  otherwise: Standard deviation of the reflectivity noise
                             in equivalent dBZ or mm^6/m^3 at 1 km;
                ATTN: The value of NAV[1] does not matter here !
                      The units of Pnoise must match Rf units
       Radrng:  fltarr(rangegates) radar range gates in meters 
       Sfactor: float, factor applied to StDev of the noise to form the 
                       threshold (must be greater than 0.; default is 1)
       Dvc:     fltarr(rg,np); Doppler velocity field corrected for aircraft
                motion and matching Rf (this parameter is optional and should
                be used in conjuction with keyword variable DVT)  
                
 KEYWORD PARAMETERS:
       DVT:     output, fltarr(rg,np); tresholded Dvc in m/s
       LEAK:    input, lonarr(4), [prof0,prof1,slkf,rg1], when defined 
                calculates the Tx leak threshold (mean(leak)+slkf*std(leak)) 
                using prof0 to prof1 data segment with no target at least in 
                the first 15 range gates and then removes it from the data for 
                range gates 0 to rg1
       MISVAL:  input,float, missing value for Rf (default -32767.)
       NAN:     input, when set replaces all missing values with NaNs if 
                missing values are not NaNs
       NAV:     input, npa, short integer, number of profiles to be avaraged;
                            (default is 1)
                [npa,nrga], intarr(2), number of profiles and range gates 
                            to average (default is [1,1])
                [npa,nrga,nsw], npa,nrga, and smoothing window size to 
                            calculate StDev(Pnoise) if Pnoise in mm6/m3 
                            (default is [1,1,101])  
       UNITS:   input,string, units for Rf and Pnoise ('dBZ' or 'mm6/m3');
                default is 'dBZ'
       RRADRNG: output,fltarr((rg/nrga)*nrga), resampled range axis of Rf
                (Radrng) when nrga > 1, otherwise returns Radrng
       HELP:    show this text (use print,wcrcalthreshnc(/help) )

 OUTPUTS:

 SIDE EFFECTS:
       If Rf size is not exactly divisible by NAV Rf size is truncated
       to the maximum divisible integer lower than the input size. Thus
       it is possible that not all input profiles are used.
       
 NOTES:
       When NAV > 1 the averages are done in linear not in dB even
       when Rf is in dBZ.  This may cause IDL to issue error messages:
       '% Program caused arithmetic error: Floating underflow',and/or
       '% Program caused arithmetic error: Floating divide by 0'
       when values less than approximately -380 dBZ (machine min 
       value for single precision) are present in the input data. 
       The numerical errors caused are minimal and thus ignored.

       When NAV > 1 and the Rf is given in dBZ keep in mind that
       1) the averaged value may be biased (due to missing points:
           noise measurements below the removed mean noise), and
       2) the statistics of every resultant(averaged) reflectivity
          point may be changing due to the possible difference in 
          the number of the valid input reflectivity data points  
          available in every averaged interval.

 EXAMPLES:


(See /tools/idl/wcrtools/wcrcalthreshnc1.pro)


WCRCDL2NC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRCDL2NC

 PURPOSE:
       Generate WCR netcdf file from a prototype cdl file (ncgen utility)

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrcdl2nc,cdlfile,profrange,ncfile=ncfile,edit=edit,wcropen=wcropen, $
                 average=average,indir=indir,outdir=outdir,savecdl=savecdl, $
                 silent=silent,big_endian=bgnd,help=help

 INPUTS:
       Cdlfile:   string, name of project prototype cdl file
                  Recommended name is .cdl or ..cdl
                  ATTN: Do not add directory path; use INDIR for dir location
       Profrange: lonarr(2), [start,stop]; profile range to be recorded in
                  Ncfile. Default is [0,tnumrec-1]; tnumrec: all profiles in
                  the open raw WCR file (or the file to be opened when
                  WCROPEN is a string or string array)

 KEYWORD PARAMETERS:
       AVERAGE: input, integer/intarr(2), # of profiles/[profiles,rangegates]
                to be averaged (default is [1,1]; 0 is same as 1)
                Note: While averaging 2 profs is recommended in order to take 
                      care of a small data acq. calibration problem, caution is 
                      advised; averaging of folded Doppler data at the folding
                      boundary can result in incorrect averaged values.
       EDIT:    input, string/strarr, what to edit in the cdlfile:
                 'all' - perform all necessary editing (default)
                 'dim' - edit/update netcdf dimension related lines
                 'glb' - edit/update netcdf global attributes lines
                 'alg' - edit/update algorithm (SPPMAG,PPMAG,FFT) related lines
                 'gen' - no editing, cdl file is directly converted to netcdf
       INDIR:   input,string, directory path to cdlfile (default current dir)

       BIG_ENDIAN: when set, assumes that the raw WCR file data are in
                      big endian order.  The default is LITTLE_ENDIAN.
                      This keyword is ignored for date prior to March 2002.
       NCFILE:  input, string, name of generated output netcdf file starting
                  with control character $.  If the first char. of the string
                  is not $ the name is ignored and a default name is created.
                  If ncfile is not defined or empty string "" ncfile name is
                  generated by the program and is an output parameter.
                output, string; WCR.....nc,
                  where cdlfile is truncated to its first dot;  is WCR
                  mode, e.g., SPH or SH1(SPP, H1), FV2(FFT,V2), PP4; yymmdd 
                  and hhmmss_hhmmss are begin and end time of the data in the
                  netcdf file. If EDIT='gen' then Ncfile=.nc   
       OUTDIR:  input,string, directory path to ncfile (default current dir)
       SAVECDL: input, integer, default is 0
                  0 - generates netcdf file and removes the modified cdl file
                  1 - saves the modified cdl file, does not generate netcdf
                  2 - saves the modified cdl file and generate netcdf file
                  If cdl file is saved it uses ncfile name with extension cdl
       SILENT:  when set supress routine informational messages
       WCROPEN: input, integer,lun for an open raw WCR file (default is 31) or
                input, strarr(3), input parameters to open a raw WCR file:
                  wcropen[0] - path and file name for a raw WCR file
                  wcropen[1] - UTC time correction(as string, default -13.)
                  wcropen[2] - average aircraft speed in m/s (default 90.)
       HELP:    shows this text

 OUTPUTS:
       Ncfile:  string, name of generated output netcdf file (if no input)

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:
       Write a binary netcdf file to the output directory. This routine
       also writes a temporary (unless savecdl keyword is set) cdl file in
       the input directory. It is the updated version of the input cdl file.

       Shell executed netcdf ncgen utility is used in the conversion.

       The variables of the new netcdf file are filled with the netcdf default
       fill values

       The following dimensions, variables, attributes and comments are
       modified depneding on the value of EDIT:
       * EDIT = 'alg' or 'all'
         - Remove comment lines in the cdl file if any
         - Add a comment line to acknowledge that this is a program generated
           file and the date of generation
         - Remove //SPP, //PPM or //FFT lines depending on the WCR algorithm
         - Remove cross-channel noise variables (for FFT only)
         - Remove cross-channels for multiple active beams
         - Remove wcrmirror if beam 1 (side/up) is not used
         - Make all aircraft id string consistent with Aircraft attribute
       * EDIT = 'glb' or 'all'
         - Update: WCRdaqalg,WCRtxseq,WCRppseq (remove for FFT),WCRpulsepacket,
                   WCRcdlfile,WCRdaqfile,WCRpulsewidth,WCRpulseav(remove for
                   FFT),WCRprfKHz, WCRprfrange, WCRprfvelocity, WCRrangegates,
                   WCRrangesampling, WCRrangeresolution, UTCcorrection,
                   WCRactivebeamsconfig
         - Remove or Update: WCRfftbins, WCRfftave, WCRfftwin, WCRfftres
       * EDIT = 'dim' or 'all'
         - Check and Update: profile, range, vector3, beam, bin, copp
         - Update: WCRprofrange, WCRprofav, WCRrangeav, WCRtimeint

 NOTES:
       * Before calling wcrcdl2nc the raw WCR file must be open (openwcrf)
         or WCROPEN keyword defined
       * Default output netcdf file name uses yyyymmdd.hhmmss_hhmmss determined
         from loaded WCR raw data segment and global attribute UTCcorrection
         (tcorrection). If later on in the processing UTCcorrection changes and
         /or global attribute Timeoffsetsync is not zero the netcdf file name
         may not represent accurately the time interval of the recoreded data.
       * The program uses simple editing and requires certain control strings
         in the input cdlfile ('//PPM', '//SPP','//FFT', '//*', '*//'). It also
         searches for certain dimension, variable and attribute names to be
         updated or removed depending on the WCR data acquisition algorithm.

 EXAMPLES:

       1) Example using CLEX-9 experiment data

       ; Set raw WCR data common blocks (not needed, loaded for convinience)

       .run commonwcrset

       ; Generate empty netcdf file from the prepared CLEX01.20020208.cdl
       ; The program will generate (temporarily) according to savecdl a
       ; WCR.CLEX01....cdl and the output
       ; netcdf file WCR.CLEX01....nc
       ; containing the updated relevant dimensions and global attributes.
       ; The output file is ready to be filled with the processed WCR
       ; variables using wcrwrite1nc for the opened WCR raw file and the
       ; requested profile range.

       ncfile=''
       wcropen=['/sova4/clex01/nov01/Wpp01-11-01-14-50-06','-13.','90.']
       wcrcdl2nc,'CLEX01.20020218.cdl',[200,500],ave=2,beams=1, $
                  edit='all',ncfile=ncfile,indir='.',outdir='.',savecdl=2, $
                  wcropen=wcropen,silent=silent

       2) As above but first opening the raw data file

       openwcrf,'/sova4/clex01/nov01/Wpp01-11-01-14-50-06',
       wcrcdl2nc,wcropen,'CLEX01.20020218.cdl',[200,500],ave=2,ncfile=ncfile, $
                  savecdl=2,/silent

       3) As 2) but loading all raw data.  This could be useful if wcrwrite1nc
       is called after wcrcdl2nc is done (see examples for wcrwrite1nc).

       openwcrf,'/sova4/clex01/nov01/Wpp01-11-01-14-50-06' ; default lun is 31
       readwcrdata,200,500,timemode=3,/noleak
       wcrcdl2nc,'CLEX01.20020218.cdl',[200,500],ave=2,ncfile=ncfile, $
                 savecdl=2,/silent

       4) Generate netcdf for WCR data from MARSF

       wcrcdl2nc,'marsf.cdl',indir='wcrtools/',ave=2,ncfile=ncfile, $
                 wcropen=['W2003-03-27-17-43-25','0.']

(See /tools/idl/wcrtools/wcrcdl2nc.pro)


WCRCDV2NC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRCDV2NC

 PURPOSE:
       Write corrected for platform motion, Doppler velocity and related
       variables to the corresponding WCR netcdf file

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrcdv2nc,ncf,cdv,beamvector,acvcbeam,acwcbeam,tas,mirror, $
          timesync=timesync,misval=misval,ncdir=ncdir,cdvstatus=cdvstatus,$
          revision=revision,close=close,silent=silent,help=help

 INPUTS:
      Ncf:        long, file id of a netcdf file open in WRITE mode or
                  string, WCR data netcdf file name
                  Note: When Ncf is a file string, the raw WCR data matching
                        the Ncf netcdf file data MUST be loaded.  If Ncf is
                        a netcdf file id NO raw WCR data are required.
      Cdv:        fltarr(range,profile) or fltarr(copp,range,profile);
                  corrected for the platform motion radar Doppler velocity
                  field(s) in m/s
      Beamvector: fltarr(3,profile) or fltarr(beam,3,profile);
                  (East,North,vertical) radar beam(s) unit vectors
      Acvcbeam:   fltarr(profile) or fltarr(beam,profile);
                  Aircraft velocity component into WCR beam(s) in m/s
      Tas:        fltarr(profile); aircraft true air speed in m/s
                  If not given the program does not update wcraspect variable
      Mirror:     fltarr(profile); side/up antenna beam pointing direction
                  (0 - side, 1 - up, -1 - in transition).  If not given the
                  program does not update wcrmirror variable (used for N2UW
                  only).

 KEYWORD PARAMETERS:
       CLOSE:     when set netcdf file will be closed. Default is to keep the
                  file open in WRITE mode. CAUTION: If a writable netcdf file
                  is not closed before exiting IDL, the disk copy of the file
                  may not reflect recent data changes or new definitions.
       CDVSTATUS: input,string, processing status for cdv variable
                  (default: 'platform motion corr.=Y, radar moment corr.=N,
                             GPS corr.=Y; noise thresh.=N, folded=Y')
       MISVAL     missing value for corrected Doppler field
                  (default: same as for uncorrected Doppler velocity)
       NCDIR:     input,string, directory path to ncf (default current dir)
       REVISION:  input,string or strarr(2) netcdf file revision
                  revision[0] - update Revision_X attribute (default, 'Corrected
                                Doppler velocity'); If the string starts with
                                $ the last Revision_X attribute is overwritten
                                otherwise a new Revision_X is created. If only
                                '$' the last Revision_X will be overwritten
                                with the default string.
                                Using # instead of $ will also cause all old
                                Revision_X to be deleted and start from Revision_1
                  revision[1] - update RevisionStatus attribute(default is 'OK')
                  If input a string, update Revision_X attribute only;
                  If empty string(s) '' - do not update the attribute(s)
       SILENT:    when set supress routine informational messages
       HELP:      shows this text

 OUTPUTS:
       Ncf:      when ClOSE is not set and Ncf is a file name returns the
                 opened WCR netcdf file id

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:

       The following variables and attributes of the netcdf files are updated:
       - time_offset (if timesync ne 0)
       - dv and attributes status and missing value (if misval given)
       - wcraspect and attributes status and missing_value
       - wcrbeamvector and beamchannel attribute
       - acvcbeam and beamchannel attribute
       - acwcbeam and beamchannel attribute
       - wcrmirror (if exist)

       The RevisionStatus and Revision_X global attributes are updated and
       RevisionNumber attribute is increased by 1

 NOTES:

 EXAMPLES:

       1) Example, assuming the netcdf file is already open and needed
          variables calculated

       wcrcdv2nc,ncid,cdv,beamvector,acvcbeam,acwcbeam,tas,mirror, $
                 timesync=-0.2,misval=!values.f_nan,rev=['$','Test']

(See /tools/idl/wcrtools/wcrcdv2nc.pro)


WCRCREATENC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRCREATENC

 PURPOSE:
       Create netcdf file(s) from a given cdl file, WCR raw data file(s), and
       optional WCR platform motion(aircraft) navigational data file

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrcreatenc,wcrfile,cdlfile,profrange, $
                   acfile=acfile,acnames=acnames,acspeed=acspeed, $
                   average=average,big_endian=bgnd,gpsc=gpsc,linz=linz,$
                   misval=misval,ncdir=ncdir,ncfile=ncfile,nswin=nswin, $
                   revision=revision,rmcor=rmcor,savecdl=savecdl,
                   silent=silent,timesync=timesync,utccorr=utccorr,$
                   unfold=unfold,help=help                  

 INPUTS:
       Wcrfile:   string, path/name of a raw WCR data file or
                  strarr(m), m WCR raw files for the same Cdlfile and Acfile
       Cdlfile:   string, path/name of project prototype cdl file; recommended
                    name is .cdl or ..cdl
       Profrange: long integer, number of profiles to be recorded in a single
                    netcdf file(minimum 50). The number of netcdf files created
                    depends on the total number of profiles in the raw wcrfile.
                  lonarr(2), [start,stop]; profile range to be recorded in
                    Ncfile. Default is [0,tnumrec-1]; tnumrec: all profiles in
                    wcrfile
                  lonarr(2,n), an array of [start,stop] for wcrfile. This means
                    n netcdf files will be created for each(m) WCR raw data
                    file matching each pair of profrange
                  lonarr(1,m), as first input option but for all m WCR files
                  lonarr(2,n,m), as lonarr(2,n) but for all m WCR files

                  If profrange is not defined one netcdf file is created for
                    every wcrfile

 KEYWORD PARAMETERS:
       ACFILE:   input,string, path/name of the relevant aircraft data netcdf 
                 file. If acfile is not defined or empty string, no correction 
                 of the WCR Doppler velocity is performed.  The content of
                 ACNAMES, if any, is ignored, as well as the keywords GPSC,
                 RMCOR and TIMESYNC. For MARSF acfile should not be defined.
       ACNAMES:  input, string array, AC netcdf varnames to be used (if not 
                        defined N2UW or N130AR default var names are used; 
                        see Notes for the default variable names)
                  acnames[0] - AC time (seconds in UNIX format)
                  acnames[1] - AC true air speed in m/s
                  acnames[2] - AC roll [deg or rad]
                  acnames[3] - AC pitch [deg or rad]
                  acnames[4] - AC true heading [deg or rad]
                  acnames[5] - AC east-west(EW) ground velocity [m/s]
                  acnames[6] - AC north-south(NS) ground velocity [m/s]
                  acnames[7] - AC vertical velocity [m/s]
                  acnames[8] - AC East component of the wind [m/s]
                  acnames[9] - AC North component of the wind [m/s]
                  acnames[10]- AC vertical wind [m/s]
                  acnames[11]- AC roll rate [rad/s] (use '' if N/A)
                  acnames[12]- AC pitch rate [rad/s](use '' if N/A)
                  acnames[13]- AC heading rate [rad/s] (use '' if N/A)
                  acnames[14]- AC EW ground vel. GPS correction(use '' if N/A)
                  acnames[15]- AC NS ground vel. GPS correction(use '' if N/A)
                  acnames[16]- AC longitude [deg]
                  acnames[17]- AC latitude [deg]
                  acnames[18]- AC altitude MSL [m]

                  Note: see ACLOADINS.PRO help for default variable names

       ACSPEED:  input, float; average aircraft speed in m/s (default 90.)
                   The default value is close to the N2UW research speed. 
                   This value/keyword is ignored if acfile is defined.
       AVERAGE:  input, integer/intarr(2), # of profiles/[profiles,rangegates]
                   to be averaged (default is [1,1]; 0 is same as 1)
                 Note: While averaging 2 profs is recommended in order to take 
                   care of a small data acq. calibration problem, caution is 
                   advised; averaging of folded Doppler data at the folding
                   boundary can result in incorrect averaged values.
     BIG_ENDIAN: when set, assumes that the WCR file data are in big endian order.
                   The default is LITTLE_ENDIAN. Ignored for data before 03/2002 
       GPSC:     when set does NOT apply GPS correction to AC E-W and N-S
                   velocity for UWKA only (ignored for NCAR C130)
                   NCAR C130 AC E-W and N-S ground speed are GPS corrected.
                   NRC CV580 GPSC is not needed.
       LINZ      when set the reflectivity data is in Z mm^6/m^3 (default is dBZ)
       MISVAL:   input, when set (1) use NaN as missing values; Values
                   different than 1 will be used as missing values in dBZ.
                   Default value is -32767. Maximum valid value is -150.
       NCDIR:    input,string, directory path to to the directory where
                   created netcdf file(s) will be saved (default current dir)
       NCFILE:   output, string or strarr(n*m); Name convention:
                   WCR.....nc,
                   where cdlfile is truncated to its first dot;  is WCR
                   mode: SPP, PP4, PP6 or FFT; yymmdd and hhmmss_hhmmss are
                   begin and end time of the data in the netcdf file.
       NSWIN:    input, for data after July 2004:
                   long, lonarr(2), lonarr(2,n), or lonarr(2,n,m), where
                   n - number of netcdf files per WCR raw data file, and
                   m - number of WCR raw files to be processed
                   nswin[0:1] - smoothing noise-window size for H and V chs
                                (default [99,99]);should be an odd number
                                (1 is added for evens); it is recommended not
                                to exceed 10% of the processed number of
                                profiles;  values less than 3 and greater than
                                50% of all profiles cause the use of constant
                                mean and stdev of the noise data;
                   If NSWIN is a scalar then nswin[1]=nswin
                 input, for data before July 2004:
                   long, lonarr(3), lonarr(3,n), or lonarr(3,n,m)
                   nswin[0:1] - smoothing noise-window size(default 99);should 
                                be an odd number(1 is added for evens); it is 
                                recommended not to exceed 10% of the processed 
                                number of profiles;  values less than 3 and 
                                greater than 50% of all profiles cause the use
                                of constant mean and stdev of the noise data 
                   nswin[2]   - defines which noise measurement pulses to use:
                     0 - (default) use matching number of noise measurement 
                         pulses with minimum mean
                     1 - uses noise measurement from one noise pulse with
                         min mean (for both h- and v-ch)
                     2 - as 1 for h-ch and 0 for v-ch noise 
                     3 - as 1 for v-ch and 0 for h-ch noise 

                   If NSWIN is a scalar, same value is applied to both channels
                   as smoothing window size and NSWIN[2] is the default.
                   If NSWIN has 2 elements, nswin[0] is applied to H and V
                   noise channels and nswin[1] is used as nswin[2].

                 lonarr(2-3,n) -as above but different for every profrange
                   pair(ncfile). All nswin values must be given explicitly.
                   If m > 1 and nswin is lonarr(3,n), same value(s) of nswin 
                   is/are used for every raw WCR file.

                 lonarr(2-3,n,m) - as above but different for every
                   wcr file. All nswin values must be given explicitly
                   except when lonarr(3,1,m) but n>1; then same values for each
                   raw WCR file (m) will be used for every segment(n)                  

       RMCOR:    input, when set applies antenna moment correction
                 Default: for UWKA or NRC Convair not applied (0) 
                          for NCAR C130 applied(1)
                 Default antenna positions can be seen in wcrprototype.cdl
                 (or the project cdl file)
       REVISION: input,string or strarr(2) netcdf file revision
                 revision[0] - update Revision_X attribute (default, depends
                               on what is processed); If the string starts with
                               $ the last Revision_X attribute is overwritten
                               otherwise a new Revision_X is created. If only
                               '$' the last Revision_X will be overwritten
                               with the default string.
                               Using # instead of $ will also cause all old
                               Revision_X to be deleted and start from Revision_1
                 revision[1] - update RevisionStatus attribute(default is 'OK')
                 If input a string, update Revision_X attribute only;
                 If empty string(s) '' - do not update the attribute(s)
       SAVECDL:  input, integer, default is 0 (see wcrcdl2nc for more info)
                   0 - removes the modified cdl file for every ncfile
                   2 - saves the modified cdl file for every ncfile
                   If cdl file is saved it uses ncfile name with extension cdl
       SILENT:   when set supress routine informational messages
       TIMESYNC: input,float, WCR time correction to sync with A/C IRS(INS)
                   data, in seconds  (default 0.0)
                 input fltarr(m), as above but different for every WCR file
       UNFOLD:   input, Doppler velocity unfolding procedure
                 0          - no unfolding is performed (default)
                 1          - use AC measured winds profile by profile (acwcbeam)
                 fltarr(3)  - [u,v,w], use the given wind vector
                              u,v,w are allowed the following values:
                              float: wind/velocity_shift value in m/s
                                888: use AC measured values profile by profile 
                                     for this component
                                777: use mean of AC measured values from 
                                     all profiles for this component
                 ATTN: Note yet modified to work for multiple files/prof_ranges

       UTCCORR:  if defined gives UTC time correction of the wcr time
                   After June 1998, IRIG card is used to set the time.
                   Normal use of the card is to get the time from a master
                   IRIG card with GPS time. Thus the default value is the leap
                   seconds(to see default leap seconds, check tcorrection
                   after opening a file).
       HELP:     shows this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:

      See the side effects described in wcrcdl2nc, wcrwrite1nc and wcrwrite2nc

 NOTES:

 EXAMPLES:

       1) Example using CLEX-9 experiment data (single antenna config, N2UW)

       wcrdir='/sova4/clex01/oct31b/'
       wcrfile=['Wpp01-10-31-16-16-07','Wpp01-10-31-16-36-17', $
                'Wpp01-10-31-16-51-25','Wpp01-10-31-17-06-50']
       cdlfile='/wcrproc/CLEX01.20020218.cdl'
       acfile ='/net/bobcat/disk2/kingair_data/20011031_2.c25.nc'
       profrange=10000L
       ave=2
       beams=1
       timesync=[-0.3,-0.3,-0.15,-0.15]
       ; the following line create nswin[3,1,4], so nswin[*,0,m] will be used
       ; for any n greater than 1; happens for 3rd WCR file only
       nswin=[[[99,99,0]],[[99,99,1]],[[199,199,0]],[[99,99,0]]]

       wcrcreatenc,wcrdir+wcrfile,cdlfile,profrange,beams=beams, $
                   acfile=acfile,ncfile=ncfile,average=ave,timesync=timesync

       2) Example using DYCOMS II experiment data (2 down antennas, N130AR)
          Implemented in a 2 step procedure, where 'cdv' is calculated and
          written in the netcdf files using wcrupdatenc routine. Note: since
          acfile was not used for wcrcreatenc, a couple of global attributes

       wcrdir='/net/fox/fox1/WCR/DYCOMS01/jul27/'
       wcrfile='Wpp01-07-27-21-31-38'
       cdlfile='/home/haimov/wcr/wcrproc/DYCOMS01.07.20020305.cdl'
       acfile ='/net/fox/fox1/C130/hi_rate/RF09.20010727.191201_034427.PNI.nc'
       ncdir  ='/home/haimov/wcr/wcrproc/'
       profrange=30000L
       beams=24
       timesync=-0.125

       wcrcreatenc,wcrdir+wcrfile,cdlfile,profrange,beams=beams,ncdir=ncdir,$
                   ncfile=ncfile,average=2,timesync=timesync,utccorr=0.

       wcrupdatenc,ncdir+ncfile,wcrdir,'cdv',acpath=acfile,timesync=timesync

       3) Example using HICU02 data

       wcrfile='W2002-07-19-17-05-58'
       cdlfile='/home/haimov/wcr/wcrproc/HICU02.20021009.cdl'
       acfile ='/net/owl/data/kingair_data/20020719.c25.nc'
       ncdir  ='/home/haimov/wcr/wcrproc'
       beams=13
       timesync=0.6

       wcrcreatenc,wcrfile,cdlfile,acfile=acfile,beams=beams,ncdir=ncdir,$
                   ncfile=ncfile,average=2,timesync=timesync

       4) Example using ground data from MARSF.  The trailer was oriented
       North-South, with the antenna directed to 0 deg azimuth and 0 deg 
       elevation.  This corresponds to H-pol for v-channel and V-pol for h-ch

       wcrfile='temp/mar27/W2003-03-27-17-43-25'
       cdlfile='temp/mar27/MARSF.cdl'
       wcrcreatenc,wcrfile,cdlfile

(See /tools/idl/wcrtools/wcrcreatenc.pro)


WCRDD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRDD

 PURPOSE:
       Performs dual-Doppler analysis using airborne WCR horizontal or
       vertical dual-beam data and aircraft(AC) supplemental data

       In addition to this program, the user should get familiar at least
       with wcrdddata.pro and wcrddinit.pro routines as well as wcrddprms.dat 
       prototype input parameters file. All routines associated with the dual-
       Doppler analysis package are named starting with 'wcrdd'.

       Currently there are no routines developed to aid in the visualization
       of the Dual-Doppler analysis results in IDL.  A filter wcrdd2tplot.pro
       is provided to allow the use of Tecplot visualization package for this
       purpose.

       Complete description of the airborne dual-Doppler technique is available
       in wcrdddoc.pdf (wcrdddoc.pdf)

       The users are expected to reference the paper "A High-Resolution Dual-
       Doppler Technique for Fixed Multiantenna Airborne Radar" by R.Damiani
       and S.Haimov published in IEEE Transactions on Geoscience and Remote
       Sensing, Vol. 44, No. 12, December 2006, pp. 3475-3489 and acknowledge 
       the use of this software package if the dual-Doppler results are
       published.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrdd,starttime,stoptime,ddprmsf,beams,wcrprm,ddd,grddd,dddaux,   $
             wcrdvsd,acnames=acnames,acddd=acddd,wcrddd=wcrddd,dvsd=dvsd,$
             pcstats=pcstats,radrange=radrange,unfold=unfold,            $
             windinfo=windinfo,help=help

 INPUTS:
       Starttime:long, start time in hhmmss. Enter -1 to start from the
                 beginning of the file
       Stoptime: long, stop time in hhmmss NOT including stop second radar
                 profiles. Enter -1 to read to the end of the file.
       Ddprmsf:  input,string, path/name to a data file containing dual- 
                 Doppler grid and other processing parameters. If the
                 file does not exist, it will be created interactively
                 (for more info get familiar with wcrddinit routine). 
       Beams:    dual-antenna configuration:
                  a) fltarr(3,2), [[hbeam],[vbeam]], unit vectors in AC coord.
                     [AC along axis, right wing, down] for H and V beams or,
                  b) use default beam unit vectors in AC coord. for each valid
                     configuration (beam vectors can be seen in wcrbeam.pro):
                     0 - N2UW KA dual-down antennas
                         hbeam: down_fore 15" antenna (~30 deg down-fore)
                         vbeam: down 18" antenna (near nadir)
                     1 - N2UW KA dual-side antennas
                         hbeam: side 12" antenna
                         vbeam: side_fore 12" antenna (~35 deg side-fore)
                     2 - NCAR C130 dual-down antennas (7/16/2001-7/30/2001)
                         hbeam: down 12" antenna
                         vbeam: down-aft 12" antenna

       Wcrprm:   fltarr(2-7) or fltarr(12),parameters related to the WCR
                 raw data, [hhcal,vvcal,thresh,timeoffset,ppselect,leakrg, 
                            radmom]:

                   hhcal: WCR h-channel/beam calibration constant
                   vvcal: WCR v-channel/beam calibration constant
                  thresh: Reflectivity threshold given in number of noise
                          channel standard deviations (e.g., 2.5 means all
                          data points below 2.5*std(noise) are marked as
                          no_signal or missing using NaN. If 0 is entered
                          no actual thresholding is done and only the points
                          below the mean noise are marked with NaNs
              timeoffset: WCR time correction to sync with AC INS(IRS)
                          data in seconds  (default/not_defined 0.0); negative
                          timeoffset means WCR time is ahead of AC time.
                          For KA, GPS leap seconds correction is applied and
                          must not be included in timeoffset.
                ppselect: select desired pulse pairs (pp) for uncorrected
                          Doppler velocity (default/not_defined 0):
                      0 - PPMAG4 (HHVV/VVHH pulse sequence only, no choice)
                          PPMAG6, uses h-/v-beam matching pp with max prf
                     XY - PPMAG6, X, Y are the desired pp counted from left
                          in the pulse sequence (e.g., for HHHVVV 12 is not
                          valid but 14 or 25 are OK)
                  leakrg: number of first range gates removed due to Tx 
                          leakage (default/not_defined 0)
                  radmom: input for applying antenna moment correction
                     a)   fltarr(6),[hradmom,vradmom], antenna positions in AC
                          coordinates (meters from INS) for H and V beams
                          (if not defined and Beams is fltarr(3,2) antenna
                           moment correction is NOT applied; IGNORED if
                           beams=0 to 2) or
                     b)   integer, code for applying antenna moment correction
                      0 - antenna moment correction NOT applied
                      1 - antenna moment correction applied
                          Antenna positions in AC coord. (meters from INS)
                          can be seen in wcracvelm.pro
                          If radmom not defined: for UWKA not applied (0)
                                                 for NCAR C130 applied(1)
                  leakrm: [lkt0,lkt1,slkf,lkrg]; determines Tx leak using data
                          between lkt0 and lkt1 times (in hhmmss.dd) and for
                          lkrg number of range gates; then thresholds (removes 
                          leakage) data below mean(leak)+slkf*stdev(leak)
                          (if not defined no Tx leak is removed)
                          ATTN: 1) both beams (h and v) should be free of any
                                   echo in the specified segment; 
                                2) works for data after 2004
 KEYWORD PARAMETERS:
       ACNAMES:  input, string array, AC netcdf varnames to be used (if not 
                        defined N2UW or N130AR default var names are used; 
                        see ACLOADINS.PRO for the default variable names)
                 acnames[0] - AC time (seconds in UNIX format)
                 acnames[1] - AC true air speed in m/s
                 acnames[2] - AC roll [deg or rad]
                 acnames[3] - AC pitch [deg or rad]
                 acnames[4] - AC true heading [deg or rad]
                 acnames[5] - AC east-west(EW) ground velocity [m/s]
                 acnames[6] - AC north-south(NS) ground velocity [m/s]
                 acnames[7] - AC vertical velocity [m/s]
                 acnames[8] - AC East component of the wind [m/s]
                 acnames[9] - AC North component of the wind [m/s]
                 acnames[10]- AC vertical wind [m/s]
                 acnames[11]- AC roll rate [rad/s] (use '' if N/A)
                 acnames[12]- AC pitch rate [rad/s](use '' if N/A)
                 acnames[13]- AC heading rate [rad/s] (use '' if N/A)
                 acnames[14]- AC EW ground vel. GPS correction(use '' if N/A)
                 acnames[15]- AC NS ground vel. GPS correction(use '' if N/A)
                 acnames[16]- AC longitude [deg](use '' if N/A)
                 acnames[17]- AC latitude [deg] (use '' if N/A)
                 acnames[18]- AC altitude MSL [m](use '' if N/A)
                 acnames[19]- AC geometric altitude [m](use '' if N/A)
                 acnames[20]- AC sideslip angle [deg or rad] (use '' if N/A)

       ACDDD:    output, structure containing AC data used for the dual-Doppler
                 analysis (n,rg - radar profiles/rangegates to be processed):
                 Acddd.beta   -> fltarr(n), AC sideslip angle [rad]
                 Acddd.lon    -> fltarr(n), longitude position of the AC [deg]
                 Acddd.lat    -> fltarr(n), latitude position of the AC [deg]
                 Acddd.alt    -> fltarr(n), AC altitude MSL [m]
                 Acddd.phi    -> fltarr(n), AC roll angle [rad]
                 Acddd.psi    -> fltarr(n), AC true heading [rad from North]
                 Acddd.ralt   -> fltarr(n), AC geometric altitude [m]
                 Acddd.rarm   -> fltarr(3,2),[h_antenna,v_antenna], antenna
                                             positions w.r.t. AC INS in AC
                                             coodinate system
                 Acddd.theta  -> fltarr(n), AC pitch angle [rad]
                 Acddd.ug     -> fltarr(n), East-West AC ground velocity [m/s]
                 Acddd.uw     -> fltarr(n), East wind velocity component [m/s]
                 Acddd.vg     -> fltarr(n), North-South AC grnd velocity [m/s]
                 Acddd.vw     -> fltarr(n), North wind velocity component [m/s]
                 Acddd.wg     -> fltarr(n), AC vertical velocity [m/s]
                 Acddd.ww     -> fltarr(n), vertical wind vel. component [m/s]

       WCRDDD:   output,structure containing WCR data used for the dual-doppler
                 analysis:
                 Wcrddd.n     -> number of profiles from start to stop time
                 Wcrddd.rg    -> number of radar range gates
                 Wcrddd.time  -> dblarr(n),    WCR time stamps (UNIX seconds)
                 Wcrddd.maxvel-> fltarr(2),    h,v-beam Nyquist velocities
                 Wcrddd.beamh -> fltarr(n,3),  h-beam vector in Earth coordinates
                 Wcrddd.beamv -> fltarr(n,3),  v-beam vector in Earth coordinates
                 Wcrddd.dvh   -> fltarr(n,rg), AC motion corrected Doppler
                                               velocity for h-beam in [m/s]
                                               (positive is toward the radar)
                 Wcrddd.dvv   -> fltarr(n,rg), AC motion corrected Doppler
                                               velocity for v-beam in [m/s]
                                               (positive is toward the radar)
                 Wcrddd.rng   -> fltarr(rg),   radar beam range gates in meters
                 Wcrddd.snrh  -> fltarr(n,rg), h-ch/beam received power SNR in dB
                 Wcrddd.snrv  -> fltarr(n,rg), v-ch/beam received power SNR in dB
                 Wcrddd.zh    -> fltarr(n,rg), h-ch/beam reflectivity in dBz
                 Wcrddd.zhstd -> fltarr(n),    h-ch/beam noise St.Dev. in dBZ@1km
                 Wcrddd.zv    -> fltarr(n,rg), v-ch/beam reflectivity in dBz
                 Wcrddd.zvstd -> fltarr(n),    h-ch/beam noise St.Dev. in dBZ@1km

       DVSD:     input, structure containing calculated Doppler velocity 
                 variance for h- and v-beam data as monotonic functions of 
                 signal-to-noise-ratio(snr). Recommended snr range is from
                 -15dB to +20dB with a 0.5dB step.
                 If not defined DVSD is calculated from the wcr data.
                 In this case the result may differ significantly from the 
                 expected curve either due to lack of sufficient
                 statistics/data or presence of other interference:

                 dvsd.snrh -> fltarr(binh), snr bins for h-beam velocity
                 dvsd.sdh  -> fltarr(binh), StDev(snr) for h-beam velocity
                 dvsd.snrv -> fltarr(binv), snr bins for v-beam velocity
                 dvsd.sdv  -> fltarr(binv), StDev(snr) for v-beam velocity
                 Note: binh/v are the number of bins between minimum and 
                       maximum snr of the data; 0.5 dB step recommended

       Pcstats: output, structure containing some statistics of the result from
                the processing. The data arrays used are contained in Dddaux 
                struct. The description of the structure depends on the 
                processing (for grddd.leg=0/1 see wcrddproc0/1 help) 

       RADRANGE: input, integer; last rangegate index in the data segment
                 (default, max rangegate); Note: to limit the rangegates from
                 the beginning use leakrg in wcrprm keyword
       SUNFOLD:  input,wind scale factor(wind profile) along the range gate
                 aaxis when UNFOLD is defined (useful in the presence of strong
                 wind shear(see wcrwunfold.pro):
                 fltarr(rgt) - apply to both beams; rgt=total number of gates
                 fltarr(rgt,2) - [*,0], apply to h-beam; [*,1], apply to v-beam
       UNFOLD:   input, if given wcrdd ignores the unfolding input from 
                 pcddd.unfold (prepared by wcrddinit) and implements the
                 unfolding based on this input (this allows for more
                 elaborated unfolding procedure as described in wcrdddata):
                 fltarr(3)  - [u,v,w], use the given wind vector for both beams
                              u,v,w are allowed the following values:
                              float: actual wind value to be used in m/s
                                888: use AC measured values for all 
                                     profiles of this component
                                777: use mean of AC measured values from 
                                     all profiles of this component
                 fltarr(6)  - [uh,vh,wh,uv,vv,wv], use the given wind vectors 
                              [uh,vh,wh] for h-beam and [uv,vv,wv] for v-beam 
                 fltarr(n,3)- use different wind vector for each profile for
                              both beam or
                 fltarr(n,6)- use different wind vector for each profile for
                              h-beam([n,0:2]) and v-beam([n,3:5])
       WINDINFO: output,fltarr(NXI,NET,3),(U,V,W) components in the GLOBAL UFRS 
                 of the external wind.(from wnddd.wext, see wcrddinit.pro)
       HELP:     shows this text

 OUTPUTS:
       Ddd:    structure containing the dual-Doppler analysis data:
               ddd.vel   -> fltarr(NXI,NET,3), dual-Doppler velocities;
                            x,y,z vel.components for every cell in WBRRS
                            (only the relevant two components are significant)
               ddd.winfo -> fltarr(NXI,NET,3), external wind info for every
                            grid cell in LOCAL WBRRS (WINDINFO,see above, is 
                            the same but in GLOBAL UFRS)
               ddd.z     -> fltarr(NXI,NET,3), averaged reflectivities for
                            each grid cell, from h-channel(zh),v-channel(zv) 
                            and their average(zz)
               ddd.snr   -> fltarr(NXI,NET,3), averaged SNR for each grid cell,
                            from h-, v-, and both channels, respectively 

       Dddaux: structure containing some auxiliary data resulting from the 
               dual-Doppler processing(NXI/NET: along/across flight grid cells):
               dddaux.ang_err->fltarr(NXI,NET),lesser angle between best-fit 
                               plane & expected scanning plane in radians
               dddaux.crank  ->fltarr(NXI,NET),Doppler velocity decomposition
                               system rank
               dddaux.resid  ->fltarr(NXI,NET), least-squares residual norm
               dddaux.dtsf   ->fltarr(2,n,rg,3), h/v beam points coordinates in
                               WBRRS;First dimension refers to [h-ch,v-ch]
               dddaux.h_ndx  ->ptrarr(NXI,NET),indices(in 1-D) of h-beam points 
                               falling in the grid cells; h_ndx[i,j] is a 
                               pointer to a lonarr(h_npts[i,j]); 
               dddaux.h_npts ->intarr(NXI,NET),h-beam # of pts falling in every
                               grid cell
               dddaux.h_odx  ->ptrarr(NXI,NET),indices(in 1-D) of h-beam points
                               falling out of their expected grid cells; h_odx[i,j]
                               is a pointer to lonarr(h_npts[i,j]);(leg=1 only)  
               dddaux.h_opts ->intarr(NXI,NET),h-beam # of pts falling out of
                               their expected grid cells; (leg=1 only)
               dddaux.v_ndx  ->ptrarr(NXI,NET),indices(in 1-D) of v-beam points 
                               falling in the grid cells; v_ndx[i,j] is a 
                               pointer to lonarr(v_npts[i,j]);
               dddaux.v_npts ->intarr(NXI,NET),v-beam # of pts falling in every
                               grid cell
               dddaux.v_odx  ->ptrarr(NXI,NET),indices(in 1-D) of v-beam points
                               falling out of their expected grid cells; v_odx[i,j]
                               is a pointer to lonarr(v_npts[i,j]);(leg=1 only)
               dddaux.v_opts ->intarr(NXI,NET),v-beam # of pts falling out of
                               their expected grid cells; (leg=1 only)
               dddaux.swnpts ->ptrarr(NXI,NET),swath in meters for each data
                               point in a cell
               dddaux.swopts ->intarr(NXI,NET),number of pts falling out of
                               every grid cell due to limited swath
               dddaux.swth   ->fltarr(NXI,NET),meadian swath in meters for
                               every grid cell (calculated from dddaux.swnpts)

       Grddd: structure containing grid parameters and other processing option
              parameters:
              grddd.alt0  -> float, altitude in meters of the first grid cell
                             corner point; can be used to locate the grid in 
                             the 3-D space
              grddd.cp    -> fltarr(NXI,NET,3), coordinates  of the grid cell
                             center points (centroids, calculated form the c.g.
                             of grid corner points)[m], in GLOBAL WBRRS; 
                             for curtain-leg case only (grddd.leg=1)
              grddd.crd1  -> fltarr(NXI),along track s-distance to cell
                             center points [m]
              grddd.crd2  -> fltarr(NET), normal to track n-distance to cell
                             center points [m]
              grddd.csize -> fltarr(2),[DHOR,DVER]: grid cell size along
                             track(DHOR) and across track(DVER) directions.
                             If HSR(along track spacing ratio,grddd.srat[0])
                             and/or VSR(across track spacing ratio,grddd.srat[1])
                             ne 1 then they represent the initial cell size
              grddd.dims  -> fltarr(2),[NXI, NET]: number of grid cells along
                             the track and across the track
              grddd.equid -> integer,criterium for construction of the grid
                             for curtain-leg case(leg=1);See wcrddgrid1.pro
                              0=s-curvilinear (along track),constant length arcs.
                              1=constant length chords.
                             Note: this parameter controls how the grid is
                             constructed along-track direction. If 0 then
                             curvilinear track distance (s-coord.) is divided
                             in equal intervals, i.e. in equal-length arcs, or
                             if a spacing ratio is assigned (HSR) in a stretching
                             fashion arcs. If equid=1, then g0p (first row of
                             grid points) are assigned along the track direction
                             with constant length segments from point to point,
                             or if HSR<>0 in a stretching fashion.
              grddd.gp    -> fltarr(NXI+1,NET+1,3), coordinates  of the
                             grid cell corner points[m], in GLOBAL WBRRS 
                             (Global WindBasedRotatedReferenceSystem: z-down,
                             y-rotated accordingly to left-hand rule, x along
                             track for leg type=0 along North otherwise,
                             moving with a given advection velocity).
              grddd.gtime -> dblarr(NXI),approx time associated with the
                             grid center points [UNIX seconds]
              grddd.latlon-> fltarr(NXI,NET,2); LAT,[*,*,0] and LON, [*,*,1],
                             coordinates of grid cell center points(grddd.cp)
              grddd.leg   -> integer, type of flight leg
                              0-straight leg; use anytime the AC track is
                                considered straight
                              1-curtain leg; non-straight flight legs; analysis
                                is slower in this case
              grddd.let   -> float,(input) length of grid normal to track [m]
              grddd.pfct  -> lonarr(2),first and last profile number to be
                             scanned (used for dual-doppler); usually these are
                             1st and last prof. read from wcr; if grddd.rst=1
                             either 1st or last, depending on beam config may
                             be different
              grddd.ptrk  -> integer, criterium for the points along the
                             direction normal(perpendicular) to the track
                              0-follow strictly vertical/horizontal direction
                              1-follow the actual straight beam direction
                             This parameter controls how the grid is built
                             along ETA. If ptrk=0 then the points along ETA
                             direction are constructed following a straight
                             vertical path(VPDD) or straight horizontal (HBDD)
                             If ptrk=1 then those points are constructed following
                             the actual straight beam direction (down or side).
              grddd.RM2   -> fltarr(3,3,NXI) for grddd.leg=1 and fltarr(3,3)
                             for grddd.leg=0;  rotation matrix to go from UFRS
                             (Unrotated FixedReference System: E,N,Up) to WBRRS
              grddd.rst   -> integer(0/1),reset flag. If set to 1 it forces the
                             grid origin to be colocated with the first point of
                             the nadir/side beam, past which data from both,
                             nadir/side and the slanted beams data are present.
                             It attempts at getting rid of the first triangle.
                             For C-130 cases it attempts at getting rid of the
                             last triangle.
              grddd.srat  -> fltarr(2),[HSR,VSR],grid spacing ratios along the
                             track and normal to track. The cell size along the
                             2 directions is determined as:
                              -along XI,  etasize[i+1]=etasize[i]*HSR
                              -along ETA, etasize[j+1]=etasize[j]*VSR
              grddd.wcrt  -> [start time, stop time] of the WCR data segment 
                             in UNIX seconds
              grddd.swth  -> grid out-of-the-plane swath [m]
              grddd.wadv  -> fltarr(3),[wadve,wadvn,wadvu], (East,North,UP)
                             advection velocity used in making of the grid, 
                             which become air-relative(WBRRS):
                              [0.,0.,0.]    - WBRRS is not moving but coincides
                                              with FRRS(FixedRotatedRefSys).
                              [Ve,Vn,Vu]    - constant advection velocity
                                              along E,N,UP Ref.Sys.(UFRS).
                              [888,888,888] - WBRRS is moving with the AC
                                              measured wind velocities w.r.t.
                                              UFRS, point by point along track
                              [777,777,777] - WBRRS is moving with measured
                                              mean AC wind w.r.t. UFRS
                              [666,666,666] - WBRRS is moving with a mean
                                              flow calculated from the Doppler
                                              field, w.r.t. UFRS

       Wcrdvsd: structure containing Doppler velocity variance estimates as a
                 function of signal-to-noise-ratio(snr). It is calculated or
                 taken from Dvsd input if given (see DVSD keyword description):

                 Wcrdvsd.snrh -> fltarr(binh), snr bins for h-beam velocity
                 Wcrdvsd.sdh  -> fltarr(binh), StDev(snr) for h-beam velocity
                 Wcrdvsd.indh -> lonarr(wbh),  indices for the bins used in the
                                               h-beam data weighting(-1=noweight)
                 Wcrdvsd.snrv -> fltarr(binv), snr bins for v-beam velocity
                 Wcrdvsd.sdv  -> fltarr(binv), StDev(snr) for v-beam velocity
                 Wcrdvsd.indv -> lonarr(wbv),  indices for the bins used in the
                                               v-beam data weighting(-1=noweight)
                 Note: binh/v are the number of bins between minimum and 
                       maximum snr of the data with 0.5 dB step; wbh/v are 
                       determined from dvsdmin & dvsdmax given in pcddd.whtprm

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:
       Plots graphs of AC Eulerian Angles and of AC ground track if requested.

       Output dddaux contains several [nxi,net] pointer arrays to integer 
       arrays of variable sizes.  If dddaux is to be deleted after running 
       wcrdd the user should also clean all dereferenced pointer arrays by
       running heap_gc routine after dddaux is deleted.

 PROCEDURE:

 NOTES AND ABBREVIATIONS:

      UFRS: it is the UnrotatedFixedReferenceSystem. x,y,z along East,North,Up.
            its origin is fixed with the first position of the aircraft
            according to the portion of the file under investigation. It can be
            considered anchored to the ground.
      FRRS: it is the FixedRotatedReferenceSystem. x,y,z along East,North,Down
            for the case leg=1, otherwise x is along the track, z points
            vertically down and y points according to the lefthand rule for the
            reference system. Its origin may be thought as anchored to the
            first position of the radar straight beam antenna in the portion of
            the file under investigation.
      WBRS: it is the WindBasedReferenceSystem. It is a GLOBAL reference system
            (as opposed to LOCAL for each single cell of the grid), with x,y,z
            aligned with UFRS. Its origin moves with the advection velocity (3
            components) of the wind as dictated by grddd.wadv.
      WBRRS(GLOBAL): it is the GLOBAL WindBasedRotatedReferenceSystem. In case
            of leg=0, the x is aligned with the AC track, z points downward and
            y to the right of the track. For leg=1, x is along East, z points
            downward and y points according to the left hand rule. Its origin
            moves with the advection velocity (3 components) of the wind as
            dictated by grddd.wadv.
      WBRRS(LOCAL): it is the LOCAL WindBasedRotatedReferenceSystem. It is used
            only in case of leg=1; there is one LOCAL WBRRS per grid column.
            The x is aligned along two consecutive(along track) grid corner
            points; if ptrk=0 then z is on a vertical plane pointing down and y on
            a horizontal plane to the right of the track; if ptrk=1 and VDD
            enabled then z is determined by an averge direction obtained
            connecting 2 points (O & Q) belonging to the 1st and 2nd rows of
            the grid as follows:O=(g0p[i,*]+g0p[i+1,*])/2,
                                Q=(gp[i,1,*]+gp[i+1,1,*])/2;
            y is then fixed by the lefthand rule. If ptrk=1 and HBDD enabled
            then y is determined in an analogous way as for z with VDD, and z
            determined by the lefthand rule.
            Its origin is associated with O, but in the process of assessing
            whether a point belongs to a cell it is associated with the
            upper-left corner point of the cell for simplicity. For the way the
            g0p (and gp) points are constructed, the origins of these local
            ref. sys. move with the advection velocity (3 components) of the
            wind as dictated by grddd.wadv.
    XI,ETA: leading directions of the grid (XI: along and ETA: normal-to-track)
      grid: NXI columns by NET rows containing the dual-doppler processed
            volumes; by row we mean a series of consecutive points along XI,
            and by column - along ETA.
   NXI,NET: number of grid center points along XI and ETA
   HSR,VSR: spacing ratios along the XI and ETA directions.
       IDW: InverseDistanceWeighting, used in weighting info coming from various
            points in each cell based on their distance from the center of the cell.
       BSW: BeamSkewnessWeighting,  used in weighting info coming from various
            points in each cell based on their associated beam-unit-vector
            component normal to the intended plane of scan.

 EXAMPLE:
       Calculate VPDD for a case from the IHOP experiment, 24 May 2002:

         startt   = 202320
         stopt    = 202520
         ddprmsf  = 'may2402_202320_202520.dat'
         beams    = [[ 0.439,  0.005,  0.8982],[-0.0565, 0.0245, 0.9981]]
         leakrg   = 1
         radrange = 60
         wcrprm   = [53.5,50.0,2.5,0.89,0,leakrg,1]

         wcrdd,startt,stopt,ddprmsf,beams,wcrprm,ddd,grddd,dddaux, $
               radrange=radrange,acddd=acddd,wcrddd=wcrddd

       Prepare an ascii file with VPDD data for Tecplot visualization:

         wcrdd2tplot,'may2402_202320_202520_tec.dat',ddd,grddd,dddaux, $
                     /alt,/twobeam,planar=2

(See /tools/idl/wcrtools/wcrdd.pro)


WCRDD2TPLOT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRDD2TPLOT
     
 PURPOSE:
      This routine is part of the WCR airborne Dual-Doppler analysis package
      (wcrdd.pro). Writes an ascii file with selected Dual-Doppler outputs
      suitable for 2-D/3-D visualization by TecPlot (preplot utility).

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      wcrdd2tplot,tecplotf,ddd,grddd,dddaux,$
                   alt=alt,twobeam=twobeam,planar=planar,help=help

 INPUTS:
      Tecplotf: string, path/filename for the ASCII output file
      Ddd:      structure containing the dual-Doppler analysis data
                (see wcrdd.pro for more help)
      Grddd:    structure containing grid parameters and other processing
                option parameters (see wcrdd.pro for more help)
      Dddaux:   structure containing some auxiliary data resulting from the 
                wcrdd calculations (see wcrdd.pro for more help)

 KEYWORD PARAMETERS:
      ALT:     when set, the grid vertical coordinate is computed by
               adding the grddd.alt0 value as 1st corner point altitude.
      TWOBEAM: when set, assigns NaNs to the velocities associated with 
               cells containing data from one beam only,if any(i.e: rank=1).
      PLANAR:  input,integer, sets the visualization layout
               0 - visualization in 3-D (default)
               1 - 2-D horizontal plane
               2 - 2-D vertical plane
      HELP:    shows this text

 OUTPUTS:
  
 SIDE EFFECTS:
      Write an ascii file in a directory and name given by tecplotf

 NOTE:
      A note about the 3-D/2-D axes for VPDD and HBDD.
      For 3-D layout the axes x-y-z are East-North-Up
      For 2-D VPDD: x-z are Along_track-Up (if alt is set); VW=W is positive up
                    or Along_track-Across_track(alt not set); VW=W is positive up
      For 2-D HBDD: x-y are Along_track-Across_track; VW=V is positive along y
                    and y-axis(to the aircraft right) must be reversed in tecplot

 EXAMPLE:

      tecplotf='data/20030826.182022.ddat'
      wcrdd2tplot,tecplotf,ddd,grddd,dddaux,planar=2,/alt

      Run TecPlot utility from OS prompt to prepare final input file 
       preplot -d 20030826.182022.ddat 
      preplot will output a file 20030826.182022.plt
      then run tecplot and use the menus to load 20030826.182022.plt

(See /tools/idl/wcrtools/wcrdd2tplot.pro)


WCRDDACDISP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	WCRDDACDISP

 PURPOSE:
    Display aircraft attitude angles and ground track.
    This routine is not stand alone and is used by wcrddgrid0.pro
    and wcrddgrid1.pro as part of the WCR airborne Dual-Doppler
    analysis package wcrdd.pro.

 CATEGORY:
    wcrtools

 CALLING SEQUENCE:
    wcrddacdisp,wcrddd,acddd,acstats,ddbreak=ddbreak,setwin=setwin

(See /tools/idl/wcrtools/wcrddacdisp.pro)


WCRDDDATA

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRDDDATA

 PURPOSE:
       Prepare input for WCR airborne dual-doppler analysis (wcrdd.pro) 
       WCR raw data file and an aircraft (AC) data file(netcdf, N2UW KingAir 
       or NCAR C130) are used.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrdddata,wcrfile,acfile,starttime,stoptime,beams,wcrprm,wcrddd,     $
                 acddd,wcrdvsd,acnames=acnames,radrange=radrange,dvsd=dvsd, $
                 acid=acid,closeac=closeac,closewcr=closewcr,unfold=unfold, $
                 pcddd=pcddd,help=help

 INPUTS:
       Wcrfile:   string, path/name of a raw WCR data file
       Acfile:    string, path/name of the aircraft(AC) data netcdf file
                  Note: should have at least 10Hz INS data (25 Hz optimal)
       Starttime: long, start time in hhmmss. Enter -1 to start from the
                  beginning of the file
       Stoptime:  long, stop time in hhmmss NOT including stop second radar
                  profiles. Enter -1 to read to the end of the file.
       Beams:     dual-antenna configuration:
                   a) fltarr(3,2), [[hbeam],[vbeam]], unit vectors in AC coord.
                      [AC along axis, right wing, down] for H and V beams or,
                   b) use default beam unit vectors in AC coord. for each valid
                      configuration (beam vectors can be seen in wcrbeam.pro):
                      0 - N2UW KA dual-down antennas
                          hbeam: down_fore 15" antenna (~30 deg down-fore)
                          vbeam: down 18" antenna (near nadir)
                      1 - N2UW KA dual-side antennas
                          hbeam: side 12" antenna
                          vbeam: side_fore 12" antenna (~35 deg side-fore)
                      2 - NCAR C130 dual-down antennas (7/16/2001-7/30/2001)
                          hbeam: down 12" antenna
                          vbeam: down-aft 12" antenna

       Wcrprm:    fltarr(2-6),fltarr(7),fltarr(11),fltarr(12),fltarr(16),
                  parameters related to WCR raw data:
                  [hhcal,vvcal,thresh,timeoffset,ppselect,leakrg,leakrm,radmom]

                  hhcal:  WCR h-channel/beam calibration constant
                  vvcal:  WCR v-channel/beam calibration constant
                  thresh: Reflectivity threshold given in number of noise
                          channel standard deviations (e.g., 2.5 means all
                          data points below 2.5*std(noise) are marked as
                          no_signal or missing using NaN. If 0 (default)
                          no actual thresholding is done and only the points
                          below the mean noise are marked with NaNs
                  timeoffset: WCR time correction to sync with AC INS(IRS)
                          data in seconds  (default/not_defined 0.0); negative
                          timeoffset means WCR time is ahead of AC time.
                          For KA GPS leap seconds correction is applied and
                          must not be included in timeoffset.
                  ppselect: select desired pulse pairs (pp) for uncorrected
                            Doppler velocity (default/not_defined 0):
                     0  - PPMAG4 (HHVV/VVHH only valid pulse sequence, no choice)
                          PPMAG6/8, uses h-/v-beam matching pp with max prf
                     XY - PPMAG6/8, X Y are the desired pulse pairs counted 
                          from left in the pulse sequence (e.g., for HHHVVV 
                          12 is not valid but 14 or 25 are OK)
                   leakrg: number of range gates removed due to Tx leakage
                           (default/not_defined 0)
                   radmom: input for applying antenna moment correction
                     a) fltarr(6),[hradmom,vradmom], antenna positions in AC
                            coordinates (meters from INS) for H and V beams
                            (if not defined and beams is fltarr(3,2) antenna
                            moment correction is NOT applied;
                            IGNORED if beams=0 to 2) or
                     b) integer, code for applying antenna moment corrections
                        0 - antenna moment correction NOT applied
                        1 - antenna moment correction applied
                            Antenna positions in AC coord. (meters from INS)
                            can be seen in wcracvelm.pro
                        If not defined: for UWKA not applied (0)
                                        for NCAR C130 applied(1)
                   leakrm: [lkt0,lkt1,slkf,lkrg]; determines Tx leak using data
                           between lkt0 and lkt1 times (in hhmmss.dd) and for
                           lkrg number of range gates; then thresholds (removes 
                           leakage) data below mean(leak)+slkf*stdev(leak)
                           (if not defined no Tx leak is removed)
                           ATTN: 1) both beams (h and v) should be free of any
                                    echo in the specified segment;
                                 2) if lkt0=lkt1 - no leak correction 
                                 3) works for data after 2004
 KEYWORD PARAMETERS:
       ACID:     output, Acfile id if left open (CLOSEAC not set)
       ACNAMES:  input, string array, AC netcdf varnames to be used (if not 
                        defined N2UW or N130AR default var names are used; 
                        see ACLOADINS.PRO for the default variable names)
                 acnames[0] - AC time (seconds in UNIX format)
                 acnames[1] - AC true air speed in m/s
                 acnames[2] - AC roll [deg or rad]
                 acnames[3] - AC pitch [deg or rad]
                 acnames[4] - AC true heading [deg or rad]
                 acnames[5] - AC east-west(EW) ground velocity [m/s]
                 acnames[6] - AC north-south(NS) ground velocity [m/s]
                 acnames[7] - AC vertical velocity [m/s]
                 acnames[8] - AC East component of the wind [m/s]
                 acnames[9] - AC North component of the wind [m/s]
                 acnames[10]- AC vertical wind [m/s]
                 acnames[11]- AC roll rate [rad/s] (use '' if N/A)
                 acnames[12]- AC pitch rate [rad/s](use '' if N/A)
                 acnames[13]- AC heading rate [rad/s] (use '' if N/A)
                 acnames[14]- AC EW ground vel. GPS correction(use '' if N/A)
                 acnames[15]- AC NS ground vel. GPS correction(use '' if N/A)
                 acnames[16]- AC longitude [deg](use '' if N/A)
                 acnames[17]- AC latitude [deg] (use '' if N/A)
                 acnames[18]- AC altitude MSL [m](use '' if N/A)
                 acnames[19]- AC geometric altitude [m](use '' if N/A)
                 acnames[20]- AC sideslip angle [deg or rad] (use '' if N/A)

       CLOSEAC:  input, when set AC netcdf file will be closed.
       CLOSEWCR: input, when set WCR raw data file will be closed.
       DVSD:     input, structure containing calculated Doppler velocity 
                 variance for h- and v-beam data as monotonic functions of 
                 signal-to-noise-ratio(snr). Recommended snr range is from
                 -15dB to +20dB with a 0.5dB step.
                 If not defined DVSD is calculated from the wcr data.
                 In this case the result may differ significantly from the 
                 expected curve either due to lack of sufficient
                 statistics/data or presence of other interference:

                 dvsd.snrh -> fltarr(binh), snr bins for h-beam velocity
                 dvsd.sdh  -> fltarr(binh), StDev(snr) for h-beam velocity
                 dvsd.snrv -> fltarr(binv), snr bins for v-beam velocity
                 dvsd.sdv  -> fltarr(binv), StDev(snr) for v-beam velocity
                 Note: binh/v are the number of bins between minimum and 
                       maximum snr of the data; 0.5 dB step recommended
       PCDDD:    input,structure containing processing parameters (output from
                 wcrddinit routine); If not defined wcrdddata will skip 
                 the calculation of Wcrdvsd structure for which pcddd is needed
       RADRANGE: input, integer; last rangegate index in the data segment
                 (default, max rangegate); Note: to limit the rangegates from
                 the beginning use leakrg in wcrprm keyword
       SUNFOLD:  input,wind scale factor(wind profile) along the range gate
                 aaxis when UNFOLD is defined (useful in the presence of strong
                 wind shear(see wcrwunfold.pro):
                 fltarr(rgt) - apply to both beams; rgt=total number of gates
                 fltarr(rgt,2) - [*,0], apply to h-beam; [*,1], apply to v-beam
       UNFOLD:   input, Doppler velocity unfolding procedure (see notes)
                 0          - no unfolding is performed (default)
                 1          - use AC measured winds profile by profile
                 3,5,...    - odd integer, use smoothed by 3,5,...profiles 
                              AC measured wind component into the beams
                 fltarr(3)  - [u,v,w], use the given wind vector for both beams
                              u,v,w are allowed the following values:
                              float: actual wind value to be used in m/s
                                888: use AC measured values for all 
                                     profiles of this component
                                777: use mean of AC measured values from 
                                     all profiles of this component
                 fltarr(6)  - [uh,vh,wh,uv,vv,wv], use the given wind vectors 
                              [uh,vh,wh] for h-beam and [uv,vv,wv] for v-beam 
                 fltarr(n,3)- use different wind vector for each profile for
                              both beam or
                 fltarr(n,6)- use different wind vector for each profile for
                              h-beam([n,0:2]) and v-beam([n,3:5])
                 Note: last 2 options require knowledge of n; NOT TESTED
       HELP:     shows this text

 OUTPUTS:
       Wcrddd:   structure containing WCR data needed for dual-doppler analysis
                 Wcrddd.n     -> number of profiles from start to stop time
                 Wcrddd.rg    -> number of radar range gates
                 Wcrddd.time  -> dblarr(n),    WCR time stamps (UNIX seconds)
                 Wcrddd.maxvel-> fltarr(2),    h,v-beam Nyquist velocities
                 Wcrddd.beamh -> fltarr(n,3),  h-beam vector in Earth coordinates
                 Wcrddd.beamv -> fltarr(n,3),  v-beam vector in Earth coordinates
                 Wcrddd.dvh   -> fltarr(n,rg), AC motion corrected Doppler
                                               velocity for h-beam in [m/s]
                 Wcrddd.dvv   -> fltarr(n,rg), AC motion corrected Doppler
                                               velocity for v-beam in [m/s]
                 Wcrddd.rng   -> fltarr(rg),   radar beam range in meters
                 Wcrddd.snrh  -> fltarr(n,rg), h-ch/beam received power SNR in dB
                 Wcrddd.snrv  -> fltarr(n,rg), v-ch/beam received power SNR in dB
                 Wcrddd.Zh    -> fltarr(n,rg), h-ch/beam reflectivity in dBz
                 Wcrddd.Zhstd -> fltarr(n),    h-ch/beam noise St.Dev. in dBZ@1km
                 Wcrddd.Zv    -> fltarr(n,rg), v-ch/beam reflectivity in dBz
                 Wcrddd.Zvstd -> fltarr(n),    h-ch/beam noise St.Dev. in dBZ@1km

       Wcrdvsd:  structure containing Doppler velocity variance estimates as a
                 function of signal-to-noise-ratio(snr). It is calculated or
                 taken from Dvsd input if given (see DVSD keyword description)

                 Wcrdvsd.snrh -> fltarr(binh), snr bins for h-beam velocity
                 Wcrdvsd.sdh  -> fltarr(binh), StDev(snr) for h-beam velocity
                 Wcrdvsd.indh -> lonarr(wbh),  indices for the bins used in the
                                               h-beam data weighting(-1=noweight)
                 Wcrdvsd.snrv -> fltarr(binv), snr bins for v-beam velocity
                 Wcrdvsd.sdv  -> fltarr(binv), StDev(snr) for v-beam velocity
                 Wcrdvsd.indv -> lonarr(wbv),  indices for the bins used in the
                                               v-beam data weighting(-1=noweight)
                 Note: binh/v are the number of bins between minimum and 
                       maximum snr of the data with 0.5 dB step; wbh/v are 
                       determined from dvsdmin & dvsdmax given in pcddd.whtprm

       Acddd:    structure containing AC data needed for dual-doppler analysis
                 Acddd.beta   -> fltarr(n), AC sideslip angle [rad]
                 Acddd.lon    -> dblarr(n), longitude position of the AC [deg]
                 Acddd.lat    -> dblarr(n), latitude position of the AC [deg]
                 Acddd.alt    -> fltarr(n), AC altitude MSL [m]
                 Acddd.phi    -> fltarr(n), AC roll angle [rad]
                 Acddd.psi    -> fltarr(n), AC true heading [rad from North]
                 Acddd.ralt   -> fltarr(n), AC geometric altitude [m]
                 Acddd.rarm   -> fltarr(3,2),[h_antenna,v_antenna], antenna
                                              positions w.r.t. AC INS in AC
                                              coodinate system
                 Acddd.theta  -> fltarr(n), AC pitch angle [rad]
                 Acddd.ug     -> fltarr(n), East-West AC ground velocity [m/s]
                 Acddd.uw     -> fltarr(n), East wind velocity component [m/s]
                 Acddd.vg     -> fltarr(n), North-South AC ground velocity [m/s]
                 Acddd.vw     -> fltarr(n), North wind velocity component [m/s]
                 Acddd.wg     -> fltarr(n), AC vertical velocity [m/s]
                 Acddd.ww     -> fltarr(n), vertical wind velocity component [m/s]

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:

 NOTES:
       When UNFOLD keyword is defined and non-zero, an attempt to unfold
       non-varying (single, double, etc.) folding in the Doppler velocity 
       field is performed.  It is based on the assumption that the AC  
       measured winds or the given mean winds are causing the folding. 
       Thus centering the corrected for aircraft motion measured folded
       Doppler velocities around the wind contribution into the WCR beam
       is expected to render non-folded velocities.

       KA/C130 netCDF files follow the NCAR-RAF/nimbus convention.  This
       convention requires that the time dimension, 'time' (unlimited or not),
       is the first (last for idl, which uses column_based order) and the next
       dimension, if exists, is always samples per second, 'sps'.

       Aircraft time stamps for every data point are assembled using sps
       dimension and the following two netcdf variables:
       'base_time' - seconds since 00:00:00 Jan 1 1970
       'time_offset' - seconds since base_time, a sequence with 1 sec step

       This routine uses jhuapl idl library routine fixang.pro

 EXAMPLES:
       1) From IHOP 2002 Experiment

       wcrdddata,'W2002-05-24-19-58-02', $
         '/net/owl/data/kingair_data/ihop02/processed/20020524.c25.nc',$
         200830,200930,0,[53.5,50.0,0,0.84],wcrddd,acddd,/closeac,/closew

       2) From DYCOMSII 2001 Experiment

       beams=2
       hhcal=49.5 & vvcal=51.5
       thresh=0                   ; no thresholding
       timeoffset=-0.125
       ppselect=14
       wcrdddata,'/net/fox/fox1/WCR/DYCOMS01/jul24/Wpp01-07-24-11-03-24',  $
         '/net/fox/fox1/C130/hi_rate/RF07.20010724.055334_154831.PNI.nc', $
         110700,110900,beams,[hhcal,vvcal,thresh,timeoffset,ppselect], $
         wcrdd,wcrdvsd,acdd,pcddd=pcddd/closeac,/closew

       3) From NASA 2006 Experiment (load dual-down data, folded velocity)

       wcrdddata,'W2006-02-09-23-04-48','20060209a.c25.nc',230530,230630,0, $
         [55.,50.5,2.5,0.1,0,2],wcrddd,acddd,/closeac,/closew

(See /tools/idl/wcrtools/wcrdddata.pro)


WCRDDDOC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
     WCRDDDOC

 PURPOSE:
     A PDF file describing the Dual-Doppler Analysis software package and
     technique is located at:  wcrdddoc.pdf

     This routine shows the location of the Dual-Doppler documentation file.

 CATEGORY:
     WCR wcrtools

 CALLING SEQUENCE:
     wcrdddoc

(See /tools/idl/wcrtools/wcrdddoc.pro)


WCRDDDV

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRDDDV

 PURPOSE:
      This routine is part of the WCR airborne Dual-Doppler analysis package
      (wcrdd.pro). It calculates the 3-D velocity vector along the grid 
      coordinates from the available doppler velocity measurements of two WCR 
      beams. The procedure uses external data to pre-condition the system (due
      to lack of 3rd dimension measurements). External estimate of the winds is
      used to calculate the component of the velocity/wind perpendicular to the 
      best-fit plane of the two beams.

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      res=wcrdddv(LSM,LSV,v_ext=v_ext,condnum=condnum,vnorm=vnorm)

 INPUTS:
      LSM: fltarr(3,k), beam unit vector components, where k is data points
                        available for each grid cell
      LSV: fltarr(k),   Doppler velocity measurements from h and v beams

 KEYWORD PARAMETERS:
      CONDNUM: input, float,max ratio between the largest and smallest singular
               values(sv). If max(w[i])/w[i] gt condnum, where w[i]=1/(sv), then
               w is set to 0. (default, 100)
      RESID:   output, float, residual |LSM##dvel-LSV|
      V_EXT:   input, float(3), external wind vector in local WBRRS 
               (default,[0,0,0])
      VNORM:   output, float(3), normal vector to the solution space (least-
               square best-fit plane of the beams) for LSM rank 2, otherwise
               0. scalar is returned.
      HELP:    shows this text

 OUTPUTS:
      Res:     dblarr(3), velocity vector in xi,eta,zi of the FRRS

 SIDE EFFECTS:

 PROCEDURE:
      Use IDL SVDC routine (in double precision) to find sv of the input matrix
      LSM. After conditioning the sv the solution is calculated as the least-
      squires minimum norm.  When V_EXT is used, the solution (altough not the
      minimum norm any more) takes advantage of the provided a priori
      information for the unresolved (null space) velocity component. 

 EXAMPLE:

(See /tools/idl/wcrtools/wcrdddv.pro)


WCRDDECHO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRDDECHO

 PURPOSE:
       This routine is part of the WCR airborne Dual-Doppler analysis package
       (wcrdd.pro). It writes out in an ascii file the values of the parameters
       used for Dual-Doppler analysis(data taken from grddd, pcddd and wnddd 
       structures). Statistics of selected aircraft(AC) attitude parameters
       (acstats) and processing results(pcstats) are also recorded.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrddecho,fstruct,grddd,pcddd,wnddd,acstats,pcstats,help=help

 INPUTS:
       Fstruct: structure containing the names of the input/output files
                (output from wcrddinit.pro)
       Grddd:   structure containing grid parameters and other processing
                (output from wcrddinit.pro, wcrddgrid0/1.pro)
       Pcddd:   structure containing processing parameters
                (output from wcrddinit.pro,wcrddgrid0/1.pro)
       Wnddd:   structure containing external wind info processing parameters
                (output from wcrddinit.pro,wcrddwext.pro)
       Acstats: structure containing statistics of the aircraft attitude angles 
                (output from wcrddgrid0/1.pro)
       Pcstats: structure containing some statistics of the result from the
                processing (output from wcrddproc0/1.pro)

 KEYWORD PARAMETERS:
       HELP:    shows this text

 OUTPUTS:

 SIDE EFFECTS:
      This program creates an ascii file using fstruct.echof to define the
      location path and the file name

      The routine expects to find grid structure fields called ALT0,DIMS,CSIZE,
      STRTT and STOPT. ALT0 value is printed in the message area (below the top
      title) of the output file. DIMS is used to verify if a change in the grid
      dimension size took place in the course of the dual-Doppler processing. 
      CSIZE is printed out next to DIMS. STRTT and STOPT are printed in 
      hh:mm:ss.

      Any field(tag) name in pcstats which starts with 'ang' is assumed
      in radians and field names containing 'crank' and 'empty' are in %.

      This routine uses getfile and putfile from JHUAPL idl library

 PROCEDURE:

 NOTES:

 EXAMPLE:

(See /tools/idl/wcrtools/wcrddecho.pro)


WCRDDGRID0

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRDDGRID0

 PURPOSE:
      This routine is part of the WCR airborne Dual-Doppler analysis package
      (wcrdd.pro). It generates a 3-D grid to be used for the dual-Doppler 
      calculations (wcrddproc0.pro) assuming a straight-leg flight pattern.

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      wcrddgrid0, beamopt,acddd,wcrddd,grddd,dtsf,acstats,strk, $
                  acdisp=acdisp,ddbreak=ddbreak,help=help

 INPUTS:
      Beamopt: integer,dual-antenna configuration 
                0    - N2UW KA dual-down antennas
                1    - N2UW KA dual-side antennas
                2    - NCAR C130 dual-down antennas 
      Acddd:   structure containing AC data (for description run wcrdd, /help)
      Wcrddd:  structure containing WCR data(for description run wcrdd, /help)
      Grddd:   structure containing grid parameters and other processing
               option parameters(for description run wcrdd, /help)

 KEYWORD PARAMETERS:
      ACDISP:  input, when set plots AC attitude angles and ground track
                      (see help for pcddd.plts in wcrddinit.pro for more)
      DDBREAK: input, when set allows the user to stop the dual-Doppler 
                      processing. AC attitude statistical information is 
                      displayed.
      HELP:    shows this text

 OUTPUTS:
      Grddd:   structure containing grid parameters and other processing
               option parameters(for description run wcrdd, /help)
      Acstats: structure containing statistics of the aircraft attitude angles 
               Acstats.beta -> fltarr(4),[rad] mean,sdev,min,max sideslip angle 
               Acstats.hdg  -> float, average heading w.r.t. GND (~track angle)
               Acstats.hdgv -> float, average heading w.r.t. WBRS (virtual heading)
               Acstats.pitch-> fltarr(4),[rad] mean,sdev,min,max 
               Acstats.roll -> fltarr(4),[rad] mean,sdev,min,max
               Acstats.yaw2 -> fltarr(4),[rad] mean,sdev,min,max (w.r.t.heading)
               Acstats.yaw2v-> fltarr(4),[rad] mean,sdev,min,max(w.r.t.vheading)
      Dtsf:    fltarr(2,n,rg,3), h-beam(dtsf[0,*,*,*]) and v-beam(dtsf[1,*,*,*])
               data points(n: profiles, rg: range gates) coordinates in WBRRS 
      Strk:    fltarr(n), s-coordinate for the length of track. It is used only
               by wcrddwext routine so far.

 SIDE EFFECTS:

 PROCEDURE:

 NOTES:
      If there is a large bank and/or yaw, the grid will result longer than 
      you would expect due to the fact that the last farthest beam point 
      determines its extent. This may then cause problems, as the time 
      associated with grid center points is interpolated starting from the 
      0th rangegate straight-beam points, which may result to have much 
      shorter xi values then the max extent of the grid. The extrapolation 
      to grid center points whose xi values are higher than the 0th rg 
      points may result in wrong numbers, i.e. the time may even go back. 
      This could be a problem if you want to use the time later on. So,
      reccomendation is to avoid these situations by changing to leg=1.

      Beamopt for NCAR C130 uses h-beam as the straight down beam; this
      will change for future installations when v-beam will be the nadir.
      Appropriate changes to the use of beamopt must be made (perhaps will
      add a new configuration to preserve the ability to work with DYCOMS01)

 EXAMPLE:

(See /tools/idl/wcrtools/wcrddgrid0.pro)


WCRDDINIT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRDDINIT

 PURPOSE:
       This routine is part of the WCR airborne Dual-Doppler analysis package
       (wcrdd.pro). It reads/creates dual-Doppler input parameters file and 
       defines data structures necessary to perform dual-Doppler analysis

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrddinit,ddprmsf,fstruct,grddd,pcddd,wnddd,help=help

 INPUTS:
       Ddprmsf: string, path/name to a data file containing Dual-Doppler
                grid and other processing parameters. If the file does
                not exist, it will be created interactively using wcrddprms.dat
                default data file (located in wcrtools directory).

 KEYWORD PARAMETERS:
       HELP:    shows this text

 OUTPUTS:
       Fstruct: structure containing the names of the input/output files
                Fstruct.wcrinf -> string, path/name wcr input raw file
                Fstruct.acinf  -> string, path/name ac input netcdf file
                Fstruct.prmsf  -> string, ddprmsf with user defined
                                          dual-doppler input parameters
                Fstruct.echof  -> string, path/name echo file of
                                          dual-doppler parameters used
                Fstruct.sndf   -> string, path/name to a sounding data file
                                  containing: 1)wind data in 4 columns: 
                                  altitude(msl), wind vel. components [m/s] 
                                  along East,North,Up, or
                                              2)AC altitude(AGL) in 2 col.:
                                  unix_time[sec],agl[m]

       Grddd:   structure containing grid parameters and other processing
                option parameters(for description run wcrdd, /help)

       Pcddd:   structure containing processing parameters
                pcddd.cndnum -> float, condition number: max ratio between the
                                largest and smallest singular values(s.v.).
                                When calculating the reciprocals of the s.v.
                                if this number is exceeded max(w(i)/w(i)>cndnum)
                                then 1/w(i) is set to 0.
                pcddd.inter  -> integer(0/1),interactive flag.
                                 1 - user is allowed to stop the program after
                                     some stats are presented.
                pcddd.plts   -> integer, plots flag. {default=-1}
                                 0    - no plots 
                                 1-30 - plot Eulerian AC angles and AC track on
                                        2 consecutive windows defined by plts
                                        and plts+1
                                >30   - as above but windows are assigned by
                                        the program
                pcddd.tol    -> lonarr(2),[TOLI,TOLJ] i-ind,j-ind tolerances in
                                the search for point-containing cells; a point
                                appearing not to fall into the expected [i,j] cell
                                might then be checked to belong to a cell in
                                the interval [i-TOLI,i+TOLI;j-TOLJ,j+TOLJ]. It
                                is suggested to use low values to speed up the
                                process; it may be necessary to increase it if
                                the AC motion is very "jittery".
                pcddd.unfold -> integer[0/1/2], Unfolding flag:
                                 0: no unfolding
                                 1: Doppler vel. unfolded using the winds
                                    component into the beams as measured
                                    by the AC, profile by profile;
                                 2: grddd.wadv advection velocity is used
                                    as wind values to unfold the Doppler vel.
                                    except for wadv=666, in which case it will
                                    be interpreted as wadv=777 for unfolding
                pcddd.whtprm -> fltarr(3-6), data weighting parameters:
                                [Code,Exp1,Exp2,ROI,Thresh1,Thresh2,Dvsdmin,Dvsdmax]

                                Code=0: NO weighting is applied.
                                        If dvsdmin and dvsdmax are given and
                                        dvsdmin>dvsdmax then uniform weighting
                                        proportional to the number of points
                                        per beam is applied
                                Code=1: IDW, inverse distance weighting
                                        [Code,Exp1,-1,ROI,Thresh1,-1,Dvsdmin,Dvsdmax]
                                Code=2: BSW, beam skewness weighting
                                        [Code,-1,Exp2,-1,-1,Thresh2,Dvsdmin,Dvsdmax]
                                Code=3: IDW+BSW
                                        [Code,Exp1,Exp2,ROI,Thresh1,Thresh2,Dvsdmin,Dvsdmax]
                                Code=4: CRW, Cressman weighting
                                        [Code,-1,-1,ROI,Thresh1,-1,Dvsdmin,Dvsdmax]
                                Code=5: CRW+BSW
                                        [Code,-1,Exp2,ROI,Thresh1,Thresh2,Dvsdmin,Dvsdmax]
                                Code=6: EXW, exponential weighting
                                        [Code,Exp1,-1,ROI,Thresh1,-1,Dvsdmin,Dvsdmax]
                                Code=7: EXW+BSW
                                        [Code,Exp1,Exp2,ROI,Thresh1,Thresh2,Dvsdmin,Dvsdmax]
                                Code=8: SNR, Signal-to-Noise ratio weighting
                                        [Code,-1,-1,-1,-1,-1,Dvsdmin,Dvsdmax]
                                
                                Exp1/2:    exponent value(s) in the power 
                                           weighting for the weigthing method(s) 
                                           used; suggested for the IDW is 1.0 
                                           or 2.0 and for the EXW, 0.1

                                ROI:       radius of influence; 99999 will use 
                                           the average size of the grid cell 
                                           (DHOR+DVER)/2)

                                Thresh1/2: cutoff threshold to discard points
                                           (default -1, no thresholding) that:
                                  IDW: fall beyond 
                                       (1+Thresh1)*(min(dist)>(0.1*ROI)), where
                                       dist is the distance of the points from
                                       the grid cell center
                                  BSW: are associated with normal-to-reference-
                                       plane components of the beam unit vectors 
                                       (normals) beyond (1+Thresh2)*min(normals). 
                                       If min(normals) is less than sin(1 deg)
                                       then threshold is (1+Thresh2)*sin(1deg). 
                                       E.g., whtprm[2]=0. will cause all data 
                                       points that deviate more than 
                                       min(1 deg,asin(min(normals))) from the
                                       desired grid plane to be discarded.
                                  CRW: fall beyond 
                                       (1+Thresh1)*(min(dist)>(0.1*ROI)), where
                                       dist is the distance of the points from
                                       the grid cell center
                                  EXW: fall beyond 
                                       (1+Thresh1)*(min(dist)>(0.1*ROI)), where
                                       dist is the distance of the points from
                                       the grid cell center

                                Dvsdmin: Min value (in m/s) of the Doppler vel.
                                         standard deviation after which 1 is
                                         assigned to the weights; if 99999 will
                                         use 0.5 m/s
                                         Applies to SNR weighting only (Code=8
                                         or Code < 0)
                                Dvsdmax: Max value (in m/s) of the Doppler vel.
                                         standard deviation after which 0 is
                                         assigned to the weights; if 99999 will
                                         use 1.5 m/s
                                         Applies to SNR weighting only (Code=8
                                         or Code < 0)

                                Note: SNR weighting is applied by default for
                                      any Code>0. If Code is negative no SNR
                                      weighting is applied.                                     
 
                pcddd.xytol  -> fltarr(2),[xi-tolerance,eta-tolerance],
                                (size relative).Tolerances in xi,eta directions
                                in the search for point-containing cells.
                                Example:[0.2,0.3] means a point is considered
                                within cell[i,j] if it falls in a cube of size
                                (xi_size+/-0.2*xi_size)*(eta_size+/-0.3*eta_size)*swth.

       Wnddd:   structure containing external wind info processing parameters
                wnddd.d0     -> float, Displacement height.(Usually~0.3 h0).
                                Used in making a log vertical profile.
                wnddd.hf     -> float, Factor describing the ratio between
                                flight level altitude and boundary layer height
                                zi*hf=palt. Used in making Ekman's Layer
                                vertical profile, where above and at the top
                                of the boundary layer conditions are supposed
                                to be constant and geostrophic.
                wnddd.kappa  -> float,Von-Karmann's constant. Used
                                in making a log vertical profile.(default=0.41)
                wnddd.wa     -> float,"a" coeff. of the parabola describing
                                the vertical profile of the vertical velocity,
                                w. Used in making a log vertical profile or
                                Ekman's Layer vertical profile:
                                       w=a(z-z0)^2.+b(z-z0), where b is calc. 
                                based on flight level boundary condition
                wnddd.wext   -> fltarr(NXI,NET,3),(U,V,W) components in the
                                GLOBAL WBRS(=UFRS) of the external wind.
                wnddd.wflag  -> integer, External info about the winds for SVDC:
                                 0: No external wind info is used.
                                 1: Use whatever has been adopted for 
                                    grddd.wadv; if it is not a constant wind
                                    vector then replicate 'profile by profile
                                    wind' along the other direction.
                                 2: Use a vertical sounding,stored in a file.
                                 3: Use whatever criteria adopted in grddd.wadv
                                    and a vertical log profile along the normal
                                    to track direction (valid for vertical scan):
                                       u=u_* / k *ln((z-d0)/z0);
                                    Vertical velocity is calculated by:
                                       w=a(z-z0)^2.+b(z-z0) (a=wnddd.wa) 
                                 4: Use whatever criteria adopted in wadv and
                                    a vertical Ekman's profile along the normal
                                    to track direction (valid for vertical scan):
                                       u= ug*(1-exp(-c*z)cos(c*z)),
                                       v= ug*exp(-c*z)sin(c*z),
                                       c=(f/2*nu)^0.5, calc. using wnddd.hf
                                    Vertical velocity is calculated by:
                                       w=a(z-z0)^2.+b(z-z0) (a=wnddd.wa) 
                                 5: Use point-by-point AC-measured winds,
                                    independently from grddd.wadv.
                                 6: Use averaged AC-measured wind
                                    independently from grddd.wadv.
                                 7: Use average coming from the corrected
                                    velocities, before the dual-doppler
                                    processor.(It is a better estimate of
                                    the mean flow from the Doppler field)
                                 8: Use wnddd.wexti wind vector (use this when 
                                    an external wind vector different than the
                                    mean AC wind (wflag=6) is needed
                wnddd.wexti  -> fltarr(3),(U,V,W) input components in the
                                GLOBAL WBRS(=UFRS) of the mean external wind
                                for wflag=8 only (otherwise ignored); in this
                                case wnddd.wext=wnddd.wexti for all grid cells
                wnddd.z0     -> float, Roughness height.(Usually~0.1 h0).
                                Used in making a log vertical profile.
                wnddd.zagl   -> float, flag determining how surface elevation
                                is calculated:
                                 0:     use mean AC radar altimeter altitude
                                 1:     use radar alt. redistributed along xi
                                 2:     use altitude(AGL) data stored in a file
                                        (not implemented yet)
                                 float: use given value as const. AGL in meters;
                                        must be greater than or equal to 75.0 m
                                 float: threshold in dBZ used to find surface 
                                        from WCR straight beam reflectivity;
                                        must be less than 75.0 dBZ. Surface
                                        elevation is assigned interpolating
                                        WCR surface range gates data along xi.

 SIDE EFFECTS:
      The input file ddprmsf is an ascii file and is expected to comply with
      the following rules:

   0) Data values equal to 99999 mean that actual values will be calculated by
      an appropriate wcrdd*.pro routine. These values can be found in the
      echo file generated by wcrddecho.pro.
   1) All non-data lines must have 1st char ";" followed by "#"            
      Ending non-data lines using "#" followed by ";" as last char is     
      optional for generating better looking report if needed.             
   2) First data line must contain the type of flight leg (leg=0|1) to
      be processed and grid dimensions NXI and NET.
   3) Data lines can have spaces anywhere except in the input values.      
      Data lines cannot be empty lines. If a data file path/name is not    
      known use '*'.  This will allow you to select a path/file.           
   4) Empty lines and lines with spaces are allowed anywhere. They are     
      ignored.                                                             
   5) The line preceeding a data line (ignoring white space lines) must be 
      a comment line containing the names of the parameters given in the   
      data line.  These names will be used to generate the proper input    
      data in the appropriate data structures.                             
   6) Parameter names must match structure tag names (case  insensitive)   
      in grddd, pcddd and wnddd. Their meaning can be found in the help of 
      wcrddinit.pro. Tag names must be unique for all three structures     
      Same name may appear in sequence which means that the structure field
      is an array.                                                         
   7) If the line containing the names have same name more than once (array
      field) the line before it is an additional name line giving names for  
      each element of the array.  This is needed only if wcrddinit is used 
      to create this file and compliments prompt info during input process.
   8) The comment lines preceeding the data file names are identifier lines
      and must contain the following identifiers: WCR_FILE, AC_FILE,       
      GRID_PROC_FILE, ECHO_FILE, and SOUNDING_FILE separated by space(s) from   
      other informational text                                                   
   9) Except for the data lines and the corresponding preceeding comment   
      lines with the parameters names all other comment lines are ignored. 
  10) The file must start with at least 6 comment lines. They are reserved 
      for program messages. 

 NOTES:
      Some components of the output structures are defined in this procedure
      but their actual values are calculated elsewhere

 EXAMPLE:

(See /tools/idl/wcrtools/wcrddinit.pro)


WCRDDLATLON

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    WCRDDLATLON

 PURPOSE:      
    Calculates lat/lon for all grid cell center points given
    lat/lon of grid first row center points.

    This routine is not stand alone and is used by wcrddproc1.pro
    as part of the WCR airborne Dual-Doppler analysis package wcrdd.pro.

 CATEGORY:
    wcrtools

 CALLING SEQUENCE:
    wcrddlatlon,beamopt,grddd,help=help

 PROCEDURE:
    Find lat,lon,alt(msl) of the grid cell center points(Q).
    To do so consider a Reference system which has its origin(O)
    in the Earth's center, z along south-north pole direction, and x
    intersects the Greenwich Meridian. This Ref. Sys. is called FFO. 
    The usual Ground Reference System (E,N,UP), UFRS, and its origin (P)
    may be considered coincident with the current position, i.e.: the 1st
    row center points. Since OP can be easily determined in FF0 from the
    known lat,lon,alt, and PQ is known in UFRS, all is needed is to put PQ
    in FFO through a rotation matrix, then calculate OQ=OP+PQ and finally,
    calculate the lat,lon for Q from the components of OQ in FFO.

(See /tools/idl/wcrtools/wcrddlatlon.pro)


WCRDDPROC0

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRDDPROC0

 PURPOSE:
      This routine is part of the WCR airborne Dual-Doppler analysis package
      (wcrdd.pro). It calculates dual-Doppler velocities using straight leg 
      grid.

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      wcrddproc0,beamopt,dtsf,wcrddd,wcrdvsd,grddd,pcddd,ddd,dddaux,pcstats,
                 winds_ext=winds_ext,help=help

 INPUTS:
      Beamopt: integer,dual-antenna configuration 
                0    - N2UW KA dual-down antennas (h-down_fore, v-nadir)
                1    - N2UW KA dual-side antennas (h-side, v-side_fore)
                2    - NCAR C130 dual-down antennas (h-nadir,v-down-aft)
      Dtsf:    fltarr(2,n,rg,3), h-beam(dtsf[0,*,*,*]) and v-beam(dtsf[1,*,*,*])
               data points(n: profiles, rg: range gates) coordinates in WBRRS 
      Wcrddd:  structure containing WCR data(for description run wcrdd, /help)
      Wcrdvsd: structure containig Doppler velocity estimate variance as a
               function of signal-to-noise-ratio(for more help run wcrdd,/help)
      Grddd:   structure containing grid parameters and other processing
               option parameters(for description run wcrdd, /help)
      Pcddd:   structure containing processing parameters(for description run
               wcrddinit, /help)

 KEYWORD PARAMETERS:
      WINDS_EXT: input,fltarr(NXI,NET,3), external info on the winds in UFRS
                 (output from wcrddwext.pro; see also wnddd.wext in wcrddinit).
                 Will be transformed into WBRRS and then passed to wcrdddv.pro.
                 It is needed to correct for the wind perpendicular to the 
                 plane of the beams. If not defined or 0 external wind not used.

 OUTPUTS:
      Ddd:     structure containing the dual-Doppler analysis output data
               (for description run wcrdd, /help)
      Dddaux:  structure containing some auxiliary data resulting from the 
               dual-Doppler processing(for description run wcrdd, /help)
      Pcstats: structure containing some statistics of the result from the
               processing. The data arrays used are contained in Dddaux struct.
                Pcstats.hinpts -> fltarr(4),mean,sdev,min,max of the number of
                                  points per cell from h-beam
                Pcstats.vinpts -> fltarr(4),mean,sdev,min,max of the number of 
                                  points per cell from v-beam
                Pcstats.inpts  -> fltarr(4),mean,sdev,min,max of the
                                  number of points per cell from both beams
                Pcstats.swopts -> fltarr(4), mean,sdev,min,max of the number of
                                  points falling out of the grid due to limited 
                                  swath; from both beams
                Pcstats.angerr -> fltarr(4),[rad] mean,sdev,min,max of the
                                  dddaux.ang_err 
                Pcstats.toutp  -> lonarr(3); [s,b,w],total number of valid data
                                  points falling out of the grid due to limited
                                  swath,outside grid boundaries, and zero weights                                
                Pcstats.crank1 -> % of grid cells with SVDC matrix rank 1
                Pcstats.empty  -> % of grid cells with no data points accepted
                                  (either below threshold or geometrically rejected)
                
                Note: The statistics for inpts,hinpts,vinpts,swopts,swnpts and
                      crank1 is based on the grid cells that contain at least 
                      one data point used in the velocity retrieval.

      HELP:      shows this text

 SIDE EFFECTS:

 PROCEDURE:

 EXAMPLE:

(See /tools/idl/wcrtools/wcrddproc0.pro)


WCRDDPROC1

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRDDPROC1

 PURPOSE:
      This routine is part of the WCR airborne Dual-Doppler analysis package
      (wcrdd.pro).It calculates dual-Doppler velocities using curtain leg grid. 

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      wcrddproc1,beamopt,dtsf,wcrddd,wcrdvsd,grddd,pcddd,strk,theta,phi,beta2, $
                 ddd,dddaux,pcstats,winds_ext=winds_ext,help=help

 INPUTS:
      Beamopt: integer,dual-antenna configuration 
                0    - N2UW KA dual-down antennas (h-down_fore, v-nadir)
                1    - N2UW KA dual-side antennas (h-side, v-side_fore)
                2    - NCAR C130 dual-down antennas (h-nadir,v-down-aft)
      Dtsf:    fltarr(2,n,rg,3), h-beam(dtsf[0,*,*,*]) and v-beam(dtsf[1,*,*,*])
               data points(n: profiles, rg: range gates) coordinates in WBRRS 
      Wcrddd:  structure containing WCR data(for description run wcrdd, /help)
      Wcrdvsd: structure containig Doppler velocity estimate variance as a
               function of signal-to-noise-ratio(for more help run wcrdd,/help)
      Grddd:   structure containing grid parameters and other processing
               option parameters(for description run wcrdd, /help)
      Pcddd:   structure containing processing parameters(for description run
               wcrddinit, /help)
      Strk:    fltarr(n), curvilinear length of track(s-coord) w.r.t. WBRS
      Theta:   fltarr(n), AC pitch angle in [rad]
      Phi:     fltarr(n), AC roll angle in [rad]
      Beta2:   fltarr(n), Angle formed by the x-axis (AC body axes) with the
                          mean of the virtual hdg direction in [rad]

 KEYWORD PARAMETERS:
      WINDS_EXT: input,fltarr(NXI,NET,3), external info on the winds in UFRS
                 (output from wcrddwext.pro; see also wnddd.wext in wcrddinit).
                 Will be transformed into WBBRS and then passed to wcrdddv.pro.
                 It is needed to correct for the wind perpendicular to the 
                 plane of the beams. If not defined or 0 external wind not used.

 OUTPUTS:
      Ddd:     structure containing the dual-Doppler analysis output data
               (for description run wcrdd, /help)
      Dddaux:  structure containing some auxiliary data resulting from the 
               dual-Doppler processing(for description run wcrdd, /help)
      Pcstats: structure containing some statistics of the result from the
               processing. The data arrays used are contained in Dddaux struct.

                Pcstats.hinpts -> fltarr(4),mean,sdev,min,max of the number of
                                  points per cell from h-beam
                Pcstats.vinpts -> fltarr(4),mean,sdev,min,max of the number of 
                                  points per cell from v-beam
                Pcstats.inpts  -> fltarr(4),mean,sdev,min,max of the
                                  number of points per cell from both beams
                Pcstats.houtpts-> fltarr(4),mean,sdev,min,max of the number of
                                  points falling out of any given cell due to
                                  cracks; from h-beam
                Pcstats.voutpts-> fltarr(4),mean,sdev,min,max of the number of
                                  points falling out of any given cell due to
                                  cracks; from v-beam
                Pcstats.outpts -> fltarr(4),mean,sdev,min,max of the number of
                                  points falling out of any given cell due to
                                  cracks; from both, h- and v-beam
                Pcstats.swopts -> fltarr(4), mean,sdev,min,max of the number of
                                  points falling out of grid due to limited 
                                  swath; from both beams
                Pcstats.swnpts -> fltarr(4), mean,sdev,min,max of the 'median
                                  swath per cell', for the whole grid.
                Pcstats.angerr -> fltarr(4),[rad] mean,sdev,min,max of the
                                  dddaux.ang_err 
                Pcstats.toutp  -> fltarr(5),[s,c,%c,b,w], total number of valid 
                                  data points falling out of the grid due to
                                  limited swath, cracks, % of crack points out
                                  of outpts+inpts, out of grid boundaries, and
                                  zero weights
                Pcstats.crank1 -> % of grid cells with SVDC matrix rank 1
                Pcstats.empty  -> % of grid cells with no data points accepted
                                  (either below threshold or geometrically rejected)
                
                Note: The statistics for inpts,hinpts,vinpts,swopts,swnpts and
                      crank1 is based on the grid cells that contain at least 
                      one data point used in the velocity retrieval.

      HELP:      shows this text

 SIDE EFFECTS:

 PROCEDURE:

 EXAMPLE:

(See /tools/idl/wcrtools/wcrddproc1.pro)


WCRDDWEXT

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRDDWEXT
     
 PURPOSE:
      This routine is part of the WCR airborne Dual-Doppler analysis package
      (wcrdd.pro). It determines external info on winds. Winds given as U,V,W 
      in the UFRS, for every cell in the grid.

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      wcrddwext,beamopt,acddd,wcrddd,grddd,wnddd,strk,strk_g,sndfile=sndfile,$
                help=help

 INPUTS:
      Beamopt: integer,dual-antenna configuration 
                0    - N2UW KA dual-down antennas
                1    - N2UW KA dual-side antennas
                2    - NCAR C130 dual-down antennas 
      Acddd:   structure containing AC data used for the dual-Doppler
               analysis (see wcrdd.pro help for more info)
      Wcrddd:  structure containing WCR data used for the dual-doppler
               analysis (see wcrdd.pro help for more); used if wnddd.wflag=7
      Grddd:   structure containing grid parameters and other processing
               option parameters (see wcrdd.pro help for more info)
      Wnddd:   structure containing external wind info processing parameters
               (see wcrddinit.pro help for more info)
      Strk:    fltarr(n), s-coordinate for the length of track (n: radar profs)
      Strk_g:  fltarr(NXI), s-coordinate for the length of track at grid 1st 
               row center points. For leg=0 this is grddd.crd1; for leg=1 it is
               an output from wcrddgrid1.pro
    
 KEYWORD PARAMETERS:
      SNDFILE: input, string, complete path to a data file with:
               1) vertical profile of wind(sounding) given in columns as 
                  [ALT(m),U(m/s),V(m/s),W(m/s)] in UFRS (when wnddd.wflag=2) or
               2) AC altitude, AGL in meters given in two columns as
                  [unix_time_stamp(sec),AGL(m)] (wnddd.zagl=2, wflag=3,4)
      HELP:    shows this text

 OUTPUTS:
      Wnddd.wext: fltarr(NXI,NET,3), winds along the UFRS (E,N,UP) [m/sec]
                  at grid cell centers.

 SIDE EFFECTS:

 PROCEDURE:

 EXAMPLE:

(See /tools/idl/wcrtools/wcrddwext.pro)


WCRDDWHTS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRDDWHTS
 
 PURPOSE:
      Set of weighting functions used by the dual-Doppler analysis (wcrdd.pro)
      Returns weights (normalized to total(weights)=1) for the Doppler velocity 
      measurements associated with each grid cell of a Dual-Doppler grid 
      generated by wcrddgrid0/1.pro  

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      res=wcrddwhts(x,x0,beam,nrp,whtprm,wcrdvsnr,wcrdvsd,wcrdvind,wcrsnr, $
                    zwhts=zwhts,help=help)

 INPUTS:
      X:        fltarr(n,3), coordinates of n points in 3-D space
      X0:       fltarr(3), center point(for all n points) coordinates 
                w.r.t. which distances are being calculated
      Beam:     fltarr(n,3), beam pointing unit vectors
      Nrp:      float(3), normal unit vector of the reference desired scanning 
                plane. Note: Beam and Nrp have to refer to the same LOCAL
                reference system.
      Whtprm:   integer or fltarr(3-6), 3 to 6 parameter array  
                defining the weighting scheme and parameters; 
                Weighting methods:
                  IDW: inverse distance, [Code,Exp1,-1,ROI,Thresh1,-1]; 
                  BSW: beam skewness; weights inversly proportional to the 
                       length of the desired plane of sacanning normal vector
                       [Code,-1,Exp2,-1,-1,Thresh2]
                  CRW: Cressman weighting [Code,-1,-1,ROI,Thresh1,-1]
                  EXW: exponential weighting [Code,Exp1,-1,ROI,Thresh1,-1]
                  SNR: Signal-to-noise ratio weighting [Code,Dvsdmin,Dvsdmax]

                Some combinations of the methods are also allowed. For more 
                information see the help for pcddd.whtprm in wcrddinit.pro

      Wcrdvsnr: fltarr(bin), signal-to-noise ratio corresponding to Doppler
                velocity standard deviation; bin: number of bins for the snr
                covering the processed radar data (in dB)
      Wcrdvsd:  fltarr(bin), StDev of Doppler velocity at wcrsnr (in m/s)
      Wcrdvind: fltarr(wbin), indices for wcrdvsd bins used in the weighting
      Wcrsnr:   fltarr(n); snr for the data to be weighted (in dB)

 OUTPUTS:
      Res:    fltarr(n), containing weights associated with the data points
              in a grid cell

 KEYWORD PARAMETERS:
      ZWHTS:  fltarr(n), non-SNR (spatial) weights to be applied to the grid 
              cell Z and SNR calculated values
      HELP:   prints this help

 PROCEDURE:
      Weights are calculated based on the following methods:
         IDW: Iiverse distance (from the center point) weighting
         BSW: Inverse value of beam vector components normal to the expected
              scanning plane (beam skewness weighting)
         CRW: Cressman weighting function
         EXW: Exponential weighting function

 EXAMPLE:

(See /tools/idl/wcrtools/wcrddwhts.pro)


WCRDISP

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    WCRDISP 
    (set of routines; initial compilation is NOT required)
    This program is obsolete.  Use wcrdisplay instead.

 PURPOSE:

    WCR "Kestrel" Real-Time Display (GUI is a blocking widget)

 CATEGORY:
    wcrtools

 CALLING SEQUENCE:

    wcrdisp, nimage,minmax=minmax,calval=calval,start=strtp,acspeed=acspeed,$
             dispctrl=dispctrl,colortable=colortable,help=help
             
 INPUT:

    nimage    -  number of images: 1 or 2 (default)

 KEYWORDS:

    ACSPEED:    input,float, average aircraft speed in m/s (default 90 m/s)
    CALVAL:     input,fltarr,[hhcal,vvcal,iso] (default [50,49,-18])
    COLORTABLE: input,integer, color table number(default is 45-Wyo dual table;
                when less than 64 colors are available the default is 41 Wyo
                table); if less than 46 tables color table 13 - Rainbow is used
                To leave the current color table enter negative number
    DISPCTRL:   when set, removes display control panel from the widget
    HELP:       display this help text
    MINMAX:     input,fltarr,[min_hh/vv,max_hh/vv,min_zdr,max_zdr,min_ldr
                ,max_ldr], default: [-45,10,-4,4,-25,-10]
                if a pair has min>=max, default values are used
    START:      input,integer,starting wcr record number

 WIDGET CONTROLS:

    New:          Open a dialog_pickfile to select a new WCR file.

    Quit:         Terminates the program without destroying the widget.  
                  This could be used to preserve interesting images for
                  later review and notes.

    Destroy:      Terminates the program and destroys the widget

    Pause/Cursor: Pressing this button will pause the display.  It also allows
                  to extract image values by clicking the left button of the
                  mouse at a desired pixel of the images.  In case of two 
                  images, clicking on either image will extract the
                  corresponding value from the other image.  The values and
                  their time stamp are printed in the status line
    Continue:     Continue label replaces Pause/Cursor label when Pause is
                  active.  Pressing Continue will restore updating the display
                  with new data.

    Catch:        Pressing this button will force the display to position
                  at the end of the currently available data in the wcr file.
                  This feature is useful if the display get behind the
                  incoming data (this could happen for various reasons,
                  including using Pause/Cursor)

    Color:        Allow change in the color table being used.  The default
                  color table is a custom dual-table to allow different colors
                  for, e.g., reflectivity and velocity images.  If the default
                  color table is replaced the program checks if a narrow black
                  strip exists in the middle of the new color table. If it does
                  the color table splits in two otherwise the same color
                  table is used for both images

    Img:          Pressing this button will toggle between 1 and 2 image widget

    InitTime:     Editable field.  Contains the starting time of wcr data.
                  Editing the field will cause the display to start again
                  from time close to the entered time.  This field should
                  not be used during data acquisition.  It is intended
                  for browsing of already recorded files.  The new time must
                  have one of the following formats: hhmm, hh:mm, hhmmss,
                  hh:mm:ss, 9999 . Incorrect entries are ignored and the start
                  time is redisplayed. If enter 9999 the field will show the
                  end time of the file.

    DispStep:     Editable field. Number of profiles to be calibrated and
                  displayed simultaneously.  Must be greater than 0. Non-valid
                  entries are ignored and the default value is used.

    AveProfs:     Editable field. Number of raw profiles averaged before
                  display.  The default is aspect ratio which scales range:time
                  to 1:1 based on acspeed (default 90 m/s).  Must be greater
                  than 0.  It is not allowed both DispStep and AveProfs to be
                  equal to 1.  In this case the second one to be changed to one
                  will be replaced automatically by 2.

       Sleep:     Editable field. Sleep time[s] between disk access attempts
                  for 'Empty file' or 'End of file. Waiting for data...' 
                  conditions. Default is 5 sec, maximum is 60 sec.

    hhcal:        Editable field. Calibration constant (dB) for H-channel
    vvcal:        Editable field. Calibration constant (dB) for V-channel
    isol:         Editable field. Isolation (dB) between H- and V-channel

    Radar products:  availability depends on the wcr operational mode
       hh:   co-reflectivity for H-ch (dBZ)
       vv:   co-reflectivity for V-ch (dBZ)
       vh:   cross-reflectivity; H-ch transmitted, V-ch received
       ldr:  vh/hh or hv/vv in dB
       zdr:  hh/vv in dB
       dv_h: uncorrected for the platform motion mean Doppler velocity in m/s
             for H-channel
       dv_v: uncorrected for the platform motion mean Doppler velocity in m/s
             for V-channel
       sv:   spectral width in m/s (for wcr FFT mode only)
    Order:   Pressing this button will toggle image display order: bottom-
             to-top or top-to-bottom (side/up antenna or down antenna)

    Color bar limits: these are editable fields and the default values
                      can be replaced.  To activate the new entry 'Enter'
                      key must be hit after typing the new number.  There is
                      no check for the validity of the new limits.
                      Non-numerical entries are replaced with 0 and a
                      non-fatal error message is issued.

    Status:  Non editable infomation message
    :    Non editable information indicator for the averaged H-ch noise.
    mxHn:    Resetable indicator for the max  noise.
    :    Non editable information indicator for the averaged V-ch noise.
    mxVn:    Resetable indicator for the max  noise.
    Hleak:   Non editable information indicator for the leaked H-ch Tx power
             WCR Tx leaked power (in dBm) at 0 range.  This indicator is used
             to help detect data acquisition bug which causes a shift in the
             range gates.  In this case the leak power will be close to the
             noise level (around -65 dBm)
    Vleak:   Non editable information indicator for the leaked V-ch Tx power.
             WCR Tx leaked power (in dBm) at 0 range. This indicator can be
             used together with Hleak to help detect a problem with Tx power
             for H or V channel.
    mxdT:    Resetable maximum average time interval (in ms) between profiles;
             If 9999 is displayed a negative time jump in the time stamps was
             encountered.

 WIDGET CONTROL NOTE: 'Enter' from the keyboard must be used after modifying an
                       editable field for the new value to take effect

 NOTES: 1) There is a positive side effect of using PICKFILE CANCEL button.
           It can restore an interrupted display of a file if a new file could
           not be open due to no data.
        2) Pause/Cursor button pauses the display and gives control to the
           mouse for image cursor trace. Clicking left mouse button while over
           image 1 or image2 will show image time and value in the status line.
        3) The displayed time is Aircraft/GPS time (after May 1999)
        4) External (custom) routines used by wcrdisp:  readse, mean, wyoctind,
           sec2timestr, timestr2sec, num2str, stradj from idltools linbrary,
           and spc from jhuapl library

(See /tools/idl/wcrtools/wcrdisp.pro)


WCRDISPLAY

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    WCRDISPLAY
   (set of routines; initial compilation is NOT required)
    This program works for data collected until July 2004.  For data after
    that use WCRDISPLAY04

 PURPOSE:

    WCR Data Display (GUI is a blocking widget)

    It uses a raw WCR data file (pre-recorded or currently being written) 
    with a minimum size set to 100 KB. 

    When DOPCOR keyword is set and/or DVC button is not OFF a netdcf
    aircraft data file is also required

 CATEGORY:
    wcrtools

 CALLING SEQUENCE:

    wcrdisplay, aconfig,acspeed=acspeed,calval=calval,colortable=colortable,$
                        dopcor=dopcor,minmax=minmax,start=strtp, $
                        timesync=timesync,help=help

 INPUT:

    aconfig - input,integer, WCR antenna configurations
               0 - side/up antenna, dual pol (H and V channels); default
               1 - two downlooking antennas(H-ch: 30 deg down-fore, V-ch: down)
               2 - side, side-slant ant.(H-ch: side, V-ch: 35 deg side-fore)
               3 - reserved (to be used for NCAR C130 configuration)
               4 - side/up and down antennas (H-ch: side/up, V-ch: down)
               5 - up and side-slant (H-ch: up, V-ch: side-slant)

 KEYWORDS:

    ACSPEED:    input,float, average A/C(aircraft) speed in m/s (default 90 m/s)
    CALVAL:     input, fltarr, [hhcal,vvcal,iso] (default [49,49,-18])
                (defaults: hhcal value is for side/up antenna H-pol;
                           vvcal value is for side/up V-pol or nadir antennas)
    COLORTABLE: input,integer, color table number(default is 45-Wyo dual table;
                when less than 64 colors are available the default is 41 Wyo
                table); if less than 46 tables color table 13 - Rainbow is used
                To leave the current color table enter negative number
    DOPCOR:     when set calculate corrected Doppler velocity; requires A/C
                data file with ins variables(currently, netcdf UW KingAir file)
                Notes: When dopcor is set negative, a gps correction to the
                       A/C ground velocities is applied
    MINMAX:     input,fltarr[min_hh/vv,max_hh/vv,min_zdr,max_zdr,min_ldr,
                max_ldr], default: [-45,10,-4,4,-25,-10]
                if a pair has min>=max, default values are used
    START:      input,integer, starting wcr record number
    TIMESYNC:   input,float, positive (WCR time lags) or negative known time 
                shift (in second) between WCR clock and A/C clock. This should 
                not be confused with GPS leap seconds, which value is read from 
                the A/C data file or the default value (currently -13 sec) is used.
    HELP:       display this help text

 WIDGET CONTROLS:

    ----------------- Top Buttons Control -----------------------

    New:          Open a dialog_pickfile to select a new WCR file.
                  Attn:  If DOPCOR keyword is set a 2nd dialog_pickfile
                         will open to select the A/C file
    DVC *:        Drop-list menu handling Doppler velocity correction for A/C
                  motion
        *          OFF - no correction
                   ON  - correction applied
                   GPS - correction applied including GPS correction to A/C
                         ground velocity
                  Note:  Positive Doppler velocity is toward the radar. There
                         is one exception to this rule for down-up antenas
                         configuration(4) simultaneously displaying velocity 
                         for both nadir and up antennas on both windows.In this
                         case nadir velocity is displayed in reversed color and 
                         positive is away from the radar.  This is done to 
                         maintain visual continuity between the two velocity 
                         images.

    Dsply 2 Img:  Pressing this button will toggle between 1 and 2 image widget

    Pause/Cursor: Pressing this button will pause the display.  It also allows
                  to extract image values by clicking the left button of the
                  mouse at a desired pixel of the images.  In case of two
                  images, clicking on either image will extract the
                  corresponding value from the other image.  The values and
                  their time stamps are printed in the status line.
    Continue:     Continue label replaces Pause/Cursor label when Pause is
                  active.  Pressing Continue will restore updating the display
                  with new data.

    Catch:        Pressing this button will force the display to position
                  at the end of the currently available data in the wcr file.
                  This feature is useful if the display get behind the
                  incoming data (this could happen for various reasons,
                  including using Pause/Cursor)

    Color:        Allow change in the color table being used.  The default
                  color table is a custom dual-table to allow different colors
                  for, e.g., reflectivity and velocity images.  If the default
                  color table is replaced the program checks if a narrow black
                  strip exists in the middle of the new color table. If it does
                  the color table splits in two otherwise the same color
                  table is used for both images

    Quit:         Terminates the program without destroying the widget.
                  This could be used to preserve interesting images for
                  later review and notes.

    Destroy:      Terminates the program and destroys the widget

    Help:         Shows Widget Control Help text

    ----------------- Second row widget Control -----------------------

    Antennae:     Drop-list menu for the antenna configuration deployed:
                    U/S     - one up/side antenna, dual polarization
                    D,D_f   - down-fore(H) and nadir(V) pointing antenae
                    S,S_f   - up/side(H) and side-fore(V) antennae
                    U/S,D   - up/side(H) and nadir(V) antennae
                    U,S_f   - up(H) and side-fore(V) antennae
                  When selecting one of the antenna configurations the image
                  order is adjusted accordingly and if DOPCOR option is set
                  applies the appropriate antenna beam coordinates

    Doppler:      Drop-lits menu for Doppler velocity processing (dopcor
                  keyword must be set):
                    dc_H,dc_V - corrected for A/C motion (no gps correction)
                    du_H,du_V - uncorrected for A/C motion
                    dc_H,du_H - corr. and uncorr. Dopp. for H-beam only
                    dc_V,du_V - corr. and uncorr. Dopp. for V-beam only
                  'c' is replaced by 'g' if dopcor=-1 (applied gps correction)

    Synch:        If DOPCOR keyword is used this editable field will show up.
                  The default value is 0.0 sec and represent any mismatch
                  between A/C and WCR clocks.  If such mismatch exists and is
                  known it can be entered as a positive or negative value.
                  The time synch correction is applied to the wcr clock.
                  This should not be confused with GPS leap seconds, which
                  are read from the A/C data file or the default value
                  (currently -13 sec) and applied to wcr data independently.
                  Entering 999 will restore the default value or the value
                  defined by timesync keyword.

    InitTime:     Editable field.  Contains the starting time of wcr data.
                  Editing the field will cause the display to start again
                  from time close to the entered time.  This field should
                  not be used during data acquisition.  It is intended
                  for browsing of already recorded files.  The new time must
                  have one of the following formats: hhmm, hh:mm, hhmmss,
                  hh:mm:ss, 9999 . Incorrect entries are ignored and the start
                  time is redisplayed. If enter 9999 the field will show the
                  end time of the file.

    AvProf:       Editable field. Number of raw profiles averaged before
                  display.  The default is aspect ratio which scales range:time
                  to 1:1 based on acspeed (default 90 m/s).  Must be greater
                  than 0.  If input is 0 the default (aspect ratio) is used.
                  DispStep and AveProfs cannot be equal to 1 simultaneously.
                  In this case the second one to be changed to one will be
                  replaced automatically by 2.

    DspStp:       Editable field. Number of profiles to be calibrated and
                  displayed simultaneously.  Must be greater than 0. Non-valid
                  entries are ignored and the default value is used.

    Sleep:        Editable field. Sleep time[s] between disk access attempts 
                  for 'Empty/short file' or 'End of file. Waiting for data...'
                  conditions. Default is calculated based on DspStp, AvProf
                  and an estimate of the time interval between profiles.
                  This field may be used in real-time display mode to reduce 
                  hard disk access and SCSI load 

    hhcal:        Editable field. Calibration constant (dB) for H-channel
                  (default value is for side/up antenna H-pol)
    vvcal:        Editable field. Calibration constant (dB) for V-channel
                  (default value is for side/up V-pol or nadir antennas)
    isol:         Editable field. Isolation (dB) between H- and V-channel

    ----------------- Image Selection Control -----------------------

    Radar products:  availability depends on the wcr operational mode and
    antenna configuration.

       hh:   co-reflectivity for H-ch/beam (dBZ)
       vv:   co-reflectivity for V-ch/beam (dBZ)
       vh:   cross-reflectivity; H-ch transmitted, V-ch received
       ldr:  vh/hh or hv/vv in dB
       zdr:  hh/vv in dB
       d*_h: mean Doppler velocity in m/s for H-channel
       d*_v: mean Doppler velocity in m/s for V-channel
       '*'   is 'u' for uncorrected velocity; 'c' for A/C motion corrected
             velocity and 'g' for A/C motion corrected using GPS corrections
       sv:   spectral width in m/s (for wcr FFT mode only)

    Color bar limits: these are editable fields and the default values
                      can be replaced.  To activate the new entry 'Enter'
                      key must be hit after typing the new number.  There is
                      no check for the validity of the new limits.
                      Non-numerical entries are replaced with 0 and a
                      non-fatal error message is issued

    ----------------- Status Display/Control -----------------------

    Status:  Non editable infomation message
    :    Non editable information indicator for the averaged H-ch noise.
    mxHn:    Resetable indicator for the max  noise.
    :    Non editable information indicator for the averaged V-ch noise.
    mxVn:    Resetable indicator for the max  noise.
    Hleak:   Non editable information indicator for the leaked H-ch Tx power
             WCR Tx leaked power (in dBm) at 0 range.  This indicator is used
             to help detect data acquisition bug which causes a shift in the
             range gates.  In this case the leak power will be close to the
             noise level (around -65 dBm)
    Vleak:   Non editable information indicator for the leaked V-ch Tx power.
             WCR Tx leaked power (in dBm) at 0 range. This indicator can be
             used together with Hleak to help detect a problem with Tx power
             for H or V channel.
    mxdT:    Resetable maximum average time interval (in ms) between profiles;
             If 9999 is displayed a negative time jump in the time stamps was
             encountered.

    -----------------------------------------------------------------

 WIDGET CONTROL NOTE: 'Enter' from the keyboard must be used after modifying an
                       editable field for the new value to take effect

 NOTES: 1) There is a positive side effect of using PICKFILE CANCEL button.
           It can restore an interrupted display of a file if a new file could
           not be open due to no data.
        2) Pause/Cursor button pauses the display and gives control to the
           mouse for image cursor trace. Clicking left mouse button while over
           image1 or image2 will show image time and value in the status line.
        3) The displayed time is UTC time (after May 1999)
        4) External (custom) routines used by wcrdisplay: readse,mean,wyoctind,
           sec2timestr,timestr2sec,num2str,stradj,ncdf_varload,ncdf_attload
           from idltools library, spc from jhuapl library, and ac2gt from
           wcrtools library

 ATTN: This browser is tailored to UW KingAir netcdf data files and thus
       the names of the needed A/C variables are hardwired into the program

(See /tools/idl/wcrtools/wcrdisplay.pro)


WCRDISPLAY04

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    WCRDISPLAY04
   (set of routines; initial compilation is NOT required)
   This program does not work with multi-port input to one receiver
   (e.g., ppmag6 with H1H1H2H2V2V2 does not work) yet. 

 PURPOSE:

    WCR Data Display (GUI is a blocking widget)

    It uses a raw WCR data file (pre-recorded or currently being written) 
    with a minimum size set to 100 KB. 

    When DOPCOR keyword is set and/or DVC button is not OFF a netdcf
    aircraft data file is also required

 CATEGORY:
    wcrtools

 CALLING SEQUENCE:

    wcrdisplay, aconfig,acspeed=acspeed,calval=calval,colortable=colortable,$
                        dopcor=dopcor,minmax=minmax,start=strtp, $
                        timesync=timesync,help=help

 INPUT:

    aconfig - input,integer, WCR antenna configurations
               0 - side/up antenna, dual pol (H and V channels); default
               1 - two downlooking antennas(H-ch: 30 deg down-fore, V-ch: down)
               2 - side, side-slant ant.(H-ch: side, V-ch: 35 deg side-fore)
               3 - reserved (to be used for NCAR C130 configuration)
               4 - side/up and down antennas (H-ch: side/up, V-ch: down)
               5 - up and side-slant (H-ch: up, V-ch: side-slant)

 KEYWORDS:

    ACSPEED:    input,float, average A/C(aircraft) speed in m/s (default 90 m/s)
    CALVAL:     input, fltarr, [hhcal,vvcal,iso] (default [49,49,-18])
                (defaults: hhcal value is for side/up antenna H-pol;
                           vvcal value is for side/up V-pol or nadir antennas)
    COLORTABLE: input,integer, color table number(default is 45-Wyo dual table;
                when less than 64 colors are available the default is 41 Wyo
                table); if less than 46 tables color table 13 - Rainbow is used
                To leave the current color table enter negative number
    DOPCOR:     when set calculate corrected Doppler velocity; requires A/C
                data file with ins variables(currently, netcdf UW KingAir file)
                Notes: When dopcor is set negative, a gps correction to the
                       A/C ground velocities is applied
    MINMAX:     input,fltarr[min_hh/vv,max_hh/vv,min_zdr,max_zdr,min_ldr,
                max_ldr], default: [-45,10,-4,4,-25,-10]
                if a pair has min>=max, default values are used
    START:      input,integer, starting wcr record number
    TIMESYNC:   input,float, positive (WCR time lags) or negative known time 
                shift (in second) between WCR clock and A/C clock. This should 
                not be confused with GPS leap seconds, which value is read from 
                the A/C data file or the default value (currently -13 sec) is used.
    HELP:       display this help text

 WIDGET CONTROLS:

    ----------------- Top Buttons Control -----------------------

    New:          Open a dialog_pickfile to select a new WCR file.
                  Attn:  If DOPCOR keyword is set a 2nd dialog_pickfile
                         will open to select the A/C file
    DVC *:        Drop-list menu handling Doppler velocity correction for A/C
                  motion
        *          OFF - no correction
                   ON  - correction applied
                   GPS - correction applied including GPS correction to A/C
                         ground velocity
                  Note:  Positive Doppler velocity is toward the radar. There
                         is one exception to this rule for down-up antenas
                         configuration(4) simultaneously displaying velocity 
                         for both nadir and up antennas on both windows.In this
                         case nadir velocity is displayed in reversed color and 
                         positive is away from the radar.  This is done to 
                         maintain visual continuity between the two velocity 
                         images.

    Dsply 2 Img:  Pressing this button will toggle between 1 and 2 image widget

    Pause/Cursor: Pressing this button will pause the display.  It also allows
                  to extract image values by clicking the left button of the
                  mouse at a desired pixel of the images.  In case of two
                  images, clicking on either image will extract the
                  corresponding value from the other image.  The values and
                  their time stamps are printed in the status line.
    Continue:     Continue label replaces Pause/Cursor label when Pause is
                  active.  Pressing Continue will restore updating the display
                  with new data.

    Catch:        Pressing this button will force the display to position
                  at the end of the currently available data in the wcr file.
                  This feature is useful if the display get behind the
                  incoming data (this could happen for various reasons,
                  including using Pause/Cursor)

    Color:        Allow change in the color table being used.  The default
                  color table is a custom dual-table to allow different colors
                  for, e.g., reflectivity and velocity images.  If the default
                  color table is replaced the program checks if a narrow black
                  strip exists in the middle of the new color table. If it does
                  the color table splits in two otherwise the same color
                  table is used for both images

    Quit:         Terminates the program without destroying the widget.
                  This could be used to preserve interesting images for
                  later review and notes.

    Destroy:      Terminates the program and destroys the widget

    Help:         Shows Widget Control Help text

    ----------------- Second row widget Control -----------------------

    Antennae:     Drop-list menu for the antenna configuration deployed:
                    U/S     - one up/side antenna, dual polarization
                    D,D_f   - down-fore(H) and nadir(V) pointing antenae
                    S,S_f   - up/side(H) and side-fore(V) antennae
                    U/S,D   - up/side(H) and nadir(V) antennae
                    U,S_f   - up(H) and side-fore(V) antennae
                  When selecting one of the antenna configurations the image
                  order is adjusted accordingly and if DOPCOR option is set
                  applies the appropriate antenna beam coordinates

    Doppler:      Drop-lits menu for Doppler velocity processing (dopcor
                  keyword must be set):
                    dc_H,dc_V - corrected for A/C motion (no gps correction)
                    du_H,du_V - uncorrected for A/C motion
                    dc_H,du_H - corr. and uncorr. Dopp. for H-beam only
                    dc_V,du_V - corr. and uncorr. Dopp. for V-beam only
                  'c' is replaced by 'g' if dopcor=-1 (applied gps correction)

    Synch:        If DOPCOR keyword is used this editable field will show up.
                  The default value is 0.0 sec and represent any mismatch
                  between A/C and WCR clocks.  If such mismatch exists and is
                  known it can be entered as a positive or negative value.
                  The time synch correction is applied to the wcr clock.
                  This should not be confused with GPS leap seconds, which
                  are read from the A/C data file or the default value
                  (currently -13 sec) and applied to wcr data independently.
                  Entering 999 will restore the default value or the value
                  defined by timesync keyword.

    InitTime:     Editable field.  Contains the starting time of wcr data.
                  Editing the field will cause the display to start again
                  from time close to the entered time.  This field should
                  not be used during data acquisition.  It is intended
                  for browsing of already recorded files.  The new time must
                  have one of the following formats: hhmm, hh:mm, hhmmss,
                  hh:mm:ss, 9999 . Incorrect entries are ignored and the start
                  time is redisplayed. If enter 9999 the field will show the
                  end time of the file.

    AvProf:       Editable field. Number of raw profiles averaged before
                  display.  The default is aspect ratio which scales range:time
                  to 1:1 based on acspeed (default 90 m/s).  Must be greater
                  than 0.  If input is 0 the default (aspect ratio) is used.
                  DispStep and AveProfs cannot be equal to 1 simultaneously.
                  In this case the second one to be changed to one will be
                  replaced automatically by 2.

    DspStp:       Editable field. Number of profiles to be calibrated and
                  displayed simultaneously.  Must be greater than 0. Non-valid
                  entries are ignored and the default value is used.

    Sleep:        Editable field. Sleep time[s] between disk access attempts 
                  for 'Empty/short file' or 'End of file. Waiting for data...'
                  conditions. Default is calculated based on DspStp, AvProf
                  and an estimate of the time interval between profiles.
                  This field may be used in real-time display mode to reduce 
                  hard disk access and SCSI load 

    hhcal:        Editable field. Calibration constant (dB) for H-channel
                  (default value is for side/up antenna H-pol)
    vvcal:        Editable field. Calibration constant (dB) for V-channel
                  (default value is for side/up V-pol or nadir antennas)
    isol:         Editable field. Isolation (dB) between H- and V-channel

    ----------------- Image Selection Control -----------------------

    Radar products:  availability depends on the wcr operational mode and
    antenna configuration.

       hh:   co-reflectivity for H-ch/beam (dBZ)
       vv:   co-reflectivity for V-ch/beam (dBZ)
       vh:   cross-reflectivity; H-ch transmitted, V-ch received
       ldr:  vh/hh or hv/vv in dB
       zdr:  hh/vv in dB
       d*_h: mean Doppler velocity in m/s for H-channel
       d*_v: mean Doppler velocity in m/s for V-channel
       '*'   is 'u' for uncorrected velocity; 'c' for A/C motion corrected
             velocity and 'g' for A/C motion corrected using GPS corrections
       sv:   spectral width in m/s (for wcr FFT mode only)

    Color bar limits: these are editable fields and the default values
                      can be replaced.  To activate the new entry 'Enter'
                      key must be hit after typing the new number.  There is
                      no check for the validity of the new limits.
                      Non-numerical entries are replaced with 0 and a
                      non-fatal error message is issued

    ----------------- Status Display/Control -----------------------

    Status:  Non editable infomation message
    :    Non editable information indicator for the averaged H-ch noise.
    mxHn:    Resetable indicator for the max  noise.
    :    Non editable information indicator for the averaged V-ch noise.
    mxVn:    Resetable indicator for the max  noise.
    Hleak:   Non editable information indicator for the leaked H-ch Tx power
             WCR Tx leaked power (in dBm) at 0 range.  This indicator is used
             to help detect data acquisition bug which causes a shift in the
             range gates.  In this case the leak power will be close to the
             noise level (around -65 dBm)
    Vleak:   Non editable information indicator for the leaked V-ch Tx power.
             WCR Tx leaked power (in dBm) at 0 range. This indicator can be
             used together with Hleak to help detect a problem with Tx power
             for H or V channel.
    mxdT:    Resetable maximum average time interval (in ms) between profiles;
             If 9999 is displayed a negative time jump in the time stamps was
             encountered.

    -----------------------------------------------------------------

 WIDGET CONTROL NOTE: 'Enter' from the keyboard must be used after modifying an
                       editable field for the new value to take effect

 NOTES: 1) There is a positive side effect of using PICKFILE CANCEL button.
           It can restore an interrupted display of a file if a new file could
           not be open due to no data.
        2) Pause/Cursor button pauses the display and gives control to the
           mouse for image cursor trace. Clicking left mouse button while over
           image1 or image2 will show image time and value in the status line.
        3) The displayed time is UTC time (after May 1999)
        4) External (custom) routines used by wcrdisplay: readse,mean,wyoctind,
           sec2timestr,timestr2sec,num2str,stradj,ncdf_varload,ncdf_attload
           from idltools library, spc from jhuapl library, and ac2gt from
           wcrtools library

 ATTN: This browser is tailored to UW KingAir netcdf data files and thus
       the names of the needed A/C variables are hardwired into the program

(See /tools/idl/wcrtools/wcrdisplay04.pro)


WCRDISPLAY07

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    WCRDISPLAY07
    (set of routines; initial compilation is NOT required)
    For PPMAG6 and PPMAG8 and more than 2 antennas a quck fix, which allows
    proper display of every beam reflectivity is implemented. No polarimetric
    quantities are available in these cases; LDR image is used to display down-
    slant antenna reflectivity and VH image is used to display side-slant 
    antenna reflectivity.  No changes to the velocity display.

 PURPOSE:

    WCR Data Display (GUI is a blocking widget)

    It uses a raw WCR data file (pre-recorded or currently being written) 
    with a minimum size set to 100 KB. 

    When DOPCOR keyword is set and/or DVC button is not OFF a netdcf
    aircraft data file is also required

 CATEGORY:
    wcrtools

 CALLING SEQUENCE:

    wcrdisplay07, aconfig,acspeed=acspeed,calval=calval,colortable=colortable,$
                          dopcor=dopcor,minmax=minmax,start=strtp, $
                          timesync=timesync,help=help

 INPUT:

    aconfig - input,integer, WCR antenna configurations
               0 - side/up antenna, dual pol (H and V channels); default
               1 - two downlooking antennas(H-ch: 30 deg down-fore, V-ch: down)
               2 - side, side-slant ant.(H-ch: side, V-ch: 35 deg side-fore)
               3 - reserved (to be used for NCAR C130 configuration)
               4 - side/up and down antennas (H-ch: side/up, V-ch: down)
               5 - up and side-slant (H-ch: up, V-ch: side-slant)

 KEYWORDS:

    ACSPEED:    input,float, average A/C(aircraft) speed in m/s (default 90 m/s)
    CALVAL:     input, fltarr, [hhcal,vvcal,iso] (default [49,49,-18])
                (defaults: hhcal value is for side/up antenna H-pol;
                           vvcal value is for side/up V-pol or nadir antennas)
    COLORTABLE: input,integer, color table number(default is 46-Wyo dual table;
                when less than 64 colors are available the default is 41 Wyo
                table); if less than 46 tables color table 13 - Rainbow is used
                To leave the current color table enter negative number
    DOPCOR:     when set calculate corrected Doppler velocity; requires A/C
                data file with ins variables(currently, netcdf UW KingAir file)
                Notes: When dopcor is set negative, a gps correction to the
                       A/C ground velocities is applied
    MINMAX:     input,fltarr[min_hh/vv,max_hh/vv,min_zdr,max_zdr,min_ldr,
                max_ldr], default: [-45,10,-4,4,-25,-10]
                if a pair has min>=max, default values are used
    START:      input,integer, starting wcr record number
    TIMESYNC:   input,float, positive (WCR time lags) or negative known time 
                shift (in second) between WCR clock and A/C clock. This should 
                not be confused with GPS leap seconds, which value is read from 
                the A/C data file or the default value (currently -13 sec) is used.
    HELP:       display this help text

 WIDGET CONTROLS:

    ----------------- Top Buttons Control -----------------------

    New:          Open a dialog_pickfile to select a new WCR file.
                  Attn:  If DOPCOR keyword is set a 2nd dialog_pickfile
                         will open to select the A/C file
    DVC *:        Drop-list menu handling Doppler velocity correction for A/C
                  motion
        *          OFF - no correction
                   ON  - correction applied
                   GPS - correction applied including GPS correction to A/C
                         ground velocity
                  Note:  Positive Doppler velocity is toward the radar. There
                         is one exception to this rule for down-up antenas
                         configuration(4) simultaneously displaying velocity 
                         for both nadir and up antennas on both windows.In this
                         case nadir velocity is displayed in reversed color and 
                         positive is away from the radar.  This is done to 
                         maintain visual continuity between the two velocity 
                         images.

    Dsply 2 Img:  Pressing this button will toggle between 1 and 2 image widget

    Pause/Cursor: Pressing this button will pause the display.  It also allows
                  to extract image values by clicking the left button of the
                  mouse at a desired pixel of the images.  In case of two
                  images, clicking on either image will extract the
                  corresponding value from the other image.  The values and
                  their time stamps are printed in the status line.
    Continue:     Continue label replaces Pause/Cursor label when Pause is
                  active.  Pressing Continue will restore updating the display
                  with new data.

    Catch:        Pressing this button will force the display to position
                  at the end of the currently available data in the wcr file.
                  This feature is useful if the display get behind the
                  incoming data (this could happen for various reasons,
                  including using Pause/Cursor)

    Color:        Allow change in the color table being used.  The default
                  color table is a custom dual-table to allow different colors
                  for, e.g., reflectivity and velocity images.  If the default
                  color table is replaced the program checks if a narrow black
                  strip exists in the middle of the new color table. If it does
                  the color table splits in two otherwise the same color
                  table is used for both images

    Quit:         Terminates the program without destroying the widget.
                  This could be used to preserve interesting images for
                  later review and notes.

    Destroy:      Terminates the program and destroys the widget

    Help:         Shows Widget Control Help text

    ----------------- Second row widget Control -----------------------

    Antennae:     Drop-list menu for the antenna configuration deployed:
                    U/S     - one up/side antenna, dual polarization
                    D,D_f   - down-fore(H) and nadir(V) pointing antenae
                    S,S_f   - up/side(H) and side-fore(V) antennae
                    U/S,D   - up/side(H) and nadir(V) antennae
                    U,S_f   - up(H) and side-fore(V) antennae
                  When selecting one of the antenna configurations the image
                  order is adjusted accordingly and if DOPCOR option is set
                  applies the appropriate antenna beam coordinates

    Doppler:      Drop-lits menu for Doppler velocity processing (dopcor
                  keyword must be set):
                    dc_H,dc_V - corrected for A/C motion (no gps correction)
                    du_H,du_V - uncorrected for A/C motion
                    dc_H,du_H - corr. and uncorr. Dopp. for H-beam only
                    dc_V,du_V - corr. and uncorr. Dopp. for V-beam only
                  'c' is replaced by 'g' if dopcor=-1 (applied gps correction)

    Synch:        If DOPCOR keyword is used this editable field will show up.
                  The default value is 0.0 sec and represent any mismatch
                  between A/C and WCR clocks.  If such mismatch exists and is
                  known it can be entered as a positive or negative value.
                  The time synch correction is applied to the wcr clock.
                  This should not be confused with GPS leap seconds, which
                  are read from the A/C data file or the default value
                  (currently -13 sec) and applied to wcr data independently.
                  Entering 999 will restore the default value or the value
                  defined by timesync keyword.

    InitTime:     Editable field.  Contains the starting time of wcr data.
                  Editing the field will cause the display to start again
                  from time close to the entered time.  This field should
                  not be used during data acquisition.  It is intended
                  for browsing of already recorded files.  The new time must
                  have one of the following formats: hhmm, hh:mm, hhmmss,
                  hh:mm:ss, 9999 . Incorrect entries are ignored and the start
                  time is redisplayed. If enter 9999 the field will show the
                  end time of the file.

    AvProf:       Editable field. Number of raw profiles averaged before
                  display.  The default is aspect ratio which scales range:time
                  to 1:1 based on acspeed (default 90 m/s).  Must be greater
                  than 0.  If input is 0 the default (aspect ratio) is used.
                  DispStep and AveProfs cannot be equal to 1 simultaneously.
                  In this case the second one to be changed to one will be
                  replaced automatically by 2.

    DspStp:       Editable field. Number of profiles to be calibrated and
                  displayed simultaneously.  Must be greater than 0. Non-valid
                  entries are ignored and the default value is used.

    Sleep:        Editable field. Sleep time[s] between disk access attempts 
                  for 'Empty/short file' or 'End of file. Waiting for data...'
                  conditions. Default is calculated based on DspStp, AvProf
                  and an estimate of the time interval between profiles.
                  This field may be used in real-time display mode to reduce 
                  hard disk access and SCSI load 

    hhcal:        Editable field. Calibration constant (dB) for H-channel
                  (default value is for side/up antenna H-pol)
    vvcal:        Editable field. Calibration constant (dB) for V-channel
                  (default value is for side/up V-pol or nadir antennas)
    isol:         Editable field. Isolation (dB) between H- and V-channel

    ----------------- Image Selection Control -----------------------

    Radar products:  availability depends on the wcr operational mode and
    antenna configuration.

       hh:   co-reflectivity for H-ch/beam (dBZ)
       vv:   co-reflectivity for V-ch/beam (dBZ)
       vh:   cross-reflectivity; H-ch transmitted, V-ch received
       ldr:  vh/hh or hv/vv in dB
       zdr:  hh/vv in dB
       d*_h: mean Doppler velocity in m/s for H-channel
       d*_v: mean Doppler velocity in m/s for V-channel
       '*'   is 'u' for uncorrected velocity; 'c' for A/C motion corrected
             velocity and 'g' for A/C motion corrected using GPS corrections
       sv:   spectral width in m/s (for wcr FFT mode only)

    Color bar limits: these are editable fields and the default values
                      can be replaced.  To activate the new entry 'Enter'
                      key must be hit after typing the new number.  There is
                      no check for the validity of the new limits.
                      Non-numerical entries are replaced with 0 and a
                      non-fatal error message is issued

    ----------------- Status Display/Control -----------------------

    Status:  Non editable infomation message
    :    Non editable information indicator for the averaged H-ch noise.
    mxHn:    Resetable indicator for the max  noise.
    :    Non editable information indicator for the averaged V-ch noise.
    mxVn:    Resetable indicator for the max  noise.
    Hleak:   Non editable information indicator for the leaked H-ch Tx power
             WCR Tx leaked power (in dBm) at 0 range.  This indicator is used
             to help detect data acquisition bug which causes a shift in the
             range gates.  In this case the leak power will be close to the
             noise level (around -65 dBm)
    Vleak:   Non editable information indicator for the leaked V-ch Tx power.
             WCR Tx leaked power (in dBm) at 0 range. This indicator can be
             used together with Hleak to help detect a problem with Tx power
             for H or V channel.
    mxdT:    Resetable maximum average time interval (in ms) between profiles;
             If 9999 is displayed a negative time jump in the time stamps was
             encountered.

    -----------------------------------------------------------------

 WIDGET CONTROL NOTE: 'Enter' from the keyboard must be used after modifying an
                       editable field for the new value to take effect

 NOTES: 1) There is a positive side effect of using PICKFILE CANCEL button.
           It can restore an interrupted display of a file if a new file could
           not be open due to no data.
        2) Pause/Cursor button pauses the display and gives control to the
           mouse for image cursor trace. Clicking left mouse button while over
           image1 or image2 will show image time and value in the status line.
        3) The displayed time is UTC time (after May 1999)
        4) External (custom) routines used by wcrdisplay: readse,mean,wyoctind,
           sec2timestr,timestr2sec,num2str,stradj,ncdf_varload,ncdf_attload
           from idltools library, spc from jhuapl library, and ac2gt from
           wcrtools library

 ATTN: This browser is tailored to UW KingAir netcdf data files and thus
       the names of the needed A/C variables are hardwired into the program

(See /tools/idl/wcrtools/wcrdisplay07.pro)


WCRDOPCOR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRDOPCOR

 PURPOSE:
      Returns WCR radial Doppler velocity w.r.t. ground and corrected for 
      aircraft (AC) motion. Positive velocity is toward the radar. 
     

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
       res=wcrdopcor(wcrvel,wcrtime,wcracv,actime,timehack=timehack, $
                     maxvel=maxvel,wcrav=wcrav,wcr2ac=wcr2ac,help=help)

 INPUTS:
       Wcrvel:   2-D or 3-D float array, uncorrected WCR Doppler velocity 
                 (fltarr(rangegates,numrec,npp-1), see wcrtools/wcrdopvel.pro)
       Wcrtime:  double array, WCR time vector (UNIX seconds)
       Wcracv:   float array, AC velocity contribution into the WCR beam
       Actime:   double array, AC time vector (UNIX seconds)

 KEYWORD PARAMETERS:
       MAXVEL:   input,float/fltarr(npp-1), Nyquist velocity for each pulse
                 pair; if npp>2 and maxvel is scalar the value is applied to
                 all pulse pairs (velocities, wcrvel);
                 If this keyword is defined the result will always be bound
                 within +- maxvel
       TIMEHACK: input, float, WCR time correction to sync with AC ins data,
                 in seconds  (default 0.0)
       WCR2AC:   when set match the output to AC data file sampling rate 
                 (default is WCR irregular sampling, see Notes)
       WCRAV:    returns Wcracv synchronized w/ wcrtime+timehack; 
                 if wcr2ac is set returns Wcrvel synchronized w/ actime
       HELP:     shows this text

 OUTPUTS:

 SIDE EFFECTS:
       The function returns an empty string if the usage is incorrect or 
       help keyword is set

 NOTES:
       Wcracv and actime are equaly spaced in time.  Wcrvel and wcrtime are 
       non-equaly spaced (varying number of profiles per second and a small 
       variation in the time interval between the profiles).

       Wcracv/actime and wcrvel/wcrtime must be matched pairs.  In other 
       words time vectors must correspond to the time dimension/profile of
       velocity data.

       The return is irregularly gridded and matches the wcrtime (plus any 
       timehack if defined) unless  wcr2ac keyword is set - then it is
       regularly gridded and matches actime

       Wcrtime+timehack must be subset of actime. If wcr2ac is set actime must
       be subset of wcrtime+timehack.  This increases the accuracy of the 
       interpolated output for the first and last data points.        

 PROCEDURE:
       The functions applies linear/bilinear interpolation scheme 
       (see, ac2wcr.pro) to match the regularly gridded AC and non-regularly 
       gridded WCR data.  Then the contribution of the aircraft motion into
       the WCR beam is subtracted to produce the WCR corrected radial velocity.
       
 EXAMPLES:

 ** 1) Calculate corrected UWKA WCR velocity matching WCR time(profiles) **

 Read raw wcr data

 .run commonwcrset
 openwcrf,'Wpp00-11-15-19-53-25

 readwcrdata,21786,24973,rawtime=wcrtime  ; ground return, 20:13:20 - 20:15:05

 Calculate the uncorrected Doppler velocity

 wcrdv=wcrdopvel(ppselect='HH')

 Get the AC motion component into the beam (ignore, radar moment and gps
 AC velocity correction)

 ncf='/net/bobcat/disk1/kingair_data/20001115.c25.nc'
 kastartt=201320  &  kastopt=201506  ; start/stop time for KA data
 wcracv=wcracvelm(acdata,ncid,file=ncf,startt=kastartt,stopt=kastopt)

 Assign time hack, if any, and calculate corrected Doppler velocity. Match
 the output to the wcr time sampling (profiles) 

 timehack=0.0
 wcrdvel=wcrdopcor(wcrdv,wcrtime,wcracv,acdata.time,timehack=timehack)

 Since this example extracts ground hits check the quality of the corrected
 velocity

 ind=where(10.*alog10(hh) gt -55.)     ; find high return ground hits 
 wcrduf=fltarr(rangegates,numrec)-100  ; initilize final array
 wcrduf[ind]=wcrdvel[ind]              ; assign only valid data
 ind1=where(wcrdvel gt 30)             ; (max vel is 31.6 m/s for HH pp)
 wcrduf[ind1]=wcrduf[ind1]-31.8        ; unfold; not very nice but it's ok
 
 aximage,wcrduf,/tr,setw=[-1,42],/bar,min=-1,max=1
 window,0 & plot,wcrduf[ind],psym=3 & grid
 print,[mean(wcrduf[ind]),std(wcrduf[ind])]
 

(See /tools/idl/wcrtools/wcrdopcor.pro)


WCRDOPCORM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRDOPCORM

 PURPOSE:
      Returns WCR radial Doppler velocity field corrected for aircraft,
      AC, motion (synched with wcr time or AC time if wcr2ac keyword is set). 

      This routine uses wcrdopvel to calculate uncorrected Doppler velocity 
      and wcracvelm to calculate AC velocity contribution to the beam.
      The corrected Doppler velocity is calculated using wcrdopcor routine.
      Positive velocity is toward the radar. The wind contribution to the
      wcr beam is calculated (wcracw) using wcracwind routine.

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
       res=wcrdopcorm(wcrtime,acncf=acncf,acdata=acdata,beaminit=beaminit, $
                      close=close,gpsc=gpsc,ncnames=ncnames,ppselect=ppselect,$
                      rmcor=rmcor,rmv=rmv,timehack=timehack,acv=acv,   $
                      radbeam=radbeam,unfold=unfold,sunfold=sunfold,
                      wcracv=wcracv,wcracw=wcracw,wcrvel=wcrvel,wcr2ac=wcr2ac,$
                      help=help)

 INPUTS:
       Wcrtime: dblarr(n), WCR time (UNIX seconds); n, number of wcr profs

 KEYWORD PARAMETERS:
       ACDATA:  input/output, structure, AC IRS/INS data matching AC time
                acdata.time   -> double(m), AC unix time in sec (see Notes)
                ; Following angles are in radians or degrees if deg keyword set
                acdata.roll   -> fltarr(m), AC roll angle
                acdata.pitch  -> fltarr(m), AC pitch angle
                acdata.heading-> fltarr(m), AC true heading from North
                ; AC ground velocities in [m/s]
                acdata.ug     -> fltarr(m), East-West AC ground velocity
                acdata.vg     -> fltarr(m), North-South AC ground velocity
                acdata.wg     -> fltarr(m), AC vertical velocity
                ; UWKA GPS corrections of ins AC velocities (ignore for C130)
                acdata.uerr   -> fltarr(m), E-W vel correction in m/s
                acdata.verr   -> fltarr(m), N-S vel correction in m/s
                ; AC measured winds in [m/s]
                acdata.uw     -> fltarr(m), East wind velocity component
                acdata.vw     -> fltarr(m), North wind velocity component
                acdata.ww     -> fltarr(m), vertical wind velocity component
                ; AC attitude rates in rad/sec or deg/sec (if deg keyword set)
                acdata.rollr  -> fltarr(m,3), roll rate
                acdata.pitchr -> fltarr(m,3), pitch rate
                acdata.yawr   -> fltarr(m,3), yaw rate
                ;
                acdata.tas    -> fltarr(m), true air speed in m/s
                ;
                ; UWKA radar wing mirror position 
                acdata.wcrmirror -> intarr(m), KA radar wing mirror position
                                    (0-side, 1-up, for side/up antenna)
                ; AC data info: aircraft id (N2UW or N130AR)
                acdata.info    -> string, aircraft ID

                Note: If any of the non-critical data (e.g., attitude rate)
                      is not available, -1 is recorded

       ACNCF:    input/output string or long, 
                 string, AC data netcdf file name
                 long, netcdf file id (if the input acncf was a netcdf 
                      file name and CLOSE was not set)

       ACV:      output, fltarr(m,3) matching ACTIME, AC velocity (GPS/RMCOR 
                        corrected if requested) in AC coordinates.

       BEAMINIT: input, Initialize antenna beam; 
                 Default beams:
                  -1(default)- dual-polarization side/up antenna, use UWKA 
                               radar mirror variable for pointing direction
                   0         - side-looking KingAir, KA, (main) 12"antenna
                   1         - up-looking KA (main+mirror) 12" antenna
                   2         - KA nadir 18" antenna
                   3         - KA side-fore antenna(~35 deg)
                   4         - KA down-fore 15" antenna(~30 deg)
                   5         - NCAR C130 nadir 12" antenna (7/16/01)
                   6         - NCAR C130 down-aft 12" antenna(7/16/01)
                   7         - NRC CV580 side looking 12" antenna, dual-pol
                   8         - NRC CV580 nadir looking 12" antenna
                   fltarr(m) - side/up antenna for KA determined by the  
                               KA mirror (0-side, 1-up), m > 3
                  Antenna beam pointing vector:
                   fltarr(3)  - beam unit vector in AC coordinate system
                                [AC along axis, right wing, down]
                   fltarr(3,m)- beam unit vectors for all data points

       CLOSE:    when set AC netcdf file will be closed.
       GPSC:     when set does NOT apply GPS correction to AC E-W and N-S
                  velocity for UWKA only (for NCAR C130 the default is also GPS
                  corrected; use ncnames and appropriate C130 var names to use
                  NO GPS corrected data
       NCNAMES:   input, string array, AC netcdf varnames to be used (if not 
                         defined N2UW or N130AR default var names are used; 
                         ignored if acdata exist 
                  ncnames[0] - AC time (seconds in UNIX format)
                  ncnames[1] - AC true air speed in m/s
                  ncnames[2] - AC roll [deg or rad]
                  ncnames[3] - AC pitch [deg or rad]
                  ncnames[4] - AC true heading [deg or rad]
                  ncnames[5] - AC east-west(EW) ground velocity [m/s]
                  ncnames[6] - AC north-south(NS) ground velocity [m/s]
                  ncnames[7] - AC vertical velocity [m/s]
                  ncnames[8] - AC East component of the wind [m/s]
                  ncnames[9] - AC North component of the wind [m/s]
                  ncnames[10]- AC vertical wind [m/s]

                  ncnames[11]- AC roll rate [rad/s] (use '' if N/A)
                  ncnames[12]- AC pitch rate [rad/s](use '' if N/A)
                  ncnames[13]- AC heading rate [rad/s] (use '' if N/A)

                  ncnames[14]- AC EW ground vel. GPS correction(use '' if N/A)
                  ncnames[15]- AC NS ground vel. GPS correction(use '' if N/A)

                  Note: a) at least the first 11 var names must be defined;
                        b) if any of the vars beyond the first 11 are not
                           needed or do not exist use empty string('') to
                           skip those variables
                        c) see ACLOADINS.PRO help for default variable names
                        d) to use Kalman GPS processed variables define ncnames
                           with the following vars: ncnames=['time','tas',
                           'kfroll','kfpitch','kfthead','kfewvel','kfnsvel',
                           'kfzvel','kfuwind','kfvwind','kfwwind']
       PPSELECT: input, string; type of pulse pair to be used:
                   'H1H1','H2H2','V1V1','V2V2','V3V3','H1V1','V1H1'-after 07/04
                   'HH','VV','VH','HV' - for data before Jul 2004
                 input integer, single pulse pair counted from left to wright
                  from the pulse sequence. E.g., for H1H1V1V1 ppselect 1,2,3
                  corresponds to H1H1, H1V1 and V1V1 pulse pair
                 Attn: Use for PPMAG only (SPPAMG and FFT ignore this keyword)
                       and when beaminit is given as a beam vector(3)
       RMCOR:    integer/fltarr(3), applies antenna moment correction
                  0 - antenna moment correction NOT applied  
                  1 - antenna moment correction applied
                  [x,y,x] - ant. position in aircraft coord w.r.t IRS in meters
                  Default: for UWKA or NRC Convair not applied (0) 
                           for NCAR C130  applied(1)
                 Default antenna positions in meters can be seen in wcracvelm.pro
       RMV:      output, fltarr(m), radar arm velocity correction vector into
                        the WCR beam w.r.t. groud in m/s
       TIMEHACK: input,float, WCR time correction to sync with AC INS data,
                 in seconds  (default 0.0)
       WCR2AC:   when set match the output to AC data file sampling rate
                 (default is matching WCR time(irregular sampling), see Notes)
       RADBEAM:  output, fltarr(3,m), WCR beam in Earth coordinate system
       SUNFOLD:  input,fltarr(rg),provides wind scale factor(wind profile) 
                 along the range gate axis when UNFOLD is defined (useful in
                 the presence of strong wind shear(see wcrwunfold.pro)
       UNFOLD:   input, Doppler velocity unfolding procedure (see notes)
                 0          - no unfolding is performed (default)
                 1          - use AC measured winds profile by profile
                 k          - use smoothed AC winds by k(odd) profiles
                 fltarr(3)  - [u,v,w], use the given velocity_shift/wind vector
                              u,v,w are allowed the following values:
                              float: actual wind value to be used in m/s
                                888: use AC measured values profile by profile 
                                     for this component
                                777: use mean of AC measured values from 
                                     all profiles for this component
                 fltarr(m,3)- use user defined shift vector for all data points
       WCRACV:   output, fltarr(m),AC velocity contribution into the WCR beam; ACTIME synched
       WCRACW:   output, fltarr(m),AC measured wind contribution into the WCR beam; ACTIME synched
       WCRVEL:   output, fltarr(rg,n),uncorrected WCR Doppler velocity (see wcrdopvel.pro)

       HELP:     shows this text

 SIDE EFFECTS:
       The function returns an empty string if the usage is incorrect or
       help keyword is set

 NOTES:
       The raw wcr data including wcrtime must be loaded before a call to
       wcrdopcorm (see wcrtools library README.txt file for details or
       the example given bellow).

       wcrtime[0] and wcrtime[last] are used to extract the necessary
       AC data in the following way:
         - wcr2ac NOT SET:  AC start time [sec] = floor(wcrtime[0])-1
                            AC stop time  [sec] = ceil(wcrtime[last])+1
         - wcr2ac SET:      AC start time [sec] = ceil(wcrtime[0])+1
                            AC stop time  [sec] = floor(wcrtime[last])-1

       The timehack, if given, serves to sync WCR and AC time/data.
       The time hack is applied to the WCR time (it should be small if any).
       The input wcrtime is not changed. You can correct wcrtime with the
       timehack before calling wcrdopcorm (wcrtime=wcrtime+timehack) - in
       this case timehack must not be used in the wcrdopcorm call.

       The return is irregularly gridded and match the wcrtime (plus any 
       timehack if defined). If wcr2ac keyword is set then it is regularly
       gridded and match actime.  The other output variables are gridded 
       corresponding to their origin (AC-regular, sps: radbeam;
       WCR-irregular, profiles/sec: wcrvel).  To convert from one grid to
       another use ac2wcr routine.

       When UNFOLD keyword is defined and non-zero, an attempt to unfold
       the Doppler velocity using wind data is performed.  It is based
       on the assumption that the AC measured winds or the given mean
       winds are causing the folding, if exists, at any range gate.
       It is also assumed that the velocity deviation w.r.t. the mean 
       wind do not exceed +-Vmax. Thus centering the corrected for
       aircraft motion measured folded Doppler velocities around the wind
       contribution into the WCR beam is expected to render non-folded 
       velocities.

 PROCEDURE:
       The functions applies linear/bilinear interpolation scheme
       (see, ac2wcr.pro) to match the regularly gridded AC and non-regularly
       gridded WCR data.  Then the contribution of the aircraft motion into
       the WCR beam is subtracted to produce the WCR corrected radial velocity.

 EXAMPLES:

 ******* 1) Calculate corrected WCR velocity matching WCR time(profiles) ******

 Read raw wcr data

 openwcrf,'Wpp00-11-15-19-53-25

 Read wcr data. Use start and stop time instead of profile numbers

 startt  = 201306   ; due to IRIG time jumps the read data start time
 stopt   = 201505   ; will be 201320; stop time 201505 is not affected
 wcrtime=1          ; get the raw (unix) wcr time and the rest
                    ; of the wcr data stored in common block

 readwcrdata,startt,stopt,rawtime=wcrtime,/timein ; ground, 1000-2500 m range

 Define inputs

 kancf   = '/net/bobcat/disk1/kingair_data/20001115.c25.nc'
 ppselect= 'HH'
 timehack= 0.0
 beaminit=-1
 gpsc    = 0    ; 0, apply GPS correction (default)
 rmcor   = 0    ; 0, no radar moment correction (default)
 wcr2ac  = 0    ; 0, match the return to the irregular wcr sampling (default)

 Calculate the corrected Doppler velocity

 wcrdvel=wcrdopcorm(wcrtime,acncf=kancf,timehack=timehack,ppselect=ppselect,$
                   beaminit=beaminit,gpsc=gpsc,rmcor=rmcor,wcr2ac=wcr2ac,   $
                   acdata=acdata,wcrvel=wcrvel,wcracv=wcracv,wcracw=wcracw, $
                   radbeam=wcrb)

(See /tools/idl/wcrtools/wcrdopcorm.pro)


WCRDOPVEL

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRDOPVEL

 PURPOSE:
       Calclulate (uncorrected) Mean Doppler velocity from WCR pulse pair or
       fft data.  Returns fltarr(rangegates, numrec) for SPPAMG and FFT and 
       fltarr(rangegates,numrec,npulse-1) for PPMAG 
       
 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       res=wcrdopvel()

 INPUTS:

 KEYWORD PARAMETERS:
       MAXV:     output, float/fltarr; return max Doppler velocities,
                 corresponding to ppselect; it is the same as or subset
                 of maxvel in wcrparams common block
       NAV:      short integer, number of profiles to be avaraged
                 intarr(2), number of profiles and range gates to average 
                 default is no averaging 
       PPSELECT: input, string; type of pulse pair to be used:
                   'ALL'-all pulse pairs(default)
                   'CO'-all co-pol pulse pairs,
                   'H1H1','H2H2','V1V1','V2V2','V3V3','H1V1','V1H1', or 
                    before July 2004: 'HH','VV','VH','HV'                   
                 input integer, single pulse pair counted from left to wright
                   from the pulse sequence. E.g., for H1H1V2V2 ppselect 1,2, or
                   3 corresponds to H1H1, H1V2 and V2V2 pulse pair
                 Attn: use for PPMAG only (SPPAMG and FFT ignore this keyword)
       PPTHRESH: input, fltarr(2), [Nstd,Val]:
                 Nstd - StDev threshold factor; if given will
                        threshold retrieved Doppler velocity using ppnoise
                        magnitude standard diviation multiplied by Nstd;
                 Val  - float, to be used for the thresholded data points
                        (default is !values.f_nan)
                 Attn: This keyword is ignored for FFT modes
       SWIDTH:   input, positive, scalar; force calculation and return 
                        of spectral width in m/s; no threshold is applied

                        negative, scalar; for SPPAMG and PPMAG only,
                        threshold for the returned power in dBm; to be used 
                        for selecting valid data points when calculating
                        spectral width (see Notes) 
                         
                        if the input is not a scalar the calculation is skipped

                 output,fltarr, spectral width in m/s
                        SPPMAG: fltarr(rangegates,numRec),   pulse pair proc.
                        PPMAG:  fltarr(rangegates,numRec,k), pulse pair proc.
                                                             k=1 to npulse-1
                        FFT:    fltarr(rangegates,numRec),   Dopppler spectrum 
                                second moment; for FFT mode only
       HELP:     shows this text

 OUTPUTS:

 SIDE EFFECTS:
       The function returns an empty string if the usage is incorrect or
       -1 if ppselect is invalid

 NOTES:
       The sign convention for the Dopler velocity is positive toward the 
       radar.

       Spectral width (SWIDTH) for SPPAMG and PPMAG data is calculated from
       the pulse pairs.  This is not a very good estimator of the spectral 
       width. It also can render negative width for low SNR (for more details 
       see Doviak & Zrnic "Doppler Radar and Weather Observations"). To avoid 
       the negative values one can define minimum returned power threshold to
       be used. The thresholded pixels are set to 0 m/s spectral width.

       SWIDTH is not calculated (pixels are set to 0 ) for cross-channel
       pulse pairs

 EXAMPLES:

(See /tools/idl/wcrtools/wcrdopvel.pro)


WCRDVSNR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRDVSNR
 
 PURPOSE:
       Calculate mean and standard deviation of the error in the measured WCR 
       Doppler velocity as a function of SNR (signal-to-noise ratio calculated
       from the received power and measured noise power)
       
 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       WCRDVSNR,dv,pwr,noise,snr,dvsd,dvmn

 INPUTS:
       Dv:    fltarr(rangegates,profs), measured mean Doppler velocity
       Pwr:   fltarr(rangegates,profs), received raw power in mW
       Noise: fltarr(profs), measured noise power in mW

 KEYWORD PARAMETERS:
       SNRHIST:  output, lonarr(bins), histogram of the received power;
                 bins is the size of the output snr.  Bins with less than
                 10 counts are excluded
       PLOTHIST: when set display received power(pwr-mean(noise)) histogram 
                 in dBm
       PLOTDVE:  when set display Doppler velocity mean and standard deviation 
                 errors in m/s as function of SNR
       PWRSNR:   output,fltarr(rangegates,profs),returns input pwr as SNR in dB
                  Minimum value is -30, i.e., all data with snr less than or
                  equal to -30dB are assigned -30 (can be replaced with NaNs)
       NAN:      when set replaces the minimum pwrsnr(-30 dB) with NaN
       HELP:     show this text

 OUTPUTS:
       Snr:  fltarr(bins), SNR in dB; bins is the number of bins for SNRHIST
             containing more than 10 data points per bin; bin size is set to
              1 dBm; Snr is limitted to -30 dB at the low end
       Dvsd: fltarr(bins), Doppler velocity error standard deviation in m/s
       Dvmn: fltarr(bins), Doppler velocity mean error in m/s

 COMMON BLOCKS:

 SIDE EFFECTS:
       When PLOTHIST and/or PLOTDVE are set the corresponding plots are
       displayed in the current graphics device

 NOTES:
       Dvsd and Dvmn are calculated assuming that two consecutive WCR profiles
       are fully target correlated while the system noise is uncorrelated.

       At very low SNR Dvsd should be close to stdev of the system phase
       (velocity) noise (uniformly distributed)  In general (see Doviak and
       Zrnic "Doppler radar and weather observations", Academic Press) the
       st.dev of the Doppler velocity estimate from a pulse-pair processor
       depends on the Doppler spectrum width, the number of independent samples
       (pulse pairs) and the SNR  

       Results may be corrupted (more likely at high SNR) if measured Doppler 
       velocity has folded, and/or ground/sea returns are present, and/or 
       range gates with noticeable transmitter leakage are included in the 
       data segment used.       

 EXAMPLE:  Using WCR data from DYCOMS II

     ; Read raw WCR data

       .run commonwcrset
       openwcrf,'Wpp01-07-24-11-03-24',timecor=0   ; raw time is UTC
       readwcrdata,110552,113642,/timein ; read data 11:05:52-11:36:42
       dv=wcrdopvel(ppselect='CO'); calculate Doppler vel. for the down beams

     ; Calculate DV errors for the 20 KHz pulse pair      

       wcrdvsnr,reform(dv[3:60,*,0]),hh[3:60,*],hhnoise,snr20,dvsd20,dvmn20

     ; Calculate DV errors for the 5 KHz pulse pair      

       wcrdvsnr,reform(dv[3:60,*,1]),hh[3:60,*],hhnoise,snr5,dvsd5,dvmn5

     ; Make a postscript file idl.ps with the results

       setxpswin,99,2
       plot,snr20,dvsd20,psym=1, $
            title=wcrfile+', 11:05:52-11:36:41; Nadir beam', $
            xtit='SNR [dB]',ytit='DV err St.Dev. [m/s]'
       oplot,snr5,dvsd5,psym=2
       grid
       plot,snr20,dvmn20,psym=1, $
            title=wcrfile+', 11:05:52-11:36:41; Nadir beam', $
            xtit='SNR [dB]',ytit='DV err Mean [m/s]'
       oplot,snr5,dvmn5,psym=2
       grid
       printwcrstamp 
       resetps2x

(See /tools/idl/wcrtools/wcrdvsnr.pro)


WCRHCOR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRHCOR

 PURPOSE:

       Linear correction of H receiver data (lookup table adjustment).  
       Data inlcude hhnoise, hhtx, hhlk, hh, hv, ppnoise, pptx, pp.

 CATEGORY:

       wcrtools

 CALLING SEQUENCE:

       wcrhcor, fitprms,what=what,silent=silent,help=help
 INPUT:

       fitprms:  [slope,intercept] - optional fltarr(2) of the correction fit
                 default: [0.95,0.]

 KEYWORD PARAMETERS:

       what   :  Use this keyword to specify which data to be corrected
                 Input: string array/scalar; Strings: 'hh','hv','hhtx','hhlk',
                 'hhnoise','pp','pptx', 'ppnoise'
                 Example: what=['hh','hhnoise']
                 Default: ['hhnoise','hh','ppnoise','pp']
       silent :  Use this keyword to supress some info messages.
       help   :  Show this text

 COMMON BLOCKS:

       common wcrparams
       common wcrdata

 PROCEDURE:

       Uses linear fit to correct lookup table calibration.
       Intercept can be used to account for receivers' gain difference,
       and in this case same cal constant should be used for H and V
       After May 1999 all lookup tables were replaced and generally
       no major correction is needed.

       hcorrection flags the status of H-ch correction: 0/1 - no/yes
       hcorrection=[Fhhnoise,Fhh,Fhv,Fhhtx,Fhhlk,Fppnoise,Fpp,Fpptx]

 EXAMPLE:

       For PPMAG mode correct hhnoise, hh, ppnoise, pp using the default 
       correction:

       wcrhcor

 SIDE EFFECTS:

       All necessary data must be loaded into the common block first.
       Co-pol pulse pairs are corrected only (e.g., 'HH' and not 'HV') 

(See /tools/idl/wcrtools/wcrhcor.pro)


WCRLEAK

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	WCRLEAK

 PURPOSE:

	Return the mean and the standard deviation fltarr(nrg,2) of the Tx power 
    leak contribution along the given nrg range gates, starting from 0th gate,
    in the WCR received power.  If no leak is present for a range gate the
    returned values are 1.5e-10 (-150 dBm). 

 CATEGORY:

	wcrtools

 CALLING SEQUENCE:

	leak=wcrleak(leakpwr,noisepwr,help=help)


 INPUT:

    Leakpwr:  fltarr(nrg,nprof), recieved power, in mW, with no target present
              in the given range gates(nrg) and profiles (nprof). The range
              gates must start from the first (0th) range gate. In other words
              this is a data segment containing receiver noise and Tx leakage 
              only. At least 100 profile data segment must be provided.
    Noisepwr: fltarr(nprof), receievr noise power in mW

 KEYWORD PARAMETERS:

    HELP:     Show this text

 NOTES:
    Some comments about removing the Tx leak from the first few range
    gates where it often is above the mean receiver noise

 1) A good approach to correct for strong leaks is to measure the
    impulse response of the receivers and use the leak measurements
    in the leak range gate.  This is not available at this time.

 2) Another approach is to do signal detection using leak+noise measurements
    along the range gates. In this case one can use leakpwr to determine
    statistically the combined leak+noise contributuions along the range gates:
      leak   =mean(leakpwr,2)
      leakstd=std(leakpwr,2)
    Then a thresholding procedure can be used to detect the target signal.
    The main problem with this correction is the non-stationarity of the 
    leakage.

 3) A third approach is to make an attampt to evaluate the actual leak values.
    Even though this scheme has even more problems than 2), for compatibility
    reasons this is the procedure implemented in this routine. The correction 
    of the target should be done using the mean and the std of the leak 
    returned. Here in addition to the possible non-stationary leakage, false
    or missed detections are added by the use of somewhat arbitrary choice of 
    3 std of the noise as detection threshold of the leakage.

 EXAMPLES:

(See /tools/idl/wcrtools/wcrleak.pro)


WCRLOADNC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRLOADNC

 PURPOSE:
       Load variables from a WCR netcdf file. This version of the WCR netcdf
       file uses 'profile' dimension instead of 'time' dimension. There is no
       time dimension for these type of WCR data files and profile dimension
       represents non-regularly sampled radar data in time. The timestamps
       matching the profiles can be composed from the netcdf file variables 
       time or base_time and time_offset. 

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       result=wcrloadnc(ncid,varname [,filename],startt=startt,stopt=stopt)

 INPUTS:
       ncid:     netCDF variable ID, returned from a previous call to 
                 ncdf_open, ncdf_create, ncdf_varload or ncdf_fcopy
       Varname:  string, netCDF variable name
       Filename: string, optional netCDF file name; if given will open netCDF 
                 file first. In this case ncid is an output var

 KEYWORD PARAMETERS:
       STARTT:   input, long, start time in hhmmss; (default is base_time or
                   time[0], see Notes); if beyond the time interval of the file
                   starts from the beginning
       STOPT:    input, long, stop time in hhmmss, inclusive the last second 
                   (default is the end if the file time, see Notes); if beyond
                   the time interval of the file, read to the end of the file
       HELP:     show this text ( use print,wcrloadnc(/help) )

 OUTPUTS:
       ncid:     netCDF variable ID, returned if Filename is given

 SIDE EFFECTS:
       The function returns an empty string if the usage is incorrect or 
       -1 if the variable is not found or
       -3 if 'time' or 'base_time' and/or 'time_offset' do not exist.
       -4 if STARTT and STOPT are not valid for this file

 NOTES:
       The use of STARTT and STOPT requires the existence of netcdf variables
       'time' or 'base_time' and 'time_offset', where 'time' is a time vector
       in unix second, 'base_time' is the start time of the data in the file 
       given in unix seconds (seconds after 00:00:00 Jan 1, 1970" and 
       'time_offset' is offset in seconds from base_time. After 2006 base_time
       and time_offset variables are obsolete.

 EXAMPLES:

       hh=wcrloadnc(ncid,'hh') ; load hh(range,profile)

(See /tools/idl/wcrtools/wcrloadnc.pro)


WCRPLOTNC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRPLOTNC

 PURPOSE:
       Display reflectivity(Z) and Doppler velocity(DV) for selected WCR 
       netcdf files. 

       This routine currently cannot handle WCR polarimteric configurations
       and multiple identical pulse pairs for 12,13,123, and 1234 beam
       configurations.

       Allowed antenna/beam configurations: 1,2,12,13,24,123,124 and 1234,
       where, 1: side/up beam, 2: down beam, 3: side-slanted, 4: down-slanted 

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrplotnc, minmax,colortb=colortb,noerase=noerase,startt=startt, $
                  stopt=stopt,thresh=thresh,help=help

 INPUTS:
       Minmax:  fltarr(3),[dvminmax,zmax,zmin]
                dvminmax - float, Doppler velocity min/max limit in m/s
                zmax     - float, Reflectivity max limit in dBZ
                Use -999 to use default values for parameters that you do not
                want to set

 KEYWORD PARAMETERS:
       COLORTB:  intarr(2), [Zcolortb,DVcolortb], color tables for Z and DV
                 (default is [41,51] or [33,17] if 41/51 not available)
       NOERASE:  when set will not erase the widgets or the graphic windows 
       STARTT:   input, long, start time in hhmmss (see SIDE EFFECTS)
       STOPT:    input, long, stop time in hhmmss, inclusive the last second 
       THRESH:   input, float, threshold level factor (0: default,no thresh); 
                 data below thresh*std(noise) is not displayed
       HELP:     show this text

 OUTPUTS:

 SIDE EFFECTS:
       Input files for this routine are selected with the dialog_pickfile

       If STARTT/STOPT is/are defined a single file selection only is allowed.
       If STARTT and/or STOPT do/does not exist read from/to beginning/end of
       file.

       Opens one or more graphic windows and/or graphic widgets.

 NOTES:

 EXAMPLES:

(See /tools/idl/wcrtools/wcrplotnc.pro)


WCRPROC_HV

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRPROC_HV

 PURPOSE:
       wcrproc_hv routine for processing radar power calibration files
       (this routine is not intened for general use)

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       WCRPROC_HV,crmax,crmean,atten

 INPUTS:
       Some input parameters have to be adjusted by editing the routine:
       d - date, hdisk - data disk, expname - experiment title, etc.

 OUTPUTS:
       depend on the processing modes (proccal,procimgz,proctstz,procimgv)

(See /tools/idl/wcrtools/wcrproc_hv.pro)


WCRPROC_S

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRPROC_S

 PURPOSE:
       wcrproc_s routine for processing radar power calibration files
       (this routine is not intened for general use)

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       WCRPROC_S,crmax,crmean,atten

 INPUTS:
       Some input parameters have to be adjusted by editing the routine:
       d - date, hdisk - data disk, expname - experiment title, etc.

 OUTPUTS:
       depend on the processing modes (proccal,procimgz,proctstz,procimgv)

(See /tools/idl/wcrtools/wcrproc_s.pro)


WCRPROC_SH

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRPROC_SH

 PURPOSE:
       Corner Reflector calibration using SPPMAG H-ch data files
       (this routine is not intened for general use)

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       WCRPROC_SH,crmax,crmean,atten

 INPUTS:
       Some input parameters have to be adjusted by editing the routine:
       d - date, hdisk - data disk, expname - experiment title, etc.

 OUTPUTS:
       Produce a ps file and a text file with calibration constants

(See /tools/idl/wcrtools/wcrproc_sh.pro)


WCRPROC_SV

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRPROC_SV

 PURPOSE:
       wcrproc_s routine similar to wcrproc script for non-batch processing
       (this routine is not intened for general use)

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       WCRPROC_SV,crmax,crmean,atten

 INPUTS:
       Some input parameters have to be adjusted by editing the routine:
       d - date, hdisk - data disk, expname - experiment title, etc.

 OUTPUTS:
       depend on the processing modes (proccal,procimgz,proctstz,procimgv)

(See /tools/idl/wcrtools/wcrproc_sv.pro)


WCRSCOPE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    WCRSCOPE

 PURPOSE:
    Creates a postscript file with plots of samples from WCR transmitter

 CATEGORY:
    wcrtools	

 CALLING SEQUENCE:
    wcrscope,fnscope,scopev,scopet,scopes,fnvxi,vvstat,timehack=timehack

 INPUTS:
    fnscope - scope file name

 KEYWORDS:
    timehack- time corr. in sec. If given correct scopet 
              and scopes using the timehack instead of leapsec  

 OUTPUTS:
    scopev  - scopev[*,0] - mean voltage
              scopev[*,1] - rms voltage
    scopet  - time in hhmmss,  corrected for leapsec=-13 (default)
    scopes  - time in sec,  corrected for leapsec=-13

 SIDE EFFECTS:
    Create PS file named .ps

(See /tools/idl/wcrtools/wcrscope.pro)


WCRTFP1SCOR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRTFP1SCOR

 PURPOSE:
       This routine corrects a specific problem with the WCR Time (IRIG) card
       The problem appears as one or more 1 second negative jumps at the top
       of a second followed by a single recovery positive jump. The problem is 
       intermittent and appears in some of the WCR data collected during IHOP
       experiment in 2002.
       
 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       res=wcrtfp1scor(time)

 INPUTS:
       Time:   dbl/fltarr(n), wcr time array for n profiles to be corrected

 KEYWORD PARAMETERS:
       HELP:   when set show this text

 OUTPUTS:
       The function returns an array with corrected time matching the input
       array type.

 COMMON BLOCKS:
       None

 SIDE EFFECTS:
       There is a small probability that this routine can generate negative
       time jumps in the corrected time.  This may happen if a fixed 1-s 
       negative time jump is combined with a simultaneous data gap (excessive
       time interval between profiles due to data acquisition problem)

 NOTES:
       This routine is intended for correcting the so-called "1-sec negative
       jumps" in the WCR time stamps caused by a problem with TFP(IRIG) card.
       It is also expected that a recovery of the one or more negative jumps
       always takes place right after the negative jumps.  Therefore the 
       routine checks the matching between the negative jumps and the recovery
       positive jumps.  If such match does not exists an error message is
       returned.

       Care should be taken to secure that the time array being corrected
       does not start or end within a time period when negative jumps/recovery
       occur.

       The function checks corrected time array for uncorrected or generated 
       negative time jumps and reports it in an informational message if such
       are found.  The user must examine the input/output time array and take
       appropriate action.

       The time problem fixed by this routine occured in the data collected
       during year 2002 (IHOP02 and HICU02 experiments)

 EXAMPLES:

(See /tools/idl/wcrtools/wcrtfp1scor.pro)


WCRTFPPJFIX

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRTFPPJFIX

 PURPOSE:
       Fixes positive time jumps in the time stamps and rewrites the raw file
       starting with 'T'. The corrupted raw file must be open and read 
       before running this routine.  The problem is intermittent and appears
       in some of the data collected during CIFEX in 2004.                

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       WCRTFPPJFIX,wcrtime,wcrtnew,dt, writewcr=writewcr,help=help

 INPUTS:
       Wcrtime:  dblarr(n), corrupted wcr time in UNIX seconds for n profs 

 KEYWORD PARAMETERS:
       WRITEWCR:      when set, the program rewrites wcrfile with first
                      char. of the name replaced with 'T'
       HELP:          show this text

 OUTPUTS:
       Wcrtnew:  dblarr(n), corrected wcr time in UNIX seconds
       Dt:       dblarr(n-1), time interval between profiles from Wcrtnew

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:

 NOTES:
       

(See /tools/idl/wcrtools/wcrtfppjfix.pro)


WCRTHRESHNC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRTHRESHNC

 PURPOSE:
       Return range adjusted reflectivity threshold,fltarr(rangegates,profile),
       given radar range gates in meters and reflectivity noise standard
       deviation in equivalent dBZ at 1km

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       result=wcrthreshnc(snoise,radrng,sfactor)

 INPUTS:
       Snoise:  fltarr(profiles), standard deviation of the reflectivity 
                noise in equivalent dBZ at 1 km
       Radrng:  fltarr(rangegates) radar range gates in meters 
       Sfactor: factor applied to snoise to form the threshold (default 1)
                (e.g., if sfactor=2, threshold is snoise+10*alog10(sfactor))

 KEYWORD PARAMETERS:
       HELP:     show this text (use print,wcrthreshnc(/help) )

 OUTPUTS:

 SIDE EFFECTS:

 NOTES:

 EXAMPLES:

(See /tools/idl/wcrtools/wcrthreshnc.pro)


WCRTIMEOFF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRTIMEOFF

 PURPOSE:
       Calculates time offset between WCR time stamps and N2UW 
       KingAir data system time stamps.  It also returns the
       corresponding correlation coefficient.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrtimeoff,toff,tcov,beam,drng,dprof, acncf=acncf,rmcor=rmcor, $
                  wcrfn=wcrfn,nowcrread=nowcrread,ground=ground,$
                  ppselect=ppselect,acdata=acdata,xplot=xplot,filt=filt,$
                  dbg=dbg,help=help

 INPUTS:
    Beam:   Anntenna beam
              fltarr(3),  [ac_along_axis,right_wing,down] or
              0         - side-looking KingAir, KA, (main) 12"antenna
              1         - up-looking KA (main+mirror) 12" antenna
              2         - KA nadir 18" antenna
              3         - KA side-fore antenna(~35 deg)
              4         - KA down-fore 15" antenna(~30 deg)
              5         - NCAR C130 nadir 12" antenna (7/16/01)
              6         - NCAR C130 down-aft 12" antenna(7/16/01)
              7         - NRC CV580 side looking 12" antenna
              8         - NRC CV580 nadir looking 12" antenna

    Drng:   [first,last] range of wcr data range gates to be used; default is
            all range gates
    Dprof:  [first,last] wcr data profile range to be used; default is  
            all profiles; to input Dprof, Drng must exists (use 0 for default)
           
 KEYWORD PARAMETERS:
    ACDATA:    input/output, structure of AC data (see acloadins help for more)
    ACNCF:     input,string; AC 25 HZ netcdf data file name or AC netcdf ID;
               ACDATA input is ignored if ACNCF is defined;
    DBG:       input, when set, does not exit the routine
    WCRFN:     input string; WCR raw data file name.  If not given the
               needed file is assumed open. The [drng,dprof] data is 
               loaded unless NOWCRREAD keyword is set.
    PPSELECT:  input, string; type of pulse pair to be used (e.g., 'H1H1')
               for the given beaminit vector (ignored if beam 0 to 8)
    NOWCRREAD: when set does not read wcr raw data and use already loaded wcr 
               data. If drng and dprof are defined it uses the subset of the
               already loaded data.
    GROUND:    input, float; using surface return data  (default 1)
                 1 - finds max returns for every profile and assumes that they
                     are surface returns. Optimal time offset is calculated
                     based on cross correlation between AC motion into the
                     wcr beam and the uncorrected wcr Doppler velocity
                 x - -abs(x) threshold in dBm; all data above the threshold
                     are considered surface returns. Optimal time offset is
                     searched based on minimum mean and stdev of the corrected
                     Doppler velocity from the surface (the surface is assumed
                     not moving) 
                -1 - surface is determined as ground=1 but optimal time offset
                     is searched like ground=x 
                ATTN: i)  For 1 and -1 make sure there is a ground return 
                          throughout the processed data segment.
                      ii) Also when using correlation analysis(1) any folding
                          in the uncorrected Doppler needs to be fixed
    RMCOR:     integer/fltarr(3), applies antenna moment correction
                0 - antenna moment correction NOT applied  
                1 - antenna moment correction applied (use default position)
                [x,y,x] - ant. position in aircraft coord w.r.t IRS in meters
    XPLOT:     when set plots the results; if set to 99 creates idl.ps file
    HELP:      when set show this text

 OUTPUTS:
    Toff:      float, time offset between WCR and AC time in seconds
               (positive means WCR time is ahead of AC time; thus to correct
                WCR time using openwcrf or readwcrdata use timecor=-toff)
    Tcov:      GROUND keyword not defined or equal to 1:
                 float, WCR/AC correaltion coeff. for Toff (-1 to 1).
               GROUND keyword defined and not equal to 1:
                 fltarr(2), [mean_grnd_vel, std_grnd_vel] at Toff

 SIDE EFFECTS:

 PROCEDURE:    GROUND keyword not defined:
                 Time offset is estimated by cross correlating the aircraft (AC)
                 motion into the WCR beam (calculated from the AC INS data and
                 predefined wcr beam pointing angles) and the WCR measured
                 Doppler velocity. The coordinate system is ground referenced.
               GROUND keyword defined:
                 Search for radar returns above the given threshold and 
                 assume they are from a surface.  Then calculate the time
                 offset based on the minimum mean and standard deviation RMS
                 error of the corrected for aircraft motion Doppler from 0 m/s

 NOTES:
               This procedure does not make an attempt to correct if folded 
               Doppler values are present. Existing folding can corrupt the 
               results and therefore screening for folding is recommended.

               The quality of the result (high correlation coefficient)
               depends on the dynamic of the AC velocity contribution into
               the radar beam and the steadiness of the wind contribution.  
               On the other hand extreme maneuvers causing high variability
               of the ac velocity contribution may not offer the best cases
               due to increase in the data measurement errors.
  
 EXAMPLES:

    1) Using cross correlation (GROUND keyword not defined):

    wcrtimeoff,toff,tcov,3,[2,5],[2800,3100],/xplot, $
               wcrf='/net/fox/fox1/WCR/HICU/jul18/W2002-07-18-16-57-03', $
               acncf='/net/owl/data/kingair_data/20020718.c25.nc'

    Another test using different range gates could be done the following way:

    wcrtimeoff,toff,tcov,3,[4,7],[2800,3100],/xplot

    Also wcr data can be read before calling wcrtimeoff and then run it with
    different profile and range gate segments.  Once the aircraft data is
    read there is no need to read it again as long as the same AC data file
    is relevant for the examined wcr data. For these cases use /nowcrread

    2) Same data as above but using the ground returns in the data
       All profiles and range gates are loaded. No new read of King Air
       data is needed.

    wcrtimeoff,toff,tcov,3,0,0,/xplot,ground=-30., $
               wcrf='/net/fox/fox1/WCR/HICU/jul18/W2002-07-18-16-57-03'

(See /tools/idl/wcrtools/wcrtimeoff.pro)


WCRTOOLS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRTOOLS

 PURPOSE:
       Show WCR IDL routines with one line description

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrtools

 KEYWORD PARAMETERS:
       HELP:  Show this text

(See /tools/idl/wcrtools/wcrtools.pro)


WCRUD2ALTNC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRUD2ALTNC

 PURPOSE:
       Returns WCR up(beam1), down(beam1), or down&up(beam1&beam2) 
       reflectivity(or velocity) resampled into the vertical plane and 
       adjusted for the radar altitude. Deviations of the beam(s) in the 
       horizontal plane are ignored (horizontal homogeneity is assumed). 
       If beam(s) pointing angles are not given assume no deviation from 
       vertical (straight leg, small attitude angles).

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       result=wcrud2altnc(var,rng,alt,beam1,beam2)

 INPUTS:
       Var:     fltarr(nrg,nprof); reflectivity or Doppler velocity for
                 nrg range gates and nprof profiles
       Rng:     fltarr(nrg), radar range in meters for Var; must be equally-
                 spaced monotonically ascending vector (See SIDE EFFECTS)
                for 'up' beam: Rng must be positive
                for 'down' beam: Rng must be negative if BEAMDIR is not given
                for 'down&up' combined: Rng must start with negative values 
                for the 'down' beam followed by positive values for 'up' beam
       Alt:     fltarr(nprof), radar altitude for every profile
       Beam1:   fltarr(3,nporf), radar beam (up or down) unit vector
                 in ground coordinates matching input data Var
       Beam2:   fltarr(3,nprof), radar beam unit vector for the 'up' beam
                 if Var is combined down&up beams; in this case Beam1 is the
                 unit vector of the 'down' beam and Rng starts with the
                 range for the down beam as negative and then the range for
                 the 'up' beam as positive (e.g., -3075 to +3075 m)

 KEYWORD PARAMETERS:
       ALTRNG:  output, fltarr(nalt), altitude vector in meters; 
                        nalt - number of resampled altitudes
       BEAMDIR: input, string; beam direction: 'up','down','updown'
                 if Beam1/2 input parameter(s) is/are given BEAMDIR is ignored.
                 If Beam1/2 is/are not given and BEAMDIR is not define it is 
                 determined by the sign of Rng
       MISVAL:  input,float, missing value for Var (default -32767.)
       HELP:    shows this text

 OUTPUTS:
       Returns array of (nalt,nprof) elements
      
 SIDE EFFECTS:
       1) Radar data is linearly interpolated to match the sampling altitudes.
          If reflectivity is in dBZ no attempt to convert to Z is made before
          interpolation (thus small mean eror/bias may be present). Missing 
          values in the input and output are filled with NaNs. Thus the output
          will have some interpolated values becoming NaNs when a missing
          value participates in the interpolation.

       2) When Beam1/2 are given:
          a) The output is also projected to the vertical plane.  No attempt is 
             made to discard data with "large" horizontal displacement (e.g.,
             for 45 deg roll and 3 km range the radar data is displaced 2.1 km 
             horizontally).
          b) The sampling of the result preserves the range spacing in Rng.
             Thus, if more than one data point falls into the vertical range
             spacing the output is the mean value; if no value falls into
             the output range missing value, NaN, is recorded.

       3) There is one exception to the requirement for Rng to be equally 
          spaced when Rng represents the combined 'up' and 'down' beam radar
          ranges.  2 equal and larger range gate spacings are allowed for the 
          first range gates above and below 0 m (they are in effect the WCR
          range gate delay).  Example: ...,-145.,-105.,-75.,75.,105.,145.,...
          or ...,-145.,-105.,-75.,0.,75.,105.,145.,... (where 0 m range is 
          always missing value for all profiles in Var)

 NOTES:
        
 EXAMPLES:

(See /tools/idl/wcrtools/wcrud2altnc.pro)


WCRUD2UDNC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRUD2UDNC

 PURPOSE:
       Returns the combined reflectivity or velocity field (nrg, nrpofs).  
       from the 'up' and the 'down' WCR beams. The ranges added in the
       gap between the first valid 'up' and 'down' gates are filled with 
       missing values.  The missing values of the output is always NaN.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       result=wcrud2udnc(ZDup,ZDdn,Radrng,Rng)

 INPUTS:
       ZDup:    fltarr(nrrg,nprof); 'up' beam reflectivity (in dBZ or mm6/m3)
                 or Doppler velocity(m/s) for nrrg range gates and nprof profs
       ZDdn:    fltarr(nrg,nprof); 'down' beam reflectivity (in dBZ or mm6/m3)
                 or Doppler velocity(m/s) for nrrg range gates and nprof profs
       Radrng:  fltarr(nrrg), equidistant radar range in meters, matching 
                 ZDup/dn data

 KEYWORD PARAMETERS:
       MISVAL:  input,float, missing value for ZDup/dn (default -32767.)
       VEL:     input,when set identifies input data as Doppler velocity
                 This is important setting in order to match the velocity
                 signs for the up and down beams with positive values being
                 'up' as a sign convention
       HELP:    shows this text

 OUTPUTS:
       Rng:     output, fltarr(nrg); combined range matching the output number
                 of range gates.  The origin is the radar location noted as
                 0 m; ranges below the radar (down beam) are negative and 
                 above the radar (up beam) as positive.  The gap between the
                 1st 'up' gate and the first 'down' gate is filled with at
                 least one 'blind' range or more based on the input range gate
                 delay (first range gate) and the range gate spacing 
      
 SIDE EFFECTS:

 NOTES:
        
 EXAMPLES:

(See /tools/idl/wcrtools/wcrud2udnc.pro)


WCRUPDATENC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRUPDATENC

 PURPOSE:
       Update reflectivity or Doppler velocity variables of WCR netcdf file(s)
       as well as some other associated variables and attributes 

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrupdatenc,ncfile,wcrdir,writestr,acpath=acpath,acnames=acnames,      $
                   acspeed=acspeed,cal=cal,dspclock=dspclock,utccorr=utccorr, $
                   timesync=timesync,unfold=unfold,gpsc=gpsc,rmcor=rmcor,     $
                   revision=revision,big_endian=bgnd,silent=silent,linz=linz, $
                   misval=misval,help=help

 INPUTS:
       Ncfile:   string or strarr with path/name(s) of WCR netcdf file(s) to
                   be updated
       Wcrdir:   string, path to the raw WCR files associated with Ncfile
                   (default is current directory)
       Writestr: input, string, determine what to update; allowed strings:
                  'all' - reflectivity and corrected doppler velocity vars.
                  'z'   - reflectivity related variables
                  'dv'  - uncorrected Doppler velocity related variables
                  'zdv' - 'z' + 'dv' variables
                  'cdv' - corrected Doppler velocity

 KEYWORD PARAMETERS:
       ACPATH:   input,string, path to the aircraft navigational netcdf data
                   file associated with Ncfile (default is current directory)
                 input, string, path/name to the aircraft navigational netcdf
                   data file, if 'cdv' is to be written for the first time

       ACNAMES:  input, string array, AC netcdf varnames to be used (if not 
                        defined N2UW or N130AR default var names are used; 
                        see Notes for the default variable names)
                  acnames[0] - AC time (seconds in UNIX format)
                  acnames[1] - AC true air speed in m/s
                  acnames[2] - AC roll [deg or rad]
                  acnames[3] - AC pitch [deg or rad]
                  acnames[4] - AC true heading [deg or rad]
                  acnames[5] - AC east-west(EW) ground velocity [m/s]
                  acnames[6] - AC north-south(NS) ground velocity [m/s]
                  acnames[7] - AC vertical velocity [m/s]
                  acnames[8] - AC East component of the wind [m/s]
                  acnames[9] - AC North component of the wind [m/s]
                  acnames[10]- AC vertical wind [m/s]
                  acnames[11]- AC roll rate [rad/s] (use '' if N/A)
                  acnames[12]- AC pitch rate [rad/s](use '' if N/A)
                  acnames[13]- AC heading rate [rad/s] (use '' if N/A)
                  acnames[14]- AC EW ground vel. GPS correction(use '' if N/A)
                  acnames[15]- AC NS ground vel. GPS correction(use '' if N/A)
                  acnames[16]- AC longitude [deg]
                  acnames[17]- AC latitude [deg]
                  acnames[18]- AC altitude MSL [m]

                  Note: see ACLOADINS.PRO help for default variable names

                 This keyword is used with WRITESTR='cdv' and 'all' only

       ACSPEED:  input, float; average aircraft speed in m/s (default 90.)
                   This keyword is used with WRITESTR='dv' and 'zdv' only

     BIG_ENDIAN: when set, assumes that the WCR file data are in big endian order.
                   The default is LITTLE_ENDIAN. Ignored for data before 03/2002 

       CAL:      input,fltarr(7),[calHH1,calHH2,calVV1,calVV2,calVV3,HViso,VHiso], 
                   calibration coefficients in dB; default are the values in
                   the Ncfile; Note: the order of cal. constants is fixed; thus
                   either define as many as needed in the given order or use
                   -999. to skip updating a particular cal. const.             
                   This keyword is used with WRITESTR='z','zdv' and 'all' only

       GPSC:     when set does NOT apply GPS correction to A/C E-W and N-S
                   velocity for UWKA only (ignored for NCAR C130)
                   NCAR C130 A/C E-W and N-S ground speed are GPS corrected.
                   NRC CV580 GPSC is not needed.
                   (default is the option used for Ncfile, if not available
                    use the default as defined in wcrcreatenc routine)
                   This keyword is used with WRITESTR='cdv' and 'all' only

       LINZ      when set the reflectivity data is in Z mm^6/m^3 (default is dBZ)
                   This keyword is used with WRITESTR='z','zdv' and 'all' only
       MISVAL    missing value, to be used for the updated variables
                   (default: the values saved in the missing_value attributes)

       RMCOR:    integer/fltarr(3), applies antenna moment correction
                  0 - antenna moment correction NOT applied  
                  1 - antenna moment correction applied
                  [x,y,x] - ant. position in aircraft coord w.r.t IRS in meters
                  Default: for UWKA or NRC Convair not applied (0) 
                           for NCAR C130 applied(1)
                  Default antenna position can be seen in wcracvelm.pro
                 This keyword is used with WRITESTR='cdv' and 'all' only

       REVISION: input,string or strarr(2) netcdf file revision
                 revision[0] - update Revision_X attribute (default, depends 
                               on what is processed); If the string starts with
                               $ the last Revision_X attribute is overwritten
                               otherwise a new Revision_X is created. If only
                               '$' the last Revision_X will be overwritten
                               with the default string.
                 revision[1] - update RevisionStatus attribute(default is 'OK')
                 If input a string, update Revision_X attribute only;
                 If empty string(s) '' - do not update the attribute(s)

       SILENT:   when set supress routine informational messages

       TIMESYNC: input,float, WCR time correction to sync with A/C IRS(INS) 
                   data, in seconds  (default Timeoffsetsync from Ncfile)
                 input, fltarr(n), different values for every ncfile 
                 This keyword is used with WRITESTR='all' and 'cdv' only

       UNFOLD:   input, Doppler velocity unfolding procedure (see notes)
                 0          - no unfolding is performed (default)
                 1          - use AC measured winds
                 fltarr(3)  - [u,v,w], use the given wind vector
                              u,v,w are allowed the following values:
                              float: actual wind value to be used in m/s
                                888: use AC measured values for all 
                                     profiles of this component
                                777: use mean of AC measured values from 
                                     all profiles of this component
                 ATTN: Note yet modified to work for multiple files/prof_ranges

       UTCCORR:  if defined gives UTC time correction of the wcr time
                   Default is UTCcorrection from Ncfile.
                   This keyword is used with WRITESTR='all' and 'cdv' only

       HELP:     shows this text

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:

      See the side effects described in wcrwrite1nc and wcrwrite2nc

 NOTES:

 EXAMPLES:

       1) Example using CLEX-9 experiment data (single antenna config, N2UW)

       ncfile=['WCR.SPP.CLEX01.20011101.145436_160822.nc',$
               'WCR.SPP.CLEX01.20011101.160822_164239.nc']
       wcrfile='/sova4/clex01/nov01'
       writestr='z'
       revision='Updated reflectivity'
       wcrupdatenc,ncfile,wcrdir,writestr,cal=[49.3,47.8,16.0],utccorr=-13.,$
                   revision=revision

       2) Example using DYCOMS II experiment data (2 down antennas, N130AR)

       ncfile=['WCR.PP4.DYCOMS01.20010727.213217_215900.nc', $
               'WCR.PP4.DYCOMS01.20010727.215900_224630.nc']
       wcrdir='/sova4/dycoms01/jul27'
       writestr='cdv'
       acpath='/net/fox/fox1/C130/hi_rate/RF09.20010727.181636_034427.PNI.nc'

       wcrupdatenc,ncfile,wcrdir,writestr,acpath=acpath,timesync=-0.125, $
                   rev='$Updated Corrected Doppler'

(See /tools/idl/wcrtools/wcrupdatenc.pro)


WCRVCOR

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRVCOR

 PURPOSE:

       Linear correction of V receiver data (lookup table adjustment).  
       Data inlcude vvnoise, vvtx, vvlk, vv, vh, ppnoise, pptx, pp.

 CATEGORY:

       wcrtools

 CALLING SEQUENCE:

       wcrvcor, fitprms,what=what,silent=silent
 INPUT:

       fitprms:  [slope,intercept] - optional fltarr(2) of the correction fit
                 default: [0.95,0.]

 KEYWORD PARAMETERS:

       what   :  Use this keyword to specify which data to be corrected
                 Input: string array/scalar; Strings: 'vv','vh','vvtx','vvlk',
                 'vvnoise','pp','pptx', 'ppnoise'
                 Example: what=['vv','vvnoise']
                 Default: ['vvnoise','vv','ppnoise','pp']
       silent :  Use this keyword to supress some info messages.
       help:     Show this text

 COMMON BLOCKS:

       common wcrparams
       common wcrdata

 PROCEDURE:

       Uses linear fit to correct lookup table calibration.
       Intercept can be used to account for receivers' gain difference,
       and in this case same cal constant should be used for H and V
       After May 1999 all lookup tables were replaced and generally
       no major correction is needed.

       vcorrection flags the status of V-ch correction: 0/1 - no/yes
       vcorrection=[Fvvnoise,Fvv,Fvh,Fvvtx,Fvvlk,Fppnoise,Fpp,Fpptx]

 EXAMPLE:

       For PPMAG mode correct V-ch using the default correction:

       wcrvcor

 SIDE EFFECTS:

       All necessary data must be loaded into the common block first.
       Co-pol pulse pairs are corrected only (e.g., 'VV' and not 'VH') 

(See /tools/idl/wcrtools/wcrvcor.pro)


WCRVPS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRVPS

 PURPOSE:
       Creates a Corrected Doppler velocity PS file with maximum 3 plots
       per page

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       WCRVPS, dvel           ; when wcr common blocks are used
       WCRSPS, dvel,r,tsec    ; for general use

 INPUTS:
    Dvel:  fltarr(rangeGates,profs), velocity in m/s.
                 If V is not given a widget to pick a WCR file will open.
    R:     fltarr(rangeGates), range;
                 mainly for non WCR files (see ASPECT keyword)
    Tsec:  fltarr(profs), time in sec.
                 mainly for non WCR files (see ASPECT keyword)

 KEYWORD PARAMETERS:
    ASP:         float, Range/Profile aspect ratio in meters.
                 When exist won't use wcr common blocks and requires r and tsec
                 This keyword is intended for non WCR files.  If it is used
                 for wcr files negative values for asp will print wcr file
                 info at the bottom of each page. 0 input will disable scaling.
                 When negative: abs(asp) is used for aspect.
    COLORTB:     color table number (default is 0, black & white)
                 Negative color numbers reverse the color tables.
                 Use -99 for reverse black & white.
    DIR:         string, when set, the directory for ps file(s) to be stored
                 default is ps dir under current dir.
    FNAME:       input, string array, [file,title,xtitle,ytitle,bar_title]
                 fname[0] - PS output file name; fname is also used for
                 labeling the plots. Default PS file name uses wcrfile.
                 Default labels are : 'DV','UTC','Range [m]','m/s'.
                 If fname[0]='' then it assumes that wcrfile exists and uses
                 it to form the output ps file name
    HELP:        show this text
    IMGORDER:    input, integer, antenna pointing position for the plotted
                 images ; define the range axis order of the images
                   0 -  up/side pointing antenna (bottom-to-top image, default)
                   1 -  downlooking antenna (top-to-bottom image)
    LANDSCAPE:   create PS file in landscape (default is portrait)
    MAXLIM:      float, maximum velocity plotted (default  50 m/s)
    MINGATES:    integer, minimum number of range gates to be plotted
                 If mingates is defined and greater than the actual number of
                 range gates the image is plotted using mingates (default, 70)
    MINLIM:      float, minimum velocity plotted (default -50 m/s)
    MINMAX:      when set (minmax=1), min and max for every subimage are used
                 minmax < 0., minmax is used as a fixed min, max is calculated
                              for every subimage
                 minmax > 0. (but ne to 1), minmax is used as a fix max,
                              min is calculated for every subimage
                 minmax=0,(default, minmax not set), min and max are calculated
                           for the whole image and used as fixed
    TLABEL:      string, adds title to the param/stat tables

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:
       wcr files with small number of range gates (< 50) may cause the pixel
       size to be too big (because of aspect ratio applied to equally scale
       the image in range/time axes).  To avoid this problem use mingates
       keyword set to number of range gates higher than the actual number.

 EXAMPLES:

       ; Read raw WCR wcr file and KingAir netcdf 25 Hz data file and
       ; create a ps file (Wpp00-11-19-21-01-23.ps) with corr. Doppler vel.
       ; Noise pixels are not thresholded.

       minmax  =  1  ; use local min/max values for every plot
       minlim  = -5  ; minimum plotted velocity in m/s
       maxlim  =  5  ; maximum plotted velocity in m/s

       tlabel  = 'Example'
       wcrdir  = '/net/orel/orel3/wyice00/nov19/'
       kafile  = '/net/bobcat/disk1/kingair_data/20001119.c25.nc'

       ppmnoav = 2   ; load 1st pulse noise readings only (for PPMAG files)
       wcrtime = 1   ; force loading WCR raw UNIX time

       openwcrf,wcrdir+'Wpp00-11-19-21-01-23'    ; PPMAG4 file from WYICE00
       readwcrdata,rawtime=wcrtime,ppmnoav=ppmnoav
       DopVel = wcrdopvelm(kafile,wcrtime)
       DopVel = reform(DopVel[*,*,0])            ; use vel from 1st pulse pair

       wcrvps, DopVel,minmax=minmax,minlim=minlim,maxlim=maxlim,tlabel=tlabel

(See /tools/idl/wcrtools/wcrvps.pro)


WCRVPSM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRVPSM

 PURPOSE:
       Create Corrected Doppler Velocity PS files from one day flight data

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       WCRVPSM, dir, acfile

 INPUTS:
       Dir:      string, wcr data file directory; undefined: use pickfile

 KEYWORD PARAMETERS:
     ACFILE:     string, Aircraft (A/C) data file path & name (ins data);
                 (undefined: use pickfile)
     ACONFIG:    input, integer or intarr; antenna configuration
                 0 - single side/up looking antenna; default
                 1 - two downlooking antennas (H-ch: down-fore, V-ch: down)
                 2 - two sidelooking antennas (V-ch: side-fore, H-ch: side/up)
                 3 - down and side/up antennas (V-ch: down, H-ch: side/up)
                 4 - two downlooking antennas (V-ch: down, H-ch: down-aft,
                     this is for C130 DYCOMS01 experiment before H/V channels 
                     were swapped in march 2002)
                 5 - down and side antennas for NRC-CV580 WCR installation

                 Note: dual-antenna configs have no polarimetric capability

     COLORTB:    color table number (default is -99, reversed black & white)
                 Negative color numbers reverse the color tables.
                 Use -99 for reverse black & white.
     FILEID:     file identification string. Common substring from the data
                 file name starting from 2nd char (default 'pp0').
     HELP:       Show this text
     BIG_ENDIAN: when set, assumes that the file data are in big endian order
                 The default is LITTLE_ENDIAN.
     MINGATES:   integer, minimum number of range gates to be plotted
                 If mingates is defined and greater than the actual number of
                 range gates (rangegates) the image is plotted using mingates
                 (default, rangegates)
     MINLIM:     float, minimum reflectivity plotted (default -50 m/s)
     MAXLIM:     float, maximum reflectivity plotted (default  50 m/s)
     PRINTER:    'lj4', 'lj4_gv', 'qms'
                 undefined: qms
                 '': suppress printing
     PROC:       byte, define what to plot (for dual-pol modes only)
                       0 - produce plots from H-ch (default)
                       1 - produce plots from V-ch
     PSDIR:      string, directory for postscript file(s)
                 Default save ps files in subdir 'ps/', which is created
                 if non-existant.  When dir='select', ps directory is always
                 sub directory of the home directory, otherwise it is sub
                 of dir
     THRESH:     negative float, returned power in dBm to be used for velocity
                 thresholding (default is 3 stdev above min noise)
                 positive float, n; n*stdev above min noise 
     TIMECOR:    if defined gives time correction of the wcr time
                 After June 1998, IRIG card is used to set the time.
                 Normal use of the card is to get the time from a master
                 IRIG card with GPS time.  Thus the default value is
                 the current leap seconds.
     TIMEHACK:   float, time adjustment to wcr time to precisely sync wcr with
                 aircraft(A/C) ins variables (default is 0). If defined it is
                 added to TIMECOR.  DO NOT USE TIMEHACK if TIMECOR includes 
                 the value of the non-zero time hack. 
     TLABEL:     string, adds title to the param/stat tables It always add
                 info about the timehack ('Corrected Doppler Velocity (timehack: ....)')

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:

 EXAMPLES:  See wcrproc_s.pro

(See /tools/idl/wcrtools/wcrvpsm.pro)


WCRWDVNC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
	WCRWDVNC

 PURPOSE:

    Adjust the airborne radar radial Doppler velocity from the Up/Down-pointing
    antenna for horizontal wind contribution (if any). The routine uses Doppler 
    velocity already corrected for the aircraft motion contribution. Velocity
    sign is left with radar convention (positive velocity is toward the radar).

 CATEGORY:

	wcrtools

 CALLING SEQUENCE:

	wdv=wcrwdvnc(dvc,beamvector,hwind,hwindp=hwindp,help=help)


 INPUT:

    Dvc:        fltarr(nrg,nprof), nrg range gates and nprof profiles of
                corrected for aircraft motion WCR Doppler velocity from
                Up or Down antennas
    Beamvector: fltarr(3,nprof), East,North,Up WCR beam unit vector
    Hwind:      Horizontal winds applicable to the Dvc field:
                - fltarr(2), East(u) and North(v) components of the mean wind
                  field applicable to all radar profiles;
                - fltarr(nprof,2), East,North wind field along flight track

 KEYWORD PARAMETERS:

    HWINDP:    fltarr(nrg,2), horizontal winds vertical profile normalized 
               to the winds at 1st rangegate (i.e., hwindp[0,*]=1.; nrg range 
               gates match the range gates of Dvc
    HELP:      Show this text

 PROCEDURE:
    DVC is corrected by the given HWIND assuming constant horizontal winds
    in the vertical.  If this assumption does not hold a vertical profile
    HWINDP can be used.  The estimated vertical Doppler velocity is calculated
    from the following equation:

    dvw = (dvc+[hwind_u,hwind_v].beamvector_u_v)/abs(beamvector_w) ;
    where beamvector_w is the vertical component of beamvector,
          hwind_u, hwind_v are the East and North wind components,
          and . designates a dot product
    
    Note that if there are missing values in dvc and they are not NaNs wdv 
    won't preserve them. Since the modifications in the missing values are
    expected to be small (mssing values that are not NaNs are usually large
    negative numbers) it should still be possible to identify them. One can
    always replace the missing values with NaNs.

 EXAMPLES:
    ; Adjust a WCR non truly vertical down beam Doppler velocity (corrected 
    ; for AC motion) using AC measured horizontal winds; HiCu03 case:

    acfile='/net/bat/R1/data/kingair_data/hicu03/processed/20030826.c25.nc'
    wcrf='/net/fox/fox1/WCR/HICU03/aug26/W2003-08-26-17-16-52' ;v-beam is down

    openwcrf,wcrf
    readwcrdata,172600,172715,/timein,rawt=wcrt
    dvv=wcrdopcorm(wcrt,acncf=acfile,beaminit=3,acdata=acdata,radbeam=wcrb)
    beamvector=ac2wcr(wcrb,acdata.time,wcrt) ; resample radbeam onto wcrtime

    dvvc=wcrwdvnc(dvv,beamvector,[mean(acdata.uw),mean(acdata.vw)])

(See /tools/idl/wcrtools/wcrwdvnc.pro)


WCRWRITE1NC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRWRITE1NC

 PURPOSE:
       Write WCR time and dimension related variables, calculated reflectivity,
       uncorrected Doppler velocity and associated attributes to an existing
       netcdf file matching loaded WCR raw data

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrwrite1nc,ncf,ncdir=ncdir,loadwcr=loadwcr,nswin=nswin,close=close, $
                  writestr=writestr,revision=revision,silent=silent, $
                  linz=linz,misval=misval,big_endian=bgnd,help=help

 INPUTS:
       Ncf:   string, name of the netcdf file matching the WCR loaded data or
              integer, id of netcdf file matching the WCR loaded data
              (see also OUTPUTS)

 KEYWORD PARAMETERS:
     BIG_ENDIAN: when set, assumes that the WCR file data are in big endian order.
                 The default is LITTLE_ENDIAN. Ignored for data before 03/2002 
       CLOSE:    when set netcdf file will be closed. Default is to keep the
                 file open in WRITE mode. CAUTION: If a writable netcdf file
                 is not closed before exiting IDL, the disk copy of the file
                 may not reflect recent data changes or new definitions.
       LINZ      when set the reflectivity data is in Z mm^6/m^3 (default is dBZ)
       LOADWCR:  input,string; WCR raw data directory.  If this keyword is
                   defined it is assumed that the raw WCR data matching ncf
                   is not loaded. ATTEN: DO NOT DEFINE this keyword if the raw
                   WCR data is already loaded in wcrparams and wcrdata common
                   blocks (see the example below)
       MISVAL:   input, when set (1) use NaN as missing values; Any value
                   different than 1 will be used as missing value in dBZ.
                   Default value is -32767. Maximum valid value is -150.
       NCDIR:    input,string, directory path to ncf (default current dir)
       NSWIN:    input, long,lonarr(2) or lonarr(3)-for data before July 2004
                   nswin[0:1] - smoothing noise-window size(default 99);should 
                                be an odd number(1 is added for evens); it is 
                                recommended not to exceed 10% of the processed 
                                number of profiles;  values less than 3 and 
                                greater than 50% of all profiles cause the use
                                of constant mean and stdev of the noise data 
                   nswin[2]   - defines which noise measurement pulses to use
                                (for data before July 2004 only):
                     0 - (default) use matching number of noise measurement 
                         pulses with minimum mean
                     1 - uses noise measurement from one noise pulse with
                         min mean (for both h- and v-ch)
                     2 - as 1 for h-ch and 0 for v-ch noise 
                     3 - as 1 for v-ch and 0 for h-ch noise 

                   If NSWIN is a scalar, same value is applied to both channels
                   as smoothing window size and NSWIN[2] is the default.
                   If NSWIN has 2 elements, nswin[0] is applied to H and V
                   noise channels and nswin[1] is used as nswin[2 for data
                   before July 2004.

       REVISION: input,string or strarr(2) netcdf file revision
                 revision[0] - update Revision_X attribute (default,'Reflectivity
                               and uncorrected Doppler velocity'); If the string 
                               starts with $ the last Revision_X attribute is 
                               overwritten otherwise a new Revision_X is created.
                               If only '$' the last Revision_X will be overwritten
                               with the default string.
                               Using # instead of $ will also cause all old
                               Revision_X to be deleted and start from Revision_1
                 revision[1] - update RevisionStatus attribute(default is 'OK')
                 If input a string, update Revision_X attribute only;
                 If empty string(s) '' - do not update the attribute(s)
       SILENT:  when set supress routine informational messages
       WRITESTR:input, string, determine what to write; allowed strings:
                  'all'  - all relevant variables (default, see side effects)
                  'time' - time related variables and other coordinates
                  'z'    - reflectivity related variables
                  'dv'   - Uncorrected Doppler velocity related variables
                  'tz'   - 'time' + 'z' variables
                  'tdv'  - 'time' + 'dv' variables
                  'zdv'  - 'z' + 'dv' variables
       HELP:    shows this text

 OUTPUTS:
       Ncf:     when ClOSE is not set and ncf is the netcdf file name returns
                WCR netcdf file id

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:
       Write time and dimension related variables, reflectivity, uncorrected
       Doppler velocity and relevant attributes into an existing netcdf file.

       The following variables and attributes are updated:
       - base_time, time_offset, time, range, range_correction, 
         psd_range(FFT only)
       - global attributes AcquisitionDate, TimeInterval, WCRstattimeint,
         WCRDSPclockstat,WCRstatpps
       - dv with attributes missing_value,pulsepair/beamchannel,maxvel,status
       - fftpsd with attributes receiver,transmitter and prf (FFT only)
       - fftnoise with attribute receiver,transmitter (FFT only)
       - wcraspect with attribute status.  At this level of processing
         all valies are identical and based on assumed average aircraft speed
         (taken from wcr common block wcrparams variable kaspeed). This speed
         is defined during WCR raw file opening with openwcrf (acspeed keyword)
       - reflectivity and noise variables: hh, vv, vh, hv, hmnoise, vmnoise,
         hsnoise, vsnoise
       - reflectivity and noise variables related attributes: missing_value,
         receiver,transmitter,pulse/rangegate,smooth
       - update global attributes: ProcessAuthor,DateProcessed,RevisionDate,
                                   RevisionStatus,RevisionNumber,Revision_1

       If the ncf had been modified between running wcrcdl2nc and
       wcrwrite1nc all the variables and attributes described above are
       overwritten.

 NOTES:
       !!!!! There is a bug in writing cross-pol channel data. Not fixed yet.   

 EXAMPLES:

       1) Example using CLEX-9 experiment data (see also wcrcdl2nc example)

       .run openwcrm   ; it outputs data from openwcrf
       ncf=''
       wcrcdl2nc,'CLEX01.20020218.cdl',[1200,2199],ncfile=ncf, $
                 savecdl=2,beams=1

       readwcrdata,1200,2199,timemode=3, ppmnoav=0, /noleak
       wcrwrite1nc,ncf,nswin=[99,99],rev=['','Test'],/close

       2) As above but using WCRLOAD, assume ncf is given and no close

       wcrwrite1nc,ncf,nswin=[99,0],rev=['','Test'],loadwcr='/sova4/clex01/'

(See /tools/idl/wcrtools/wcrwrite1nc.pro)


WCRWRITE2NC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRWRITE2NC

 PURPOSE:
       Calculate and write corrected for platform motion, Doppler velocity and
       related variables to the corresponding WCR netcdf file

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrwrite2nc,acfile,ncf,acnames=acnames,gpsc=gpsc,rmcor=rmcor, $
                   timesync=timesync,unfold=unfold,misval=misval,ncdir=ncdir, $
                   close=close,revision=revision,loadwcr=loadwcr,$
                   big_endian=bgnd,silent=silent,help=help

 INPUTS:
       Acfile:   string, path/name of the relevant aircraft data netcdf file
       Ncf:      integer, id of netcdf file matching the WCR loaded data or
                 string, name of the netcdf file matching the WCR loaded data
                 (Acfile and Ncf are checked for matching using FlightDate
                  and TimeInterval global attributes); (also see OUTPUTS)
 KEYWORD PARAMETERS:
       ACNAMES:  input, string array, AC netcdf varnames to be used (if not 
                        defined N2UW or N130AR default var names are used; 
                        see Notes for the default variable names)
                  acnames[0] - AC time (seconds in UNIX format)
                  acnames[1] - AC true air speed in m/s
                  acnames[2] - AC roll [deg or rad]
                  acnames[3] - AC pitch [deg or rad]
                  acnames[4] - AC true heading [deg or rad]
                  acnames[5] - AC east-west(EW) ground velocity [m/s]
                  acnames[6] - AC north-south(NS) ground velocity [m/s]
                  acnames[7] - AC vertical velocity [m/s]
                  acnames[8] - AC East component of the wind [m/s]
                  acnames[9] - AC North component of the wind [m/s]
                  acnames[10]- AC vertical wind [m/s]
                  acnames[11]- AC roll rate [rad/s] (use '' if N/A)
                  acnames[12]- AC pitch rate [rad/s](use '' if N/A)
                  acnames[13]- AC heading rate [rad/s] (use '' if N/A)
                  acnames[14]- AC EW ground vel. GPS correction(use '' if N/A)
                  acnames[15]- AC NS ground vel. GPS correction(use '' if N/A)
                  acnames[16]- AC longitude [deg]
                  acnames[17]- AC latitude [deg]
                  acnames[18]- AC altitude MSL [m]

                  Note: see ACLOADINS.PRO help for default variable names

     BIG_ENDIAN: when set, assumes that the WCR file data are in big endian order.
                 The default is LITTLE_ENDIAN. Ignored for data before 03/2002 
       CLOSE:    when set netcdf file will be closed. Default is to keep the
                 file open in WRITE mode. CAUTION: If a writable netcdf file
                 is not closed before exiting IDL, the disk copy of the file
                 may not reflect recent data changes or new definitions.
       GPSC:     when set does NOT apply GPS correction to AC E-W and N-S
                 velocity for UWKA only (ignored for NCAR C130 or NRC CV580)
                 NCAR C130 AC E-W and N-S ground speed are GPS corrected.
                 NRC CV580 does not use GPSC.
       LOADWCR:  input,string; WCR raw data directory.  If this keyword is
                 defined it is assumed that the raw WCR data matching ncf
                 is not loaded. ATTEN: DO NOT DEFINE this keyword if the raw
                 WCR data is already loaded in wcrparams and wcrdata common
                 blocks (see the example below)
       MISVAL    missing value for corrected Doppler field
                 (default: same as for uncorrected Doppler velocity)
       NCDIR:    input,string, directory path to ncf (default current dir)
       RMCOR:    input, when set applies antenna moment correction
                 Default: for UWKA or NRC Convair not applied (0) 
                          for NCAR C130 applied(1)
                 Default antenna positions can be seen in wcrprototype.cdl
                 (or the project cdl file)
       REVISION: input,string or strarr(2) netcdf file revision
                 revision[0] - update Revision_X attribute (default, 'Corrected
                               Doppler velocity'); If the string starts with
                               $ the last Revision_X attribute is overwritten
                               otherwise a new Revision_X is created. If only
                               '$' the last Revision_X will be overwritten
                               with the default string.
                               Using # instead of $ will also cause all old
                               Revision_X to be deleted and start from Revision_1
                 revision[1] - update RevisionStatus attribute(default is 'OK')
                 If input a string, update Revision_X attribute only;
                 If empty string(s) '' - do not update the attribute(s)
       SILENT:   when set supress routine informational messages
       TIMESYNC: input,float, WCR time correction to sync with A/C IRS(INS)
                 data, in seconds  (default 0.0)
       UNFOLD:   input, Doppler velocity unfolding procedure
                 0          - no unfolding is performed (default)
                 1          - use AC measured winds profile by profile (acwcbeam)
                 k          - use smoothed AC winds by k(odd) profiles
                 fltarr(3)  - [u,v,w], use the given wind vector
                              u,v,w are allowed the following values:
                              float: wind/velocity_shift value in m/s
                                888: use AC measured values profile by profile 
                                     for this component
                                777: use mean of AC measured values from 
                                     all profiles for this component
       HELP:     shows this text

 OUTPUTS:
       Ncf:     when ClOSE is not set, WCR netcdf file id

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:

       The following variables and attributes of the netcdf files are updated:
       - time_offset (if timesync ne 0)
       - dv and attributes dvshift, status and missing value (if misval given)
       - wcraspect and status attribute
       - wcrbeamvector and beamchannel attribute
       - acvcbeam and beamchannel attribute
       - acwcbeam and beamchannel attribute
       - wcrmirror (if exist)
       - LON, LAT, ALT, TAS

       The global attributes, AircraftDataSource: the name of the file used
       for INS/IRS aircraft data, and AircraftDateProcessed: processing date
       for AircraftDatSource file are updated using input acfile name and
       ProcessedDate from the netcdf acfile if exists.

       The RevisionStatus and Revision_X global attributes are updated and
       RevisionNumber attribute is increased by 1


 NOTES:

 EXAMPLES:

       1) Example using CLEX-9 experiment data (single antenna config, N2UW)

       .run openwcrm
       readwcrdata,1200,2199,timemode=3, /noleak

       ncfile=''
       cdlfile='CLEX01.20020218.cdl'
       wcrcdl2nc,cdlfile,[1200,2199],averages=2,ncfile=ncfile,savecdl=2,beams=1

       ncid=ncfile
       wcrwrite1nc,ncid,nswin=[99,99],rev=['$','Test']

       acfile='/net/bobcat/disk2/kingair_data/20011101.c25.nc'
       wcrwrite2nc,acfile,ncid,timesync=-0.2,rev='Corrected velocity'

       2) Example using DYCOMS-II experiment data (2 down antennas, N130AR)

       .run commonwcrset
       openwcrf,'/sova4/dycoms01/jul10/Wpp01-07-10-10-33-12', $
                timecor=0.,acspeed=115.
       readwcrdata,timemode=3, /noleak, /nocross

       cdlfile='DYCOMS01.06.20020305.cdl'
       indir='~/wcr/wcrproc'
       outdir=indir
       wcrcdl2nc,cdlfile,indir=indir,outdir=outdir,ncfile=ncfile, $
                 beams=24,savecdl=2

       ncid=ncfile
       wcrwrite1nc,ncid,rev=['$','Test']

       acfile='/sova4/dycoms01/jul10/RF01.20010710.060111_151725.PNI.nc'
       wcrwrite2nc,acfile,ncid,timesync=-0.125,rmcor=0
       ; Note: Radar moment correction is not applied (rmcor=0) due to missing
       ;       pitch/roll/heading rates in the C130 data files

(See /tools/idl/wcrtools/wcrwrite2nc.pro)


WCRWUNFOLD

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
      WCRWUNFOLD

 PURPOSE:
      Returns WCR Doppler velocity centered (and possibly unfolded) at 
      given shift_velocity into the WCR beam. In some cases (e.g., 
      Doppler measurements in horizontal planes) the aircraft measured
      wind can be used successfully.

 CATEGORY:
      wcrtools

 CALLING SEQUENCE:
      res=wcrwunfold(wcrdvf,vmax,wcrwind)
    or
      res=wcrwunfold(wcrdvf,vmax,wind,wcrbeam)

 INPUTS:
      Wcrdvf:  fltarr(rg,prof),WCR measured radial Doppler velocity field
               corrected for AC motion in m/s; rg: range gates, pro: radar 
               profiles; positive values means toward the radar
      Vmax:    float, Doppler Nyquist velocity in m/s
      -------
      Wcrwind: fltarr(prof),shift_velocity into the WCR beam
               Positive values means away from the radar

      -------  or

      Wind:    fltarr(3),      Mean shift_velocity vector [EW,NS,Up] 
                               to be applied for all vel. points or
               fltarr(prof,3), Shift_velocity vector,[EW,NS,Up], for each 
                               radar profile, in m/s 
      Wcrbeam: fltarr(3,prof), WCR beam vectors in Earth corrdinate system
      -------

 KEYWORD PARAMETERS:
      WINDSCALE: fltarr(rg), if defined scales the wind given in wcrwind/wind 
                 along the range gate axis
      HELP:      show this text

 SIDE EFFECTS:
      The function returns an empty string if the usage is incorrect

 NOTES:
      Attention is needed when AC measured wind component into the WCR
      beam is to be used as wcrwind. When taken from wcrdopcorm or
      wcracvelm (wcracw) it is synched with AC time and therefore it
      has to be re-synched with wcrtime first.  Same is true for using Wind
      and Wcrbeam inputs when they are taken/derived from the AC data 
      (e.g., wcrdopcorm,wcracvelm,acloadins)            

 PROCEDURE:
      This routine shifts the Doppler velocity data according to the shift
      velocity(wcrwind or wind) given as an input.  If wind estimate is used 
      it is assumed that its values are not changing along the range gate 
      dimension of the measured Doppler field.  It is also assumed that any 
      folding that takes place in the input Doppler field is caused by the
      input shift velocity.  In this case this procedure will unfold any 
      folded velocities even in cases of multiple folding as long as the
      number of foldings is constant for the corrected region. The
      unfolding may not be successful if the folded velocities are affected
      by other phenomena, e.g., perturbations to the velocity field exceeding
      the unambiguous range, strong shear, etc.

      Windscale keyword is an attempt to deal with folding in the presence 
      of a strong shear.  The combination of the wind defined at 0th range
      gate by wcrwind or wind and windscale will generate a wind profile,
      which then is used to offset/shift the Doppler data accordingly.
 

 EXAMPLES:
   1) Use raw data from HBDD test experiment in September 2001 and unfold
      the corrected for AC motion Doppler by using the AC measured winds

      .run commonwcrset
      openwcrf,'Wpp01-09-18-18-01-39'
      readwcrdata,192830,192930,/timein,rawtime=wcrtime
      acncf='/net/owl/data/kingair_data/20010918.c25.nc' & acid=acncf

      ;Get folded velocities for the side beam
       wcrdvf=wcrdopcorm(wcrtime,acncf=acid,timehack=-0.3,ppselect='VV')

      ;Get unfolded velocities for the side beam
       wcrdvu=wcrdopcorm(wcrtime,acncf=acid,timehack=-0.3,ppselect='VV',/unfold)

      ;Get folded velocities for the side-slanted beam
       wcrdvf=wcrdopcorm(wcrtime,acncf=acid,timehack=-0.3,ppselect='HH')

      ;Get unfolded velocities for the side-slanted beam
       wcrdvu=wcrdopcorm(wcrtime,acncf=acid,timehack=-0.3,ppselect='HH',/unfold)

   2) Use processed folded velocity data from RICO experiment
      Folding occurred at ~ 18:44 UTC, 23 January 2005 on a up-down wcr mode
      Use custom correction vector, dvs, to unfold the folded Doppler, vertical
      measurements

      ; Load corrected for AC motion but folded Doppler data and wcr beam data
        dv     =wcrloadnc(ncid,'dv','WCR.RICO04.20050123.182521_195546.PP4.nc')
        wcrbeam=wcrloadnc(ncid,'wcrbeamvector')

      ; Select a shift_velocity vector for the unfolding 
        dvs=[0.,0.,-3.5]  ; this selecton is made after examining the
                          ; velocity field containing the folding

      ; Unfold velocities for the up beam
        wcrbeamu=reform(wcrbeam[0,*,8000:12000])
        wcrdvu=wcrwunfold(reform(dv[0,*,8000:12000]),7.9,dvs,wcrbeamu)

      ; Unfold velocities for the down beam
        wcrbeamd=reform(wcrbeam[1,*,8000:12000])
        wcrdvd=wcrwunfold(reform(dv[1,*,8000:12000]),7.9,dvs,wcrbeamd)

(See /tools/idl/wcrtools/wcrwunfold.pro)


WCRZOOMPROF

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRZOOMPROF

 PURPOSE:
       Determine indexes of the wcr file profiles or time

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       WCRZOOMPROF, Zoom, Ind, Btime, Etime

 INPUTS:
       Zoom:      [ readmode, str, stp ]
                  readmode: 0  - str/stp, start/stop record numbers
                            1  - str/stp, start/stop profile numbers
                            2  - str/stp, start/stop UTC in hhmmss

 KEYWORD PARAMETERS:

 OUTPUTS:
       Ind:       long array, record indices according to zoom
       Btime:     string, begining UTC for start record/profile
       Etime:     string, end UTC for stop record/profile
       Help:      Show this text

 COMMON BLOCKS:
       wcrdata 

 NOTES:
       1) See READWCRTB.PRO for somewhat similar algorithm.  In READWCRTB
          zoom is implemented by reading the appropriate segment from the
          wcr file, while zoomind uses data in the memory 
       2) WCRZOOMPROF requires that READWCRTB with timeMode = 2 or 3 
          or READWCRDATA with timeMode = 2 or 4 run first

(See /tools/idl/wcrtools/wcrzoomprof.pro)


WCRZOOMRANGE

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRZOOMRANGE

 PURPOSE:
       Return indices of the requested range gates

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       result=WCRZOOMRANGE(Zoom)

 INPUTS:
       Zoom:  [ readmode, str, stp ]
              readmode: 0  - str/stp, start/stop range gate (0 to rangegates-1)
                        1  - str/stp, start/stop range in [m]
       Help:  Show this text

 KEYWORD PARAMETERS:

 COMMON BLOCKS:
       wcrparams, wcrdata 

(See /tools/idl/wcrtools/wcrzoomrange.pro)


WCRZPS

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRZPS

 PURPOSE:
       Creates a reflectivity PS file with maximum 3 plots per page

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       WCRZPS, Z,r,tsec

 INPUTS:
    Z:     fltarr(rangeGates,profs), reflectivity in dBZ. If noread keyword is
                 not used, Z is an output. HH reflectivity only.
                 If Z is not given a widget to pick a WCR file will open.
    R:     fltarr(rangeGates), range;
                 mainly for non WCR files (see PRMS keyword)
    Tsec:  fltarr(profs), time in sec.
                 mainly for non WCR files (see PRMS keyword)

 KEYWORD PARAMETERS:
    CALCOEF:     reflectivity (hh) calibration coefficient in dB
                 (default, 31.)
    COLORTB:     [colortb,revct,bf], integer/intarr(3), manipulate color table
                 colortb: color table number (default is 0, black & white)
                 -99 - use reversed black/white color table
                 revct: manipulate loaded color table
                   0 - leave the original color order 
                   1 - reverse color table 
                   2 - reverse color table not including first and last colors
                   3 - swap first and last colors in the color table
                 bf: change background and foreground colors in the loaded table
                   0 - no action
                   1 - replace first/last (back/foreground) colors w/ black/white
                   2 - replace first/last (back/foreground) colors w/ white/black                 
    DIR:         string, when set, the directory for ps file(s) to be stored
                 default is ps dir under current dir.
    FNAME:       input, string array, [file,title,xtitle,ytitle,bar_title]
                 if noread is not used fname(0) is a required wcr file name
                 When prms is set fname(0) is also required and used for naming
                 the output ps file. fname is also used for labeling the plots.
                 Default labels: 'HH','UTC','Range [m]','dBZ'
                 If fname[0]='' then it assumes that wcrfile exists and uses
                 it to form the output ps file name
    HCOR:        when set corrects h channel w.r.t. v channel using 0.95 slope
    HELP:        show this text
    IMGORDER:    when set reverse the image order and the x-axis
    LANDSCAPE:   create PS file in landscape (default is portrait)
    BIG_ENDIAN:  when set, assumes that the file data are in big endian order.
                 The default is LITTLE_ENDIAN.(ignored if noread=1)
    MAXLIM:      float, maximum reflectivity plotted (default  150 dB)
    MINGATES:    integer, minimum number of range gates to be plotted
                 If mingates is defined and greater than the actual number of
                 range gates the image is plotted using mingates (default, 70)
    MINLIM:      float, minimum reflectivity plotted (default -150 dB)
    MINMAX:      when set (minmax=1), min and max for every subimage are used
                 minmax < 0., minmax is used as a fixed min, max is calculated
                              for every subimage
                 minmax > 0. (but ne to 1), minmax is used as a fix max,
                              min is calculated for every subimage
                 minmax=0,(default, minmax not set), min and max are calculated
                           for the whole image and used as fixed

    NOREAD:      skip reading wcr file when it is already loadad; for wcr only;
                 when not set (0), calculates and plots HH reflectivity or
                 VV reflectivity (if HH is N/A)
    PRMS:        [aspect,interrupts].  When exist won't use wcr common blocks
                 and work with inputs Z, r and tsec.
                 This keyword is intended for non WCR files.  If it is used
                 for wcr files negative values for aspect will print wcr file
                 info at the bottom of each page
                 aspect      - aspect ratio for profile/range scaling
                               0 will disable scaling.
                               For negative values: abs(aspect) is used
                 interrupts  - begin/end profiles for every data on/data off
                               interrupt during the flight.
                 Length of prms is 1+2*num_of_interrupts.  If the length
                 is 1, it is assumed that there are no interrupts.  Zero
                 as 2nd element of prms is not acceptable.
    TIMECOR:     if defined gives UTC time correction of the wcr time
                 After June 1998, IRIG card is used to set the time.
                 Normal use of the card is to get the time from a master
                 IRIG card with GPS time.  The default value is set to
                 the leap seconds in openwcrf.
    TLABEL:      string, adds title to the param/stat tables
    VCOR:        when set corrects v channel w.r.t. v channel using default val

 OUTPUTS:
    Z:     fltarr(rangeGates,profs), reflectivity. If NOREAD keyword is
           not used, Z is an output. HH reflectivity only.

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:
       Calling wcrzps without input parameters always must read and load a wcr
       file.
       wcr files with small number of range gates (< 50) may cause the pixel
       size to be too big (because of aspect ratio applied to equally scale
       the image in range/time axes).  To avoid this problem use mingates
       keyword set to number of range gates higher than the actual number.

 EXAMPLES:

(See /tools/idl/wcrtools/wcrzps.pro)


WCRZPSM

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRZPSM

 PURPOSE:
       Create reflectivity PS files from one day flight wcr data

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       WCRZPSM, dfsel

 INPUTS:
       Dfsel: string, wcr file directory to process all wcr files; must end
                with directory separator (/); if undefined use pickfile to
                acquire the data directory;
              'select': use pickfile with an option to select desired file(s)
              strarr(n), full path and names for n files to be processed

 KEYWORD PARAMETERS:

     ACSPEED:   input, float; average aircraft speed in m/s (default 90.)
     BIG_ENDIAN:when set, assumes that the file data are big endian order.
                The default is LITTLE_ENDIAN.
     CALCOEFF:  fltarr(5),[h1cal,h2cal,v1cal,v2cal,v3cal] cal. coeffs. in dB
                  after July 2004; for unused port/antenna use -999
                fltarr(2) or fltarr(2,n); [hhcal,vvcal],n=n_elements(ACONFIG)
                  cal. coeffs. in dB before July 2004  
     COLORTB:   [colortb,revct,bf], integer/intarr(3), manipulate color table
                  colortb: color table number; -99 - use reversed black/white
                           color table (default)
                  revct: manipulate loaded color table
                   0 - leave the original color order 
                   1 - reverse color table 
                   2 - reverse color table not including first and last colors
                   3 - swap first and last colors in the color table
                  bf: change background and foreground colors in the loaded table
                   0 - no action
                   1 - replace first/last (back/foreground) colors w/ black/white
                   2 - replace first/last (back/foreground) colors w/ white/black                 
     FILEID:    string, file search string (default '*20??-??-??-*')
     HELP:      Show this text
     MINGATES:  integer, minimum number of range gates to be plotted
                If mingates is defined and greater than the actual number of
                range gates (rangegates) the image is plotted using mingates
                (default, rangegates)
     MINLIM:    float, minimum reflectivity plotted (default -150 dB)
     MAXLIM:    float, maximum reflectivity plotted (default  150 dB)
     MINMAX:     when set (minmax=1), min and max for every subimage are used
                 minmax < 0., minmax is used as a fixed min, max is calculated
                              for every subimage
                 minmax > 0. (but ne to 1), minmax is used as a fix max,
                              min is calculated for every subimage
                 minmax=0,(default, minmax not set), min and max are calculated
                           for the whole image and used as fixed
     PRINTER:   string, valid printer name
                '': suppress printing (default)
     PROC:      byte, define what to plot
                  0 - produce plots for sppmag and fft (HH or VV); default
                  1 - produce plots for  ppmag (HH and VV)
                  2 - produce plots for HH only except in case of sppmag V
                  3 - produce plots for VV only except in case of sppmag H
     PSDIR:     string, directory for postscript file(s)
                Default save ps files in subdir 'ps/', which is created
                if non-existent.  ps directory is sub directory of dfsel
     SETNOISE:  sets noise subtraction; scalar or array
                1) 0, uses the normal noise channels (averaged for ppmag
                   mode), smoothing window size is 101, thresh=3*sigma_noise
                2) 1, uses one noise pulse (matching the channel) with minimum
                   mean only (for ppmag only, sppmag ignores it)
                3) 99...999 - smoothing noise window (default is 99)
                4) 10099 ... 10999 smoothing noise window using one noise 
                   pulse,matching the channel, with minimum mean (ppmag only) 
                5) [1)...4),#_sigma_noise], (e.g., [10200,2]-use one pulse
                   noise channel, noise_window=200, thresh= 2*sigma_noise

     TIMECOR:   if defined gives time correction of the wcr time
                After June 1998, IRIG card is used to set the time.
                Normal use of the card is to get the time from a master
                IRIG card with GPS time.  Thus the default value is
                the current leap seconds
     TLABEL:    string, adds title to the param/stat tables; It always adds
                info about the cal const. ('(Pwr cal: ....)')

 OUTPUTS:
       Dfsel:   strarr(n), full path and file name of the n processed files
                when dfsel='select' as an input

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:

 EXAMPLES:

(See /tools/idl/wcrtools/wcrzpsm.pro)


WCRZPSM1

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRZPSM1

 PURPOSE:
       Create reflectivity PS files from one day flight wcr data.

       This routine is similar to WCRZPSM but requires less memory use.
       It averages a number of profiles equal to the range-to-profile aspect
       ratio before plotting (this also improves SNR). For wcr data with large
       aspect ratios and more than 150 range gates it is much faster when the
       computer real memory is 512M or less.

       The averaging is applied to PPMag and SPPMag data files only.

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       WCRZPSM1, dir

 INPUTS:
       Dir:      string, wcr data file directory; undefined: use pickfile

 KEYWORD PARAMETERS:
     ACONFIG:   input, integer/intarr(n); antenna configuration
                0 - single side/up looking antenna; default
                1 - two downlooking antennas (H-ch: down-fore, V-ch: down)
                2 - two sidelooking antennas (V-ch: side-fore, H-ch: side/up)
                3 - down and side/up antennas (V-ch: down, H-ch: side/up)
                4 - two downlooking antennas (V-ch: down, H-ch: down-aft,
                     this is for C130 DYCOMS01 experiment before H/V channels 
                     were swapped in march 2002)
                5 - down and side antennas for NRC-CV580 WCR installation

                Note: dual-antenna configs have no polarimetric capability

     CALCOEFF:   fltarr(2) or fltarr(2,n); n=n_elements(ACONFIG)
                 [hhcal,vvcal], cal. coeffs. in dB 
     COLORTB:    color table number (default is -99, reversed black & white)
                 Negative color numbers reverse the color tables.
                 Use -99 for reverse black & white.
     FILEID:     file identification string. Common substring from the data
                 file name starting from 2nd char (default '2-98-').
     HCOR:       when set correct h channel w.r.t. v channel using 0.95 slope
     HELP:       Show this text
     BIG_ENDIAN: when set, assumes that the file data are in big endian order.
                 The default is LITTLE_ENDIAN.
     MINGATES:   integer, minimum number of range gates to be plotted
                 If mingates is defined and greater than the actual number of
                 range gates (rangegates) the image is plotted using mingates
                 (default, rangegates)
     MINLIM:     float, minimum reflectivity plotted (default -150 dB)
     MAXLIM:     float, maximum reflectivity plotted (default  150 dB)
     PRINTER:    'lj4', 'lj4_gv', 'qms'
                 undefined: qms
                 '': suppress printing
     PROC:       byte, 0 - produce plots for sppmag or fft (HH or VV)
                       1 - produce plots for  ppmag (HH and VV)
                       2 - produce plots for HH only except in case of sppmag V
                       3 - produce plots for VV only except in case of sppmag H
     PSDIR:      string, directory for postscript file(s)
                 Default save ps files in subdir 'ps/', which is created
                 if non-existant.  When dir='select', ps directory is always
                 sub directory of the home directory, otherwise it is sub
                 of dir
     SETNOISE:  sets noise subtraction; scalar or array
                1) 0, uses the normal noise channels (averaged for ppmag
                   mode), smoothing window size is 99, thresh=3*sigma_noise
                2) 1, uses one noise pulse (matching the channel) with minimum
                   mean only (for ppmag only, sppmag ignores it)
                3) 99...999 - smoothing noise window (default is 99)
                4) 10099 ... 10999 smoothing noise window using one noise 
                   pulse,matching the channel, with minimum mean (ppmag only) 
                5) [1)...4),#_sigma_noise], (e.g., [10200,2]-use one pulse
                   noise channel, noise_window=200, thresh= 2*sigma_noise

     TIMECOR:    if defined gives time correction of the wcr time
                 After June 1998, IRIG card is used to set the time.
                 Normal use of the card is to get the time from a master
                 IRIG card with GPS time.  Thus the default value is
                 the current leap seconds
     TLABEL:     string, adds title to the param/stat tables; It always add
                 info about the cal const. ('Data (cal: ....)')
     VCOR:       when set correct v channel w.r.t. v channel using default vals

 OUTPUTS:

 COMMON BLOCKS:
       wcrparams, wcrdata

 SIDE EFFECTS:

 EXAMPLES:

(See /tools/idl/wcrtools/wcrzpsm1.pro)


WCRZRGNC

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
       WCRZRGNC

 PURPOSE:
       Returns thresholded reflectivity (see NOTES) for given rangegates and 
       beam from a WCR processed netcdf file. This is a fltarr(m,n), where
       m=rangagate, n=profile

 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       wcrzrgnc, fileid,beam,rgs,nan=nan,startt=startt,stopt=stopt,$
                 alt=alt,dvt=dvt,ncid=ncid,radrng=radrng,time=time,help=help

 INPUTS:
       FileID:  string, path/name of a WCR netcdf data file or
                long, netcdf ID for an already open WCR netcdf file
       Beam:    string of the radar beam given by beam direction: 
                  'up','side','side-aft'(N2UW only),'down',
                  'down-slant'(forward for N2UW and aft for N130AR);
       Rgs:     integer or intarr(m), a radar range gate or m gates to extract; 
                  gates are defined between 0 and the last gate number;
                  any gate below 0 or above last gate is set to 0 or last gate
                  (default is all recorded gates)

 KEYWORD PARAMETERS:
       NAN:     input, when set replaces all missing values with NaNs 
                  (default missing value is -32767.)
       STARTT:  input, long, start time in hhmmss
       STOPT:   input, long, stop time in hhmmss, inclusive the last second
       DVT:     output, fltarr(m,n),Doppler velocity matching the reflectivity
                  and thresholded
       ALT:     output,fltarr(n), radar altitude for the extracted n profiles
       NCID:    output, long, netCDF file ID of the open file if FileID input
                  is the name of the file otherwise the same as FileID
       RADRNG:  output,float or fltarr(m); radar range(s) along the beam
                  for the m given rangegates 
       TIME:    output,fltarr(n),time stamps in seconds after midnight 
       HELP:    show this text

 OUTPUTS:

 NOTES:
        Returned reflectivity in dBZ is corrected for range and thresholded 
        with 3 sigma of the receiver noise.  There is no correction for 
        attenuation and/or contamination by 2nd trip echo, transmitter 
        leakage or other clutter.

 EXAMPLES:
        ; ICE-L, 11 Dec 2007 19:12:43-19:30:07 UTC
        ; extract reflectivity from the 25-profile averaged data set
        fileid='dec11_dBZ/WCR.ICEL07.20071211.191243_193007.PP6.nc'
        zup=wcrzrgnc(fileid,'up',/nan,alt=alt,radrng=radrng,$
                     time=time,ncid=ncid) ; returns all gates
        zdn=wcrzrgnc(ncid,'down',lindgen(30),/nan) ; returns first 30 gates
        ; and plot it
        aximage,zup,/tr,setw=[-1,41],asp=2,time,radrng,/timeax
        aximage,zdn,/tr,setw=[-1,41],time,radrng,/timeax,/ord

        ; Now get the 2nd range gate for up and down beams
        zup2=wcrzrgnc(ncid,'up',2,/nan,radrng=radrng2)
        zdn2=wcrzrgnc(ncid,'down',2,/nan)
        ; and plot it
        window,0
        plot,time,zup2,line=1,xtit='UTC [sec after midnight]',ytit='dBZ'
        oplot,time,zdn2,line=2

        ; do the same thing using the non-averaged reflectivity data recorded
        ; in mm^6/m^3 instead of dBZ
        ncid1=ncdf_open('dec11_Z/WCR.ICEL07.20071211.191243_193007.PP6.nc')
        zup2_1=wcrzrgnc(ncid1,'up',2,/nan,radrng=radrng2,time=time1,alt=alt1)
        zdn2_1=wcrzrgnc(ncid1,'down',2,/nan)
        ; and plot 2nd range gate for the up beam
        window,1
        plot,time1,zup2_1,line=1,xtit='UTC [sec after midnight]',xstyle=5
        oplot,time1,zdn2_1,line=2
        timeaxis, title='UTC'

(See /tools/idl/wcrtools/wcrzrgnc.pro)


WRITEWCRRAW

[Previous Routine] [List of Routines]
 NAME:
       WRITEWCRRAW

 PURPOSE:
       Write a WCR file from raw data loaded into the structure 
       Recraw(readwcrraw). If Recraw is not defined, first load the input data
       file (FNIN) and then write the output file (FNOUT). 
       
 CATEGORY:
       wcrtools

 CALLING SEQUENCE:
       WRITEWCRRAW [, Recraw, Fileheader]

 INPUTS:
       Recraw:  Nr-element array of structures with raw WCR data 
                previously read with readwcrraw.  Structure format:
                {header: lonarr(headervars),data:fltarr(Nch,Nn+Ntx+Nrg,Nmode)}
                headervars= 25 after Oct 1996 and 40 after May 1999
                Nch   = 2  ; real & imag for pulse pairs and V & H 
                             for magnitudes ; SPPMAG and PPMAG modes
                        fftbins ; for FFT mode
                Nn    = noise samples (always 1 before May 1999)
                Ntx   = 1, Tx pulse leakage; internal cal. pulse (before 1997)
                Nrg   = # of range gates
                Nmode =  2 - for SPPMAG
                         7 - for PPMAG4
                        11 - for PPMAG6
                         1 - for FFT
                Nr    = # of records read (max Nr=tnumrec)
       Fileheader: structure with the file header fields 
                   (output from readwcraw)
                   For data files before April 2002 this input is ignored

 KEYWORD PARAMETERS:
       FNIN:     string, input file name (default is wcrfile in the current
                 directory). If recraw and fnout exists fnin is ignored.
                 If recraw exists and fnout is not given, fnin is used to
                 form fnout
                 use 'load' to get a file selction;
       FNOUT:    string, output file name (default fnin, where first char.
                 is substituted with 'S'and saved in the current directory)    
                 When TIMECOR is greater than 0 and there is no LSHIFT
                 the default output file name first char is 'T'
                 If TIMECOR and LSHIFT are set 1st char. of the default output 
                 file name is 'R'
       LSHIFT:   shifts all range gates one position to the left
                 This resolves a bug in wcr data acquisition system,
                 which happens intermittently
                 0 - no shift (default)
                 1 - shift all profiles
                 2 - shift even profiles
                 3 - shift odd profiles
 
       BIG_ENDIAN: when set, assumes big endian order for the input file and
                   write output file in big endian order. The default is
                   LITTLE_ENDIAN. Thus the byte order of the input file is 
                   preserved in the output file regardless of the computer
                   architecture running the current idl session.
                      
       STARTREC: long, start record (0 to tnumrec-2, default, 0)
       STOPREC:  long, stop record (1 to tnumrec-1, default, Nr-1)
       TIMECOR:  long/float, time correction 
                   - long, abs(timecor) >= 1, in seconds 
                   - float, 0. < timecor < 1., time will be raplaced with 
                     a counter starting with 0 and step equal to timecor
                     IRIG flag (irigflag/fileheader.irigstatus) is set to -2
       HELP:     show this text

 OUTPUTS:
       Recraw:  n-element array of structures, which was written into 
                the output file; n=Nr or STOPREC-STARTREC+1

 SIDE EFFECTS:
       Creates a new file containing data given in recraw or read from fnin. 
       This routine will not work with WCR files before Oct. 1996.

 NOTES:
       For very large files it is more efficient to let writewcrraw
       read the data from the input file rather than reading it in 
       using readwcrraw first.

 EXAMPLE:
       Following example will read in Wpp00-03-29-21-35-38, shift the range 
       gates one range gate to the left and write out Spp00-03-29-21-35-38

       writewcrraw,fnin='Wpp00-03-29-21-35-38',/lshift

(See /tools/idl/wcrtools/writewcrraw.pro)