#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ # # Process ATLAS file # Using the oasis time stamp, add atlas variables # #////////////////////////////////////////////////////////////////////////////// sub processAtlas { $ncOffset = 0; @start = $ncOffset; NetCDF::varget1($ncID, $varID{"oasisTime"}, \@start, $ncTime); open( ATLAS, $atlasFile ) || die; #----------------------------------------------------------------------- # Skip beginning records in Atlas file #----------------------------------------------------------------------- while( ) { #-------------------------------------------------------------------- # Skip # - comment lines # - mooring M1 day 97212 # - mooring M2 day 97125 # - mooring M3 day 97126 # # The mooring & day skipage above is a HORRIBLE KLUDGE but I just # don't have time to make it right. The issue is that mooring # turnaround times have gone from weeks to hours, which means the # oasis directory structure has the daily info for those particular # days in two separate files. I don't want to deal with that...so # I do this kludge as a workaround :>{ # #-------------------------------------------------------------------- if( /^\#/ ) { next; } elsif( $Mooring eq "M1" && /^212/ ) { next; } elsif( $Mooring eq "M2" && /^125/ ) { next; } elsif( $Mooring eq "M2" && /^126/ ) { next; } else { last; } } #----------------------------------------------------------------------- # process all records in Atlas file #----------------------------------------------------------------------- while( $_ ) { #-------------------------------------------------------------------- # Extract fields from file input #-------------------------------------------------------------------- s/^\s+//; @field = split('\s+',$_); for( $i=0; $i <= $#field; $i++ ) { if( $field[$i] =~ /\D\./ ) { $field[$i] = "-99.99"; } } #-------------------------------------------------------------------- # assign field values to variables #-------------------------------------------------------------------- $atlasTime = $field[0]; $air = $field[2]; $sst = $field[3]; $humidity = $field[16]; $windSpeed = $field[17]; $windDir = $field[18]; $windU = $field[19]; $windV = $field[20]; $compass = $field[21]; $vane = $field[22]; $rawDir = $field[23]; $rawSpeed = $field[24]; $year = $field[25]; #-------------------------------------------------------------------- # assign field values to variable arrays #-------------------------------------------------------------------- push( @temperature, @field[4 .. 13] ); push( @pressure, $field[14], $field[15] ); #-------------------------------------------------------------------- # convert oasis time to Epoch Secs # column 01 is YDAY, column 25 is YEAR. Both are needed for EPOCH SECS #-------------------------------------------------------------------- $epochSecs = timegm(0,0,0,1,0,substr($year,2,2)) + int(($atlasTime-1) * $secsPerDay); #-------------------------------------------------------------------- # set offset into nc file for this IO #-------------------------------------------------------------------- setNcOffset(); #-------------------------------------------------------------------- # write atlas values at ncOffset #-------------------------------------------------------------------- atlasIO( $ncOffset ); #-------------------------------------------------------------------- # grab next sequential ncTime (hopefully the next required) #-------------------------------------------------------------------- $ncOffset++; if( $ncOffset < $ncNumRecs ) { @ndx = $ncOffset; NetCDF::varget1($ncID, $varID{"oasisTime"}, \@ndx, $ncTime); } #-------------------------------------------------------------------- # read the next ATLAS record #-------------------------------------------------------------------- $_ = ; } close( ATLAS ); } #---processAtlas---# #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ # # #////////////////////////////////////////////////////////////////////////////// sub atlasIO { my( $offSet ) = ($_[0]); @start = $offSet; NetCDF::varput1( $ncID, $varID{"air"}, \@start, $air ); NetCDF::varput1( $ncID, $varID{"sst"}, \@start, $sst ); NetCDF::varput1( $ncID, $varID{"humidity"}, \@start, $humidity ); NetCDF::varput1( $ncID, $varID{"windSpeed"}, \@start, $windSpeed ); NetCDF::varput1( $ncID, $varID{"windDir"}, \@start, $windDir ); NetCDF::varput1( $ncID, $varID{"windU"}, \@start, $windU ); NetCDF::varput1( $ncID, $varID{"windV"}, \@start, $windV ); NetCDF::varput1( $ncID, $varID{"windV"}, \@start, $windV ); if( $deployNum > 1 ) { NetCDF::varput1( $ncID, $varID{"compass"}, \@start, $compass ); NetCDF::varput1( $ncID, $varID{"vane"}, \@start, $vane ); NetCDF::varput1( $ncID, $varID{"rawDir"}, \@start, $rawDir ); NetCDF::varput1( $ncID, $varID{"rawSpeed"}, \@start, $rawSpeed); } @start = ($offSet, 0); @count = (1, 10); NetCDF::varput($ncID, $varID{"temperature"}, \@start, \@count, \@temperature ); @start = ($offSet, 0); @count = (1, 2); NetCDF::varput($ncID, $varID{"pressure"}, \@start, \@count, \@pressure ); ( @temperature, @pressure ) = (); } #---atlasIO---# #------------------------------------------------------------------------------ # require needs to evaluate a final TRUE statement #------------------------------------------------------------------------------ 1;