#!/usr/bin/env perl

use strict;

my $file = 'WG1_SE1_2021_019_15_46_10_0004_203441542_HWK2020344154113.L1A_SE1';
my @gmtopts = qw(-Jt-78/1:984252 -R-81/18/-75/28r);

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
--
