Minor updates

pull/10/head
Cees Bassa 2015-04-16 09:31:57 +02:00
parent 7e2a488189
commit 7b75ff732e
6 changed files with 150 additions and 27 deletions

View File

@ -19,11 +19,11 @@ va_list arg_ptr;
vfprintf(stderr, format, arg_ptr);
va_end(arg_ptr);
fprintf(stderr, "\nNow terminating the program...\n");
fflush(stderr);
exit(5);
// fprintf(stderr, "\nNow terminating the program...\n");
// fflush(stderr);
// exit(5);
return;
}
/* ===================================================================== */

View File

@ -326,3 +326,35 @@
31797 2273.072
35951 2272.842
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

16
rffit.c
View File

@ -23,8 +23,8 @@ struct site {
} site;
struct point {
char timestamp[24];
double mjd,freq,v;
float t,f;
double mjd,freq,v,freq0;
float t,f,res;
float flux;
int flag,site_id,rsite_id;
struct site s,r;
@ -464,7 +464,7 @@ int main(int argc,char *argv[])
cpgbox("BCTSN",0.,0,"BTSN",0.,0);
// cpgenv(xmin,xmax,ymin,ymax,0,0);
cpglab(xlabel,ylabel,"");
// Plot orbit
if (satno>0 && plot_curve==1 && residuals==0) {
@ -512,17 +512,16 @@ int main(int argc,char *argv[])
cpgsci(1);
cpgsls(1);
}
}
}
// Plot selected points
for (i=0;i<d.n;i++) {
for (j=0;j<nsite;j++)
if (d.p[i].site_id==site_number[j])
break;
color=j+2;
style=17;
x=d.p[i].t;
y=d.p[i].f;
if (d.p[i].flag==1) {
@ -1421,7 +1420,8 @@ double compute_rms(void)
} else {
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);
n++;
}

116
rfplot.c
View File

@ -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 usage(void);
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)
{
@ -82,7 +151,7 @@ void filter(struct spectrogram s,int site_id)
else
mask[j]=0;
}
/*
// Find maximum when points are adjacent
for (j=0;j<s.nchan-1;j++) {
if (mask[j]==1 && mask[j+1]==1) {
@ -96,7 +165,7 @@ void filter(struct spectrogram s,int site_id)
mask[j]=0;
}
}
*/
// Mark points
for (j=0;j<s.nchan;j++) {
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_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;
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;
float dt,zzmax,s1,s2;
float dt,zzmax,s1,s2,z,za,sigma,zs,zm;
int ix=0,iy=0,isub=0;
int i0,j0,i1,j1,jmax;
float width=1500;
@ -294,7 +363,7 @@ int main(int argc,char *argv[])
cpgsci(7);
// Plot points
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
for (i=0;i<sel.n;i++) {
if (i==0)
@ -323,6 +392,14 @@ int main(int argc,char *argv[])
if (c=='q')
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
if (c=='s') {
sel.x[isel]=x;
@ -338,7 +415,7 @@ int main(int argc,char *argv[])
// Fit
if (c=='f') {
tf=locate_trace(s,sel,site_id);
tf=fit_trace(s,sel,site_id);
tf.site=site_id;
continue;
}
@ -468,16 +545,28 @@ int main(int argc,char *argv[])
for (i=i0;i<i1;i++) {
zzmax=0.0;
jmax=0;
s1=0.0;
s2=0.0;
sn=0;
for (j=j0;j<j1;j++) {
if (s.z[i+s.nsub*j]>zzmax) {
zzmax=s.z[i+s.nsub*j];
z=s.z[i+s.nsub*j];
if (z>zzmax) {
zzmax=z;
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;
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);
cpgpt1((float) i,(float) jmax,17);
cpgpt1((float) i,(float) jmax,17);
}
}
fclose(file);
}
@ -822,8 +911,8 @@ void plot_traces(struct trace *t,int nsat)
return;
}
// Locate trace
struct trace locate_trace(struct spectrogram s,struct select sel,int site_id)
// Fit trace
struct trace fit_trace(struct spectrogram s,struct select sel,int site_id)
{
int i,j,k,l,sn;
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;
}

View File

@ -192,7 +192,7 @@ void identify_trace(char *tlefile,struct trace t,int satno)
// Initialize
imode=init_sgdp4(&orb);
if (imode==SGDP4_ERROR)
printf("Error\n");
printf("SGDP4 Error\n");
// Loop over points
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].site=site_id;
t[j].n=m;
t[j].freq0=freq0;
t[j].mjd=(double *) malloc(sizeof(double)*m);
t[j].freq=(double *) malloc(sizeof(double)*m);
t[j].za=(float *) malloc(sizeof(float)*m);

View File

@ -1,7 +1,7 @@
struct trace {
int satno,n,site;
double *mjd;
double *freq;
double *freq,freq0;
float *za;
};
struct trace *compute_trace(char *tlefile,double *mjd,int n,int site_id,float fmin,float fmax,int *nsat);