==========================================
        simend2end - An end-to-end simulation tool
             for radio occultation events
        ==========================================


Installation
------------

- create a new directory for simend2end andd unzip the archive

- add the directory to the MATLAB search paath

- edit local parameter file 'private/priv_ccontrolparlocal.m'
  (optional)


Usage
-----

The simulation tool is started from the MATLAB command line with

>> simend2end( OccNo, TrkType, CN0, Control)

The integer 'OccNo' characterizes an occulation event calculated
for a specific refractivity profile. The refractivity profile
is defined in the parameter file ['simend2endrefrpar_' OccNo '.m'].
I.e. for OccNo=17 the file 'simend2endrefrpar_17.m' is called.
Predefined ranges are (see 'priv_initrefrparameter.m')
  100,000 - 199,999 : radio sonde data
  200,000 - 299,999 : DWD local model
  300,000 - 399,999 : planetary boundary layer studies

The integer 'TrkType' determines the type of signal tracking employed.
The tracking parameters are defined in the parameter file
['simend2endtrkpar_' TrkType '.m']. I.e. for TrkType=11 the file
'simend2endtrkpar_11.m' is called.

 'TrkType'
      0   : no receiver (no noise is added to signal)
      2   : closed-loop tracking, no fly-wheeling, 4-quad carrier
            phase extraction, 3rd order PLL, 30 Hz bandwidth
     11   : open-loop, with navigation data modulation
     12   : open-loop, with navigation data modulation,
            Doppler model shifted by +10 Hz
     13   : closed-loop, no fly-wheeling, 4-quad phase extraction,
            3rd order PLL, 5 Hz bandwidth
     14   : closed-loop, no fly-wheeling, 4-quad phase extraction,
            2nd order PLL, 30 Hz bandwidth
     15   : closed-loop, fly-wheeling active, 2-quad phase extraction,
            3rd order PLL, 30 Hz bandwidth

The float number 'CN0' determines the carrier signal-to-noise
density ratio in units of dB Hz; default value is 45 dB Hz.

Parameters controlling the simulation flow can be set with the
structure 'Control':

  Control.NewA
    1 : calculate orbit data
    0 : read orbit from intermediate MAT file

  Control.SaveDataA
    1 : save orbit data to intermediate MAT file
    0 : don't save

  Control.NewB               
    1 : run forward model to calculate bending angle profile
    0 : read forward model results from intermediate MAT file

  Control.SaveDataB          
    1 : save forward model results to intermediate MAT file
    0 : don't save

  Control.NewC               
    1 : run signal tracking and FSI retrieval
    0 : read simulation results from intermediate MAT file

  Control.SaveDataC          
    1 : save simulation results to intermediate MAT file
    0 : don't save

  Control.Visual
    1 : plot results on screen (default)
    0 : don't create figures

  Control.RandomNoise
    0 : initialize random generator with 'OccNo' (default)
    1 : initialize random generator with system time
        (results may not reproducible)

  Control.SaveResultsAsASCII
    1 : write results to file in ASCII format
    0 : no ASCII output (default)

  Control.SondeProfileSmooth
    width of smoothing window applied to sonde refractivity in meters
    (default: 150 m)


Further customization is done by setting parameters in

  priv_controlparlocal.m   : machine/site specific settings
  priv_controlpardefault.m : general parameters


Example:

>> simend2end( 100010, 15, 45)

Calculate refractivity profile AWI radio sonde profile #10, add noise to
obtain signal-to-noise density ratio of 45 dB Hz, track with closed-loop
fly-wheeling enabled receiver and plot result on screen.


Parameter files
---------------

a) Refractivity profile

