From f536a2ab193b70c09ced6a1f6830874b7a56e297 Mon Sep 17 00:00:00 2001 From: Edward Zhang Date: Sun, 22 Oct 2023 11:36:05 -0700 Subject: [PATCH 1/4] Potential (minor) bug fix, refactor --- src/io.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/io.cpp b/src/io.cpp index 6646f8e4..b2965a8a 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -101,12 +101,13 @@ const Catalog &CatalogRead() { std::sort(catalog.begin(), catalog.end(), [](const CatalogStar &a, const CatalogStar &b) { return a.spatial.x < b.spatial.x; }); - for (int i = catalog.size(); i > 0; i--) { + for (int i = catalog.size()-1; i > 0; i--) { // [BUG]? catalog[catalog.size()] is invalid if ((catalog[i].spatial - catalog[i-1].spatial).Magnitude() < 5e-5) { // 70 stars removed at this threshold. if (catalog[i].magnitude > catalog[i-1].magnitude) { - catalog.erase(catalog.begin() + i); - } else { + // [BUG]? If mag of i > mag of i-1, we want to keep i? Here we remove i catalog.erase(catalog.begin() + i - 1); + } else { + catalog.erase(catalog.begin() + i); } } } From db2210708e08ce3457d7eedb0f52074001f5bc44 Mon Sep 17 00:00:00 2001 From: Edward Zhang Date: Sun, 22 Oct 2023 11:36:46 -0700 Subject: [PATCH 2/4] smol refactor --- src/databases.hpp | 4 ++-- src/star-id.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/databases.hpp b/src/databases.hpp index c8337c11..f33d6643 100644 --- a/src/databases.hpp +++ b/src/databases.hpp @@ -14,7 +14,7 @@ const int32_t kCatalogMagicValue = 0xF9A283BC; /** * A data structure enabling constant-time range queries into fixed numerical data. - * + * * @note Not an instantiable database on its own -- used in other databases */ // TODO: QueryConservative, QueryExact, QueryTrapezoidal? @@ -114,7 +114,7 @@ class MultiDatabaseEntry { std::vector bytes; }; -typedef std::vector MultiDatabaseDescriptor; +using MultiDatabaseDescriptor = std::vector; void SerializeMultiDatabase(SerializeContext *, const MultiDatabaseDescriptor &dbs); diff --git a/src/star-id.cpp b/src/star-id.cpp index b0787313..93cd38d2 100644 --- a/src/star-id.cpp +++ b/src/star-id.cpp @@ -32,7 +32,7 @@ StarIdentifiers GeometricVotingStarIdAlgorithm::Go( StarIdentifiers identified; MultiDatabase multiDatabase(database); const unsigned char *databaseBuffer = multiDatabase.SubDatabasePointer(PairDistanceKVectorDatabase::kMagicValue); - if (databaseBuffer == NULL) { + if (databaseBuffer == nullptr) { return identified; } DeserializeContext des(databaseBuffer); @@ -173,7 +173,7 @@ class PairDistanceInvolvingIterator { * If another PairDistanceInvolvingIterator is equal to this, then it is done iterating. */ PairDistanceInvolvingIterator() - : pairs(NULL), end(NULL) { }; + : pairs(nullptr), end(nullptr) { }; /** * The main constructor. @@ -252,7 +252,7 @@ std::vector ConsumeInvolvingIterator(PairDistanceInvolvingIterator it) /** * Given the result of a pair-distance kvector query, build a hashmultimap of stars to other stars * that appeared with it in the query. - * + * * The resulting map is "symmetrical" in the sense that if a star B is in the map for star A, then * star A is also in the map for star B. */ @@ -447,7 +447,7 @@ IRUnidentifiedCentroid *SelectNextUnidentifiedCentroid(std::vector maxMismatchProbability) { - std::cout << "skip: mismatch prob." << std::endl; + std::cerr << "skip: mismatch prob." << std::endl; continue; } From 9ddbed2fd5b7311161a58e04cd132e20a5b63046 Mon Sep 17 00:00:00 2001 From: Edward Zhang Date: Sun, 22 Oct 2023 11:37:13 -0700 Subject: [PATCH 3/4] Edit pipeline man page, move commands out of Misc --- documentation/pipeline.man | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/documentation/pipeline.man b/documentation/pipeline.man index 9ff82016..efd1ccbf 100644 --- a/documentation/pipeline.man +++ b/documentation/pipeline.man @@ -1,4 +1,4 @@ -.TH PIPELINE 3 "06 November 2021" +.TH PIPELINE 3 "06 November 2021" .SH NAME @@ -88,21 +88,6 @@ The field of view of the camera that took the picture (in degrees). Defaults to .SH MISC PIPELINE OPTIONS -.TP -\fB--centroid-mag-filter\fP \fImin-mag\fP -Will not consider centroids with magnitude below \fImin-mag\fP. - -.TP -\fB--centroid-filter-brightest\fP \fInum-stars\fP -Remove all but the brightest \fInum-stars\fP many stars from the list of centroids before sending to -star-id. Often a better choice than \fB--centroid-mag-filter\fP, because you can ensure that you -keep enough stars to do star-id. If both this option and \fB--centroid-mag-filter\fP are provided, -then all stars satisfying both criteria are kept (intersection). - -.TP -\fB--database\fP \fIfilename\fP -Chooses \fIfilename\fP as the database to use during star identification. - .TP \fB--help\fI Prints the contents of the manual entry for the command to the terminal. @@ -117,12 +102,27 @@ Runs the \fIalgo\fP centroiding algorithm. Recognized options are: dummy (random \fB--centroid-dummy-stars\fP \fInum-stars\fP Runs the dummy centroiding algorithm (random centroid algorithm) with \fInum-stars\fP stars centroided. Defaults to 5 if option is not selected. +.TP +\fB--centroid-mag-filter\fP \fImin-mag\fP +Argument is optional. Will not consider centroids with magnitude below \fImin-mag\fP. + +.TP +\fB--centroid-filter-brightest\fP \fInum-stars\fP +Argument is optional. Remove all but the brightest \fInum-stars\fP many stars from the list of centroids before sending to +star-id. Often a better choice than \fB--centroid-mag-filter\fP, because you can ensure that you +keep enough stars to do star-id. If both this option and \fB--centroid-mag-filter\fP are provided, +then all stars satisfying both criteria are kept (intersection). + .SH STAR IDENTIFICATION OPTIONS .TP \fB--star-id-algo\fP \fIalgo\fP Runs the \fIalgo\fP star identification algorithm. Current options are "dummy", "gv", and "pyramid". Defaults to "dummy" if option is not selected. +.TP +\fB--database\fP \fIfilename\fP +Chooses \fIfilename\fP as the database to use during star identification. + .TP \fB--angular-tolerance\fP [\fItolerance\fP] Sets the estimated angular centroiding error tolerance, used in some star id algorithms, to \fItolerance\fP degrees. Defaults to 0.04 degrees. From bebab20505ae12acc6ac92dab3e438519640c078 Mon Sep 17 00:00:00 2001 From: Edward Zhang Date: Sun, 22 Oct 2023 13:51:06 -0700 Subject: [PATCH 4/4] fix iterator erase-read conflict --- src/io.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/io.cpp b/src/io.cpp index b2965a8a..e366a8ab 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -97,15 +97,22 @@ const Catalog &CatalogRead() { char *tsvPath = getenv("LOST_BSC_PATH"); catalog = BscParse(tsvPath ? tsvPath : DEFAULT_BSC_PATH); // perform essential narrowing - // remove all stars with exactly the same position as another, keeping the one with brighter magnitude + // remove all stars with exactly the same position as another, keeping the one with brighter + // magnitude std::sort(catalog.begin(), catalog.end(), [](const CatalogStar &a, const CatalogStar &b) { - return a.spatial.x < b.spatial.x; + if (a.spatial.x != b.spatial.x) { + return a.spatial.x < b.spatial.x; + } else if (a.spatial.y != b.spatial.y) { + return a.spatial.y < b.spatial.y; + } + return a.spatial.z < b.spatial.z; }); - for (int i = catalog.size()-1; i > 0; i--) { // [BUG]? catalog[catalog.size()] is invalid - if ((catalog[i].spatial - catalog[i-1].spatial).Magnitude() < 5e-5) { // 70 stars removed at this threshold. - if (catalog[i].magnitude > catalog[i-1].magnitude) { - // [BUG]? If mag of i > mag of i-1, we want to keep i? Here we remove i + for (int i = catalog.size() - 1; i > 0; i--) { // [BUG]? catalog[catalog.size()] is invalid + if ((catalog[i].spatial - catalog[i - 1].spatial).Magnitude() < 5e-5) { // 70 stars removed at this threshold. + if (catalog[i].magnitude > catalog[i - 1].magnitude) { + // [BUG]? If mag of i > mag of i-1, we want to keep i, not i-1 catalog.erase(catalog.begin() + i - 1); + i--; } else { catalog.erase(catalog.begin() + i); }