bpmrf/rf_addLO.c

Go to the documentation of this file.
00001 
00005 #include <bpm/bpm_interface.h>
00006 #include <bpm/bpm_rf.h>
00007 #include <bpm/bpm_nr.h>
00008 #include <math.h>
00009 
00015 int rf_addLO( double amp, double lofreq, enum bpmphase_t type, double phi0, double d_phi,
00016               double **LO ) {
00017 
00018   if ( ! LO ) {
00019     bpm_error( "Invalid LO pointer in rf_addLO(...)",
00020                __FILE__, __LINE__ );
00021     return BPM_FAILURE;
00022   }
00023 
00024   int i;
00025   double t, phase;
00026 
00027   // Phase type
00028   
00029   if ( type == locked ) {
00030 
00031     if ( d_phi == 0 ) phase= phi0; else phase= nr_rangauss(phi0, d_phi);
00032 
00033   } else {
00034 
00035     if ( d_phi == 0 ) phase= phi0; else nr_ranuniform( phi0-d_phi, phi0+d_phi );
00036 
00037   }
00038 
00039 //double phase = ( type == locked ? 0 : 0 ); //nr_rangauss(phi0, d_phi) : nr_ranuniform(phi0-d_phi, phi0+d_phi) );
00040 
00041   for( i = 0; i < rf_nsamples; i++ ) {
00042 
00043     // calculate the sampling time
00044     t = i / rf_samplefreq;
00045 
00046     LO[i][Re] +=  amp * cos( 2.* PI * lofreq * t + phase );
00047     LO[i][Im] +=  amp * sin( 2.* PI * lofreq * t + phase );
00048 
00049   } /* for( i = 0; i<nS; i++ ) */
00050 
00051   return BPM_SUCCESS;
00052 }
00053 // end of file

Generated on Fri Nov 9 21:17:11 2007 for libbpm by  doxygen 1.5.1