Difference between revisions of "Robin subwindow density/quality calculations"

From ecology
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
The ROBIN_CORRECTED_DENSITY and ROBIN_CORRECTED_QUALITY are caclulated according to the following function :
+
The ROBIN_CORRECTED_DENSITY and ROBIN_CORRECTED_QUALITY are calculated according to the following function :
  
  
Function NewDensity(denQual, land_cl_perc, rain_cl_perc, total_mass_density, land_mass_density,  bird_echo_density, echo_mass, nr_of_tracks, land_clutter_mode, window)
 
  
'Calculate density and quality parameter based on measurement conditions, i.e. influence of Robin
+
  sub Quantify_ROBIN
  'algoritme. Robin-algoritme is influencing density calculations when (1) bird density is high
+
  {
'(rain mask is removing birds), (2) birds fly in large flocks (rain mask is removing birds).
+
   
  'Rules have been designed and tested for Wier, Milligen and Glons to overcome the above problems
+
    my ($whole_window, $sub_window, $correction_level, $radar_name, $beam_name, $window, $log) = @_;
'The quality parameter is decreasing from 1 (optimal functionality) to 0 (no radar video)
+
    my $ROB_density = 0;
 
+
    my $ROB_quality = 0;
'denQual            Parse through density (denQual = 0) or quality parameter (denQual = 1)
+
    my $ROB_cor_level = undef;
'land_cl_perc      Percentage landclutter in image
+
    my $ClutPerc = 25;
'rain_cl_perc      Percentage rainclutter in image
+
   
'total_mass_density Total mass per window before Robin processing
+
    my ($radar) = $radar_name =~ /RP-(\w{3})/;
  'land_mass_density  Total mass per window within the land clutter mask
+
    my ($beam) = $beam_name =~ /BEAM_(\d+)/;
'bird_echo_density  Calculated bird density per km2, taking measurement area into account (%  clutter)
+
    $beam = 'B' . $beam;
'echo_mass          Mean mass per bird echo (re-scaled number bird_mass_density / bird_echo_density if bird_echo_density  > 0 and 0 otherwise)
+
    my $key = $radar . '_' . $beam . '_' . $window;
'nr_of_tracks      Number of tracks in the whole image
+
   
'land_clutter_mode  Type of landclutter filtering
+
    my %DEFAULT_VALUES = (
'window            Name of selected subwindow
+
    GLO_B1_SE => { cthresh        => 1864,
 
+
                  defReflectivity => 3033,
'Normal clutter in a subwindow is assumed to be zero. This is not always true and is the reason
+
                  defClut        => 18.65,
'why rules are not appicable to all subwindows without modification. Therefore modus of standard  clutter percentage
+
                  CP              => 15
'is added for each subwindow to default clutPerc
+
                },
'              NW      SE
+
    GLO_B1_NW => { cthresh        => 1864,
'GLONS_B1      15.05%  18.65%
+
                  defReflectivity => 901,
'GLONS_B2        1.28%  5.33%
+
                  defClut        => 15.05,
  'RPN_B1          0.06%  0.07%
+
                  CP              => 15
'RPN_B2          0.00%  0.00%
+
                },
'MIL_B1          0.00%  0.00%
+
    GLO_B2_SE => { cthresh        => 1804,
'MIL_B2          0.00%  0.00%
+
                  defReflectivity => 527,
 
+
                  defClut        => 3.33,
clutPerc = 25      'Clutter percentage threshold for bird_density calculation
+
                  CP              => 15
defClut = 0        'Default clutter percentage
+
                },
contentC = 1        'Quality parameter for radar data availability (0 if no data)
+
    GLO_B2_NW => { cthresh        => 1804,
highBDC = 1        'Quality parameter for high bird density correction
+
                  defReflectivity => 44,
largeFlockC = 1    'Quality parameter for large flocks
+
                  defClut        => 1.28,
maxBDC = 1          'Quality parameter for high bird density, but image is saturated (no   bird_echo_density calculated)
+
                  CP              => 15
  defC = 1            'Quality parameter in standard situations, but land_cl_perc reduces value
+
                },
 
+
   
    If (window = "GLONS_B1_SE-window") Then
+
    WIE_B1_SE => { cthresh        => 310,
        defClut = 18.65
+
                  defReflectivity => 0,
    ElseIf (window = "GLONS_B1_NW-window") Then
+
                  defClut        => 0,
         defClut = 15.05
+
                  CP              => 15
     ElseIf (window = "GLONS_B2_SE-window") Then
+
                },
         defClut = 5.33
+
    WIE_B1_NW => { cthresh        => 310,
     ElseIf (window = "GLONS_B2_NW-window") Then
+
                  defReflectivity => 0,
        defClut = 1.28
+
                  defClut        => 0,
    End If
+
                  CP              => 15
 
+
                },
    clutPerc = clutPerc + defClut
+
    WIE_B2_SE => { cthresh        => 594,
 
+
                  defReflectivity => 0,
 +
                  defClut         => 0,
 +
                  CP              => 15
 +
                },
 +
    WIE_B2_NW => { cthresh         => 594,
 +
                  defReflectivity => 0,
 +
                  defClut        => 0,
 +
                  CP              => 15
 +
                },
 +
   );
 +
   
 +
  my $cthresh        = 0;
 +
  my $defReflectivity = 0;
 +
  my $defClut        = 0;
 +
  my $CP              = 0;
 +
 +
  if(exists($DEFAULT_VALUES{$key})) {
 +
    $cthresh         = $DEFAULT_VALUES{$key}->{cthresh};
 +
     $defReflectivity = $DEFAULT_VALUES{$key}->{defReflectivity};
 +
    $defClut         = $DEFAULT_VALUES{$key}->{defClut};
 +
     $CP              = $DEFAULT_VALUES{$key}->{CP};
 +
  }
 +
 +
  # Calculate echo mass. If subwindow is saturated, echo_mass is extracted
 +
  # from the whole window (radar.subwindow_result.subwindow_id = 0).
 
    
 
    
     If total_mass_density < 10 And land_cl_perc = 0 And nr_of_tracks = 0 Then
+
  my $echo_mass;
        'Image does exist, but no data, density is NOT calculated, quality parameter set to zero
+
  if($sub_window->{bird_echo_density} > 0) {
        contentC = 0
+
     $echo_mass = $sub_window->{bird_mass_density} / $sub_window->{bird_echo_density};
    ElseIf (land_clutter_mode = "ALWAYS_OFF") Then
+
  } elsif($whole_window->{bird_echo_density} > 0) {
        'During long period of time land_clutter_mode was set to "ALWAYS_OFF" in Milligen B2 image.
+
    $echo_mass = $whole_window->{bird_mass_density} / $whole_window->{bird_echo_density};
        'Therefore landclutter mask is not calculated. But, the following rules do expect a landclutter mask!
+
  } else {
        'Since quality check and calculation of expected density could not be performed, these
+
    $echo_mass = 400;
        'measurements are expected as Robin-algoritme works well and quality parameter is OK
+
  }
        NewDensity = bird_echo_density
+
     ElseIf (land_cl_perc < clutPerc And bird_echo_density > 1) Then
+
  # Calculate adjusted density (#/km²), quality parameter (0..1) and
        'High bird densities are partly masked as rain. New density is calculated expecting total_mass_density
+
  # correction level for peak adjustments (1..3)
        'are all birds, except for that part marked as landclutter. Quality parameter is decreasing, see function
+
  if ($whole_window->{total_mass_density} < 10 and  
        NewDensity = (total_mass_density - land_mass_density) / echo_mass
+
      $whole_window->{land_cl_perc} == 0 and  
        highBDC = (100 - land_cl_perc) / (100 - defClut)
+
      $whole_window->{n} == 0)  {
     ElseIf (land_cl_perc < clutPerc And rain_cl_perc > 99 And nr_or_tracks > 0) Then
+
     # No data in image: total_mass<10, land_cl_perc=0, n=0
        'Under exceptional situations all birds are masked as rain and can only be recalculated
+
    $ROB_density = undef;
        'using expected echo_masses. Since these situations only occur during the night the mean echo_mass
+
    $ROB_quality = 0;
        'was calculated from historic data (1-15 nov 2007: RPN (mainly night), B1: 553; B2: 413,
+
  } elsif($sub_window->{rain_cl_perc} == 100 and $sub_window->{land_cl_perc} == 100) {
        'MIL (only day), B1: 676, B2: 676. Therefore for the moment a value of 500 is used for mean echo_mass
+
     $ROB_density = undef;
        NewDensity = (total_mass_density - land_mass_density) / 500
+
    $ROB_quality = 0;
        maxBDC = ((100 - land_cl_perc) / (100 - defClut)) ^ 2 'Same method as highBDC, but by taking square quality-param lowered
+
  } elsif($correction_level > $cthresh) { # S/N ratio is above threshold, measurement removed
 
+
    $ROB_density = undef;
  ElseIf (rain_cl_perc > 90 And (rain_cl_perc - land_cl_perc) > clutPerc * 1.5 And bird_echo_density > 0) Then
+
    $ROB_quality = 0;
        'Special cases as above, with higher land_cl_percentages. Also these images are probably birds,
+
  } elsif ($sub_window->{rain_cl_perc} > 90 and
        'but the quality parameter is decreasing stronger
+
          ($sub_window->{rain_cl_perc}-$sub_window->{land_cl_perc}) >= $CP and $echo_mass > 0) {
        NewDensity = (total_mass_density - land_mass_density) / echo_mass
+
    $ROB_density = ($sub_window->{total_mass_density} - $defReflectivity) / $echo_mass;
        maxBDC = ((100 - land_cl_perc) / (100 - defClut)) ^ 2 'Same method as highBDC, but by taking square quality-param lowered
+
    $ROB_quality = sqrt( (100 - $sub_window->{land_cl_perc}) / (100 - $defClut) );
 
+
    $ROB_cor_level = 3;
  ElseIf (land_cl_perc < clutPerc And bird_echo_density > 0.25 And echo_mass > 800) Then
+
  } elsif ($sub_window->{rain_cl_perc}-$sub_window->{land_cl_perc} >= ($ClutPerc - $defClut) * 1.5 and $echo_mass > 0) {
        'Large bird echoes are wrongly marked as rain by the ROBIN rain_mask algoritme. Correction of density
+
    $ROB_quality = (100 - $sub_window->{land_cl_perc}) / (100 - $defClut);
        'according 'high bird density rule'. Quality parameter is decreasing due to rain_clutter_percentage.
+
    $ROB_density = ($sub_window->{total_mass_density} - $sub_window->{land_mass_density}) / $echo_mass;
        NewDensity = (total_mass_density - land_mass_density) / echo_mass
+
    if($ROB_quality > 0.8) {
        largeFlockC = Sqr((100 - rain_cl_perc) / (100 - defClut)) 'Rain is removing echo's, therefore this should be in quality param
+
      $ROB_cor_level = 1;
 
+
    } elsif($ROB_quality > 0.5) {
  Else
+
      $ROB_cor_level = 2;
      'Everything seems OK, bird_echo_density is taken and quality parameter is set as square root of clutter percentage.
+
    }
 
+
  } elsif ($sub_window->{bird_echo_density} > 0.05 and $echo_mass > 800) {
      NewDensity = bird_echo_density
+
    $ROB_quality = sqrt((100 - $sub_window->{rain_cl_perc}) / (100 - $defClut));
      defC = Sqr((100 - land_cl_perc) / (100 - defClut))
+
    $ROB_density = ($sub_window->{total_mass_density} - $sub_window->{land_mass_density}) / $echo_mass;
  End If
+
    if($ROB_quality > 0.8) {
  If denQual = 1 Then
+
      $ROB_cor_level = 1;
      'Quality parameter is passed through
+
    } elsif($ROB_quality > 0.5) {
      NewDensity = contentC * highBDC * largeFlockC * maxBDC * defC
+
      $ROB_cor_level = 2;
  End If
+
    }
End Function
+
  } else {
 +
    $ROB_quality = sqrt((100 - $sub_window->{land_cl_perc}) / (100 - $defClut));
 +
    $ROB_density = $sub_window->{bird_echo_density};
 +
    if($ROB_quality > 0.8) {
 +
      $ROB_cor_level = 1;
 +
    } elsif($ROB_quality > 0.5) {
 +
      $ROB_cor_level = 2;
 +
    }
 +
  }
 +
  return ( $ROB_density, $ROB_quality, $ROB_cor_level);
 +
  }

