[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 737a0cd 046/113: Merged recent corrections in
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 737a0cd 046/113: Merged recent corrections in master branch |
Date: |
Fri, 16 Apr 2021 10:33:42 -0400 (EDT) |
branch: master
commit 737a0cd1f471b16177e30e945eb17f76940a81fe
Merge: 325d717 c876a2b
Author: Mohammad Akhlaghi <akhlaghi@gnu.org>
Commit: Mohammad Akhlaghi <akhlaghi@gnu.org>
Merged recent corrections in master branch
The two recent fixes in the master branch are now merged here.
---
bin/match/match.c | 4 +-
lib/match.c | 212 +++++++++++++++++++++++++++---------------------------
2 files changed, 109 insertions(+), 107 deletions(-)
diff --git a/bin/match/match.c b/bin/match/match.c
index 09260b1..403c625 100644
--- a/bin/match/match.c
+++ b/bin/match/match.c
@@ -96,7 +96,7 @@ match_catalog(struct matchparams *p)
{
match_catalog_write(p, p->input1name, p->cp.hdu, mcols->array,
nummatched, p->out1name, "INPUT_1");
- match_catalog_write(p, p->input2name, p->cp.hdu, mcols->next->array,
+ match_catalog_write(p, p->input2name, p->hdu2, mcols->next->array,
nummatched, p->out2name, "INPUT_2");
}
@@ -147,7 +147,7 @@ match_catalog(struct matchparams *p)
/* Print the number of matches if not in quiet mode. */
if(!p->cp.quiet)
- fprintf(stdout, "%zu", nummatched);
+ fprintf(stdout, "%zu\n", nummatched);
}
diff --git a/lib/match.c b/lib/match.c
index 2c7467b..d64373c 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -480,8 +480,8 @@ match_coordinates_second_in_first(gal_data_t *A, gal_data_t
*B,
redundant variables (those that equal a previous value) are only
defined to make it easy to read the code.*/
int iscircle=0;
- size_t ai, bi, blow, prevblow=0;
size_t i, ar=A->size, br=B->size;
+ size_t ai, bi, blow=0, prevblow=0;
size_t ndim=gal_list_data_number(A);
double r, c[3]={NAN, NAN, NAN}, s[3]={NAN, NAN, NAN};
double dist[3]={NAN, NAN, NAN}, delta[3]={NAN, NAN, NAN};
@@ -495,112 +495,114 @@ match_coordinates_second_in_first(gal_data_t *A,
gal_data_t *B,
in catalog b within the maximum distance. Note that both catalogs are
sorted by their first axis coordinate.*/
for(ai=0;ai<ar;++ai)
- {
- /* Initialize `bina'. */
- bina[ai]=NULL;
-
- /* Find the first (lowest first axis value) row/record in catalog `b'
- that is within the search radius for this record of catalog
- `a'. `blow' is the index of the first element to start searching
- in the catalog `b' for a match to `a[][ai]' (the record in catalog
- a that is currently being searched). `blow' is only based on the
- first coordinate, not the second.
-
- Both catalogs are sorted by their first coordinate, so the `blow'
- to search for the next record in catalog `a' will be larger or
- equal to that of the previous catalog `a' record. To account for
- possibly large distances between the records, we do a search here
- to change `blow' if necessary before doing further searching.*/
- for( blow=prevblow; blow<ar && b[0][blow] < a[0][ai]-dist[0]; ++blow)
- {/* This can be blank, the `for' does all we need :-). */}
-
-
- /* `blow' is now found for this `ai' and will be used unchanged to
- the end of the loop. So keep its value to help the search for the
- next entry in catalog `a'. */
- prevblow=blow;
-
-
- /* Go through catalog `b' (starting at `blow') with a first axis
- value smaller than the maximum acceptable range for `si'. */
- for( bi=blow; bi<br && b[0][bi] <= a[0][ai] + dist[0]; ++bi )
- {
- /* Only consider records with a second axis value in the
- correct range, note that unlike the first axis, the
- second axis is no longer sorted. so we have to do both
- lower and higher limit checks for each item.
-
- Positions can have an accuracy to a much higher order of
- magnitude than the search radius. Therefore, it is
- meaning-less to sort the second axis (after having sorted
- the first). In other words, very rarely can two first
- axis coordinates have EXACTLY the same floating point
- value as each other to easily define an independent
- sorting in the second axis. */
- if( ndim<2
- || ( b[1][bi] >= a[1][ai]-dist[1]
- && b[1][bi] <= a[1][ai]+dist[1] ) )
- {
- /* Now, `bi' is within the rectangular range of `ai'. But
- this is not enough to consider the two objects matched for
- the following reasons:
-
- 1) Until now we have avoided calculations other than
- larger or smaller on double precision floating point
- variables for efficiency. So the `bi' is within a
- square of side `dist[0]*dist[1]' around `ai' (not
- within a fixed radius).
-
- 2) Other objects in the `b' catalog may be closer to `ai'
- than this `bi'.
-
- 3) The closest `bi' to `ai' might be closer to another
- catalog `a' record.
-
- To address these problems, we will use a linked list to
- keep the indexes of the `b's near `ai', along with their
- distance. We only add the `bi's to this list that are
- within the acceptable distance.
-
- Since we are dealing with much fewer objects at this
- stage, it is justified to do complex mathematical
- operations like square root and multiplication. This fixes
- the first problem.
-
- The next two problems will be solved with the list after
- parsing of the whole catalog is complete.*/
- if( ndim<3
- || ( b[2][bi] >= a[2][ai]-dist[2]
- && b[2][bi] <= a[2][ai]+dist[2] ) )
- {
- for(i=0;i<ndim;++i) delta[i]=b[i][bi]-a[i][ai];
- r=match_coordinates_distance(delta, iscircle, ndim,
- aperture, c, s);
- if(r<aperture[0])
- match_coordinate_add_to_sfll(&bina[ai], bi, r);
- }
- }
- }
-
-
- /* If there was no objects within the acceptable distance, then the
- linked list pointer will be NULL, so go on to the next `ai'. */
- if(bina[ai]==NULL)
- continue;
-
- /* For checking the status of affairs uncomment this block
+ if(blow<br)
{
- struct match_coordinate_sfll *tmp;
- printf("\n\nai: %lu:\n", ai);
- printf("ax: %f (%f -- %f)\n", a[0][ai], a[0][ai]-dist[0],
- a[0][ai]+dist[0]);
- printf("ay: %f (%f -- %f)\n", a[1][ai], a[1][ai]-dist[1],
- a[1][ai]+dist[1]);
- for(tmp=bina[ai];tmp!=NULL;tmp=tmp->next)
- printf("%lu: %f\n", tmp->v, tmp->f);
+ /* Initialize `bina'. */
+ bina[ai]=NULL;
+
+ /* Find the first (lowest first axis value) row/record in catalog
+ `b' that is within the search radius for this record of catalog
+ `a'. `blow' is the index of the first element to start searching
+ in the catalog `b' for a match to `a[][ai]' (the record in
+ catalog a that is currently being searched). `blow' is only
+ based on the first coordinate, not the second.
+
+ Both catalogs are sorted by their first coordinate, so the
+ `blow' to search for the next record in catalog `a' will be
+ larger or equal to that of the previous catalog `a' record. To
+ account for possibly large distances between the records, we do
+ a search here to change `blow' if necessary before doing further
+ searching.*/
+ for( blow=prevblow; blow<br && b[0][blow] < a[0][ai]-dist[0]; ++blow)
+ { /* This can be blank, the `for' does all we need :-). */ }
+
+
+ /* `blow' is now found for this `ai' and will be used unchanged to
+ the end of the loop. So keep its value to help the search for
+ the next entry in catalog `a'. */
+ prevblow=blow;
+
+
+ /* Go through catalog `b' (starting at `blow') with a first axis
+ value smaller than the maximum acceptable range for `si'. */
+ for( bi=blow; bi<br && b[0][bi] <= a[0][ai] + dist[0]; ++bi )
+ {
+ /* Only consider records with a second axis value in the
+ correct range, note that unlike the first axis, the second
+ axis is no longer sorted. so we have to do both lower and
+ higher limit checks for each item.
+
+ Positions can have an accuracy to a much higher order of
+ magnitude than the search radius. Therefore, it is
+ meaning-less to sort the second axis (after having sorted
+ the first). In other words, very rarely can two first axis
+ coordinates have EXACTLY the same floating point value as
+ each other to easily define an independent sorting in the
+ second axis. */
+ if( ndim<2
+ || ( b[1][bi] >= a[1][ai]-dist[1]
+ && b[1][bi] <= a[1][ai]+dist[1] ) )
+ {
+ /* Now, `bi' is within the rectangular range of `ai'. But
+ this is not enough to consider the two objects matched
+ for the following reasons:
+
+ 1) Until now we have avoided calculations other than
+ larger or smaller on double precision floating point
+ variables for efficiency. So the `bi' is within a square
+ of side `dist[0]*dist[1]' around `ai' (not within a
+ fixed radius).
+
+ 2) Other objects in the `b' catalog may be closer to
+ `ai' than this `bi'.
+
+ 3) The closest `bi' to `ai' might be closer to another
+ catalog `a' record.
+
+ To address these problems, we will use a linked list to
+ keep the indexes of the `b's near `ai', along with their
+ distance. We only add the `bi's to this list that are
+ within the acceptable distance.
+
+ Since we are dealing with much fewer objects at this
+ stage, it is justified to do complex mathematical
+ operations like square root and multiplication. This
+ fixes the first problem.
+
+ The next two problems will be solved with the list after
+ parsing of the whole catalog is complete.*/
+ if( ndim<3
+ || ( b[2][bi] >= a[2][ai]-dist[2]
+ && b[2][bi] <= a[2][ai]+dist[2] ) )
+ {
+ for(i=0;i<ndim;++i) delta[i]=b[i][bi]-a[i][ai];
+ r=match_coordinates_distance(delta, iscircle, ndim,
+ aperture, c, s);
+ if(r<aperture[0])
+ match_coordinate_add_to_sfll(&bina[ai], bi, r);
+ }
+ }
+ }
+
+
+ /* If there was no objects within the acceptable distance, then the
+ linked list pointer will be NULL, so go on to the next `ai'. */
+ if(bina[ai]==NULL)
+ continue;
+
+ /* For checking the status of affairs uncomment this block
+ {
+ struct match_coordinate_sfll *tmp;
+ printf("\n\nai: %lu:\n", ai);
+ printf("ax: %f (%f -- %f)\n", a[0][ai], a[0][ai]-dist[0],
+ a[0][ai]+dist[0]);
+ printf("ay: %f (%f -- %f)\n", a[1][ai], a[1][ai]-dist[1],
+ a[1][ai]+dist[1]);
+ for(tmp=bina[ai];tmp!=NULL;tmp=tmp->next)
+ printf("%lu: %f\n", tmp->v, tmp->f);
+ }
+ */
}
- */
- }
}
- [gnuastro-commits] master e2aba57 083/113: Recent work in master imported, conflicts fixed, (continued)
- [gnuastro-commits] master e2aba57 083/113: Recent work in master imported, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master e92fd9c 039/113: Merged recent work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 54b099d 043/113: Neighbors options doc generalized for different dimensions, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 5cd3c1e 044/113: Recent work in master merged, small conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 1b0046b 051/113: Recent additions in master imported here, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master b1ea932 054/113: Separate Segment program now available in 3D, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master f537368 066/113: Segment's default 3D configuration file in tarball, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 133e277 071/113: Imported recent work from master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master a42ac37 085/113: Fixed MakeProfiles loop in checking radius values, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 1f9d941 090/113: Imported recent work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 737a0cd 046/113: Merged recent corrections in master branch,
Mohammad Akhlaghi <=
- [gnuastro-commits] master 486f915 067/113: Imported recent work in master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master d6051a1 074/113: Upperlimit magnitude in 3D, corrected creation of check table, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 5dac3c3 075/113: Recent work in master imported, small conflict in book fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 3882956 077/113: Narrow-band areas from MakeCatalog in 3D datasets, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master abe82cb 086/113: Imported recent work in master, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 924787b 098/113: Updated copyright year in files specific to this branch, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master fbbc2fc 100/113: Imported recent work in master, minor conflict fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 22d0fba 089/113: Imported recent work in master, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 8edc804 092/113: Imported recent work in master, minor conflic fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master b5385f7 093/113: Projected spectra given NaN when no measurement on slice, Mohammad Akhlaghi, 2021/04/16