IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34359


Ignore:
Timestamp:
Aug 25, 2012, 5:02:24 PM (14 years ago)
Author:
bills
Message:

add blank sources for gaps in ipp_idet. psphotStack no longer has sources for
all objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/listcmf

    r33967 r34359  
    9494}
    9595
     96my $flags_col;
     97my $flags2_col;
    9698
    9799my %extensions;
     
    225227    extend_incomplete_lines(\@lines, $total_cols, $ncols_previous);
    226228} else {
    227     print STDERR "no xfit extension found in $cmf\n" unless $xfit_ext;
     229    print STDERR "no xfit extension found in $cmf\n" if $verbose;
    228230}
    229231
    230232my $base = basename($cmf) ;
     233# data to be output for "missing" sources
     234my $null_line = "";
    231235{
    232236    print $oh "# cmf: $base       FILTER: $filter       ZPT: $zero_point       EXPTIME: $exp_time\n";
     
    235239
    236240    print $oh "IPP_IDET ";
     241    # Loop over columns and print out the header line and build $null_line
    237242    for (my $i = 1; $i < scalar @psf_cols; $i++) {
    238243        print $oh " $psf_cols[$i]_$filter";
     244        if ($i eq $flags_col) {
     245            # for no source set flags to zero
     246            $null_line .= '     0';
     247        } elsif ($i eq $flags2_col) {
     248            # for no source use PM_SOURCE_MODE2_DIFF_WITH_DOUBLE as a "no source" flag
     249            # isnan(X_PSF_$filter) also works but this should be faster to process
     250            $null_line .= '     2';
     251        } elsif ($i > 1) {
     252            # for other columns just print NULL which mana converts to nan
     253            # Note data for column 1, IPP_IDET == $linenum, is added for the null line below
     254            $null_line .= ' NULL';
     255        }
    239256    }
    240257    for (my $i = 0; $i < scalar @xsrc_cols; $i++) {
    241         print $oh " $xsrc_cols[$i]_$filter"
     258        print $oh " $xsrc_cols[$i]_$filter";
     259        $null_line .= ' NULL';
    242260    }
    243261    for (my $i = 0; $i < scalar @xfit_cols; $i++) {
    244262        print $oh " $xfit_cols[$i]_$filter";
     263        $null_line .= ' NULL';
    245264    }
    246265    print $oh "\n";
    247266}
    248267
    249 foreach my $line (@lines) {
     268my $num_lines = scalar @lines;
     269for (my $i = 1; $i < $num_lines; $i++) {
     270    my $line = $lines[$i];
     271    if (!$line) {
     272        # Add line for missing source
     273        $line = sprintf "%11d %s", $i, $null_line;
     274    }
    250275    print $oh "$line\n";
    251276}
     
    323348            # XXX TODO: check the format and insure that it is not a vector
    324349            # because we currently don't support them
     350            if ($name eq 'FLAGS') {
     351                # print STDERR "found flags in column $col\n";
     352                $flags_col = $col;
     353            }
     354            if ($name eq 'FLAGS2') {
     355                # print STDERR "found flags2 in column $col\n";
     356                $flags2_col = $col;
     357            }
    325358        }
    326359        push @$r_cols, $name;
     
    336369        # XXX: we are assuming here that the ids in a psf extension
    337370        # are sequential
    338         foreach my $line (@lines) {
     371        # foreach my $line (@lines) {
     372        my $num_lines = scalar @lines;
     373        for (my $i = 0; $i < $num_lines; $i++) {
     374            my $line = $lines[$i];
    339375            # id is first column
    340376            chomp $line;
    341377            my ($ipp_idet) = split " ", $line;
    342             push @$r_ids, $ipp_idet;
    343             push @$r_lines, $line;
     378#            push @$r_ids, $ipp_idet;
     379#            push @$r_lines, $line;
     380            $r_ids->[$ipp_idet] = $ipp_idet;
     381            $r_lines->[$ipp_idet] = $line;
    344382        }
    345383    } else {
    346         my $num_objects = scalar @$r_lines;
     384        my $num_lines = scalar @$r_lines;
    347385        foreach my $line (@lines) {
    348386            chomp $line;
    349387            my ($id, $rest_of_line) = identify_line($line);
    350             if ($id > $num_objects) {
    351                 die "TILT: id $id is greater than num objects\n";
     388            if ($id > $num_lines) {
     389#                die "TILT: id $id is greater than num objects\n";
    352390            }
    353391            # just append the line to this object's line
     
    374412    my $nprevious = shift;
    375413    for (my $i = 0; $i < scalar @$lines; $i++) {
     414        next if !$lines->[$i];
    376415        my @words = split " ", $lines->[$i];
    377416        my $nwords = scalar @words;
Note: See TracChangeset for help on using the changeset viewer.