Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Cees Bassa committed Sep 22, 2018
1 parent eb5e510 commit 9629bf1
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions rfpng.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct select {
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);
void plot_traces(struct trace *t,int nsat,float foff);
void filter(struct spectrogram s,int site_id,float sigma,char *filename,int graves);

int main(int argc,char *argv[])
Expand All @@ -43,7 +43,7 @@ int main(int argc,char *argv[])
float dt,zzmax,s1,s2;
int ix=0,iy=0,isub=0;
int i0,j0,i1,j1,jmax;
float width=1500,sigma=5.0;
float width=1500,sigma=5.0,foff=0.0;
float x,y,x0,y0;
char c;
char path[128],xlabel[64],ylabel[64],filename[32],tlefile[128],pngfile[128],datfile[128];
Expand All @@ -58,7 +58,7 @@ int main(int argc,char *argv[])
int nsat,satno;
struct select sel;
char *env;
int site_id=0,cmap=2,graves=0;
int site_id=0,cmap=2,graves=0,create_dat=1,fname_flag=1;

// Get site
env=getenv("ST_COSPAR");
Expand All @@ -72,13 +72,22 @@ int main(int argc,char *argv[])

// Read arguments
if (argc>1) {
while ((arg=getopt(argc,argv,"p:f:w:s:l:b:z:hc:C:m:gS:"))!=-1) {
while ((arg=getopt(argc,argv,"p:f:w:s:l:b:z:hc:C:m:gS:qo:O:"))!=-1) {
switch (arg) {

case 'p':
strcpy(path,optarg);
break;

case 'o':
strcpy(pngfile,optarg);
fname_flag=0;
break;

case 'O':
foff=atof(optarg);
break;

case 's':
isub=atoi(optarg);
break;
Expand Down Expand Up @@ -111,6 +120,10 @@ int main(int argc,char *argv[])
sigma=atof(optarg);
break;

case 'q':
create_dat=0;
break;

case 'C':
site_id=atoi(optarg);
break;
Expand Down Expand Up @@ -141,16 +154,18 @@ int main(int argc,char *argv[])
return 0;

// Output filename
sprintf(pngfile,"%.19s_%08.3f.png/png",s.nfd0,s.freq*1e-6);
sprintf(datfile,"%.19s_%08.3f.dat",s.nfd0,s.freq*1e-6);
if (fname_flag==1)
sprintf(pngfile,"%.19s_%08.3f.png/png",s.nfd0,s.freq*1e-6);

if (create_dat==1)
sprintf(datfile,"%.19s_%08.3f.dat",s.nfd0,s.freq*1e-6);

printf("Read spectrogram\n%d channels, %d subints\nFrequency: %g MHz\nBandwidth: %g MHz\n",s.nchan,s.nsub,s.freq*1e-6,s.samp_rate*1e-6);

// Compute traces
t=compute_trace(tlefile,s.mjd,s.nsub,site_id,s.freq*1e-6,s.samp_rate*1e-6,&nsat,graves);
printf("Traces for %d objects for location %d\n",nsat,site_id);

printf("%s\n",pngfile);
cpgopen(pngfile);
// cpgctab(cool_l,cool_r,cool_g,cool_b,9,1.0,0.5);
cpgsch(0.8);
Expand Down Expand Up @@ -191,7 +206,8 @@ int main(int argc,char *argv[])
cpgswin(xmin,xmax,ymin,ymax);

// Filter points
filter(s,site_id,sigma,datfile,graves);
if (create_dat)
filter(s,site_id,sigma,datfile,graves);

time_axis(s.mjd,s.nsub,xmin,xmax,ymin,ymax);

Expand All @@ -203,8 +219,9 @@ int main(int argc,char *argv[])

// Plot traces
cpgswin(xmin,xmax,fmin,fmax);
cpgsch(0.6);
plot_traces(t,nsat);
cpgsch(0.7);
plot_traces(t,nsat,foff);
plot_traces(t,nsat,-foff);
cpgsch(0.8);

// Human readable frequency axis
Expand Down Expand Up @@ -358,7 +375,7 @@ void usage(void)
return;
}

void plot_traces(struct trace *t,int nsat)
void plot_traces(struct trace *t,int nsat,float foff)
{
int i,j,flag,textflag;
char text[8];
Expand All @@ -381,14 +398,14 @@ void plot_traces(struct trace *t,int nsat)
for (j=0,flag=0,textflag=0;j<t[i].n;j++) {
// Plot label for rising sources
if (j>0 && t[i].za[j-1]>90.0 && t[i].za[j]<=90.0)
cpgtext((float) j,(float) t[i].freq[j],text);
cpgtext((float) j,(float) (t[i].freq[j]+foff),text);

// Plot line
if (flag==0) {
cpgmove((float) j,(float) t[i].freq[j]);
cpgmove((float) j,(float) (t[i].freq[j]+foff));
flag=1;
} else {
cpgdraw((float) j,(float) t[i].freq[j]);
cpgdraw((float) j,(float) (t[i].freq[j]+foff));
}

// Below horizon
Expand Down

0 comments on commit 9629bf1

Please sign in to comment.