commit
6063067c21
|
@ -22,6 +22,6 @@
|
|||
/rffft
|
||||
/rffind
|
||||
/rffit
|
||||
/rfinfo
|
||||
/rfplot
|
||||
/rfpng
|
||||
/rfinfo
|
6
dsmin.c
6
dsmin.c
|
@ -16,9 +16,6 @@ int dsmin(double **p,double *y,int n,double ftol,double (*func)(double *))
|
|||
double *vector_sum(double **,int);
|
||||
double dsmod(double **,double *,double *,int,double (*func)(double *),int,double);
|
||||
|
||||
// Allocate memory
|
||||
psum=(double *) malloc(sizeof(double) * n);
|
||||
|
||||
// Get function values
|
||||
for (i=0;i<=n;i++)
|
||||
y[i]=func(p[i]);
|
||||
|
@ -69,7 +66,8 @@ int dsmin(double **p,double *y,int n,double ftol,double (*func)(double *))
|
|||
}
|
||||
}
|
||||
nfunk+=n;
|
||||
|
||||
|
||||
free(psum);
|
||||
psum=vector_sum(p,n);
|
||||
}
|
||||
} else --nfunk;
|
||||
|
|
6
makefile
6
makefile
|
@ -17,10 +17,10 @@ all:
|
|||
make rfedit rfplot rffft rfpng rffit rffind rfdop
|
||||
|
||||
rffit: rffit.o sgdp4.o satutl.o deep.o ferror.o dsmin.o simplex.o versafit.o
|
||||
gfortran -o rffit rffit.o sgdp4.o satutl.o deep.o ferror.o dsmin.o simplex.o versafit.o $(LFLAGS)
|
||||
$(CC) -o rffit rffit.o sgdp4.o satutl.o deep.o ferror.o dsmin.o simplex.o versafit.o $(LFLAGS)
|
||||
|
||||
rfpng: rfpng.o rftime.o rfio.o rftrace.o sgdp4.o satutl.o deep.o ferror.o
|
||||
gfortran -o rfpng rfpng.o rftime.o rfio.o rftrace.o sgdp4.o satutl.o deep.o ferror.o $(LFLAGS)
|
||||
$(CC) -o rfpng rfpng.o rftime.o rfio.o rftrace.o sgdp4.o satutl.o deep.o ferror.o $(LFLAGS)
|
||||
|
||||
rfdop: rfdop.o rftrace.o rfio.o rftime.o sgdp4.o satutl.o deep.o ferror.o
|
||||
$(CC) -o rfdop rfdop.o rftrace.o rfio.o rftime.o sgdp4.o satutl.o deep.o ferror.o -lm
|
||||
|
@ -35,7 +35,7 @@ rftrack: rftrack.o rfio.o rftime.o rftrace.o sgdp4.o satutl.o deep.o ferror.o
|
|||
$(CC) -o rftrack rftrack.o rfio.o rftime.o rftrace.o sgdp4.o satutl.o deep.o ferror.o -lm
|
||||
|
||||
rfplot: rfplot.o rftime.o rfio.o rftrace.o sgdp4.o satutl.o deep.o ferror.o versafit.o dsmin.o simplex.o
|
||||
gfortran -o rfplot rfplot.o rftime.o rfio.o rftrace.o sgdp4.o satutl.o deep.o ferror.o versafit.o dsmin.o simplex.o $(LFLAGS)
|
||||
$(CC) -o rfplot rfplot.o rftime.o rfio.o rftrace.o sgdp4.o satutl.o deep.o ferror.o versafit.o dsmin.o simplex.o $(LFLAGS)
|
||||
|
||||
rffft: rffft.o rftime.o
|
||||
$(CC) -o rffft rffft.o rftime.o -lfftw3f -lm
|
||||
|
|
13
rffind.c
13
rffind.c
|
@ -213,6 +213,9 @@ int main(int argc,char *argv[])
|
|||
|
||||
// Filter
|
||||
filter(s,site_id,sigma,filename,graves);
|
||||
|
||||
// Free
|
||||
free_spectrogram(s);
|
||||
}
|
||||
} else {
|
||||
// Read data
|
||||
|
@ -225,14 +228,10 @@ int main(int argc,char *argv[])
|
|||
// Filter
|
||||
filter(s,site_id,sigma,filename,graves);
|
||||
}
|
||||
}
|
||||
|
||||
// Free
|
||||
free(s.z);
|
||||
free(s.mjd);
|
||||
// free(s.zavg);
|
||||
// free(s.zstd);
|
||||
// free(s.length);
|
||||
// Free
|
||||
free_spectrogram(s);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
52
rffit.c
52
rffit.c
|
@ -81,6 +81,8 @@ struct site get_site(int site_id)
|
|||
char *env,filename[LIM];
|
||||
|
||||
env=getenv("ST_DATADIR");
|
||||
if(env==NULL||strlen(env)==0)
|
||||
env=".";
|
||||
sprintf(filename,"%s/data/sites.txt",env);
|
||||
|
||||
file=fopen(filename,"r");
|
||||
|
@ -142,6 +144,7 @@ void format_tle(orbit_t orb,char *line1,char *line2)
|
|||
{
|
||||
int i,csum;
|
||||
char sbstar[]=" 00000-0",bstar[13];
|
||||
char csumstr[2];
|
||||
|
||||
// Format Bstar term
|
||||
if (fabs(orb.bstar)>1e-9) {
|
||||
|
@ -160,14 +163,16 @@ void format_tle(orbit_t orb,char *line1,char *line2)
|
|||
else if (line1[i]=='-')
|
||||
csum++;
|
||||
}
|
||||
sprintf(line1,"%s%d",line1,csum%10);
|
||||
sprintf(csumstr,"%d",csum%10);
|
||||
strcat(line1,csumstr);
|
||||
for (i=0,csum=0;i<strlen(line2);i++) {
|
||||
if (isdigit(line2[i]))
|
||||
csum+=line2[i]-'0';
|
||||
else if (line2[i]=='-')
|
||||
csum++;
|
||||
}
|
||||
sprintf(line2,"%s%d",line2,csum%10);
|
||||
sprintf(csumstr,"%d",csum%10);
|
||||
strcat(line2,csumstr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -291,7 +296,7 @@ int main(int argc,char *argv[])
|
|||
int site_id=4171;
|
||||
float xmin,xmax,ymin,ymax;
|
||||
float xminsel,xmaxsel,yminsel,ymaxsel;
|
||||
float x0,y0,x,y;
|
||||
float x0=0.0,y0=0.0,x=0.0,y=0.0;
|
||||
double mjd,v,v1,azi,alt,rms=0.0,day,mjdtca=56658.0,altmin=0.0;
|
||||
float t,f,vtca,foffset=0.0;
|
||||
char c,nfd[32]="2014-01-01T00:00:00";
|
||||
|
@ -316,6 +321,8 @@ int main(int argc,char *argv[])
|
|||
}
|
||||
|
||||
env=getenv("ST_DATADIR");
|
||||
if(env==NULL||strlen(env)==0)
|
||||
env=".";
|
||||
// Decode options
|
||||
while ((arg=getopt(argc,argv,"d:c:i:hs:gm:"))!=-1) {
|
||||
switch(arg) {
|
||||
|
@ -706,6 +713,8 @@ int main(int argc,char *argv[])
|
|||
// Flux limit
|
||||
if (c=='l') {
|
||||
env=getenv("ST_DATADIR");
|
||||
if(env==NULL||strlen(env)==0)
|
||||
env=".";
|
||||
sprintf(freqlist,"%s/data/frequencies.txt",env);
|
||||
fp=fopen(freqlist,"a");
|
||||
fprintf(fp,"%05d %lf\n",orb.satno,d.ffit/1000.0);
|
||||
|
@ -914,7 +923,7 @@ int main(int argc,char *argv[])
|
|||
}
|
||||
|
||||
// Invert selection
|
||||
if (c=='I') {
|
||||
if (c=='T') {
|
||||
for (i=0;i<d.n;i++) {
|
||||
if (d.p[i].flag==2)
|
||||
d.p[i].flag=1;
|
||||
|
@ -1053,7 +1062,40 @@ int main(int argc,char *argv[])
|
|||
|
||||
// Help
|
||||
if (c=='h') {
|
||||
printf("Usage:\n================================================================================\nq Quit\np Toggle curve plotting\n1 Toggle fitting parameter (Inclination)\n2 Toggle fitting parameter (RA of ascending node)\n3 Toggle fitting parameter (Eccentricity)\n4 Toggle fitting parameter (Argyment of perigee)\n5 Toggle fitting parameter (Mean anomaly)\n6 Toggle fitting parameter (Mean motion)\nc Change parameter\nm Move highlighted points in frequency\nl Select points on flux limit\nf Fit highlighted points\ng Get TLE from catalog\ni Identify satellite from catalog based on Doppler curve\nI Identify satellite from catalog based on visibility\nw Write present TLE\nR Reread TLE from catalog\nX Delete nearest point (right mouse button)\nz Start box to zoom\nd Start box to delete points\nA Zoom/delete points (left mouse button)\nh Highlight points in present window\nx Deselect all except highlighted\nI Invert selection\nD Delete highlighted points\ns Save highlighted points into file\nU Deselect all points\nu Deselect highlighted points\nt Load template tle\nr Reset zoom\nh This help\n================================================================================\n\n");
|
||||
printf("Usage:\n");
|
||||
printf("================================================================================\n");
|
||||
printf("q Quit\n");
|
||||
printf("p Toggle curve plotting\n");
|
||||
printf("1 Toggle fitting parameter (Inclination)\n");
|
||||
printf("2 Toggle fitting parameter (RA of ascending node)\n");
|
||||
printf("3 Toggle fitting parameter (Eccentricity)\n");
|
||||
printf("4 Toggle fitting parameter (Argyment of perigee)\n");
|
||||
printf("5 Toggle fitting parameter (Mean anomaly)\n");
|
||||
printf("6 Toggle fitting parameter (Mean motion)\n");
|
||||
printf("c Change parameter\n");
|
||||
printf("m Move highlighted points in frequency\n");
|
||||
printf("l Select points on flux limit\n");
|
||||
printf("f Fit highlighted points\n");
|
||||
printf("g Get TLE from catalog\n");
|
||||
printf("i Identify satellite from catalog based on Doppler curve\n");
|
||||
printf("I Identify satellite from catalog based on visibility\n");
|
||||
printf("w Write present TLE\n");
|
||||
printf("R Reread TLE from catalog\n");
|
||||
printf("X Delete nearest point (right mouse button)\n");
|
||||
printf("z Start box to zoom\n");
|
||||
printf("d Start box to delete points\n");
|
||||
printf("A Zoom/delete points (left mouse button)\n");
|
||||
printf("H Highlight points in present window\n");
|
||||
printf("x Deselect all except highlighted\n");
|
||||
printf("T Invert selection\n");
|
||||
printf("D Delete highlighted points\n");
|
||||
printf("s Save highlighted points into file\n");
|
||||
printf("U Deselect all points\n");
|
||||
printf("u Deselect highlighted points\n");
|
||||
printf("t Load template tle\n");
|
||||
printf("r Reset zoom\n");
|
||||
printf("h This help\n");
|
||||
printf("================================================================================\n\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
18
rfio.c
18
rfio.c
|
@ -148,10 +148,13 @@ struct spectrogram read_spectrogram(char *prefix,int isub,int nsub,double f0,dou
|
|||
}
|
||||
|
||||
// Scale last subint
|
||||
s.mjd[i]/=(float) nadd;
|
||||
if(nadd>0)
|
||||
{
|
||||
s.mjd[i]/=(float) nadd;
|
||||
|
||||
for (j=0;j<s.nchan;j++)
|
||||
s.z[i+s.nsub*j]/=(float) nadd;
|
||||
for (j=0;j<s.nchan;j++)
|
||||
s.z[i+s.nsub*j]/=(float) nadd;
|
||||
}
|
||||
|
||||
// Swap frequency range
|
||||
if (f0>0.0 && df0>0.0) {
|
||||
|
@ -238,3 +241,12 @@ void write_spectrogram(struct spectrogram s,char *prefix)
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
void free_spectrogram(struct spectrogram s)
|
||||
{
|
||||
free(s.z);
|
||||
free(s.zavg);
|
||||
free(s.zstd);
|
||||
free(s.mjd);
|
||||
free(s.length);
|
||||
}
|
||||
|
|
1
rfio.h
1
rfio.h
|
@ -9,3 +9,4 @@ struct spectrogram {
|
|||
};
|
||||
struct spectrogram read_spectrogram(char *prefix,int isub,int nsub,double f0,double df0,int nbin,double foff);
|
||||
void write_spectrogram(struct spectrogram s,char *prefix);
|
||||
void free_spectrogram(struct spectrogram s);
|
||||
|
|
3
rfplot.c
3
rfplot.c
|
@ -61,7 +61,7 @@ int main(int argc,char *argv[])
|
|||
int ix=0,iy=0,isub=0;
|
||||
int i0,j0,i1,j1,jmax;
|
||||
float width=1500;
|
||||
float x,y,x0,y0,yfit;
|
||||
float x=0.0,y=0.0,x0=0.0,y0=0.0,yfit;
|
||||
char c;
|
||||
char path[128],xlabel[128],ylabel[64],filename[32],tlefile[128];
|
||||
int sec,lsec,ssec;
|
||||
|
@ -767,6 +767,7 @@ int main(int argc,char *argv[])
|
|||
free(s.zavg);
|
||||
free(s.zstd);
|
||||
free(s.mjd);
|
||||
free(s.length);
|
||||
if (tf.n>0) {
|
||||
free(tf.mjd);
|
||||
free(tf.freq);
|
||||
|
|
3
rfpng.c
3
rfpng.c
|
@ -256,9 +256,6 @@ int main(int argc,char *argv[])
|
|||
free(t[i].freq);
|
||||
free(t[i].za);
|
||||
}
|
||||
// free(tf.mjd);
|
||||
// free(tf.freq);
|
||||
// free(tf.za);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
20
rftrace.c
20
rftrace.c
|
@ -124,6 +124,8 @@ struct site get_site(int site_id)
|
|||
char *env,filename[LIM];
|
||||
|
||||
env=getenv("ST_DATADIR");
|
||||
if(env==NULL||strlen(env)==0)
|
||||
env=".";
|
||||
sprintf(filename,"%s/data/sites.txt",env);
|
||||
|
||||
file=fopen(filename,"r");
|
||||
|
@ -181,6 +183,8 @@ void identify_trace_graves(char *tlefile,struct trace t,int satno)
|
|||
char *env,freqlist[LIM];
|
||||
|
||||
env=getenv("ST_DATADIR");
|
||||
if(env==NULL||strlen(env)==0)
|
||||
env=".";
|
||||
sprintf(freqlist,"%s/data/frequencies.txt",env);
|
||||
|
||||
// Reloop stderr
|
||||
|
@ -331,6 +335,8 @@ void identify_trace(char *tlefile,struct trace t,int satno)
|
|||
char tbuf[30];
|
||||
|
||||
env=getenv("ST_DATADIR");
|
||||
if(env==NULL||strlen(env)==0)
|
||||
env=".";
|
||||
sprintf(freqlist,"%s/data/frequencies.txt",env);
|
||||
|
||||
// Reloop stderr
|
||||
|
@ -448,6 +454,8 @@ int is_classified(int satno)
|
|||
|
||||
// Get classfd.tle path
|
||||
env=getenv("ST_TLEDIR");
|
||||
if(env==NULL||strlen(env)==0)
|
||||
env=".";
|
||||
sprintf(tlefile,"%s/classfd.tle",env);
|
||||
|
||||
// Does it exist
|
||||
|
@ -464,8 +472,8 @@ int is_classified(int satno)
|
|||
if (no==satno) flag=1;
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
@ -488,6 +496,8 @@ struct trace *compute_trace(char *tlefile,double *mjd,int n,int site_id,float fr
|
|||
double ra,de,azi,alt;
|
||||
|
||||
env=getenv("ST_DATADIR");
|
||||
if(env==NULL||strlen(env)==0)
|
||||
env=".";
|
||||
sprintf(freqlist,"%s/data/frequencies.txt",env);
|
||||
|
||||
// Frequency limits
|
||||
|
@ -502,7 +512,8 @@ struct trace *compute_trace(char *tlefile,double *mjd,int n,int site_id,float fr
|
|||
infile=fopen(freqlist,"r");
|
||||
if (infile==NULL) {
|
||||
printf("%s not found\n",freqlist);
|
||||
return t;
|
||||
*nsat=0;
|
||||
return NULL;
|
||||
} else {
|
||||
for (i=0;;) {
|
||||
if (fgetline(infile,line,LIM)<=0)
|
||||
|
@ -522,7 +533,10 @@ struct trace *compute_trace(char *tlefile,double *mjd,int n,int site_id,float fr
|
|||
}
|
||||
// Break out
|
||||
if (i==0)
|
||||
return t;
|
||||
{
|
||||
*nsat=0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Valid MJDs
|
||||
for (i=0;i<n;i++)
|
||||
|
|
10
simplex.c
10
simplex.c
|
@ -26,3 +26,13 @@ double **simplex(int n,double *a,double *da)
|
|||
return p;
|
||||
}
|
||||
|
||||
void simplex_free(double **p,int n)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(p==NULL)
|
||||
return;
|
||||
for(i=0;i<=n;i++)
|
||||
free(p[i]);
|
||||
free(p);
|
||||
}
|
||||
|
|
15
versafit.c
15
versafit.c
|
@ -9,6 +9,7 @@ int ERRCOMP=0; // Set reduced Chi-Squared to unity (1 = yes; 0 = no)
|
|||
|
||||
int dsmin(double **,double *,int,double,double (*func)(double *));
|
||||
double **simplex(int,double *,double *);
|
||||
void simplex_free(double **,int);
|
||||
double parabolic_root(double,double,double,double);
|
||||
|
||||
// Versafit fitting routine
|
||||
|
@ -51,6 +52,8 @@ void versafit(int m,int n,double *a,double *da,double (*func)(double *),double d
|
|||
a[i]/=(double) (n+1);
|
||||
}
|
||||
|
||||
simplex_free(p,n);
|
||||
|
||||
// Compute minimum
|
||||
chisqmin=func(a);
|
||||
|
||||
|
@ -109,6 +112,8 @@ void versafit(int m,int n,double *a,double *da,double (*func)(double *),double d
|
|||
}
|
||||
d[0]=parabolic_root(d[0],func(b),chisqmin,dchisq);
|
||||
|
||||
simplex_free(p,n);
|
||||
|
||||
if (fabs(chisqmin+dchisq-func(b))<tol) break;
|
||||
}
|
||||
|
||||
|
@ -131,6 +136,8 @@ void versafit(int m,int n,double *a,double *da,double (*func)(double *),double d
|
|||
}
|
||||
d[1]=parabolic_root(d[1],func(b),chisqmin,dchisq);
|
||||
|
||||
simplex_free(p,n);
|
||||
|
||||
if (fabs(chisqmin+dchisq-func(b))<tol) break;
|
||||
}
|
||||
da[i]=0.5*(fabs(d[0])+fabs(d[1]));
|
||||
|
@ -138,16 +145,16 @@ void versafit(int m,int n,double *a,double *da,double (*func)(double *),double d
|
|||
}
|
||||
}
|
||||
|
||||
free(b);
|
||||
free(db);
|
||||
|
||||
if (OUTPUT)
|
||||
for (i=0;i<n;i++)
|
||||
printf(" a(%i): %12.5f +- %9.5f\n",i+1,a[i],da[i]);
|
||||
}
|
||||
if (OUTPUT) printf("\nTotal number of iterations: %i\n",nfunk);
|
||||
|
||||
// free(p);
|
||||
// free(y);
|
||||
// free(b);
|
||||
// free(db);
|
||||
free(y);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue