Changeset 243

Show
Ignore:
Timestamp:
10/31/08 14:41:29
Author:
dan
Message:

Sunroutine: ProcessADCPVar
Changes: Compare the data value to the missing value or fill value so we can correctly handle those cases.
Subroutine:ProcessVar
Changes: If the measurement is either water_depth or water_level, we handle their elevation differently.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • scout/trunk/cdl_profiler_adcp.pl

    r240 r243  
    528528  for( $iNdx = 0; $iNdx < $iDataCnt; $iNdx++ ) 
    529529  { 
    530     my $Val = @{$Data[0]}[$iStartNdx]; 
     530    my $Val = @{$Data[0]}[$iStartNdx];     
    531531    if( $iZDimCnt ) 
    532532    { 
     
    536536    { 
    537537      $iZVal = @$ZData[0]; 
     538    } 
     539    if( $strVarName eq 'water_depth' ) 
     540    { 
     541      $iZVal = $Val; 
     542    } 
     543    elsif( $strVarName eq 'water_level' ) 
     544    { 
     545      $iZVal = 0; 
    538546    } 
    539547    my $iSOrder = $iNdx + 1; 
     
    593601  my $TimeVal = ''; 
    594602  my $iZVal = 0; 
     603  my $iPositiveUp = 0; 
     604  #Is the Z increasing(bottom to surface) or decreasing(surface to bottom)? 
     605  if( @$ZData[0] < @$ZData[-1] ) 
     606  { 
     607    $iPositiveUp = 1; 
     608  } 
    595609  foreach my $strDimName ( sort keys %{$refVarData->{'var_name'}{$strVarName}{'dim_name'}} ) 
    596610  { 
     
    669683    { 
    670684      my $Val = @{$Data[0]}[$iStartNdx]; 
     685      if( $Val == $Fill_value_value || $Val == $missing_value_value ) 
     686      {  
     687        $Val = 'NULL'; 
     688      } 
     689      else 
     690      { 
     691        $Val = sprintf("%.3f", $Val ); 
     692      } 
    671693      if( $iZDimCnt ) 
    672694      { 
     
    678700      } 
    679701      my $iSOrder = $iNdx + 1; 
    680       $Val = sprintf("%.3f", $Val ); 
     702      if( $iPositiveUp ) 
     703      { 
     704        $iSOrder = $iDataCnt - $iNdx; 
     705      } 
    681706      OutputData( $strPlatformID, 
    682707                  $strVarName,  
     
    691716                   
    692717      #Calculate the Speed/Direction? 
    693       if( $bHasCurrentAndSpeed == 0 && @CalcData ) 
    694       { 
    695         my $NorthVal = @{$CalcData[0]}[$iStartNdx]; 
    696          
    697         my @MagDir = GetMagAndDir( $Val, $NorthVal, 1 ); 
    698          
     718      if( ( $bHasCurrentAndSpeed == 0 ) &&  
     719          ( @CalcData ) ) 
     720      { 
     721        my @MagDir; 
     722        @MagDir[0] = 'NULL'; 
     723        @MagDir[1] = 'NULL'; 
     724        if( $Val != 'NULL' ) 
     725        { 
     726          my $NorthVal = @{$CalcData[0]}[$iStartNdx];         
     727          @MagDir = GetMagAndDir( $Val, $NorthVal, 1 ); 
     728        }     
    699729        #Write the current speed. 
    700730        OutputData( $strPlatformID, 
     
    721751      } 
    722752      #Calculate the east/north components? 
    723       elsif( $bHasEastNorth == 0 && @CalcData ) 
    724       { 
    725         my( $EastCurrent, $NorthCurrent ); 
    726         my $DirVal = @{$CalcData[0]}[$iStartNdx]; 
    727         CalcVectorComponents( $Val, $DirVal, \$EastCurrent, \$NorthCurrent ); 
     753      elsif(( $bHasEastNorth == 0 ) &&  
     754            ( @CalcData ) ) 
     755      { 
     756        my( $EastCurrent, $NorthCurrent ) = 'NULL'; 
     757                 
     758        if( $Val != 'NULL' ) 
     759        { 
     760          my $DirVal = @{$CalcData[0]}[$iStartNdx]; 
     761          CalcVectorComponents( $Val, $DirVal, \$EastCurrent, \$NorthCurrent ); 
     762        } 
    728763        OutputData( $strPlatformID, 
    729764                    $strVarName,