#!/usr/arch/bin/perl # Different Views: # Regular # Water Coverage # Gamma 2 # Quadrants $user = `whoami`; chomp $user; if ($user ne "ice" && $user ne "bppresto") { print "ERROR: Script MUST be run as user 'ice'... \n"; exit (1); } # Set up the library path for the convert command # add /usr/arch/graphics/lib to $LD_LIBRARY_PATH #$ENV{'LD_LIBRARY_PATH'} = '/usr/arch/graphics/lib/:' . $ENV{'LD_LIBRARY_PATH'}; $ARGC = @ARGV; if ($ARGC != "1") { print "Not enough arguments specified for ProcessImage script... \n"; print "Expecting 1 argument...\n"; print " 1. Trailer File \n"; exit(1); } $trailerFile = @ARGV[0]; @tSplit = split(/\//, $trailerFile); $sizeTSplit = @tSplit; $tf = @tSplit[$sizeTSplit-1]; $fileName = substr($tf, 0, length($tf)-2); print "Parsing out text from trailer file \n"; $numDays = substr($tf, 13, 3); $year = substr($tf, 11, 2); if (($year % 4) eq 0) { @monthStart = (1, 32, 61, 92, 122, 153, 183, 214, 245, 275, 306, 336); } else { @monthStart = (1, 32, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335); } $finmonth = 12; $finday = $numDays - @monthStart[11] + 1; for ($mon = 1; $mon < 13; $mon++) { if (@monthStart[$mon] > $numDays) { $finmonth = $mon; $leftover = $numDays - @monthStart[$mon-1] + 1; $finday = $leftover; $mon = 12; } } $day = $finday; $month = $finmonth; $UTCtime = (substr($tf, 18, 2) - 5) . ":" . substr($tf, 20, 2) . ":" . substr($tf, 22, 2); $ESTtime = substr($tf, 18, 2) . ":" . substr($tf, 20, 2) . ":" . substr($tf, 22, 2); $topLeft = substr($tf, 26, 6); $botRight = substr($tf, 34, 6); $count = 0; open (TRAILER, $trailerFile); while () { $tmp = ""; $line = $_; # split the data at the whitespaces @splitMe = split(/\ /, $line); foreach $item(@splitMe) { # if it's not just a space, put in onto the data list if ($item ne "") { # if it's negative, put ()'s around it instead since pbmtext doesn't like negative signs if ($item < 0) { $item =~ s/-/\ /g; $item = "(" . $item . ")"; } push @dataArray, $item; } } } close(TRAILER); # 51 - MET - (Ascending / Decending) # 52 - Latitude at Image Center # 53 - Longitude at Image Center # 64 - Processed Scene Azimuth # 65 - Processed Scene Range (km) # 74 - Platform Heading # 76 - Incidence Angle # 106 + # 107 - Sensor Type # 109 - # azimuth looks # 110 - # range looks # 128 - Line Spacing (m) # 129 - Pixel Spacing (m) $met = @dataArray[51]; $lat = @dataArray[52]; $long = @dataArray[53]; $proAzimuth = @dataArray[64]; $proRange = @dataArray[65]; $heading = @dataArray[74]; $angle = @dataArray[76]; # what other types besides SCANSAR WIDE? $type = @dataArray[106] . " " . @dataArray[107]; $numAzimuth = @dataArray[109]; $numRange = @dataArray[110]; $line = @dataArray[128]; $pixel = substr(@dataArray[129], 0, 10); # build title `pbmtext "File: $fileName Copyright Canadian Space Agency" > R_tit1_tmp.pbm`; `pbmtext "RADARSAT: $month / $day / $year $ESTtime EST" > R_tit2_tmp.pbm`; `pnmcat -white -tb -jleft R_tit1_tmp.pbm R_tit2_tmp.pbm > R_TopTable.pbm`; # build data `pbmtext "Day: $numDays" > R_day_tmp.pbm`; `pbmtext "Time: $UTCtime UTC" > R_time_tmp.pbm`; `pbmtext "Top Left Coords: $topLeft" > R_tL_tmp.pbm`; `pbmtext "Bottom Right Coords: $botRight" > R_bR_tmp.pbm`; `pbmtext "MET: $met " > R_met_tmp.pbm`; `pbmtext "Image Center Latitude: $lat " > R_lat_tmp.pbm`; `pbmtext "Image Center Longitude: $long " > R_long_tmp.pbm`; `pbmtext "Processed Scene Azimuth (km): $proAzimuth " > R_pA_tmp.pbm`; `pbmtext "Processed Scene Range (km): $proRange " > R_pR_tmp.pbm`; `pbmtext "Sensor Platform Heading (deg): $heading " > R_head_tmp.pbm`; `pbmtext "Incidence Angle: $angle " > R_angle_tmp.pbm`; `pbmtext "Product Type: $type " > R_type_tmp.pbm`; `pbmtext "Number Azimuth Looks: $numAzimuth " > R_nA_tmp.pbm`; `pbmtext "Number Range Looks: $numRange " > R_nR_tmp.pbm`; `pbmtext "Line Spacing (m): $line " > R_line_tmp.pbm`; `pbmtext "Pixel Spacing (m): $pixel " > R_pixel_tmp.pbm`; # build each of the three columns `pnmcat -white -tb -jleft R_day_tmp.pbm R_time_tmp.pbm R_tL_tmp.pbm R_bR_tmp.pbm R_head_tmp.pbm R_angle_tmp.pbm > R_c1_tmp.pbm`; `pnmcat -white -tb -jleft R_met_tmp.pbm R_lat_tmp.pbm R_long_tmp.pbm R_pR_tmp.pbm R_pA_tmp.pbm > R_c2_tmp.pbm`; `pnmcat -white -tb -jleft R_type_tmp.pbm R_nA_tmp.pbm R_nR_tmp.pbm R_pixel_tmp.pbm R_line_tmp.pbm > R_c3_tmp.pbm`; # put the three columns together `pnmcat -white -lr -jtop R_c1_tmp.pbm R_c2_tmp.pbm R_c3_tmp.pbm > R_BotTable.pbm`; `rm R_*_tmp.pbm`; print "Done getting information from trailer file... \n";