Changeset 42677
- Timestamp:
- May 1, 2024, 10:11:40 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20230313/Ohana/src/tools/src/mpcorb_predict.c
r42389 r42677 51 51 PlanetDatum mpcorb_predict (Planets *planet, double mjdObs, int FullCalc); 52 52 53 Planets *mpcorb_read_text (char *filename, int *nplanets );53 Planets *mpcorb_read_text (char *filename, int *nplanets, int noHeader); 54 54 Planets *mpcorb_read_fits (char *filename, int *nplanets); 55 55 void mpcorb_save_fits (char *filename, Planets *planets, int Nplanets); … … 73 73 74 74 int main (int argc, char **argv) { 75 76 if (get_argument (argc, argv, "-h")) goto usage; 77 if (get_argument (argc, argv, "--help")) goto usage; 75 78 76 79 // XXX test … … 84 87 // load the planets 85 88 int Nplanets = 0; 86 Planets *planets = mpcorb_read_text (filename, &Nplanets );89 Planets *planets = mpcorb_read_text (filename, &Nplanets, FALSE); 87 90 for (int i = 0; i < 10; i++) { 88 91 // if it is in the region, use the more accurate calculation … … 92 95 } 93 96 94 if ((argc != 9) && (argc != 10)) goto usage; 95 97 if (argc < 2) goto usage; 96 98 if (!strcasecmp (argv[1], "trange")) mpcorb_trange (argc, argv); 97 99 if (!strcasecmp (argv[1], "moment")) mpcorb_moment (argc, argv); … … 99 101 usage: 100 102 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]); 102 104 103 105 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"); 106 115 exit (2); 107 116 } … … 110 119 void mpcorb_trange (int argc, char **argv) { 111 120 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]); 113 142 114 143 char *filename = argv[2]; … … 122 151 123 152 int Nplanets = 0; 124 Planets *planets = mpcorb_read_text (filename, &Nplanets );153 Planets *planets = mpcorb_read_text (filename, &Nplanets, noHeader); 125 154 if (VERBOSE) fprintf (stderr, "loaded %d planets\n", Nplanets); 126 155 … … 133 162 if (i % 1000 == 0) fprintf (stderr, "."); 134 163 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; 137 167 138 168 // is the object in the region for the start of the period? … … 804 834 805 835 // read the full MPCORB file, storing desired information in Planets structure 806 Planets *mpcorb_read_text (char *filename, int *nplanets ) {836 Planets *mpcorb_read_text (char *filename, int *nplanets, int noHeader) { 807 837 808 838 ALLOCATE_PTR (buffer, char, NBYTE); … … 838 868 839 869 Nline ++; 840 if ((Nline > 43) && (q - p > 5)) { 870 int doParse = (noHeader || (Nline > 43)); 871 if (doParse && (q - p > 5)) { 841 872 mpcorb_parseline (p, &planets[Nplanets], Nbyte - offset); 873 if ((Nplanets < 10) && DEBUG) fprintf (stderr, "object: %s", planets[Nplanets].ID); 842 874 Nplanets ++; 843 875 CHECK_REALLOCATE (planets, Planets, NPLANETS, Nplanets, 10000);
Note:
See TracChangeset
for help on using the changeset viewer.
