• Main Page
  • Related Pages
  • Classes
  • Files
  • File List
  • File Members

ocsOptSpectrumAnalyzer.hh

Go to the documentation of this file.
00001 // $Id: ocsOptSpectrumAnalyzer.hh,v 1.2 2006/05/11 23:46:55 zweck Exp $
00002 
00003 //###################################################################
00004 //
00005 //           Optical Communication Systems Simulator
00006 //
00007 //       Copyright (2001):
00008 //       Optical Fiber Communications Laboratory (OFCL)
00009 //       Computer Science & Electrical Engineering Department (CSEE)
00010 //       University of Maryland Baltimore County (UMBC)
00011 //
00012 //###################################################################
00013 
00014 #ifndef _OCS_OPT_SPECTRUM_ANALYZER_HH_
00015 #define _OCS_OPT_SPECTRUM_ANALYZER_HH_
00016 
00017 #include "ocsOptSignal.hh"
00018 
00019 // Written by John Zweck, 10 Jan, 2001 (10/1/01).
00020 
00021 // This class is an implementation of an optical spectrum analyzer (OSA).
00022 // It was written to have two modes, Gaussian and Rectangular,
00023 // corresponding to  two types of filters which can be used to average 
00024 // the optical signal over a given input ResolutionBandwidthHz.
00025 // (FIX: We should probably use ResolutionBandwidth_nm instead of 
00026 // ResolutionBandwidthHz.)
00027 // The choice of mode is determined by the variable OSAMode, with 1 being
00028 // Gaussian and 2 being Rectangular.
00029 // At this stage the Gaussian mode is fairly well tested. The rectangular
00030 // mode is not quite so well tested, but it also simpler
00031 // and so is probably less buggy.
00032 
00033 // The Gaussian OSA does the following. Given a distance along the fiber
00034 // it outputs the Gaussian-filtered optical spectrum at that distance,
00035 // in the form of (wavelength, Power in dB) pairs. It also computes 
00036 // the Signal-to-Noise ratio for each channel by taking the difference
00037 // between the maximum power of the signal (in dB) and the maximum noise power
00038 // in  two side bands, one on either side of the given channel. 
00039 // (Code has also been written to compute average rather than maximum noise
00040 // powers but this code (or its application?) still seems a little buggy to me.
00041 //  In any case the maximum noise  value seems to be a good enough measure
00042 // of the noise power.) The SNR's for each channel as well as associated
00043 // quantities are output to a file in the method OutputSNR_OSA().
00044 
00045 // To use the OSA in an application you just need to do the following.
00046 // (1) For each distance you want to output the OSA and/or measure the SNR
00047 //     you must construct an OSA object.
00048 // (2) At the appropriate point in your application code you need to 
00049 //     call the Update(double PropagatedLength2) method.
00050 //     This method is usually called multiple times in the course of
00051 //     a simulation, once per Monte Carlo experiment.
00052 // (3) Either at the very end of the program, or periodically after 
00053 //     a number of Monte Carlo experiments, the user can output the 
00054 //     most recent estimates of the optical spectrum and the SNR by calling
00055 //     the Output(int NumExpts) method.
00056 
00057 // The Update() and Output() methods call other  methods
00058 // in the OSA class which actually perform the required computations.
00059 
00060 // The code has been tested in against a real experimental system in Gary 
00061 // Carter's lab. We obtained very close agreement between simulation
00062 // and experiment.
00063 
00064  
00065 
00066 class OptSpectrumAnalyzer
00067 {
00068 
00069  public:
00070 
00071  OptSpectrumAnalyzer(string InFileName,string Job2,
00072                      int AppendFlag2,OptSignal *oOptSignal2);
00073 
00074   // The following constructor is used in the OptAmplifier class
00075 
00076  OptSpectrumAnalyzer(OptSignal *oOptSignal2,
00077                      double ResolutionBandwidthHz2,
00078                      int ModeOSA2,
00079                      double SuperGaussExponent2);
00080 
00081  OptSpectrumAnalyzer(OptSignal *oOptSignal2,
00082                      double ResolutionBandwidthHz2,
00083                      int ModeOSA2,
00084                      double SuperGaussExponent2,
00085                      int TypeAmplifierNoise2);
00086 
00087   ~OptSpectrumAnalyzer();
00088 
00089   void AllocateMemory(void);
00090   void Update(double PropagatedLength2);
00091   void Output(int NumExpts);
00092   double GetPeakPowerdBm(int ChannelArrayIndex, int ExptNum);
00093   double GetValleyPowerdBm(int ChannelArrayIndex, int ExptNum);
00094   void  Clear();
00095   
00096  //void  UpdateSignalNoiseAverages(double PropagatedLength2);
00097  void  UpdateSNR_OSA(double PropagatedLength2);
00098  double ComputeAveragePowerFreqWindow(double LeftFreq,double RightFreq);
00099 
00100  void OutputSignalNoiseAverages(int NumExpts);
00101  void OutputSNR_OSA(int NumExpts);
00102  void OutputSNR_OSA(int NumExpts, string Str);
00103  void WriteFileOutputOSA( string OutFileName, int ExptNum);
00104 
00105  void UpdateOSA(double PropagatedLength2);
00106 
00107  void UpdateOSA_OLD(double PropagatedLength2);
00108 
00109  void ComputeAveragePowerFreqWindowOSA
00110           (double LeftFreq,double RightFreq,
00111            double *Average_Watts);
00112 
00113   double ComputeMaxPowerLinFreqWindowOSA(double LeftFreq,double RightFreq);
00114 
00115  double GetNoiseEquivalentBandwidth(void);
00116 
00117  void OutputOSA(int ExptNum);
00118 void OutputOSA(int ExptNum, string Str);
00119 
00120   double GetSNR_OSA(int ChannelArrayIndex) //## Ivan Lima (6/4/01)
00121          {return GetSignalOSA(ChannelArrayIndex)
00122                 /GetNoiseOSA(ChannelArrayIndex);};
00123   double GetSNRdB_OSA(int ChannelArrayIndex) //## Ivan Lima (6/4/01)
00124          {return GetSNR_OSA(ChannelArrayIndex);};
00125   double GetSignalOSA(int ChannelArrayIndex) //## Ivan Lima (6/4/01)
00126          {return SignalPeakLin[ChannelArrayIndex]
00127                 -NoiseAverageLin[ChannelArrayIndex];};
00128   double GetNoiseOSA(int ChannelArrayIndex) //## Ivan Lima (6/4/01)
00129          {return NoiseAverageLin[ChannelArrayIndex];};
00130   double GetNoiseSpectralDensityOSA(int ChannelArrayIndex) //## IL (5/11/02)
00131          {return NoiseAverageLin[ChannelArrayIndex]
00132                 /ResolutionBandwidthHz;};
00133   //## Interface to the old function with bad english
00134   double GetSpectralNoiseDensityOSA(int ChannelArrayIndex)
00135         {return GetNoiseSpectralDensityOSA(ChannelArrayIndex);};
00136 
00137   double GetResolutionBandwidthHz(void)
00138                {return ResolutionBandwidthHz;}; 
00139 
00140   void SwitchOptSignalData(OptSignal *oOptSignal2);
00141 
00142 
00143   // The following PowerMeter methods were written by John Zweck, Apr 9th 2001
00144   // The OSA can also be used as a simple power meter
00145   // Experimentalists often measure the power map using
00146   // the peak signal power per channel in an OSA.
00147   // The power meter is designed to do just this.
00148 
00149 
00150   void  RunPowerMeter(double PropagatedLength2);
00151   void  ClearPowerMeter(void);
00152   void  OutputPowerMeter(void);
00153 
00154   // The power meter is also used to compute the average input power
00155   // level of the signal (averaged over the channels) for use in
00156   // the FIXED_OUTPUT_POWER method for computing the gain in the
00157   // optical amplifier. 
00158 
00159   double AmpPowerMeterInputLinear(void);
00160   double PowerMeterComputeAverageSignalPowerLin(void);
00161 
00162   void SetJob(string Job2) { Job = Job2;};
00163   void SetResolutionBandwidthHz(double ResolutionBandwidthHz2)
00164                   {ResolutionBandwidthHz = ResolutionBandwidthHz2;};
00165 
00166   void SetSuperGaussExponent(double SuperGaussExponent2)
00167                        {SuperGaussExponent = SuperGaussExponent2;};
00168 
00169   void SetModeOSA(int ModeOSA2) { ModeOSA = ModeOSA2;};
00170   void SetTypeAmplifierNoise(int TypeAmplifierNoise2) 
00171                              {TypeAmplifierNoise = TypeAmplifierNoise2;};
00172 
00173   void SetPowerMeterFlag(int PowerMeterFlag2) 
00174       { PowerMeterFlag = PowerMeterFlag2;};
00175 
00176 
00177   int GetNumChanns(void) {return NumChannels;};
00178 
00179   double GetOSAOutputLinear(int ExptNum, double RelFreq);
00180 
00181  private:
00182 
00183   OptSignal * oOptSignal;
00184 
00185   cfftw *fft;
00186 
00187   cplx * fPowerSignal;
00188   cplx * fOSA;
00189 
00190   cplx * tPowerSignal;
00191   cplx * tOSA;
00192 
00193 
00194   int ModeOSA; // 1: Gaussian OSA, 2: Rectangular Channel SNR's
00195   int TypeAmplifierNoise;
00196   int PowerMeterFlag;  
00197 
00198   string Job;
00199   
00200   double PropagatedLength;
00201   double AppendFlag;
00202 
00203   double ResolutionBandwidthHz;
00204 
00205   double * SignalPeakLin;
00206   double * NoiseAverageLin;
00207 
00208 
00209   int NumChannels;
00210   int qtPoints;
00211   double DeltaFreq;
00212   double SuperGaussExponent;
00213 
00214 };
00215 
00216 
00217 #endif /* _OCS_OPT_SPECTRUM_ANALYZER_HH_ */
00218 
00219 
00220 
00221 
00222 
00223 
00224 

Generated on Fri Jul 2 2010 12:57:47 for OCS by  doxygen 1.7.1