Friday, September 26, 2014

IDL Syntax

1. IDL Routines Syntax 

Refer to : http://www.physics.nyu.edu/grierlab/idl_html_help/idl_alph.html

 

 2. IDL Statement Syntax

Refer to :  https://www.astro.virginia.edu/class/oconnell/astr511/IDLresources/idl-syntx-sterner.html

Index

Definitions
Assignment
If
For
While
Repeat
Case
Goto
Block
Common
Procedure
Function

Some definitions


  • Operators: Items like +,-,*,/ and so on.
  • Constants: Items like 3, [3,2,5], "A string", AND, OR, and so on.
  • Variables: A named item used to store a value.
  • Expression: A constant, variable, or set of constants and/or variables combined by operators.
  • Statement: A single IDL statement or a statement block (see below).
  • Routine: A procedure or a function.


Assignment


  • Purpose: place a value in a variable.
  • Syntax: Variable = expression
  • Examples:
    • x = 7
    • num = [12,32,52,12]
    • y = 3*x^2 + 7*x - 5
    • cat = dog
  • Notes: expression may be a constant, variable, or combination of terms and operators


If


  • Purpose: Conditionally execute a statement.
  • Syntax:
    if expression then statement
    if expression then statement1 else statement2
  • Examples:
    • if y lt 0 then t=2
    • if y lt 0 then t=2 else t=3
    •  if y lt 0 then begin
          t=2
          txt='Negative'
        endif
    •  if y lt 0 then begin
          t=2
          txt='Negative'
        endif else begin
          t=3 
          txt='Non-negative'
        endelse
        
    • if ((x gt -2) and (x lt 3)) and ((y gt 5) and (y lt 8)) then t=2
  • Notes: For complicated expressions parentheses may be used to make sure expression has the desired meaning.


For Loops


  • Purpose: Repeat a statement a specified number of times.
  • Syntax: for variable = init, limit, step do statement
  • Examples:
    • for i=0,9 do print,i
    • for t=1.0, 0.01, -.01 do plots,x*t,y*t
    •   for ix=0L, n, 10 do begin
          x(j) = xx(ix)
          j = j+1
          print,ix
        endfor 
  • Notes: The loop variable has the same data type as the initial value (init above). Make sure to use the correct data type for the initial value. A common error is: for t=0,1,.1 do ... which gives an infinite loop since .1 added to an integer variable does nothing. This is easily fixed: t=0.,1,.1 (note the 0. instead of 0). Another common error is not forcing a loop variable to be a long integer when the loop can go above 32767. The fix is: for i=0L,... A for loop may be executed 0 times if the loop variable starts beyond the loop limit.


While Loops


  • Purpose: Repeat a statement while some condition is true.
  • Syntax: while expression do statement
  • Examples:
    • while x gt 0 do x=x-1
    •   while not eof(lun) do begin
          readf,lun,txt
          print,txt
        endwhile
  • Notes: A while statement may be executed 0 or more times depending on the value of the expression.


Repeat Loops


  • Purpose: Repeat a statement until some condition is true.
  • Syntax: repeat statement until expression
  • Examples:
    • repeat x=x-1 until x le 0
    •   repeat begin
          readf, lun, x
          x = x-c
        endrep until x le 0
        
  • Notes: A repeat statement is always executed at least once.


Case


  • Purpose: Selectively execute a statement based on the value of an expression.
  • Syntax:
    case expression of
       expression:    statement
       . . .
       expression:    statement
       else:          statement
    endcase 
  • Examples:
    •        case animal of
      'cat':   print,'meow'
      'dog':   print,'arf arf'
      'bird':  print,'tweet tweet'
      else:    print,'??'
             endcase
    •        case t>0<2 of
      0:       begin
                 txt = 'red'
                 err = 0
               end
      1:       begin
                 txt = 'green'
                 err = 0
               end
      2:       begin
                 txt = 'blue'
                 err = 1
               end
             endcase
  • Notes: The expression following the word case is compared to a list of expressions. The statement corresponding to the first match is executed. If no match is found the statement following the else is executed. Else is optional but if no match is found and else is not included an error will result.


Goto


  • Purpose: Jump to a specified label in a routine.
  • Syntax: goto, label
  • Examples:
    •        . . .
      loop:
             . . .
             goto, loop
    •        . . .
             goto, err
             . . .
      err:   print,' Error ...'
             . . .  
  • Notes: May only be used in routines. Program flow jumps to the specified label. If label does not occur in the routine a compile error results.


