/*************************************************************************** * * phase -- fold light curve to a particular period and epoch. * * usage: * phase period [epoch] < input > output * * Examples: * phase 1.28237982 output.pho * * Folds the light curve to a period of 0.061042 days, starting at * epoch 1813.1234 (same units as time in the input file). Output * is redirected to a second file as shown. * * Input Format: * hjd magnitude error * * Output Format: * hjd phase magnitude error * * The epoch for folding the light curve is taken to be first input time * unless the epoch is given, in the same units as time appears in the * data files, is given as the second command-line argument. * * based on phase.c by Donald Terndrup. * * Modified by R. Pogge, OSU Astronomy Dept. * pogge@astronomy.ohio-state.edu * 2000 Nov 10 * ***************************************************************************/ #include main(argc,argv) int argc; char *argv[]; { double period; double jd, jd0, floor(), temp; float mag, toterr, phase; float n; double epoch; /* parse the command line */ if (argc == 2) { sscanf(*++argv, "%lf", &period); } else if (argc == 3) { sscanf(*++argv, "%lf", &period); sscanf(*++argv, "%lf", &epoch); jd0 = -1.0; } else { printf("Usage: phase period [epoch] < input > output\n"); exit(1); } /* -- do the stuff -- */ n = 0; while (scanf ("%lf %f %f", &jd, &mag, &toterr) != EOF) { if (n == 0) { if (jd0 == -1.0) jd0 = epoch; else jd0 = jd; printf("Using period %10.6lf days, epoch %10.6lf\n", period,jd0); } temp = (jd - jd0) / period; phase = (temp - floor(temp)); printf ("%13.6f %12.8f %8.3f %8.3f\n", jd, phase, mag, toterr); n++; } }