Changeset 34359
- Timestamp:
- Aug 25, 2012, 5:02:24 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/tools/listcmf (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/listcmf
r33967 r34359 94 94 } 95 95 96 my $flags_col; 97 my $flags2_col; 96 98 97 99 my %extensions; … … 225 227 extend_incomplete_lines(\@lines, $total_cols, $ncols_previous); 226 228 } 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; 228 230 } 229 231 230 232 my $base = basename($cmf) ; 233 # data to be output for "missing" sources 234 my $null_line = ""; 231 235 { 232 236 print $oh "# cmf: $base FILTER: $filter ZPT: $zero_point EXPTIME: $exp_time\n"; … … 235 239 236 240 print $oh "IPP_IDET "; 241 # Loop over columns and print out the header line and build $null_line 237 242 for (my $i = 1; $i < scalar @psf_cols; $i++) { 238 243 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 } 239 256 } 240 257 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'; 242 260 } 243 261 for (my $i = 0; $i < scalar @xfit_cols; $i++) { 244 262 print $oh " $xfit_cols[$i]_$filter"; 263 $null_line .= ' NULL'; 245 264 } 246 265 print $oh "\n"; 247 266 } 248 267 249 foreach my $line (@lines) { 268 my $num_lines = scalar @lines; 269 for (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 } 250 275 print $oh "$line\n"; 251 276 } … … 323 348 # XXX TODO: check the format and insure that it is not a vector 324 349 # 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 } 325 358 } 326 359 push @$r_cols, $name; … … 336 369 # XXX: we are assuming here that the ids in a psf extension 337 370 # 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]; 339 375 # id is first column 340 376 chomp $line; 341 377 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; 344 382 } 345 383 } else { 346 my $num_ objects = scalar @$r_lines;384 my $num_lines = scalar @$r_lines; 347 385 foreach my $line (@lines) { 348 386 chomp $line; 349 387 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"; 352 390 } 353 391 # just append the line to this object's line … … 374 412 my $nprevious = shift; 375 413 for (my $i = 0; $i < scalar @$lines; $i++) { 414 next if !$lines->[$i]; 376 415 my @words = split " ", $lines->[$i]; 377 416 my $nwords = scalar @words;
Note:
See TracChangeset
for help on using the changeset viewer.
