& /htmlheader &> <& modelheader &> % my $sm_str = ", $sm" || '';
<& stamp_pager, rooturi => "?nn=$nn&sort=$sort&maxv=$maxv&minv=$minv&sm=$sm&min_dets=$min_dets&max_dets=$max_dets", limit => $limit, offset => $offset, found => $found, nostamp => $nostamp &> <& /htmlfooter &> <%args> $nn $limit => 500 $offset => 0 $sort => 'd' # 'd', 'v', 'q', 'p' allowed (digest, velocity, q, posang) $found => undef $minv => 0 $maxv => 20 $min_dets => 2 $max_dets => 2 $sm => 'nomd' $nostamp => undef # set to show no postage stamps %args> <%init> use Astro::Time; use PS::MOPS::DC::Orbit; use PS::MOPS::Lib qw(:all); use PS::MOPS::Constants qw(:all); use PS::MOPS::DC::Field; use PS::MOPS::DC::Tracklet; use PS::MOPS::DC::Known; #my $ISS_Q_THRESHOLD = 5.5; # don't submit with q > this my $ISS_Q_THRESHOLD = 99; # disabled, NASA/NEOO my $MPC_DIGEST_THRESHOLD = 20; # NEO digest threshold # XXX LD Put IASC outreach exposure names here. my %OUTREACH_MAP = $m->comp('/lib/outreach'); # If $offset and $inc are defined, use them for the mysql query. # Otherwise use $limit, then as a last resort, all of em. my $limit_str = ''; my $sort_str = ''; my $found_str = ''; if (defined($offset)) { $limit = 100 unless $limit; $limit_str = sprintf 'limit %d,%d', $offset, $limit; } else { $limit_str = $limit ? "limit $limit" : ''; } if ($sort eq 'q') { $sort_str = 'order by if(q is null,999,q)'; } elsif ($sort eq 'v') { $sort_str = 'order by v_tot desc'; } elsif ($sort eq 'va') { $sort_str = 'order by v_tot'; } elsif ($sort eq 'p') { $sort_str = 'order by pos_ang_deg'; } else { $sort_str = 'order by digest desc, v_tot desc'; } my $survey_mode_str = ''; if ($sm =~ /^MD/) { $survey_mode_str = "and (f.survey_mode like '$sm%')"; } elsif ($sm ne 'nomd') { $survey_mode_str = "and (f.survey_mode like '%$sm%')"; } else { $survey_mode_str = "and (not f.survey_mode like 'MD%')"; } my $utdate_str = mopslib_mjd2utctimestr($nn + 1); $utdate_str =~ s/T.*//; # trim everything after date $utdate_str .= 'UT'; if (!defined($found)) { $found_str = 'SQL_CALC_FOUND_ROWS'; } my $inst = $m->notes('INST'); my $dbname = $inst->dbname; my $model = $m->notes('MODEL'); my $dbh = $inst->dbh(); my $substh = $dbh->prepare(<<"SQL") or die $dbh->errstr; select disposition, desig, mpc_desig from export.mpc_sub where dbname=? and tracklet_id=? limit 1 SQL my $sql = <<"SQL"; select $found_str t.tracklet_id tracklet_id, t.digest digest, t.v_tot v_tot, t.pos_ang_deg pos_ang_deg, t.gcr_arcsec gcr_arcsec, t.probability probability, k.q q, k.known_name known_name, f.se_deg sol_elong, f.eb_deg ecl_lat, f.survey_mode, f.fpa_id from fields f join tracklets t ignore index(classification,known_id) using(field_id) join tracklet_attrib ta using(tracklet_id) join known k using(known_id) where f.nn = $nn and t.classification='N' $survey_mode_str and v_tot < $maxv group by t.tracklet_id having count(*) between $min_dets and $max_dets $sort_str $limit_str SQL my $sth = $dbh->prepare($sql) or die $dbh->errstr; $sth->execute() or die $sth->errstr; my @rows; my $href; while ($href = $sth->fetchrow_hashref()) { push @rows, $href; } $sth->finish(); if ($found_str) { ($found) = $dbh->selectrow_array("select FOUND_ROWS()"); } # Make a list of survey modes used. my @survey_modes_found = map { $_->[0] } modcf_retrieveSurveyModes($inst, nn => $nn); s/^\d+\.\w+\.\w\.// foreach @survey_modes_found; s/\.[PQ][12]$// foreach @survey_modes_found; %init>