<%args>
$nn
</%args>

<%init>
#use File::Slurp;
#use File::Temp qw/tempfile/;
use PS::MOPS::Lib qw(:all);
my $imgtype = 'png';
my %typemap = (
    png => 'image/png',
);
my $model = $m->notes('MODEL');
my $inst = $m->notes('INST');
my $mjd = mopslib_nn2mjd($nn, $inst->getConfig()->{site}->{gmt_offset_hours});

die "bogus image type: $imgtype" unless exists($typemap{$imgtype});
$r->content_type($typemap{$imgtype});

my $stuff = join '', `catFields --instance=$model --date_mjd=$mjd |  miniPlot --size 300x150 --terminal $imgtype --sun --moon`;
$m->clear_buffer;
$m->print($stuff);
$m->abort;
</%init>
