#include #include #include #include "tecToPhase.h" /** * Convert from a map of Total Electron Count (TEC) to phase in radians * * @param tecFilename the file containing the Total Electron Count [electrons/m^2/1e16] * @param outFilename the output file name for phase * @param width the width of the input and output files in number of samples in range * @param fc the carrier frequency of the radar [Hz] */ int convertToPhase(char *tecFilename, char *outFilename, int width, float fc) { int length,i,j; float *tec,*phase; FILE *tecFile,*outFile; tecFile = fopen(tecFilename,"rb"); outFile = fopen(outFilename,"wb"); fseek(tecFile,0L,SEEK_END); length = ftell(tecFile); rewind(tecFile); if ( (length%width) != 0 ) { printf("File has a non-integer number of lines\n"); exit(EXIT_FAILURE); } length = (int)(length/(sizeof(float)*width)); tec = (float *)malloc(width*sizeof(float)); phase = (float *)malloc(width*sizeof(float)); for(i=0;i