#!/usr/bin/perl
#
# Grab a few select columns of data from big AIJ photometry file
#
#    usage:  grab_cols.pl   file.csv
#
# MWR 3/24/2022

$debug = 0;

if ($#ARGV != 0) {
  printf "usage: grab_cols.pl   file.csv \n";
  exit 1;
}
$infile = $ARGV[0];
if ($debug > 0) {
  printf " reading data from file %s \n", $infile;
}

$num_obs = 0;
open(INFILE, "$infile") || die("can't open $infile");
while (<INFILE>) {
  $line = $_;
  @words = split(/,/, $line);
  if ($words[1] eq "Label") {
    next;
  }

  $slice = $words[2];
  $jd = $words[5];
  $inten_t1 = $words[37];
  $uncert_t1 = $words[40];
  $inten_c2 = $words[52];
  $uncert_c2 = $words[53];
  $inten_c3 = $words[67];
  $uncert_c3 = $words[68];
  $inten_c4 = $words[82];
  $uncert_c4 = $words[83];
  $inten_c5 = $words[97];
  $uncert_c5 = $words[98];

 
  if ($debug > -1) {
    printf " num %4d  slice %4d  JD %12.5f  ", $num_obs, $slice, $jd;
    printf "  t1  %8.0f %7.0f  ", $inten_t1, $uncert_t1;
    printf "  c2  %8.0f %7.0f  ", $inten_c2, $uncert_c2;
    printf "  c3  %8.0f %7.0f  ", $inten_c3, $uncert_c3;
    printf "  c4  %8.0f %7.0f  ", $inten_c4, $uncert_c4;
    printf "  c5  %8.0f %7.0f  ", $inten_c5, $uncert_c5;
    printf " \n";
  }




  $num_obs++;
}
close(INFILE);




exit 0;



