Misc updates

pull/10/head
Cees Bassa 2014-12-14 23:03:37 +01:00
parent 6a99239b6f
commit 131d9e103d
8 changed files with 125 additions and 20 deletions

View File

@ -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

View File

@ -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

36
rffft.c
View File

@ -6,6 +6,7 @@
#include <getopt.h>
#include <time.h>
#include <sys/time.h>
#include "rftime.h"
void usage(void)
{
@ -19,6 +20,7 @@ void usage(void)
printf("-n <nsub> Number of integrations per file [60]\n");
printf("-m <use> Use every mth integration [1]\n");
printf("-F <format> char, int, float [int]\n");
printf("-T <start time> 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<nchan;i++)
z[i]*=(float) nuse/(float) nchan;
// Time stats
length=(end.tv_sec-start.tv_sec)+(end.tv_usec-start.tv_usec)*1e-6;
// Format start time
strftime(tbuf,30,"%Y-%m-%dT%T",gmtime(&start.tv_sec));
sprintf(nfd,"%s.%03ld",tbuf,start.tv_usec/1000);
if (realtime==1) {
strftime(tbuf,30,"%Y-%m-%dT%T",gmtime(&start.tv_sec));
sprintf(nfd,"%s.%03ld",tbuf,start.tv_usec/1000);
} else {
mjd2nfd(mjd+(m*tint*nsub+k)/86400.0,nfd);
length=tint;
}
// Header
sprintf(header,"HEADER\nUTC_START %s\nFREQ %lf Hz\nBW %lf Hz\nLENGTH %f s\nNCHAN %d\nNSUB %d\nEND\n",nfd,freq,samp_rate,length,nchan,nsub);

View File

@ -829,7 +829,7 @@ int main(int argc,char *argv[])
// Save
if (c=='S') {
printf("%s_%8.3f_%05d.dat\n",nfd,d.ffit/1000.0,satno);
printf("%s_%.3f_%05d.dat\n",nfd,d.ffit/1000.0,satno);
printf("Save highlighted points, provide filename: ");
status=scanf("%s",filename);
save_data(xmin,ymin,xmax,ymax,filename);

37
rfinfo.c 100644
View File

@ -0,0 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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;
}

2
rfio.c
View File

@ -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;

View File

@ -38,6 +38,9 @@ void filter(struct spectrogram s,int site_id)
// Loop over subints
for (i=0;i<s.nsub;i++) {
if (s.mjd[i]==0.0)
continue;
// Set mask
for (j=0;j<s.nchan;j++)
mask[j]=1;
@ -802,10 +805,10 @@ void plot_traces(struct trace *t,int nsat)
// Plot line
if (flag==0) {
cpgmove((float) j,(float) t[i].freq[j]);
cpgmove((float) j,t[i].freq[j]);
flag=1;
} else {
cpgdraw((float) j,(float) t[i].freq[j]);
cpgdraw((float) j,t[i].freq[j]);
}
// Below horizon

View File

@ -16,6 +16,7 @@
struct point {
xyz_t obspos,obsvel;
xyz_t grpos,grvel;
};
struct site {
int id;
@ -272,11 +273,11 @@ struct trace *compute_trace(char *tlefile,double *mjd,int n,int site_id,float fr
{
int i,j,imode,flag,satno,tflag,m,status;
struct point *p;
struct site s;
struct site s,sg;
FILE *file,*infile;
orbit_t orb;
xyz_t satpos,satvel;
double dx,dy,dz,dvx,dvy,dvz,r,v,za;
double dx,dy,dz,dvx,dvy,dvz,r,v,za,vg;
double freq0;
char line[LIM],text[8];
struct trace *t;
@ -330,6 +331,13 @@ struct trace *compute_trace(char *tlefile,double *mjd,int n,int site_id,float fr
for (i=0;i<m;i++)
obspos_xyz(mjd[i],s.lng,s.lat,s.alt,&p[i].obspos,&p[i].obsvel);
// Compute Graves positions
if (site_id==9000) {
sg=get_site(9999);
for (i=0;i<m;i++)
obspos_xyz(mjd[i],sg.lng,sg.lat,sg.alt,&p[i].grpos,&p[i].grvel);
}
infile=fopen(freqlist,"r");
for (j=0;;) {
if (fgetline(infile,line,LIM)<=0)
@ -370,12 +378,25 @@ struct trace *compute_trace(char *tlefile,double *mjd,int n,int site_id,float fr
v=(dvx*dx+dvy*dy+dvz*dz)/r;
za=acos((p[i].obspos.x*dx+p[i].obspos.y*dy+p[i].obspos.z*dz)/(r*XKMPER))*R2D;
freq=(1.0-v/C)*freq0;
// Store
t[j].mjd[i]=mjd[i];
t[j].freq[i]=freq;
t[j].freq[i]=(1.0-v/C)*freq0;
t[j].za[i]=za;
// Compute Graves velocity/frequency
if (site_id==9000) {
dx=satpos.x-p[i].grpos.x;
dy=satpos.y-p[i].grpos.y;
dz=satpos.z-p[i].grpos.z;
dvx=satvel.x-p[i].grvel.x;
dvy=satvel.y-p[i].grvel.y;
dvz=satvel.z-p[i].grvel.z;
r=sqrt(dx*dx+dy*dy+dz*dz);
vg=(dvx*dx+dvy*dy+dvz*dz)/r;
// Graves frequency
t[j].freq[i]=(1.0-v/C)*(1.0-vg/C)*freq0;
}
}
}
fclose(file);