Blocks


  • Purpose: Allows multiple statements to be executed anywhere a single statement is allowed.
  • Syntax:
      begin
        statement 1
        . . .
        statement n
      end
      
  • Examples:
    • if x lt 0 then begin print,x & a=2 & endif
    • for i=0, 10 do begin readf, lun, txt & print,txt & endfor
  • Notes: The plain end statement may be replaced by a more specific end statement for the following cases: if, else, for, while, and repeat. The corresponding end statements are: endif, endelse, endfor, endwhile, and endrep. While not enforced, these should always be used so the compiler can do better error checking. Only the case statement uses the plain begin/end pair to execute multiple statements for a match (the endcase is not really one of the end statements).


Common


  • Purpose: Share variables between routines or remember values between calls to a routine.
  • Syntax: common name, variable_1, variable_2, . . . variable_n, name is the name of the common block. Variables are matched by position so need not have the same name in each routine.
  • Examples:
    • common xkodak_com, x, y, dx, dy, file, count
    • common random_plot_com, seed
  • Notes: A single routine may use a common to save the value of a variable between calls. Some examples of where this is useful: to remember default values, to remember a seed value for the randomu (or randomn) function since the system clock is used if no seed is given and for fast computers the same seed may be used for several calls. Several routines may use a common to share status values. In such cases it is useful to store the common in a separate file and include it in each routine (@filename where @ is in column 1). This way only a single copy of the common need be maintained.
    A good way to name commons is to use the main routine name followed by _com, like xkodak_com. This helps prevent the accidental use of the same name for diffrent commons.


Procedure definition


  • Purpose: Specify a procedure name and parameters.
  • Syntax: pro name, parameter_1, parameter_2, ... parameter_n name is the name of the procedure.
  • Examples:
    • pro test, a, b, c
    • pro compute, x, y, z, flag=flg, help=hlp
  • Notes: A procedure must end with an end statement and may have one or more return statements inside. If program flow reaches the final end statement a return is implied. Example calls to the above procedures:
    test, 2, 3, out
    compute, x, y, z, /flag


Function definition


  • Purpose: Specify a function name and parameters.
  • Syntax: function name, parameter_1, parameter_2, ... parameter_n name is the name of the function.
  • Examples:
    • function test, a, b, c
    • function compute, x, y, z, flag=flg, help=hlp
  • Notes: A function must end with an end statement and must have one or more return statements inside. A return statement in a function must include the return value: return, value. Example calls to the above procedures:
    a = test(2, 3, 5)
    t = compute(x, y, z, /flag)

Wednesday, September 17, 2014

Radiance Monitoring statistics type chart













Radiance Monitoring file structure


1. working space :

1.1) vrfyrad  :    one dir per cycle
/data/dxu/wk_tmp/dxu

drwxr-xr-x  2 dxu domain users   4096 Sep 16 17:03 gdas_vrfyrad_2014060812.13926
drwxr-xr-x  2 dxu domain users   4096 Sep 16 17:03 gdas_vrfyrad_2014060912.32040
drwxr-xr-x  2 dxu domain users   4096 Sep 16 17:03 gdas_vrfyrad_2014060918.17849
drwxr-xr-x  2 dxu domain users   4096 Sep 16 17:03 gdas_vrfyrad_2014061000.6890
drwxr-xr-x  2 dxu domain users   4096 Sep 16 17:03 gdas_vrfyrad_2014061012.11715
drwxr-xr-x  2 dxu domain users   4096 Sep 16 17:04 gdas_vrfyrad_2014061018.5946
-rw-r--r--  1 dxu domain users  19453 Sep 16 17:04 jlogfile_kgarrett_radmon
drwxr-xr-x  2 dxu domain users   4096 Sep 16 17:04 gdas_vrfyrad_2014061006.8633

eg:
/data/dxu/wk_tmp/dxu/gdas_vrfyrad_2014061018.5946
diag_mhs_metop-a_anl.2014061018    radmon_time                     stdout.sndrd2_g13
diag_mhs_metop-b_anl.2014061018    scaninfo.txt                    stdout.sndrd2_g15
diag_mhs_n18_anl.2014061018        seviri_m10                      stdout.sndrd3_g13
diag_mhs_n19_anl.2014061018        seviri_m10.ctl                  stdout.sndrd3_g15


1.2) imgn: one dir for all cycles
/data/dxu/wk_tmp/dxu
drwxr-xr-x  2 dxu domain users 163840 Sep 16 18:10 plot_summary_kgarrett_radmon.2014061018
drwxr-xr-x  6 dxu domain users   4096 Sep 17 11:33 plotjobs_kgarrett_radmon

