<%args>
$field_id
$imgtype => 'png'
$leetle => 0
$hilightobj => undef
$hilightdet  => undef
$show_known => 0
</%args>

<%init>
my $model = $m->notes('MODEL');
my %typemap = (
    epsc => 'application/postscript',
    eps => 'application/postscript',
    png => 'image/png',
);

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

my $title = "MOPS SSM Detections, Field ID $field_id";
my $leetle_str;
my $show_known_str = $show_known ? '--mpcheck' : '';

$leetle_str = '--leetle' if ($leetle);
#my $cmd = qq{obsTool --instance $model $leetle_str --detections --plot $show_known_str --$imgtype --title "$title" $field_id};
my $cmd = qq{fieldplot $model $field_id};
$cmd .= " --hilightobj $hilightobj" if $hilightobj;
$cmd .= " --hilightdet $hilightdet" if $hilightdet;
my $stuff = join '', `$cmd`;
$m->clear_buffer;
$m->print($stuff);
$m->abort;
</%init>
