From 39f9972751c505449dfcea0a4cd366e9d6329cf5 Mon Sep 17 00:00:00 2001 From: Cees Bassa Date: Thu, 1 Mar 2018 17:15:04 +0100 Subject: [PATCH] Bug in angles expecting degrees, getting arcseconds --- makefile | 8 ++++---- residuals.c | 24 ++++++++++++++++++++++++ satfit.c | 30 +++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/makefile b/makefile index 24a5a56..cb3c54f 100644 --- a/makefile +++ b/makefile @@ -112,8 +112,8 @@ faketle: faketle.o sgdp4.o satutl.o deep.o ferror.o imgstat: imgstat.o $(CC) -o imgstat imgstat.o -lm -lqfits -satfit: satfit.o sgdp4.o satutl.o deep.o ferror.o versafit.o dsmin.o simplex.o forward.o - $(F77) -o satfit satfit.o sgdp4.o satutl.o deep.o ferror.o versafit.o dsmin.o simplex.o forward.o $(LFLAGS) +satfit: satfit.o sgdp4.o satutl.o deep.o ferror.o versafit.o dsmin.o simplex.o + $(F77) -o satfit satfit.o sgdp4.o satutl.o deep.o ferror.o versafit.o dsmin.o simplex.o $(LFLAGS) uk2iod: uk2iod.o $(CC) -o uk2iod uk2iod.o -lm @@ -124,8 +124,8 @@ rde2iod: rde2iod.o stviewer: stviewer.o $(CC) -o stviewer stviewer.o -lm -lqfits -residuals: residuals.o sgdp4.o satutl.o deep.o ferror.o forward.o - $(CC) -o residuals residuals.o sgdp4.o satutl.o deep.o ferror.o forward.o -lm -lwcs +residuals: residuals.o sgdp4.o satutl.o deep.o ferror.o + $(CC) -o residuals residuals.o sgdp4.o satutl.o deep.o ferror.o -lm -lwcs tleinfo: tleinfo.o sgdp4.o satutl.o deep.o ferror.o $(CC) -o tleinfo tleinfo.o sgdp4.o satutl.o deep.o ferror.o -lm diff --git a/residuals.c b/residuals.c index 4b0e36f..f737012 100644 --- a/residuals.c +++ b/residuals.c @@ -566,3 +566,27 @@ struct data read_data(char *filename) return d; } +// Get a x and y from a RA and Decl +void forward(double ra0,double de0,double ra,double de,double *x,double *y) +{ + int i,status; + double phi,theta; + struct celprm cel; + + // Initialize Reference Angles + celini(&cel); + cel.ref[0]=ra0; + cel.ref[1]=de0; + cel.ref[2]=999.; + cel.ref[3]=999.; + cel.flag=0.; + strcpy(cel.prj.code,"TAN"); + + if (celset(&cel)) { + printf("Error in Projection (celset)\n"); + return; + } + cels2x(&cel,1,0,1,1,&ra,&de,&phi,&theta,x,y,&status); + + return; +} diff --git a/satfit.c b/satfit.c index 263b8fc..d0aeb42 100644 --- a/satfit.c +++ b/satfit.c @@ -1486,7 +1486,8 @@ double chisq(double a[]) r=sqrt(dx*dx+dy*dy+dz*dz); d.p[i].rac=modulo(atan2(dy,dx)*R2D,360.0); d.p[i].dec=asin(dz/r)*R2D; - + + // Compute offset forward(d.p[i].ra,d.p[i].de,d.p[i].rac,d.p[i].dec,&d.p[i].dx,&d.p[i].dy); d.p[i].dr=sqrt(d.p[i].dx*d.p[i].dx+d.p[i].dy*d.p[i].dy); @@ -1937,3 +1938,30 @@ orbit_t rv2el(int satno,double mjd,xyz_t r0,xyz_t v0) return orb[i]; } + + +// Get a x and y from a RA and Decl +void forward(double ra0,double de0,double ra,double de,double *x,double *y) +{ + int i,status; + double phi,theta; + struct celprm cel; + + // Initialize Reference Angles + celini(&cel); + cel.ref[0]=ra0; + cel.ref[1]=de0; + cel.ref[2]=999.; + cel.ref[3]=999.; + cel.flag=0.; + strcpy(cel.prj.code,"STG"); + + if (celset(&cel)) { + printf("Error in Projection (celset)\n"); + return; + } + cels2x(&cel,1,0,1,1,&ra,&de,&phi,&theta,x,y,&status); + + return; +} +