Changeset 253
- Timestamp:
- 08/14/09 09:19:29
- Files:
-
- scout/trunk/samos_moving_point.pl (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
scout/trunk/samos_moving_point.pl
r252 r253 4 4 5 5 6 use constant USE_DEBUG_PRINTS => 1; 7 6 8 sub samos_moving_point 7 9 { … … 15 17 # Open the netCDF file 16 18 17 $ncid = NetCDF::open($ncFilename, NetCDF::READ);19 my $ncid = NetCDF::open($ncFilename, 0); 18 20 if($ncid < 0) 19 21 { … … 23 25 # 24 26 # General file query 25 $inquire = NetCDF::inquire($ncid,$ndims,$nvars,$natts,$recdim); 27 my( $ndims,$nvars,$natts,$recdim ); 28 my $inquire = NetCDF::inquire($ncid,$ndims,$nvars,$natts,$recdim); 26 29 if( $inquire < 0 ) 27 30 { … … 44 47 #Create the platform handle 45 48 my $id='None'; 46 $attget = NetCDF::attget($ncid,NetCDF::GLOBAL,'ID',\$id);49 my $attget = NetCDF::attget($ncid,NetCDF::GLOBAL,'ID',\$id); 47 50 if( $attget < 0 ) 48 51 { 49 52 print( "No ID provided in file.\n" ); 50 53 } 51 #my $strPlatformID = "samos.$id.ship";52 my $strPlatformID = $id;53 54 $institution_url_value = 'http://samos.coaps.fsu.edu/html/data.php';54 my $strPlatformID = "samos.$id.ship"; 55 #my $strPlatformID = $id; 56 57 my $institution_url_value = 'http://samos.coaps.fsu.edu/html/data.php'; 55 58 56 59 my @KMLTimeStamp; … … 67 70 ); 68 71 69 for ($i = 0; $i < $nvars; $i++) 70 { 71 my $this_var_name; 72 my $this_var_name; 73 my $timeCnt = 0; 74 for (my $i = 0; $i < $nvars; $i++) 75 { 72 76 my $this_var_type; 73 77 my $this_var_dims; … … 121 125 $rTime = \%VariableHash; 122 126 123 $ iTimeCnt = %$rTime->{'var_name'}{$this_var_name}{'dim_name'}{'time'}{'dim_size'};127 $timeCnt = %$rTime->{'var_name'}{$this_var_name}{'dim_name'}{'time'}{'dim_size'}; 124 128 my $strUnits = %$rTime->{'var_name'}{$this_var_name}{'units'}; 125 129 my @Data = %$rTime->{'var_name'}{$this_var_name}{'data'}; 126 130 my $iDataSize = @{$Data[0]}; 127 if( $ iTimeCnt != $iDataSize )131 if( $timeCnt != $iDataSize ) 128 132 { 129 die( "ABORT! Time Dimension: $ iTimeCnt does not match the data count: $iDataSize!\n");133 die( "ABORT! Time Dimension: $timeCnt does not match the data count: $iDataSize!\n"); 130 134 } 131 135 } … … 152 156 #If we have more entries in the time_values array, let's set the starting index at the spot in the array which 153 157 #will get us to the first of the N time stamps. 154 print( "iTimeCnt: $ iTimeCnt iLastNTimeStamps: $iLastNTimeStamps\n" );155 if( $ iTimeCnt > $iLastNTimeStamps )156 { 157 $iStartingNdx = $ iTimeCnt - $iLastNTimeStamps;158 print( "iTimeCnt: $timeCnt iLastNTimeStamps: $iLastNTimeStamps\n" ); 159 if( $timeCnt > $iLastNTimeStamps ) 160 { 161 $iStartingNdx = $timeCnt - $iLastNTimeStamps; 158 162 if( USE_DEBUG_PRINTS ) 159 163 { 160 print( "moving_point()::Printing Last: $iLastNTimeStamps out of $iTimeCnt entries. Starting Index: $iStartingNdx. $ncid\n" ); 161 } 162 } 163 elsif( $iLastNTimeStamps > $iTimeCnt ) 164 { 165 print( "moving_point()::iLastNTimeStamps: $iLastNTimeStamps is greater than total number of times in file. Resetting to iLastNTimeStamps to $iTimeCnt\n" ); 166 $iLastNTimeStamps = $iTimeCnt; 167 } 168 } 164 print( "moving_point()::Printing Last: $iLastNTimeStamps out of $timeCnt entries. Starting Index: $iStartingNdx. $ncid\n" ); 165 } 166 } 167 elsif( $iLastNTimeStamps > $timeCnt ) 168 { 169 print( "moving_point()::iLastNTimeStamps: $iLastNTimeStamps is greater than total number of times in file. Resetting to iLastNTimeStamps to $timeCnt\n" ); 170 $iLastNTimeStamps = $timeCnt; 171 } 172 } 173 my %ObsHash; 169 174 # write data to file(s) 170 my %TimeRef = %{$time[0]};171 175 my $iVarCnt = @vars; 172 176 if( $bWriteobsKMLFile ) … … 174 178 #TIme is always the outer loop. Each measurement is taken at a specific time. 175 179 my $iTimeNdx = $iStartingNdx; 176 for( ; $iTimeNdx < $ iTimeCnt; $iTimeNdx++ )177 { 178 $strTimeVal = getDateTimeFromEpoch( $rTime, $iTimeNdx );180 for( ; $iTimeNdx < $timeCnt; $iTimeNdx++ ) 181 { 182 my $strTimeVal = getDateTimeFromEpoch( $rTime, $iTimeNdx ); 179 183 my( $LatVal, $LonVal ); 180 184 netcdfFuncs::ncGetLatLong( $rLat, $rLong, $iTimeNdx, \$LatVal, \$LonVal ); … … 233 237 #Add the $strDate which gives us a unique file name. Some providers don't uniquely name the netcdf files, so to prevent overwritting of my 234 238 #kml, I add the time. 235 $strXMLPath = "$strObsKMLFilePath/$strFileName.kml";239 $strXMLPath = $strObsKMLFilePath . $strFileName . '.kml'; 236 240 print( "XMLFilePath: $strXMLPath\n" ); 237 241 obsKMLSubRoutines::BuildKMLFile( \%ObsHash, $strXMLPath ); … … 289 293 my @Data = $refVarData->{'var_name'}{$strVarName}{'data'}; 290 294 #Get "missing value" value. 291 my $missingVal = $refVar Hash->{'var_name'}{$strVarName}{'missing_value'};295 my $missingVal = $refVarData->{'var_name'}{$strVarName}{'missing_value'}; 292 296 293 297 my $iStartNdx = $iDataNdx; … … 303 307 else 304 308 { 305 $Val = NULL;309 $Val = 'NULL'; 306 310 } 307 311 my $iSOrder = 1; 308 $obsName = convertToXeniaObsName( $strVarName );312 my $obsName = convertToXeniaObsName( $strVarName ); 309 313 netcdfFuncs::ncOutputData( $strPlatformID, 310 314 $obsName,
