Skip to content

Commit

Permalink
Add toggle for showing bin file numbers
Browse files Browse the repository at this point in the history
Signed-off-by: Cees Bassa <[email protected]>
  • Loading branch information
cbassa committed Dec 19, 2024
1 parent a32e583 commit 8922648
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
8 changes: 5 additions & 3 deletions rfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct spectrogram read_spectrogram(char *prefix,int isub,int nsub,double f0,dou
if (strstr(header,"NBITS 8")==NULL) {
status=sscanf(header,"HEADER\nUTC_START %s\nFREQ %lf Hz\nBW %lf Hz\nLENGTH %f s\nNCHAN %d\nNSUB %d\n",s.nfd0,&s.freq,&s.samp_rate,&length,&nch,&msub);
} else {
status=sscanf(header,"HEADER\nUTC_START %s\nFREQ %lf Hz\nBW %lf Hz\nLENGTH %f s\nNCHAN %d\nNSUB %d\nNBITS 8\nMEAN %f\nRMS %f",s.nfd0,&s.freq,&s.samp_rate,&length,&nch,&dummy,&zavg,&zstd);
status=sscanf(header,"HEADER\nUTC_START %s\nFREQ %lf Hz\nBW %lf Hz\nLENGTH %f s\nNCHAN %d\nNSUB %d\nNBITS 8\nMEAN %f\nRMS %f",s.nfd0,&s.freq,&s.samp_rate,&length,&nch,&msub,&zavg,&zstd);
nbits=8;
}
s.freq+=foff;
Expand Down Expand Up @@ -69,7 +69,9 @@ struct spectrogram read_spectrogram(char *prefix,int isub,int nsub,double f0,dou

// Number of subints
s.nsub=nsub/nbin;

s.msub=msub;
s.isub=isub;

printf("Allocating %.2f MB of memory\n",(4* (float) s.nchan * (float) s.nsub)/(1024 * 1024));

// Allocate
Expand Down Expand Up @@ -202,7 +204,7 @@ struct spectrogram read_spectrogram(char *prefix,int isub,int nsub,double f0,dou
free(z);
free(cz);

return s;
return s;
}

void write_spectrogram(struct spectrogram s,char *prefix)
Expand Down
2 changes: 1 addition & 1 deletion rfio.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef RFIO_H
#define RFIO_H
struct spectrogram {
int nsub,nchan;
int nsub,nchan,msub,isub;
double *mjd;
double freq,samp_rate;
float *length;
Expand Down
47 changes: 44 additions & 3 deletions rfplot.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct data {

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 bin_axis(int isub,int msub,float xmin,float xmax,float ymin,float ymax);
void usage(void);
void plot_traces(struct trace *t,int nsat,float fcen,float xmin,float xmax, int show_names);
struct trace fit_trace(struct spectrogram s,struct select sel,int site_id,int graves);
Expand Down Expand Up @@ -56,7 +57,7 @@ int main(int argc,char *argv[])
float heat_b[] = {0.0, 0.0, 0.0, 0.3, 1.0};
float xmin,xmax,ymin,ymax,zmin,zmax=1.0;
int i,j,k,flag=0,sn,maxflag=0;
int redraw=1,mode=0,posn=0,click=0,graves=0,grid=0;
int redraw=1,mode=0,posn=0,click=0,graves=0,grid=0,binaxis=0;
float dt,zzmax,s1,s2,z,za,sigma,zs,zm;
int ix,iy,isub=0,nx,ny,jx=-1,jy=-1;
int i0,j0,i1,j1,jmax;
Expand Down Expand Up @@ -255,8 +256,14 @@ int main(int argc,char *argv[])
}

// Pixel axis
cpgbox("CTSM1",0.,0,"CTSM1",0.,0);

//cpgbox("CTSM1",0.,0,"CTSM1",0.,0);
if (binaxis==0) {
cpgbox("CTSM1",0.,0,"CTSM1",0.,0);
} else {
cpgbox("C",0.,0,"CTSM1",0.,0);
bin_axis(s.isub,s.msub,xmin,xmax,ymin,ymax);
}

// Time axis
cpgbox("B",0.,0,"",0.,0);
time_axis(s.mjd,s.nsub,xmin,xmax,ymin,ymax);
Expand Down Expand Up @@ -367,6 +374,7 @@ int main(int argc,char *argv[])
printf("c Center view\n");
printf("C Toggle through color maps\n");
printf("p/right Toggle overlays\n");
printf("a Toggle subint/bin file horizontal axis\n");
printf("n Toggle display of satellite names in overlay\n");
printf("+ Zoom\n");
printf("-/x Unzoom\n");
Expand All @@ -387,6 +395,14 @@ int main(int argc,char *argv[])
if (c=='q')
break;

// Toggle bin axis
if (c=='a') {
if (binaxis==0)
binaxis=1;
else
binaxis=0;
redraw=1;
}

// Toggle grid
if (c=='k') {
Expand Down Expand Up @@ -1601,3 +1617,28 @@ float fit_gaussian_point(struct spectrogram s,float x,float y,struct select sel,

return a[0];
}

// Plot horizontal axis in bin file steps
void bin_axis(int isub,int msub,float xmin,float xmax,float ymin,float ymax)
{
int i,imin,imax,di,istep;
float x;
char s[16];

// Get tickmark settings
imin=(int) floor(xmin/msub);
imax=(int) floor(xmax/msub);
di=imax-imin;
istep=(int) floor(di/6);
if (istep==0)
istep=1;

// Add ticks
for (i=imin;i<imax;i+=istep) {
x=i*msub;
sprintf(s,"%d",isub+i);
cpgtick(xmin,ymax,xmax,ymax,(x-xmin)/(xmax-xmin),0.5,0.5,-0.6,0.0,s);
}

return;
}

0 comments on commit 8922648

Please sign in to comment.