#include #include #include #include "frToTEC.h" /** * Convert from a map of Faraday rotation to Total Electron Count (TEC) * This function assumes a constant value for the magnetic field in the * look direction of the radar (bdotk). * * @param frFilename the file containing the Faraday rotation map [radians] * @param outFilename the output file name * @param width the width of the input and output files in number of samples * @param bdotk a constant value for the B field in the direction k [gauss] * @param fc the carrier frequency of the radar [Hz] */ int convertToTec(char *frFilename, char *outFilename, int width, float bdotk, float fc) { int i,j,length; float *fr,*tec; FILE *frFile,*outFile; frFile = fopen(frFilename,"rb"); outFile = fopen(outFilename,"wb"); fseek(frFile,0L,SEEK_END); length = ftell(frFile); rewind(frFile); if ( (length%width) != 0 ) { printf("File has a non-integer number of lines\n"); exit(EXIT_FAILURE); } length = (int)(length/(sizeof(float)*width)); fr = (float *)malloc(width*sizeof(float)); tec = (float *)malloc(width*sizeof(float)); for(i=0;i