From 131d9e103d7a11286421f3051da8a26f91c4dfd3 Mon Sep 17 00:00:00 2001 From: Cees Bassa Date: Sun, 14 Dec 2014 23:03:37 +0100 Subject: [PATCH] Misc updates --- frequencies.txt | 21 +++++++++++++++++++++ makefile | 9 ++++++--- rffft.c | 36 +++++++++++++++++++++++++++--------- rffit.c | 2 +- rfinfo.c | 37 +++++++++++++++++++++++++++++++++++++ rfio.c | 2 ++ rfplot.c | 7 +++++-- rftrace.c | 31 ++++++++++++++++++++++++++----- 8 files changed, 125 insertions(+), 20 deletions(-) create mode 100644 rfinfo.c diff --git a/frequencies.txt b/frequencies.txt index 468e3bd..819f5ea 100644 --- a/frequencies.txt +++ b/frequencies.txt @@ -290,3 +290,24 @@ 19822 2280.509 37387 2280.008 39012 2279.672 +39497 2280.036 +39497 2279.972 +37941 2280.727 +39497 2279.404 +39497 2280.604 +40301 2280.011 +31304 2280.504 +31698 2280.000 +19460 2282.452 +27640 2222.307 +33412 2225.147 +40013 2224.005 +37820 2232.603 +35683 2233.338 +38709 2233.333 +37216 2232.315 +40344 2232.5 +40344 2277.515 +39765 2279.406 +36037 2235.009 +25544 143.050 diff --git a/makefile b/makefile index 385eb7b..f51e538 100644 --- a/makefile +++ b/makefile @@ -8,7 +8,10 @@ LFLAGS = -lcpgplot -lpgplot -lX11 -lpng -lm -lgsl -lgslcblas CC = gcc all: - make rfedit rfplot rffft rfpng rffind rffit + make rfedit rfplot rffft rfpng rffind rffit rfsim + +rfsim: rfsim.o sgdp4.o satutl.o deep.o ferror.o rftime.o + $(CC) -o rfsim rfsim.o sgdp4.o satutl.o deep.o ferror.o rftime.o -lm rffit: rffit.o sgdp4.o satutl.o deep.o ferror.o dsmin.o simplex.o versafit.o gfortran -o rffit rffit.o sgdp4.o satutl.o deep.o ferror.o dsmin.o simplex.o versafit.o $(LFLAGS) @@ -25,8 +28,8 @@ rfedit: rfedit.o rfio.o rftime.o rfplot: rfplot.o rftime.o rfio.o rftrace.o sgdp4.o satutl.o deep.o ferror.o gfortran -o rfplot rfplot.o rftime.o rfio.o rftrace.o sgdp4.o satutl.o deep.o ferror.o $(LFLAGS) -rffft: rffft.o - $(CC) -o rffft rffft.o -lfftw3f -lm +rffft: rffft.o rftime.o + $(CC) -o rffft rffft.o rftime.o -lfftw3f -lm clean: rm -f *.o diff --git a/rffft.c b/rffft.c index 8540123..fa37efb 100644 --- a/rffft.c +++ b/rffft.c @@ -6,6 +6,7 @@ #include #include #include +#include "rftime.h" void usage(void) { @@ -19,6 +20,7 @@ void usage(void) printf("-n Number of integrations per file [60]\n"); printf("-m Use every mth integration [1]\n"); printf("-F char, int, float [int]\n"); + printf("-T YYYY-MM-DDTHH:MM:SSS.sss\n"); printf("-h This help\n"); return; @@ -26,7 +28,7 @@ void usage(void) int main(int argc,char *argv[]) { - int i,j,k,l,m,nchan,nint=1,arg=0,nbytes,nsub=60,flag,nuse=1; + int i,j,k,l,m,nchan,nint=1,arg=0,nbytes,nsub=60,flag,nuse=1,realtime=1; fftwf_complex *c,*d; fftwf_plan fft; FILE *infile,*outfile; @@ -36,13 +38,13 @@ int main(int argc,char *argv[]) char *cbuf; float *fbuf; float *z,length,fchan=100.0,tint=1.0; - double freq,samp_rate; + double freq,samp_rate,mjd; struct timeval start,end; char tbuf[30],nfd[32],header[256]=""; // Read arguments if (argc>1) { - while ((arg=getopt(argc,argv,"i:f:s:c:t:p:n:hm:F:"))!=-1) { + while ((arg=getopt(argc,argv,"i:f:s:c:t:p:n:hm:F:T:"))!=-1) { switch(arg) { case 'i': @@ -86,6 +88,11 @@ int main(int argc,char *argv[]) tint=atof(optarg); break; + case 'T': + strcpy(nfd,optarg); + realtime=0; + break; + case 'h': usage(); return 0; @@ -129,8 +136,13 @@ int main(int argc,char *argv[]) fft=fftwf_plan_dft_1d(nchan,c,d,FFTW_FORWARD,FFTW_ESTIMATE); // Create prefix - gettimeofday(&start,0); - strftime(prefix,30,"%Y-%m-%dT%T",gmtime(&start.tv_sec)); + if (realtime==1) { + gettimeofday(&start,0); + strftime(prefix,30,"%Y-%m-%dT%T",gmtime(&start.tv_sec)); + } else { + sprintf(prefix,"%.19s",nfd); + mjd=nfd2mjd(nfd); + } // Open file infile=fopen(infname,"r"); @@ -202,17 +214,23 @@ int main(int argc,char *argv[]) // Log end time gettimeofday(&end,0); + + // Time stats + length=(end.tv_sec-start.tv_sec)+(end.tv_usec-start.tv_usec)*1e-6; // Scale for (i=0;i +#include +#include + +int main(int argc,char *argv[]) +{ + int i,firstfile=1,status; + FILE *file; + char header[256],filename[128],nfd[32]; + double freq,samp_rate; + float length; + int nchan; + + // Open first file + for (i=0;;i++) { + sprintf(filename,"%s_%06d.bin",argv[1],i); + file=fopen(filename,"r"); + + // Break if file does not exist + if (file==NULL) + break; + + // Read header + if (firstfile==1) { + // Read header + status=fread(header,sizeof(char),256,file); + status=sscanf(header,"HEADER\nUTC_START %s\nFREQ %lf Hz\nBW %lf Hz\nLENGTH %f s\nNCHAN %d\n",nfd,&freq,&samp_rate,&length,&nchan); + firstfile=0; + } + + fclose(file); + } + + printf("%s %8.3lf %8.3lf %d %d\n",argv[1],freq*1e-6,samp_rate*1e-6,nchan,i); + + return 0; +} diff --git a/rfio.c b/rfio.c index 11f1eb8..91e0ee4 100644 --- a/rfio.c +++ b/rfio.c @@ -15,6 +15,7 @@ struct spectrogram read_spectrogram(char *prefix,int isub,int nsub,double f0,dou double freq,samp_rate; float length; int nchan; + float s1,s2; // Open first file to get number of channels sprintf(filename,"%s_%06d.bin",prefix,isub); @@ -119,6 +120,7 @@ struct spectrogram read_spectrogram(char *prefix,int isub,int nsub,double f0,dou // Close file fclose(file); } + // Scale last subint s.mjd[i]/=(float) nadd; diff --git a/rfplot.c b/rfplot.c index 35cb0b4..1dc911a 100644 --- a/rfplot.c +++ b/rfplot.c @@ -38,6 +38,9 @@ void filter(struct spectrogram s,int site_id) // Loop over subints for (i=0;i