#!/usr/bin/env perl

sub vsystem {
    print STDERR "@_\n";
    $status = system ("@_");
    $status;
}

sub goodbye {
    die "@_\n";
}

if (@ARGV != 2) { die "USAGE: darktime.cfht (image.exptime) (dark.exptime)\n" }

$t1 = $ARGV[0];
$t2 = $ARGV[1];

$a = 0.000781480;
$b = 5.45879e-06;
$c = -1.21674e-09;

$d1 = $a*$t1 + $b*$t1**2 + $c*$t1**3;

$d2 = $a*$t2 + $b*$t2**2 + $c*$t2**3;

$f = $d1 / $d2;

# no dark correction for exptime < 15 sec
if ($t1 < 15) { $f = 0.001; }

print STDOUT "$f\n";

exit 0;