Information on the refractivity profile is stored in the structure
'RefrPar' comprising the following six fields:

  RefrPar.pp = spline( Altitude, Refractivity)
    fit parameters derived from a spline fit of a (high resolution)
    refractivity profile as a function of altitude.

  RefrPar.zMin
    lower limit of altitude range [m]

  RefrPar.RefrMin    
    refractivity at altitude 'RefrPar.zMin'

  RefrPar.zMax       
    upper limit of altitude range [m]

  RefrPar.RefrMax    
    refractivity at altitude 'RefrPar.zMax'

  RefrPar.ScaleHeight
    scale height, profile is extrapolated below 'RefrPar.zMin' and above
    'RefrPar.zMax' with exponential function using a scale height of
    'RefrPar.ScaleHeight'


b) Signal tracking parameters

  Control.FourQuadExtraction
    1 : four quadrant carrier phase extraction (atan2(Q,I))
    0 : two quadrant carrier phase extraction (atan(Q/I))

  Control.TrackClosedLoop
    1 : track in closed-loop mode
    0 : don't track in closed-loop mode

  Control.TrackOpenLoop
    1 : track in open-loop mode
    0 : don't track in open-loop mode
  
  Control.OLModelFrqOffset
    over-all shift of open-loop Doppler model [Hz]

  Control.PLLOrder
    loop order employed in closed-loop tracking

  Control.LoopBLT
    bandwidth of carrier tracking loop times loop update time (1 ms)
    (i.e. 0.030 corresponds to 30 Hz loop bandwidth)

  Control.DataWipeActive
    1 : 50 Hz navigation data is predicted and removed
        from signal (data-wipe)
    0 : don't do data-wipe

  Control.CohIntegTime
    coherent integration time [s] (default: 0.020)

  Control.FlyWheeling
    0 : fly-wheeling deactivated
    1 : fly-wheeling activate

  Control.FlyWheelDataWipeActive
    1 : data-wipe during fly-wheeling
    0 : no data-wipe during fly-wheeling

	Control.FlyWheelSNRThreshLo
    active fly-wheeling if SNR drops below this value [V/V]
  
	Control.FlyWheelSNRThreshHi
    deactive fly-wheeling if SNR rises above this value [V/V]

	Control.FlyWheelAvgTime
    time period used for NCO frequency extrapolation [s]

	Control.FlyWheelDelayAct
	  delay for activation of fly-wheeling [s]

	Control.FlyWheelDelayDeAct
	  delay for deactivation of fly-wheeling [s]

	Control.FlyWheelFourQuadExtr
	  1 : four-quadrant phase extraction during fly-wheeling
	  0 : two-quadrant phase extraction during fly-wheeling

	Control.FlyWheelNoResPhase
    1 : don't add residual phase to NCO phase durung fly-wheeling
    0 : add residual phase to NCO phase durung fly-wheeling
    
	Control.FlyWheelPolyDegree
    degree of fit polynomial used for extrapolation


Input & output
--------------

Intermediate and final results stored in files (binary MATLAB format),
default output directory is '.../simend2end/data/out/mat/'


The following figures are created with the call to private function
'priv_plotresults.m'

'Figure 1: SNR':
Signal-to-noise ratio as a function of occultation time

'Figure 3: path difference':
Difference between retrieved and true optical path as a function
of occultation time

'Figure 4: residual phase':
Residual phase as a function of occultation time

'Figure 5: Doppler deviation':
Deviation between true and retrieved Doppler as a function of
occultation time

'Figure 6: path difference':
Difference between true and retrieved optical path as a function of
occultation time

'Figure 7: bending angle':
Bending angle as a function of ray height
blue : true profile
red  : retrieved profile

'Figure 8: FSI amplitude':
FSI amplitude as a function of ray height
black : FSI amplitude
green : smoothed amplitude
red   : cut-off ray height

'Figure 9: refractivity':
Refractivity as a function of altitude
red  : true profile
blue : retrieved profile

'Figure 10: refractivity gradient':
Refractivity gradient as a function of altitude
red  : true profile
blue : retrieved profile

'Figure 11: refractivity error':
Fractional deviation between true and retrieved
refractivity as a function of altitude.


License
-------

Copyright (C) 2000-2005  Georg Beyerle

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA

    Source: geocities.com/gbeyerle/software

               ( geocities.com/gbeyerle)