/data/dxu/wk_tmp/dxu/plotjobs_kgarrett_radmon

-rw-r--r--   1 dxu domain users   2400 Sep 16 17:23 cmdfile_psummary
drwxr-xr-x 100 dxu domain users  20480 Sep 16 17:48 plotangle_kgarrett_radmon
drwxr-xr-x  88 dxu domain users  16384 Sep 16 18:07 plotbcor_kgarrett_radmon
drwxr-xr-x   2 dxu domain users 532480 Sep 16 18:14 plot_bcoef_kgarrett_radmon.2014061018
drwxr-xr-x  48 dxu domain users  12288 Sep 16 18:18 plot_time_kgarrett_radmon


2. log files
2.1) vrfyrad  : one JOB log per cycle
/home/dxu
-rw-r--r-- 1 dxu domain users 18430 Sep 16 17:03 data_extract_kgarrett_radmon.o3033152
-rw-r--r-- 1 dxu domain users 18430 Sep 16 17:03 data_extract_kgarrett_radmon.o3033153
-rw-r--r-- 1 dxu domain users 18444 Sep 16 17:03 data_extract_kgarrett_radmon.o3033154
-rw-r--r-- 1 dxu domain users 18430 Sep 16 17:03 data_extract_kgarrett_radmon.o3033156
-rw-r--r-- 1 dxu domain users 18418 Sep 16 17:04 data_extract_kgarrett_radmon.o3033157
-rw-r--r-- 1 dxu domain users 18426 Sep 16 17:04 data_extract_kgarrett_radmon.o3033155

eg: vi  data_extract_kgarrett_radmon.o3033155
/data/kgarrett/rad_files/cntrl/radstat.gdas.2014061006 is available
/data/kgarrett/rad_files/cntrl/biascr.gdas.2014061006 is available

2.2) imgn log files
a) one log file per instrument per statistics type
/data/dxu/log_tmp/dxu/logs/radkgarrett_radmon
plot_angle_cris_npp_ordang1.log    plot_angle_iasi_metop-b_scangl.log
plot_angle_cris_npp_ordang2.log    plot_angle_iasi_metop-b_sin.log
plot_angle_cris_npp_ordang3.log    plot_angle_iasi_metop-b_total.log
plot_angle_cris_npp_ordang4.log    plot_angle_sndrd2_g15.log
plot_angle_cris_npp_penalty.log    plot_angle_sndrd3_g13.log

b) JOB log file:   one JOB log file per instrument per statistics type
/home/dxu
-rw-r--r-- 1 dxu domain users      0 Sep 17 12:04 plot_kgarrett_radmon_tm_iasi_metop-b_omgbc.pe3034482
-rw-r--r-- 1 dxu domain users 130139 Sep 17 12:13 plot_kgarrett_radmon_tm_iasi_metop-b_omgbc.e3034482




3. output data
3.1) vrfyrad    :  one dir per cycle
/data/dxu/radmon_tank/stats/kgarrett_radmon
rwxrwxr-x 2 dxu domain users 36864 Sep 16 17:01 radmon.20140605
rwxr-xr-x 2 dxu domain users 45056 Sep 16 17:02 radmon.20140606
rwxr-xr-x 2 dxu domain users 40960 Sep 16 17:02 radmon.20140607
rwxr-xr-x 2 dxu domain users 40960 Sep 16 17:03 radmon.20140608
rwxrwxr-x 2 dxu domain users 49152 Sep 16 17:03 radmon.20140609
rwxr-xr-x 2 dxu domain users 40960 Sep 16 17:04 radmon.20140610

eg :
/data/dxu/radmon_tank/stats/kgarrett_radmon/radmon.20140610
bcoef.stdout.ssmis_f17.gz                 time.stdout.ssmis_f17.gz
bcoef.stdout.ssmis_f18.gz                 time.stdout.ssmis_f18.gz
bcor.airs_aqua.2014061000.ieee_d.gz

3.2) imgn  :  one dir for all cycles 
/data/dxu/radmon_tank/imgn/kgarrett_radmon/pngs
drwxr-xr-x 2 dxu domain users    4096 Sep 15 19:42 summary
drwxr-xr-x 2 dxu domain users 3379200 Sep 17 11:33 angle
drwxr-xr-x 2 dxu domain users  364544 Sep 17 11:33 bcoef
drwxr-xr-x 2 dxu domain users 2777088 Sep 17 11:33 bcor
drwxr-xr-x 2 dxu domain users  933888 Sep 17 11:33 time

eg:
/data/dxu/radmon_tank/imgn/kgarrett_radmon/pngs/time