Minor updates
parent
7e2a488189
commit
7b75ff732e
8
ferror.c
8
ferror.c
|
@ -19,11 +19,11 @@ va_list arg_ptr;
|
||||||
vfprintf(stderr, format, arg_ptr);
|
vfprintf(stderr, format, arg_ptr);
|
||||||
va_end(arg_ptr);
|
va_end(arg_ptr);
|
||||||
|
|
||||||
fprintf(stderr, "\nNow terminating the program...\n");
|
// fprintf(stderr, "\nNow terminating the program...\n");
|
||||||
fflush(stderr);
|
// fflush(stderr);
|
||||||
|
|
||||||
exit(5);
|
|
||||||
|
|
||||||
|
// exit(5);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===================================================================== */
|
/* ===================================================================== */
|
||||||
|
|
|
@ -326,3 +326,35 @@
|
||||||
31797 2273.072
|
31797 2273.072
|
||||||
35951 2272.842
|
35951 2272.842
|
||||||
19822 2279.984
|
19822 2279.984
|
||||||
|
39462 2242.505
|
||||||
|
35951 2253.531
|
||||||
|
35951 2254.555
|
||||||
|
05560 2242.534
|
||||||
|
39088 2243.334
|
||||||
|
26958 2243.013
|
||||||
|
40555 2280.006
|
||||||
|
35938 2281.725
|
||||||
|
35938 2280.701
|
||||||
|
39210 2280.006
|
||||||
|
27858 2232.711
|
||||||
|
37849 2235.445
|
||||||
|
39768 2235.006
|
||||||
|
37391 2234.069
|
||||||
|
24753 2235.450
|
||||||
|
33434 2245.995
|
||||||
|
38248 2246.006
|
||||||
|
33434 2245.995
|
||||||
|
33434 2245.995
|
||||||
|
29522 2249.423
|
||||||
|
39630 2247.384
|
||||||
|
35951 2249.436
|
||||||
|
35951 2247.388
|
||||||
|
39630 2246.361
|
||||||
|
39630 2248.409
|
||||||
|
39630 2249.433
|
||||||
|
40143 2248.555
|
||||||
|
40298 2271.604
|
||||||
|
25789 2264.989
|
||||||
|
25476 2264.857
|
||||||
|
40588 2215.993
|
||||||
|
23802 2264.978
|
||||||
|
|
8
rffit.c
8
rffit.c
|
@ -23,8 +23,8 @@ struct site {
|
||||||
} site;
|
} site;
|
||||||
struct point {
|
struct point {
|
||||||
char timestamp[24];
|
char timestamp[24];
|
||||||
double mjd,freq,v;
|
double mjd,freq,v,freq0;
|
||||||
float t,f;
|
float t,f,res;
|
||||||
float flux;
|
float flux;
|
||||||
int flag,site_id,rsite_id;
|
int flag,site_id,rsite_id;
|
||||||
struct site s,r;
|
struct site s,r;
|
||||||
|
@ -513,7 +513,6 @@ int main(int argc,char *argv[])
|
||||||
cpgsls(1);
|
cpgsls(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plot selected points
|
// Plot selected points
|
||||||
for (i=0;i<d.n;i++) {
|
for (i=0;i<d.n;i++) {
|
||||||
for (j=0;j<nsite;j++)
|
for (j=0;j<nsite;j++)
|
||||||
|
@ -1421,7 +1420,8 @@ double compute_rms(void)
|
||||||
} else {
|
} else {
|
||||||
f=(1.0-v/C)*d.ffit;
|
f=(1.0-v/C)*d.ffit;
|
||||||
}
|
}
|
||||||
|
d.p[i].freq0=f;
|
||||||
|
d.p[i].res=d.p[i].freq-f;
|
||||||
rms+=pow(d.p[i].freq-f,2);
|
rms+=pow(d.p[i].freq-f,2);
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
116
rfplot.c
116
rfplot.c
|
@ -20,7 +20,76 @@ void dec2sex(double x,char *s,int f,int len);
|
||||||
void time_axis(double *mjd,int n,float xmin,float xmax,float ymin,float ymax);
|
void time_axis(double *mjd,int n,float xmin,float xmax,float ymin,float ymax);
|
||||||
void usage(void);
|
void usage(void);
|
||||||
void plot_traces(struct trace *t,int nsat);
|
void plot_traces(struct trace *t,int nsat);
|
||||||
struct trace locate_trace(struct spectrogram s,struct select sel,int site_id);
|
struct trace fit_trace(struct spectrogram s,struct select sel,int site_id);
|
||||||
|
|
||||||
|
// Fit trace
|
||||||
|
struct trace locate_trace(struct spectrogram s,struct trace t,int site_id)
|
||||||
|
{
|
||||||
|
int i,j,k,l,sn,w=100.0;
|
||||||
|
int i0,i1,j0,j1,jmax;
|
||||||
|
double f,fmin;
|
||||||
|
float x,y,s1,s2,z,za,zs,zm,sigma;
|
||||||
|
FILE *file;
|
||||||
|
char filename[64];
|
||||||
|
|
||||||
|
sprintf(filename,"track_%05d_%08.3f.dat",t.satno,t.freq0);
|
||||||
|
|
||||||
|
// Open file
|
||||||
|
file=fopen(filename,"a");
|
||||||
|
|
||||||
|
fmin=(s.freq-0.5*s.samp_rate)*1e-6;
|
||||||
|
|
||||||
|
// Loop over trace
|
||||||
|
for (i=0;i<t.n;i++) {
|
||||||
|
// Skip when satellite is below the horizon
|
||||||
|
if (t.za[i]>90.0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Compute position
|
||||||
|
y=(t.freq[i]-fmin)*s.nchan/(s.samp_rate*1e-6);
|
||||||
|
j0=(int) floor(y-w);
|
||||||
|
j1=(int) floor(y+w);
|
||||||
|
|
||||||
|
// Keep in range
|
||||||
|
if (j0<0)
|
||||||
|
j0=0;
|
||||||
|
if (j1>=s.nchan)
|
||||||
|
j1=s.nchan;
|
||||||
|
|
||||||
|
// Find maximum and significance
|
||||||
|
zm=0.0;
|
||||||
|
jmax=0;
|
||||||
|
s1=0.0;
|
||||||
|
s2=0.0;
|
||||||
|
sn=0;
|
||||||
|
for (j=j0;j<j1;j++) {
|
||||||
|
z=s.z[i+s.nsub*j];
|
||||||
|
s1+=z;
|
||||||
|
s2+=z*z;
|
||||||
|
sn++;
|
||||||
|
if (z>zm) {
|
||||||
|
zm=z;
|
||||||
|
jmax=j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
za=s1/(float) sn;
|
||||||
|
zs=sqrt(s2/(float) sn-za*za);
|
||||||
|
sigma=(zm-za)/zs;
|
||||||
|
|
||||||
|
// Store
|
||||||
|
if (sigma>5.0 && s.mjd[i]>1.0) {
|
||||||
|
f=s.freq-0.5*s.samp_rate+(double) jmax*s.samp_rate/(double) s.nchan;
|
||||||
|
fprintf(file,"%lf %lf %f %d\n",s.mjd[i],f,sigma,site_id);
|
||||||
|
cpgpt1((float) i,(float) jmax,17);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close file
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void filter(struct spectrogram s,int site_id)
|
void filter(struct spectrogram s,int site_id)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +151,7 @@ void filter(struct spectrogram s,int site_id)
|
||||||
else
|
else
|
||||||
mask[j]=0;
|
mask[j]=0;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
// Find maximum when points are adjacent
|
// Find maximum when points are adjacent
|
||||||
for (j=0;j<s.nchan-1;j++) {
|
for (j=0;j<s.nchan-1;j++) {
|
||||||
if (mask[j]==1 && mask[j+1]==1) {
|
if (mask[j]==1 && mask[j+1]==1) {
|
||||||
|
@ -96,7 +165,7 @@ void filter(struct spectrogram s,int site_id)
|
||||||
mask[j]=0;
|
mask[j]=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// Mark points
|
// Mark points
|
||||||
for (j=0;j<s.nchan;j++) {
|
for (j=0;j<s.nchan;j++) {
|
||||||
if (mask[j]==1) {
|
if (mask[j]==1) {
|
||||||
|
@ -123,9 +192,9 @@ int main(int argc,char *argv[])
|
||||||
float cool_g[]={0.0,0.0,0.0,1.0,1.0,1.0,0.6,0.0,1.0};
|
float cool_g[]={0.0,0.0,0.0,1.0,1.0,1.0,0.6,0.0,1.0};
|
||||||
float cool_b[]={0.0,0.3,0.8,1.0,0.3,0.0,0.0,0.0,1.0};
|
float cool_b[]={0.0,0.3,0.8,1.0,0.3,0.0,0.0,0.0,1.0};
|
||||||
float xmin,xmax,ymin,ymax,zmin,zmax=8.0;
|
float xmin,xmax,ymin,ymax,zmin,zmax=8.0;
|
||||||
int i,j,k,flag=0,isel=0;
|
int i,j,k,flag=0,isel=0,sn;
|
||||||
int redraw=1,mode=0,posn=0,click=0;
|
int redraw=1,mode=0,posn=0,click=0;
|
||||||
float dt,zzmax,s1,s2;
|
float dt,zzmax,s1,s2,z,za,sigma,zs,zm;
|
||||||
int ix=0,iy=0,isub=0;
|
int ix=0,iy=0,isub=0;
|
||||||
int i0,j0,i1,j1,jmax;
|
int i0,j0,i1,j1,jmax;
|
||||||
float width=1500;
|
float width=1500;
|
||||||
|
@ -294,7 +363,7 @@ int main(int argc,char *argv[])
|
||||||
cpgsci(7);
|
cpgsci(7);
|
||||||
// Plot points
|
// Plot points
|
||||||
for (i=0;i<sel.n;i++)
|
for (i=0;i<sel.n;i++)
|
||||||
cpgpt1(sel.x[i],sel.y[i],17);
|
cpgpt1(sel.x[i],sel.y[i],4);
|
||||||
// Plot upper bound
|
// Plot upper bound
|
||||||
for (i=0;i<sel.n;i++) {
|
for (i=0;i<sel.n;i++) {
|
||||||
if (i==0)
|
if (i==0)
|
||||||
|
@ -323,6 +392,14 @@ int main(int argc,char *argv[])
|
||||||
if (c=='q')
|
if (c=='q')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Track
|
||||||
|
if (c=='t') {
|
||||||
|
for (i=0;i<nsat;i++) {
|
||||||
|
printf("Locating trace for object %05d\n",t[i].satno);
|
||||||
|
locate_trace(s,t[i],4171);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Select start
|
// Select start
|
||||||
if (c=='s') {
|
if (c=='s') {
|
||||||
sel.x[isel]=x;
|
sel.x[isel]=x;
|
||||||
|
@ -338,7 +415,7 @@ int main(int argc,char *argv[])
|
||||||
|
|
||||||
// Fit
|
// Fit
|
||||||
if (c=='f') {
|
if (c=='f') {
|
||||||
tf=locate_trace(s,sel,site_id);
|
tf=fit_trace(s,sel,site_id);
|
||||||
tf.site=site_id;
|
tf.site=site_id;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -468,16 +545,28 @@ int main(int argc,char *argv[])
|
||||||
for (i=i0;i<i1;i++) {
|
for (i=i0;i<i1;i++) {
|
||||||
zzmax=0.0;
|
zzmax=0.0;
|
||||||
jmax=0;
|
jmax=0;
|
||||||
|
s1=0.0;
|
||||||
|
s2=0.0;
|
||||||
|
sn=0;
|
||||||
for (j=j0;j<j1;j++) {
|
for (j=j0;j<j1;j++) {
|
||||||
if (s.z[i+s.nsub*j]>zzmax) {
|
z=s.z[i+s.nsub*j];
|
||||||
zzmax=s.z[i+s.nsub*j];
|
if (z>zzmax) {
|
||||||
|
zzmax=z;
|
||||||
jmax=j;
|
jmax=j;
|
||||||
}
|
}
|
||||||
|
s1+=z;
|
||||||
|
s2+=z*z;
|
||||||
|
sn++;
|
||||||
}
|
}
|
||||||
|
za=s1/(float) sn;
|
||||||
|
zs=sqrt(s2/(float) sn-za*za);
|
||||||
|
sigma=(zzmax-za)/zs;
|
||||||
|
|
||||||
f=s.freq-0.5*s.samp_rate+(double) jmax*s.samp_rate/(double) s.nchan;
|
f=s.freq-0.5*s.samp_rate+(double) jmax*s.samp_rate/(double) s.nchan;
|
||||||
if (s.mjd[i]>1.0)
|
if (sigma>5.0 && s.mjd[i]>1.0) {
|
||||||
fprintf(file,"%lf %lf %f %d\n",s.mjd[i],f,zzmax,site_id);
|
fprintf(file,"%lf %lf %f %d\n",s.mjd[i],f,zzmax,site_id);
|
||||||
cpgpt1((float) i,(float) jmax,17);
|
cpgpt1((float) i,(float) jmax,17);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
@ -822,8 +911,8 @@ void plot_traces(struct trace *t,int nsat)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locate trace
|
// Fit trace
|
||||||
struct trace locate_trace(struct spectrogram s,struct select sel,int site_id)
|
struct trace fit_trace(struct spectrogram s,struct select sel,int site_id)
|
||||||
{
|
{
|
||||||
int i,j,k,l,sn;
|
int i,j,k,l,sn;
|
||||||
int i0,i1,j0,j1,jmax;
|
int i0,i1,j0,j1,jmax;
|
||||||
|
@ -895,3 +984,4 @@ struct trace locate_trace(struct spectrogram s,struct select sel,int site_id)
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ void identify_trace(char *tlefile,struct trace t,int satno)
|
||||||
// Initialize
|
// Initialize
|
||||||
imode=init_sgdp4(&orb);
|
imode=init_sgdp4(&orb);
|
||||||
if (imode==SGDP4_ERROR)
|
if (imode==SGDP4_ERROR)
|
||||||
printf("Error\n");
|
printf("SGDP4 Error\n");
|
||||||
|
|
||||||
// Loop over points
|
// Loop over points
|
||||||
for (i=0,sum1=0.0,sum2=0.0;i<t.n;i++) {
|
for (i=0,sum1=0.0,sum2=0.0;i<t.n;i++) {
|
||||||
|
@ -350,6 +350,7 @@ struct trace *compute_trace(char *tlefile,double *mjd,int n,int site_id,float fr
|
||||||
t[j].satno=satno;
|
t[j].satno=satno;
|
||||||
t[j].site=site_id;
|
t[j].site=site_id;
|
||||||
t[j].n=m;
|
t[j].n=m;
|
||||||
|
t[j].freq0=freq0;
|
||||||
t[j].mjd=(double *) malloc(sizeof(double)*m);
|
t[j].mjd=(double *) malloc(sizeof(double)*m);
|
||||||
t[j].freq=(double *) malloc(sizeof(double)*m);
|
t[j].freq=(double *) malloc(sizeof(double)*m);
|
||||||
t[j].za=(float *) malloc(sizeof(float)*m);
|
t[j].za=(float *) malloc(sizeof(float)*m);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
struct trace {
|
struct trace {
|
||||||
int satno,n,site;
|
int satno,n,site;
|
||||||
double *mjd;
|
double *mjd;
|
||||||
double *freq;
|
double *freq,freq0;
|
||||||
float *za;
|
float *za;
|
||||||
};
|
};
|
||||||
struct trace *compute_trace(char *tlefile,double *mjd,int n,int site_id,float fmin,float fmax,int *nsat);
|
struct trace *compute_trace(char *tlefile,double *mjd,int n,int site_id,float fmin,float fmax,int *nsat);
|
||||||
|
|
Loading…
Reference in New Issue