#!/usr/bin/perl
#
# Reformat a portion of the USNO B1.0 catalog, supplied by 
#    Vizier service.  We cut remove all information after
#    column 10 = Dec value, then we append the 
#    first Red magnitude (if that value is valid).
#
# In other words, we create a version with fewer columns, in which
#    column 11 always contains a valid magnitude.
#
# usage:        perl reformat_usnob1.pl  < input > output
#
# MWR 1/16/2009 
#

$debug = 0;

while (<STDIN>) {
  $line = $_;
  @words = split(/\s+/, $line);
  $start_line = substr($line, 0, 79);
  $redmag = substr($line, 124, 6);

  if ($debug > 0) {
    printf " red mag is %6.2f \n", $redmag;
  }

  # skip stars with invalid magnitudes
  if (($redmag < 1) || ($redmag > 30)) {
    next;
  }

  printf "%s %s \n", $start_line, $redmag;





}


exit 0;
