Changeset 232
- Timestamp:
- 08/26/08 09:04:08
- Files:
-
- scout/trunk/cdl_fixed_point.pl (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
scout/trunk/cdl_fixed_point.pl
r209 r232 1 1 sub fixed_point() { 2 2 3 3 4 # top timestamp … … 842 843 for my $j (0..$#this_wind_gust_data) { 843 844 push @{$wind_gust[$i]{'data'}}, $this_wind_gust_data[$j]; 845 print( "$this_wind_gust_data $j: $this_wind_gust_data[$j] wind_gust $i: $wind_gust[$i]{'data'} \n" ); 844 846 } 845 847 } … … 943 945 944 946 #DWR 4/5/2008 945 $air_pressure[$i]{'units'} = $units_value; 947 #DWR v1.1.1.0 948 #Hardcode millibras string since the conversion below on the data is hardcoded and does not come from UDUNITS. 949 $air_pressure[$i]{'units'} = "millibar"; 946 950 947 951 # we need to loop through the attributes, so find out how many there are … … 972 976 #also canceling conversion if air_pressure > 900 973 977 #print "$this_air_pressure_data[$j]\n"; 974 if ($this_air_pressure_data[$j] == $missing_value_value || $this_air_pressure_data[$j] == $Fill_value_value || $this_air_pressure_data[$j] > 900) { $this_slope = 1; $this_intercept = 0; } else { $this_slope = 1000; $this_intercept = 0;} 978 if ($this_air_pressure_data[$j] == $missing_value_value || $this_air_pressure_data[$j] == $Fill_value_value || $this_air_pressure_data[$j] > 900) 979 { 980 $this_slope = 1; $this_intercept = 0; 981 } else 982 { 983 $this_slope = 1000; $this_intercept = 0; 984 } 975 985 print STATION_ID_SQLFILE "-- this_air_pressure_data[j]=".$this_air_pressure_data[$j]." missing_value_value=".$missing_value_value." Fill_value_value=".$Fill_value_value."\n"; 976 986 push @{$air_pressure[$i]{'data'}}, … … 1051 1061 $varget = NetCDF::varget($ncid, $sea_surface_eastward_current[$i]{'var_id'}, 1052 1062 (0), $time_dim{'dim_size'}, \@this_sea_surface_eastward_current_data); 1063 1053 1064 if ($varget < 0) {die "ABORT! Cannot get $sea_surface_eastward_current[$i]{'var_name'} data.\n";} 1054 1065 # get all the attributes for this variable … … 1072 1083 1073 1084 #DWR 4/5/2008 1074 $sea_surface_eastward_current[$i]{'units'} = $units_value;1085 $sea_surface_eastward_current[$i]{'units'} = 'm_s-1'; 1075 1086 1076 1087 # we need to loop through the attributes, so find out how many there are … … 1098 1109 # add a NULL where missing value 1099 1110 for my $j (0..$#this_sea_surface_eastward_current_data) { 1100 #cancel out conversion operation if missing value1101 if ($this_sea_surface_eastward_current_data[$j] == $missing_value_value || $this_sea_surface_eastward_current_data[$j] == $Fill_value_value) { $this_slope = 1; $this_intercept = 0; }1111 #cancel out conversion operation if missing value 1112 if ($this_sea_surface_eastward_current_data[$j] == $missing_value_value || $this_sea_surface_eastward_current_data[$j] == $Fill_value_value) { $this_slope = 1; $this_intercept = 0; } 1102 1113 push @{$sea_surface_eastward_current[$i]{'data'}}, 1103 1114 ($this_sea_surface_eastward_current_data[$j] * $this_slope + $this_intercept); … … 1491 1502 $this_val = sprintf("%.2f",$water_level[$i]{'data'}[$j]); 1492 1503 1493 $DataVal = $ water_level[$i]{'reference'};1504 $DataVal = $this_val; 1494 1505 1495 1506 if (length $water_level[$i]{'reference_to_mllw'} > 0) { … … 1499 1510 $this_val = 'NULL'; 1500 1511 } 1501 $MLLWDataVal = $ this_val;1502 1512 $MLLWDataVal = $DataVal + $this_val; 1513 =comment 1503 1514 if (length $water_level[$i]{'reference_to_msl'} > 0) { 1504 1515 $this_val = sprintf("%.2f",$water_level[$i]{'reference_to_msl'}); … … 1517 1528 #DWR 4/5/2008 1518 1529 $NavD88DataVal = $this_val; 1530 =cut 1519 1531 } 1520 1532 obsKMLSubRoutines::KMLAddObsToHash( 'water_level', … … 1526 1538 'm(MLLW)', 1527 1539 $rObsHash ); 1540 =comment 1528 1541 obsKMLSubRoutines::KMLAddObsToHash( 'water_level', 1529 1542 $KMLTimeStamp[$j], … … 1542 1555 'm(NAVD88)', 1543 1556 $rObsHash ); 1557 =cut 1544 1558 } 1545 1559 } … … 2008 2022 2009 2023 if ($wind_gust[$j]{'data'}[$k] == $missing_value_value 2010 || $wind_gust[$j]{'data'}[$k] == $Fill_value_value 2011 || $wind_gust[$j]{'data'}[$k] == '') { 2024 || $wind_gust[$j]{'data'}[$k] == $Fill_value_value ) 2025 #|| $wind_gust[$j]{'data'}[$k] == '') DWR v1.1.2.0 2026 { 2012 2027 print WIND_SQLFILE ',NULL'; 2013 2028 } … … 2089 2104 2090 2105 if ($wind_gust[$j]{'data'}[$k] != $missing_value_value 2091 && $wind_gust[$j]{'data'}[$k] != $Fill_value_value 2092 && $wind_gust[$j]{'data'}[$k] != '')2106 && $wind_gust[$j]{'data'}[$k] != $Fill_value_value ) 2107 #&& $wind_gust[$j]{'data'}[$k] != '') DWR v1.1.2.0 2093 2108 { 2094 2109 $WindGstDataVal = sprintf("%.2f",$wind_gust[$j]{'data'}[$k]); … … 2372 2387 } 2373 2388 my $strUnits; 2389 #DWR v1.1.1.0 2390 #Added UnitsStringConversionfucntion. 2391 $strUnits = obsKMLSubRoutines::UnitsStringConversion( $salinity[$i]{'units'}, $XMLControlFile ); 2392 2374 2393 if( lc( $salinity[$i]{'units'} ) eq 'ppt' ) 2375 2394 { … … 2510 2529 my $ECurrentDataVal = 'NULL'; 2511 2530 my $NCurrentDataVal = 'NULL'; 2512 my $Height = ''; 2531 my @VectorDataVal; 2532 my $Height = ''; 2533 my $strUnits; 2534 $strUnits = obsKMLSubRoutines::UnitsStringConversion( $sea_surface_eastward_current[$i]{'units'}, $XMLControlFile ); 2535 if( length( $strUnits ) == 0 ) 2536 { 2537 #DWR v1.1.0.0 2538 #Make sure we don't have any unprintable characters. 2539 $strUnits = obsKMLSubRoutines::CleanString( $sea_surface_eastward_current[$i]{'units'} ); 2540 } 2541 2513 2542 if( $this_time_stamp_sec > $oldest_ok_timestamp ) 2514 2543 { … … 2524 2553 { 2525 2554 $Height = sprintf("%.2f",$sea_surface_eastward_current[$i]{'height'}); 2526 } 2555 } 2527 2556 $ECurrentDataVal = sprintf("%.2f",$sea_surface_eastward_current[$i]{'data'}[$k]); 2528 2557 2529 2558 $NCurrentDataVal = sprintf("%.2f",$sea_surface_northward_current[$j]{'data'}[$k]); 2530 2559 @VectorDataVal = get_mag_and_dir( $ECurrentDataVal, $NCurrentDataVal, 1 ); 2531 2560 } 2532 my $strUnits; 2533 $strUnits = obsKMLSubRoutines::UnitsStringConversion( $sea_surface_eastward_current[$i]{'units'}, $XMLControlFile ); 2534 if( length( $strUnits ) == 0 ) 2535 { 2536 #DWR v1.1.0.0 2537 #Make sure we don't have any unprintable characters. 2538 $strUnits = obsKMLSubRoutines::CleanString( $sea_surface_eastward_current[$i]{'units'} ); 2539 } 2540 2541 obsKMLSubRoutines::KMLAddObsToHash( 'eastward_current', 2561 obsKMLSubRoutines::KMLAddObsToHash( 'current_to_direction', 2542 2562 $KMLTimeStamp[$k], 2543 $ECurrentDataVal,2563 @VectorDataVal[1], 2544 2564 1, 2545 2565 $strPlatformID, 2546 2566 $Height, 2547 $strUnits, 2567 'degrees_true', 2568 $rObsHash ); 2569 2570 2571 obsKMLSubRoutines::KMLAddObsToHash( 'current_speed', 2572 $KMLTimeStamp[$k], 2573 @VectorDataVal[0], 2574 1, 2575 $strPlatformID, 2576 $Height, 2577 'm_s-1', 2548 2578 $rObsHash ); 2549 2579 $strUnits = ''; … … 2631 2661 print WAVE_SQLFILE ','.'\''.$height_var{'positive'}.'\''; 2632 2662 if ($significant_wave_height[$i]{'data'}[$j] == $missing_value_value 2633 || $significant_wave_height[$i]{'data'}[$j] == $Fill_value_value 2634 || $significant_wave_height[$i]{'data'}[$j] == '') { 2663 || $significant_wave_height[$i]{'data'}[$j] == $Fill_value_value ) 2664 #|| $significant_wave_height[$i]{'data'}[$j] == '') DWR v1.1.2.0 2665 { 2635 2666 print WAVE_SQLFILE ',NULL'; 2636 2667 } … … 2642 2673 } 2643 2674 if ($dominant_wave_period[$i]{'data'}[$j] == $missing_value_value 2644 || $dominant_wave_period[$i]{'data'}[$j] == $Fill_value_value 2645 || $dominant_wave_period[$i]{'data'}[$j] == '') { 2675 || $dominant_wave_period[$i]{'data'}[$j] == $Fill_value_value ) 2676 #|| $dominant_wave_period[$i]{'data'}[$j] == '') DWR v1.1.2.0 2677 { 2646 2678 print WAVE_SQLFILE ',NULL'; 2647 2679 } … … 2689 2721 } 2690 2722 if ($significant_wave_height[$i]{'data'}[$j] != $missing_value_value 2691 && $significant_wave_height[$i]{'data'}[$j] != $Fill_value_value 2692 && $significant_wave_height[$i]{'data'}[$j] != '')2723 && $significant_wave_height[$i]{'data'}[$j] != $Fill_value_value ) 2724 #&& $significant_wave_height[$i]{'data'}[$j] != '') DWR v1.1.2.0 2693 2725 { 2694 2726 $SigWaveHgtDataVal = sprintf("%.2f",$significant_wave_height[$i]{'data'}[$j]); 2695 2727 } 2696 2728 if ($dominant_wave_period[$i]{'data'}[$j] != $missing_value_value 2697 && $dominant_wave_period[$i]{'data'}[$j] != $Fill_value_value 2698 && $dominant_wave_period[$i]{'data'}[$j] != '')2729 && $dominant_wave_period[$i]{'data'}[$j] != $Fill_value_value ) 2730 #&& $dominant_wave_period[$i]{'data'}[$j] != '') DWR v1.1.2.0 2699 2731 { 2700 2732 $DomWaveDataVal = sprintf("%.2f",$dominant_wave_period[$i]{'data'}[$j]); … … 2749 2781 2750 2782 my $strXMLPath; 2751 #my $strDate = `date +% Y-%m-%dT%H-%M-%S`;2783 #my $strDate = `date +%H%M%S`; 2752 2784 #chomp( $strDate ); 2753 $strXMLPath = "$strObsKMLFilePath/$this_station_id"; 2754 $strXMLPath = $strXMLPath . '_latest.kml'; 2785 my @aSrcFileParts = split( /\//, $net_cdf_file ); 2786 my $strSrcFileName = @aSrcFileParts[-1]; 2787 #Break the filename and extension apart. 2788 #print( "$strSrcFileName\n" ); 2789 my $iPos = rindex( $strSrcFileName, '.' ); 2790 my $strFileName = $strSrcFileName; 2791 if( $iPos != -1 ) 2792 { 2793 $strFileName = substr( $strSrcFileName, 0, $iPos ); 2794 } 2795 #print( "$strFileName\n" ); 2796 2797 #$strXMLPath = "$strObsKMLFilePath/$this_station_id"; 2798 #DWR v1.1.1.0 2799 #Use the source netcdf filename. 2800 #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 2801 #kml, I add the time. 2802 $strXMLPath = "$strObsKMLFilePath/$strFileName.kml"; 2803 #$strXMLPath = $strXMLPath . '_latest.kml'; 2755 2804 print( "XMLFilePath: $strXMLPath\n" ); 2756 2805 obsKMLSubRoutines::BuildKMLFile( \%ObsHash, $strXMLPath ); … … 2767 2816 } 2768 2817 } 2818 2819 sub get_mag_and_dir { 2820 2821 my ($x, $y, $scale) = @_; 2822 my ($mag,$angle); 2823 2824 $mag = sprintf("%d",$scale*sqrt($x*$x+$y*$y)); 2825 #print "$mag\n"; 2826 2827 $angle = atan2($y,$x); 2828 $angle = sprintf("%d",180/3.1416*$angle); 2829 $angle = 90 - $angle; 2830 #only return positive degrees 2831 if ($angle < 0) 2832 { 2833 $angle = 360 + $angle; 2834 } 2835 2836 my @result = ($mag, $angle); 2837 2838 return (@result); 2839 2840 }
