IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42677


Ignore:
Timestamp:
May 1, 2024, 10:11:40 AM (2 years ago)
Author:
eugene
Message:

adding options to mpcorb_predict

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20230313/Ohana/src/tools/src/mpcorb_predict.c

    r42389 r42677  
    5151PlanetDatum mpcorb_predict (Planets *planet, double mjdObs, int FullCalc);
    5252
    53 Planets *mpcorb_read_text (char *filename, int *nplanets);
     53Planets *mpcorb_read_text (char *filename, int *nplanets, int noHeader);
    5454Planets *mpcorb_read_fits (char *filename, int *nplanets);
    5555void     mpcorb_save_fits (char *filename, Planets *planets, int Nplanets);
     
    7373
    7474int main (int argc, char **argv) {
     75
     76  if (get_argument (argc, argv, "-h")) goto usage;
     77  if (get_argument (argc, argv, "--help")) goto usage;
    7578
    7679  // XXX test
     
    8487    // load the planets
    8588    int Nplanets = 0;
    86     Planets *planets = mpcorb_read_text (filename, &Nplanets);
     89    Planets *planets = mpcorb_read_text (filename, &Nplanets, FALSE);
    8790    for (int i = 0; i < 10; i++) {
    8891      // if it is in the region, use the more accurate calculation
     
    9295  }
    9396
    94   if ((argc != 9) && (argc != 10)) goto usage;
    95 
     97  if (argc < 2) goto usage;
    9698  if (!strcasecmp (argv[1], "trange")) mpcorb_trange (argc, argv);
    9799  if (!strcasecmp (argv[1], "moment")) mpcorb_moment (argc, argv);
     
    99101usage:
    100102  fprintf (stderr, "USAGE: %s trange (MPCORB.DAT) (Tmin) (Tmax) (Rmin) (Rmax) (Dmin) (Dmax) (range.fits)\n", argv[0]);
    101   fprintf (stderr, "USAGE: %s moment (range.fits) (Tobs) (Rmin) (Rmax) (Dmin) (Dmax) (output)\n", argv[0]);
     103  fprintf (stderr, "USAGE: %s moment (range.fits) (Tobs) (Rmin) (Rmax) (Dmin) (Dmax) (output)\n\n", argv[0]);
    102104
    103105  fprintf (stderr, " trange : generate a table of asteroid orbital elements which fall within the region at Tmin or Tmax (in MJD)\n");
    104   fprintf (stderr, " moment : generate a table of asteroid positions which fall within the region at Tobs (in MJD)\n");
    105 
     106  fprintf (stderr, " moment : generate a table of asteroid positions which fall within the region at Tobs (in MJD)\n\n");
     107
     108  fprintf (stderr, " Tmin, Tmax, Tobs are in MJD; Rmin, Rmax, Dmin, Dmax are in decimal degrees\n");
     109  fprintf (stderr, " Orbital predictions are valid for the PS1 site\n");
     110
     111  fprintf (stderr, " trange options:\n");
     112  fprintf (stderr, " -no-header (for files other than MPCORB.DAT)\n");
     113  fprintf (stderr, " -min-obs (Nobs) : minimum number of observations to keep object\n");
     114  fprintf (stderr, " -min-opp (Nopp) : minimum number of oppositions to keep object\n");
    106115  exit (2);
    107116}
     
    110119void mpcorb_trange (int argc, char **argv) {
    111120
    112   if (argc != 10) Shutdown ("USAGE: %s trange (MPCORB.DAT) (Tmin) (Tmax) (Rmin) (Rmax) (Dmin) (Dmax) (range.fits)\n", argv[0]);
     121  int N;
     122 
     123  int noHeader = FALSE;
     124  if ((N = get_argument (argc, argv, "-no-header"))) {
     125    remove_argument (N, &argc, argv);
     126    noHeader = TRUE;
     127  }
     128  int MIN_OBS = 0;
     129  if ((N = get_argument (argc, argv, "-min-obs"))) {
     130    remove_argument (N, &argc, argv);
     131    MIN_OBS = atoi(argv[N]);
     132    remove_argument (N, &argc, argv);
     133  }
     134  int MIN_OPP = 0;
     135  if ((N = get_argument (argc, argv, "-min-opp"))) {
     136    remove_argument (N, &argc, argv);
     137    MIN_OPP = atoi(argv[N]);
     138    remove_argument (N, &argc, argv);
     139  }
     140
     141  if (argc != 10) Shutdown ("USAGE: %s trange (MPCORB.DAT) (Tmin) (Tmax) (Rmin) (Rmax) (Dmin) (Dmax) (range.fits) [-no-header] [-min-obs] [-min-opp]\n", argv[0]);
    113142
    114143  char  *filename = argv[2];
     
    122151
    123152  int Nplanets = 0;
    124   Planets *planets = mpcorb_read_text (filename, &Nplanets);
     153  Planets *planets = mpcorb_read_text (filename, &Nplanets, noHeader);
    125154  if (VERBOSE) fprintf (stderr, "loaded %d planets\n", Nplanets);
    126155
     
    133162    if (i % 1000 == 0) fprintf (stderr, ".");
    134163
    135     // XXX make these quality cuts user options
    136     if (SKIP_BAD && ((planets[i].Nobs < 20) || (planets[i].Nopp < 2))) continue;
     164    // skip poor-quality observations
     165    if (planets[i].Nobs < MIN_OBS) continue;
     166    if (planets[i].Nopp < MIN_OPP) continue;
    137167
    138168    // is the object in the region for the start of the period?
     
    804834
    805835// read the full MPCORB file, storing desired information in Planets structure
    806 Planets *mpcorb_read_text (char *filename, int *nplanets) {
     836Planets *mpcorb_read_text (char *filename, int *nplanets, int noHeader) {
    807837
    808838  ALLOCATE_PTR (buffer, char, NBYTE);
     
    838868
    839869      Nline ++;
    840       if ((Nline > 43) && (q - p > 5)) {
     870      int doParse = (noHeader || (Nline > 43));
     871      if (doParse && (q - p > 5)) {
    841872        mpcorb_parseline (p, &planets[Nplanets], Nbyte - offset);
     873        if ((Nplanets < 10) && DEBUG) fprintf (stderr, "object: %s", planets[Nplanets].ID);
    842874        Nplanets ++;
    843875        CHECK_REALLOCATE (planets, Planets, NPLANETS, Nplanets, 10000);
Note: See TracChangeset for help on using the changeset viewer.