Add semi-automatic image calibration (work in progress)
This commit is contained in:
parent
cc0e0c0bff
commit
1116220455
37
plotfits.c
37
plotfits.c
|
@ -337,7 +337,7 @@ void identify_triangles(struct catalog *cat, struct catalog *ast, int *nselect,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// if last time a suitable reference triangle was found
|
// if last time a suitable reference triangle was found
|
||||||
if(*nselect==3){
|
if(*nselect>=3){
|
||||||
// and also a match was found
|
// and also a match was found
|
||||||
if(nmatch==3){
|
if(nmatch==3){
|
||||||
// this time search for another match beginning with the following 3rd star
|
// this time search for another match beginning with the following 3rd star
|
||||||
|
@ -370,7 +370,7 @@ void identify_triangles(struct catalog *cat, struct catalog *ast, int *nselect,
|
||||||
#endif
|
#endif
|
||||||
// Search candidate for 1st star
|
// Search candidate for 1st star
|
||||||
|
|
||||||
for(s1=tricat[0];(*nselect<3) && (s1 < cat->n);s1++){
|
for(s1=tricat[0];(*nselect<3) && (s1 <= cat->n);s1++){
|
||||||
// discard if outside high magnitude range
|
// discard if outside high magnitude range
|
||||||
r=cat->mag[s1];
|
r=cat->mag[s1];
|
||||||
if(r > mave){
|
if(r > mave){
|
||||||
|
@ -403,7 +403,7 @@ void identify_triangles(struct catalog *cat, struct catalog *ast, int *nselect,
|
||||||
fprintf(stdout,"Looking for 2nd star of triangle.\n");
|
fprintf(stdout,"Looking for 2nd star of triangle.\n");
|
||||||
#endif
|
#endif
|
||||||
// Search candidate for 2nd star
|
// Search candidate for 2nd star
|
||||||
for(s2=tricat[1];(*nselect<3) && (s2 < cat->n);s2++){
|
for(s2=tricat[1];(*nselect<3) && (s2 <= cat->n);s2++){
|
||||||
// discard candidate if outside magnitude range
|
// discard candidate if outside magnitude range
|
||||||
r=cat->mag[s2];
|
r=cat->mag[s2];
|
||||||
if(r > mave){
|
if(r > mave){
|
||||||
|
@ -444,7 +444,7 @@ void identify_triangles(struct catalog *cat, struct catalog *ast, int *nselect,
|
||||||
fprintf(stdout,"Looking for 3rd star of triangle.\n");
|
fprintf(stdout,"Looking for 3rd star of triangle.\n");
|
||||||
#endif
|
#endif
|
||||||
// Search candidate for 3rd star beginning from the last candidate found
|
// Search candidate for 3rd star beginning from the last candidate found
|
||||||
for(s3=tricat[2];(*nselect<3) && (s3 < cat->n);s3++){
|
for(s3=tricat[2];(*nselect<3) && (s3 <= cat->n);s3++){
|
||||||
// discard candidate if outside magnitude range
|
// discard candidate if outside magnitude range
|
||||||
r=cat->mag[s3];
|
r=cat->mag[s3];
|
||||||
if(r > mave){
|
if(r > mave){
|
||||||
|
@ -505,9 +505,13 @@ void identify_triangles(struct catalog *cat, struct catalog *ast, int *nselect,
|
||||||
// also magnitude difference between stars of astrometric cat should closely match magn diff between stars of img cat.
|
// also magnitude difference between stars of astrometric cat should closely match magn diff between stars of img cat.
|
||||||
// a tolerance for this magnitude match is given and should not be high (0.5 magn)
|
// a tolerance for this magnitude match is given and should not be high (0.5 magn)
|
||||||
|
|
||||||
|
//persiste un problema con la identificacion de triangulos y el fit
|
||||||
|
//el fit da mal con el segundo triangulo pero da bien con el cuarto que es el mismo triangulo con el orden de 2da y 3er estrellas intercambiadas
|
||||||
|
|
||||||
|
|
||||||
nmatch=0;
|
nmatch=0;
|
||||||
// Search for candidate 1st match star
|
// Search for candidate 1st match star
|
||||||
for(m1=triast[0];((nmatch<3) && (m1<ast->n));m1++){
|
for(m1=triast[0];((nmatch<3) && (m1<=ast->n));m1++){
|
||||||
// discard if outside magnitude tolerance
|
// discard if outside magnitude tolerance
|
||||||
// this tolerance includes magnitude extraction tolerance on sextractor tool
|
// this tolerance includes magnitude extraction tolerance on sextractor tool
|
||||||
r=fabs(cat->mag[s1] - ast->mag[m1]);
|
r=fabs(cat->mag[s1] - ast->mag[m1]);
|
||||||
|
@ -525,7 +529,7 @@ void identify_triangles(struct catalog *cat, struct catalog *ast, int *nselect,
|
||||||
triast[0]=m1;
|
triast[0]=m1;
|
||||||
nmatch=1;
|
nmatch=1;
|
||||||
// Search candidate for 2nd star
|
// Search candidate for 2nd star
|
||||||
for(m2=triast[1];(nmatch<3) && (m2<ast->n);m2++){
|
for(m2=triast[1];(nmatch<3) && (m2<=ast->n);m2++){
|
||||||
// magn difference between star 1 and star 2 should be very close to magn diff between matching star 1 and matching star 2
|
// magn difference between star 1 and star 2 should be very close to magn diff between matching star 1 and matching star 2
|
||||||
// discard if difference is outside match tolerance
|
// discard if difference is outside match tolerance
|
||||||
r=fabs(cat->mag[s2] - cat->mag[s1]);
|
r=fabs(cat->mag[s2] - cat->mag[s1]);
|
||||||
|
@ -590,7 +594,7 @@ void identify_triangles(struct catalog *cat, struct catalog *ast, int *nselect,
|
||||||
// Search candidate for 2nd star
|
// Search candidate for 2nd star
|
||||||
// start from the following star that was found as viable candidate last time
|
// start from the following star that was found as viable candidate last time
|
||||||
// this allows for selecting a new match each time operator launches auto-calibrate
|
// this allows for selecting a new match each time operator launches auto-calibrate
|
||||||
for(m3=triast[2];(nmatch<3) && (m3<ast->n);m3++){
|
for(m3=triast[2];(nmatch<3) && (m3<=ast->n);m3++){
|
||||||
// discard if magn difference is outside match tolerance
|
// discard if magn difference is outside match tolerance
|
||||||
r=fabs(cat->mag[s3] - cat->mag[s1]);
|
r=fabs(cat->mag[s3] - cat->mag[s1]);
|
||||||
if((r - fabs(ast->mag[m3] - ast->mag[m1])) > MAGMATCHTOL){
|
if((r - fabs(ast->mag[m3] - ast->mag[m1])) > MAGMATCHTOL){
|
||||||
|
@ -661,17 +665,21 @@ void identify_triangles(struct catalog *cat, struct catalog *ast, int *nselect,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if no triangle selected we will try next 2nd star and try again all possible 3rd stars
|
// if no triangle selected we will try next 2nd star and try again all possible 3rd stars
|
||||||
if(*nselect<3) tricat[2]=0;
|
if(*nselect<3){
|
||||||
|
tricat[2]=0;
|
||||||
#if DEBUG>2
|
#if DEBUG>2
|
||||||
fprintf(stdout,"Try next 2nd star.\n");
|
fprintf(stdout,"Try next 2nd star.\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// if no triangle selected we will try next 1st star and try again all possible 2nd stars
|
// if no triangle selected we will try next 1st star and try again all possible 2nd stars
|
||||||
if(*nselect<3) tricat[1]=0;
|
if(*nselect<3){
|
||||||
|
tricat[1]=0;
|
||||||
#if DEBUG>2
|
#if DEBUG>2
|
||||||
fprintf(stdout,"Try next 1st star.\n");
|
fprintf(stdout,"Try next 1st star.\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// at this point either found 3 candidate stars or already tried all candidate stars without success
|
// at this point either found 3 candidate stars or already tried all candidate stars without success
|
||||||
// if loop continues will look for smaller triangles and accept higher magnitudes next iteration
|
// if loop continues will look for smaller triangles and accept higher magnitudes next iteration
|
||||||
if(*nselect<3){
|
if(*nselect<3){
|
||||||
|
@ -799,7 +807,6 @@ int main(int argc,char *argv[])
|
||||||
zmin=img.zmin;
|
zmin=img.zmin;
|
||||||
zmax=img.zmax;
|
zmax=img.zmax;
|
||||||
|
|
||||||
|
|
||||||
// For ever loop
|
// For ever loop
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (redraw==1) {
|
if (redraw==1) {
|
||||||
|
@ -957,18 +964,24 @@ int main(int argc,char *argv[])
|
||||||
identify_triangles(&cat,&ast,&nselect,tricat,triast);
|
identify_triangles(&cat,&ast,&nselect,tricat,triast);
|
||||||
// if match was found mark stars into selected fields of catalogs
|
// if match was found mark stars into selected fields of catalogs
|
||||||
if((nselect >=3) && (triast[2] > 0)){
|
if((nselect >=3) && (triast[2] > 0)){
|
||||||
|
// erase prior selection first
|
||||||
|
for (i=0;i<cat.n;i++) {
|
||||||
|
cat.select[i]=0;
|
||||||
|
}
|
||||||
|
for (i=0;i<ast.n;i++) {
|
||||||
|
ast.select[i]=0;
|
||||||
|
}
|
||||||
cat.select[tricat[0]]=1;
|
cat.select[tricat[0]]=1;
|
||||||
cat.select[tricat[1]]=2;
|
cat.select[tricat[1]]=2;
|
||||||
cat.select[tricat[2]]=3;
|
cat.select[tricat[2]]=3;
|
||||||
ast.select[triast[0]]=1;
|
ast.select[triast[0]]=1;
|
||||||
ast.select[triast[1]]=2;
|
ast.select[triast[1]]=2;
|
||||||
ast.select[triast[2]]=3;
|
ast.select[triast[2]]=3;
|
||||||
|
nselect=3;
|
||||||
}
|
}
|
||||||
redraw=1;
|
redraw=1;
|
||||||
click=1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Plot identified stars
|
// Plot identified stars
|
||||||
if (c=='p') {
|
if (c=='p') {
|
||||||
if (plotstars==1)
|
if (plotstars==1)
|
||||||
|
|
Loading…
Reference in a new issue