Latest revision as of 11:15, 24 June 2009

The ROBIN_CORRECTED_DENSITY and ROBIN_CORRECTED_QUALITY are calculated according to the following function :


 sub Quantify_ROBIN
 {

   my ($whole_window, $sub_window, $correction_level, $radar_name, $beam_name, $window, $log) = @_;
   my $ROB_density = 0;
   my $ROB_quality = 0;
   my $ROB_cor_level = undef;
   my $ClutPerc = 25;

   my ($radar) = $radar_name =~ /RP-(\w{3})/;
   my ($beam) = $beam_name =~ /BEAM_(\d+)/; 
   $beam = 'B' . $beam;
   my $key = $radar . '_' . $beam . '_' . $window;

   my %DEFAULT_VALUES = (
   GLO_B1_SE => { cthresh         => 1864,
                  defReflectivity => 3033,
                  defClut         => 18.65,
                  CP              => 15
                },
   GLO_B1_NW => { cthresh         => 1864,
                  defReflectivity => 901,
                  defClut         => 15.05,
                  CP              => 15
                },
   GLO_B2_SE => { cthresh         => 1804,
                  defReflectivity => 527,
                  defClut         => 3.33,
                  CP              => 15
                },
   GLO_B2_NW => { cthresh         => 1804,
                  defReflectivity => 44,
                  defClut         => 1.28,
                  CP              => 15
                },

   WIE_B1_SE => { cthresh         => 310,
                  defReflectivity => 0,
                  defClut         => 0,
                  CP              => 15
                },
   WIE_B1_NW => { cthresh         => 310,
                  defReflectivity => 0,
                  defClut         => 0,
                  CP              => 15
                },
   WIE_B2_SE => { cthresh         => 594,
                  defReflectivity => 0,
                  defClut         => 0,
                  CP              => 15
                },
   WIE_B2_NW => { cthresh         => 594,
                  defReflectivity => 0,
                  defClut         => 0,
                  CP              => 15
                },
 );

 my $cthresh         = 0;
 my $defReflectivity = 0;
 my $defClut         = 0;
 my $CP              = 0;

 if(exists($DEFAULT_VALUES{$key})) {
   $cthresh         = $DEFAULT_VALUES{$key}->{cthresh};
   $defReflectivity = $DEFAULT_VALUES{$key}->{defReflectivity};
   $defClut         = $DEFAULT_VALUES{$key}->{defClut};
   $CP              = $DEFAULT_VALUES{$key}->{CP};
 }

 # Calculate echo mass. If subwindow is saturated, echo_mass is extracted 
 # from the whole window (radar.subwindow_result.subwindow_id = 0).
  
 my $echo_mass;
 if($sub_window->{bird_echo_density} > 0) {
   $echo_mass = $sub_window->{bird_mass_density} / $sub_window->{bird_echo_density};
 } elsif($whole_window->{bird_echo_density} > 0) {
   $echo_mass = $whole_window->{bird_mass_density} / $whole_window->{bird_echo_density};
 } else {
   $echo_mass = 400;
 }

 # Calculate adjusted density (#/km²), quality parameter (0..1) and 
 # correction level for peak adjustments (1..3)
 if ($whole_window->{total_mass_density} < 10 and 
     $whole_window->{land_cl_perc} == 0 and 
     $whole_window->{n} == 0)  {
   # No data in image: total_mass<10, land_cl_perc=0, n=0
   $ROB_density = undef;
   $ROB_quality = 0;
 } elsif($sub_window->{rain_cl_perc} == 100 and $sub_window->{land_cl_perc} == 100) {
   $ROB_density = undef;
   $ROB_quality = 0;
 } elsif($correction_level > $cthresh) { # S/N ratio is above threshold, measurement removed
   $ROB_density = undef;
   $ROB_quality = 0;
 } elsif ($sub_window->{rain_cl_perc} > 90 and 
          ($sub_window->{rain_cl_perc}-$sub_window->{land_cl_perc}) >= $CP and $echo_mass > 0) {
   $ROB_density = ($sub_window->{total_mass_density} - $defReflectivity) / $echo_mass;
   $ROB_quality = sqrt( (100 - $sub_window->{land_cl_perc}) / (100 - $defClut) );
   $ROB_cor_level = 3;
 } elsif ($sub_window->{rain_cl_perc}-$sub_window->{land_cl_perc} >= ($ClutPerc - $defClut) * 1.5 and $echo_mass > 0) {
   $ROB_quality = (100 - $sub_window->{land_cl_perc}) / (100 - $defClut);
   $ROB_density = ($sub_window->{total_mass_density} - $sub_window->{land_mass_density}) / $echo_mass;
   if($ROB_quality > 0.8) {
     $ROB_cor_level = 1;
   } elsif($ROB_quality > 0.5) {
     $ROB_cor_level = 2;
   }
 } elsif ($sub_window->{bird_echo_density} > 0.05 and $echo_mass > 800) {
   $ROB_quality = sqrt((100 - $sub_window->{rain_cl_perc}) / (100 - $defClut));
   $ROB_density = ($sub_window->{total_mass_density} - $sub_window->{land_mass_density}) / $echo_mass;
   if($ROB_quality > 0.8) {
     $ROB_cor_level = 1;
   } elsif($ROB_quality > 0.5) {
     $ROB_cor_level = 2;
   }
 } else {
   $ROB_quality = sqrt((100 - $sub_window->{land_cl_perc}) / (100 - $defClut));
   $ROB_density = $sub_window->{bird_echo_density};
   if($ROB_quality > 0.8) {
     $ROB_cor_level = 1;
   } elsif($ROB_quality > 0.5) {
     $ROB_cor_level = 2;
   }
 }
 return ( $ROB_density, $ROB_quality, $ROB_cor_level);
 }