diff --git a/rfio.c b/rfio.c index d9955d6..3b75583 100644 --- a/rfio.c +++ b/rfio.c @@ -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; @@ -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 @@ -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) diff --git a/rfio.h b/rfio.h index 8cf2451..15630b0 100644 --- a/rfio.h +++ b/rfio.h @@ -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; diff --git a/rfplot.c b/rfplot.c index aff1d1c..a808d04 100644 --- a/rfplot.c +++ b/rfplot.c @@ -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); @@ -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; @@ -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); @@ -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"); @@ -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') { @@ -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