#!/usr/bin/env perl

use strict;

my $file = 'WG1_SE1_2021_074_15_28_03_0007_210731039_HWK2021073103810.L1A_SE1';
my @gmtopts = qw(-Jt0/1:984252 -R-3/34/4/44r);

my ($findex,$roll,$pitch,$yaw) = @ARGV;

system("gmt set PROJ_LENGTH_UNIT inch");
my ($w,$h) = map sprintf("%.2f",$_),split ' ',`gmt mapproject -W @gmtopts`;
my ($wid,$hgt) = map 100*$_,$w,$h;

system(join ' ',split ' ',<<"--")==0 or die;
/data1/www-data/oceancolor.gsfc.nasa.gov/src/finderpixcoords/finderpixcoords
$file
$findex $roll $pitch $yaw
| gmt mapproject @gmtopts -bi3f -bo3f
| gmt nearneighbor -Gtest.grd -I0.01
 -R0/$w/0/$h -N4 -S0.05 -r -bi3f;
gmt grd2xyz test.grd -ZTLH >test.dat;
convert -size ${wid}x$hgt -depth 16 GRAY:test.dat
 -transparent black -auto-level -evaluate log 10
/home/nkuring/oceanshare401/norman_kuring/Hawkeye/finder.png;
rm test.grd test.dat
--
