From 41f3482286df96ab4b2d47b7fd1f00678e4649dd Mon Sep 17 00:00:00 2001
From: Ingrid Luijx <ingrid.vanderlaan@wur.nl>
Date: Mon, 17 Jun 2013 14:55:33 +0000
Subject: [PATCH] Added option to transition from 25 to 34 layers for OD meteo
 after December 2005. Added option to read initial random seed from file.
 Localization method is now read in from rc file. Changed terminology of
 mixing ratio to mole fraction.

---
 da/analysis/expand_mixingratios.py    | 341 --------------------------
 da/analysis/siteseries.py             |   6 +-
 da/baseclasses/optimizer.py           |   6 +-
 da/carbondioxide/obs.py               |  26 +-
 da/carbondioxide/obspack.py           |  26 +-
 da/carbondioxide/obspack_geocarbon.py |  26 +-
 da/examples/das.py                    |   4 +-
 da/examples/dasgridded.py             |   4 +-
 da/rc/carbontracker.rc                |  16 +-
 da/test/test_optimizer.py             |   4 +-
 da/tm5/observationoperator.py         |  55 ++++-
 da/tools/MixingratioToPermil.py       |  40 ---
 da/tools/initexit.py                  |  48 ++--
 da/tools/pipeline.py                  |   4 +-
 template.py                           |   4 +-
 template.rc                           |   7 +-
 16 files changed, 139 insertions(+), 478 deletions(-)
 delete mode 100755 da/analysis/expand_mixingratios.py
 delete mode 100755 da/tools/MixingratioToPermil.py

diff --git a/da/analysis/expand_mixingratios.py b/da/analysis/expand_mixingratios.py
deleted file mode 100755
index 8d79d5f0..00000000
--- a/da/analysis/expand_mixingratios.py
+++ /dev/null
@@ -1,341 +0,0 @@
-#!/usr/bin/env python
-# expand_fluxes.py
-import sys
-import os
-import getopt
-import shutil
-import logging
-import netCDF4
-import numpy as np
-from string import join
-from datetime import datetime, timedelta
-from pylab import date2num, num2date
-sys.path.append('../../')
-from da.tools.general import create_dirs
-import da.tools.io4 as io
-
-
-"""
-Author: Wouter Peters (Wouter.Peters@wur.nl)
-
-Revision History:
-File created on 11 May 2012.
-
-"""
-
-def write_mixing_ratios(dacycle):
-    """ 
-    
-    Write Sample information to NetCDF files. These files are organized by site and 
-    have an unlimited time axis to which data is appended each cycle.
-
-    The needed information is obtained from the sample_auxiliary.nc files and the original input data files from ObsPack. 
-
-    The steps are:
-
-    (1) Create a directory to hold timeseries output files
-    (2) Read the sample_auxiliary.nc file for this cycle and get a list of original files they were obtained from
-    (3) For each file, copy the original data file from ObsPack (if not yet present)
-    (4) Open the copied file, find the index of each observation, fill in the simulated data
-    
-    """
-
-    dirname = create_dirs(os.path.join(dacycle['dir.analysis'], 'data_molefractions'))
-#
-# Some help variables
-#
-    dectime0 = date2num(datetime(2000, 1, 1))
-    dt = dacycle['cyclelength']
-    startdate = dacycle['time.start'] 
-    enddate = dacycle['time.end'] 
-
-    logging.debug("DA Cycle start date is %s" % startdate.strftime('%Y-%m-%d %H:%M'))
-    logging.debug("DA Cycle end   date is %s" % enddate.strftime('%Y-%m-%d %H:%M'))
-
-    dacycle['time.sample.stamp'] = "%s_%s" % (startdate.strftime("%Y%m%d%H"), enddate.strftime("%Y%m%d%H"),)
-
-    # Step (1): Get the posterior sample output data file for this cycle
-
-    infile = os.path.join(dacycle['dir.output'], 'sample_auxiliary_%s.nc' % dacycle['time.sample.stamp'])
-
-    ncf_in = io.ct_read(infile, 'read')
-
-    obs_num = ncf_in.get_variable('obs_num')
-    obs_val = ncf_in.get_variable('observed')
-    simulated = ncf_in.get_variable('modelsamples')
-    infilename = ncf_in.get_variable('inputfilename')
-    infiles = netCDF4.chartostring(infilename).tolist()
-
-    #infiles   = [join(s.compressed(),'') for s in infilename]
-
-    ncf_in.close()
-
-    # Step (2): Get the prior sample output data file for this cycle
-
-    infile = os.path.join(dacycle['dir.output'], 'optimizer.%s.nc' % startdate.strftime('%Y%m%d'))
-
-    if os.path.exists(infile): 
-        optimized_present = True
-    else:
-        optimized_present = False
-
-    if optimized_present:
-
-        ncf_fc_in = io.ct_read(infile, 'read')
-
-        fc_obs_num = ncf_fc_in.get_variable('obspack_num')
-        fc_obs_val = ncf_fc_in.get_variable('observed')
-        fc_simulated = ncf_fc_in.get_variable('modelsamplesmean_prior')
-        fc_simulated_ens = ncf_fc_in.get_variable('modelsamplesdeviations_prior')
-        fc_flag      = ncf_fc_in.get_variable('flag')
-        if not dacycle.dasystem.has_key('opt.algorithm'):
-            fc_r         = ncf_fc_in.get_variable('modeldatamismatchvariance')
-            fc_hphtr     = ncf_fc_in.get_variable('totalmolefractionvariance')
-        elif dacycle.dasystem['opt.algorithm'] == 'serial':
-            fc_r         = ncf_fc_in.get_variable('modeldatamismatchvariance')
-            fc_hphtr     = ncf_fc_in.get_variable('totalmolefractionvariance')
-        elif dacycle.dasystem['opt.algorithm'] == 'bulk':
-            fc_r         = ncf_fc_in.get_variable('modeldatamismatchvariance').diagonal()
-            fc_hphtr     = ncf_fc_in.get_variable('totalmolefractionvariance').diagonal()
-        filesitecode = ncf_fc_in.get_variable('sitecode')
-
-        fc_sitecodes = netCDF4.chartostring(filesitecode).tolist()
-        #fc_sitecodes = [join(s.compressed(),'') for s in filesitecode]
-
-        ncf_fc_in.close()
-
-        # Expand the list of input files with those available from the forecast list
-
-        infiles_rootdir = os.path.split(infiles[0])[0]
-        infiles.extend(os.path.join(infiles_rootdir, f + '.nc') for f in fc_sitecodes)
-
-
-    #Step (2): For each observation timeseries we now have data for, open it and fill with data
-
-    for orig_file in set(infiles):
-
-        if not os.path.exists(orig_file):
-            logging.error("The original input file (%s) could not be found, continuing to next file..." % orig_file)
-            continue
-
-
-        copy_file = os.path.join(dirname, os.path.split(orig_file)[-1])
-        if not os.path.exists(copy_file):
-            shutil.copy(orig_file, copy_file)
-            logging.debug("Copied a new original file (%s) to the analysis directory" % orig_file)
-
-            ncf_out = io.CT_CDF(copy_file, 'write')
-
-            # Modify the attributes of the file to reflect added data from CTDAS properly
-     
-
-            ncf_out.Caution = '==================================================================================='
-            try:
-                ncf_out.History += '\nOriginal observation file modified by user %s on %s\n' % (os.environ['USER'], datetime.today().strftime('%F'),)
-            except:
-                ncf_out.History = '\nOriginal observation file modified by user %s on %s\n' % (os.environ['USER'], datetime.today().strftime('%F'),)
-            ncf_out.CTDAS_info = 'Simulated values added from a CTDAS run by %s on %s\n' % (os.environ['USER'], datetime.today().strftime('%F'),)\
-                               + '\nCTDAS was run on platform %s' % (os.environ['HOST'],)\
-                               + '\nCTDAS job directory was %s' % (dacycle['dir.da_run'],)\
-                               + '\nCTDAS Da System was %s' % (dacycle['da.system'],)\
-                               + '\nCTDAS Da ObsOperator was %s' % (dacycle['da.obsoperator'],)
-            ncf_out.CTDAS_startdate = dacycle['time.start'].strftime('%F')
-            ncf_out.CTDAS_enddate = dacycle['time.finish'].strftime("%F")
-            ncf_out.original_file = orig_file
-
-
-            # get nobs dimension
-
-            if ncf_out.dimensions.has_key('id'): 
-                dimidob = ncf_out.dimensions['id']
-                dimid = ('id',)
-            elif ncf_out.dimensions.has_key('obs'): 
-                dimidob = ncf_out.dimensions['obs']
-                dimid = ('obs',)
-
-            if dimidob.isunlimited:
-                nobs = ncf_out.inq_unlimlen()
-            else:
-                nobs = len(dimid)
-
-
-            # add nmembers dimension
-
-            dimmembersob = ncf_out.createDimension('nmembers', size=simulated.shape[1])
-            dimmembers = ('nmembers',)
-            nmembers = len(dimmembers)
-
-            # Create empty arrays for posterior samples, as well as for forecast sample statistics
-
-            savedict = io.std_savedict.copy()
-            savedict['name'] = "flag_forecast"
-            savedict['long_name'] = "flag_for_obs_model in forecast"
-            savedict['units'] = "None"
-            savedict['dims'] = dimid
-            savedict['comment'] = 'Flag (0/1/2/99) for observation value, 0 means okay, 1 means QC error, 2 means rejected, 99 means not sampled'
-            ncf_out.add_variable(savedict)
-
-            savedict = io.std_savedict.copy()
-            savedict['name'] = "modeldatamismatch"
-            savedict['long_name'] = "modeldatamismatch"
-            savedict['units'] = "[mol mol-1]^2"
-            savedict['dims'] = dimid
-            savedict['comment'] = 'Variance of mole fractions resulting from model-data mismatch'
-            ncf_out.add_variable(savedict)
-
-            savedict = io.std_savedict.copy()
-            savedict['name'] = "totalmolefractionvariance_forecast"
-            savedict['long_name'] = "totalmolefractionvariance of forecast"
-            savedict['units'] = "[mol mol-1]^2"
-            savedict['dims'] = dimid
-            savedict['comment'] = 'Variance of mole fractions resulting from prior state and model-data mismatch'
-            ncf_out.add_variable(savedict)
-
-            savedict = io.std_savedict.copy()
-            savedict['name'] = "modelsamplesmean"
-            savedict['long_name'] = "mean modelsamples"
-            savedict['units'] = "mol mol-1"
-            savedict['dims'] = dimid
-            savedict['comment'] = 'simulated mixing ratios based on optimized state vector'
-            ncf_out.add_variable(savedict)
-
-            savedict = io.std_savedict.copy()
-            savedict['name'] = "modelsamplesmean_forecast"
-            savedict['long_name'] = "mean modelsamples from forecast"
-            savedict['units'] = "mol mol-1"
-            savedict['dims'] = dimid
-            savedict['comment'] = 'simulated mixing ratios based on prior state vector'
-            ncf_out.add_variable(savedict)
-
-            savedict = io.std_savedict.copy()
-            savedict['name'] = "modelsamplesstandarddeviation"
-            savedict['long_name'] = "standard deviaton of modelsamples over all ensemble members"
-            savedict['units'] = "mol mol-1"
-            savedict['dims'] = dimid
-            savedict['comment'] = 'std dev of simulated mixing ratios based on optimized state vector'
-            ncf_out.add_variable(savedict)
-
-            savedict = io.std_savedict.copy()
-            savedict['name'] = "modelsamplesstandarddeviation_forecast"
-            savedict['long_name'] = "standard deviaton of modelsamples from forecast over all ensemble members"
-            savedict['units'] = "mol mol-1"
-            savedict['dims'] = dimid
-            savedict['comment'] = 'std dev of simulated mixing ratios based on prior state vector'
-            ncf_out.add_variable(savedict)
-
-            savedict = io.std_savedict.copy()
-            savedict['name'] = "modelsamplesensemble"
-            savedict['long_name'] = "modelsamples over all ensemble members"
-            savedict['units'] = "mol mol-1"
-            savedict['dims'] = dimid + dimmembers
-            savedict['comment'] = 'ensemble of simulated mixing ratios based on optimized state vector'
-            ncf_out.add_variable(savedict)
-
-            savedict = io.std_savedict.copy()
-            savedict['name'] = "modelsamplesensemble_forecast"
-            savedict['long_name'] = "modelsamples from forecast over all ensemble members"
-            savedict['units'] = "mol mol-1"
-            savedict['dims'] = dimid + dimmembers
-            savedict['comment'] = 'ensemble of simulated mixing ratios based on prior state vector'
-            ncf_out.add_variable(savedict)
-
-        else:
-            logging.debug("Modifying existing file (%s) in the analysis directory" % copy_file)
-
-            ncf_out = io.CT_CDF(copy_file, 'write')
-
-
-        # Get existing file obs_nums to determine match to local obs_nums
-
-        if ncf_out.variables.has_key('id'):
-            file_obs_nums = ncf_out.get_variable('id')
-        elif ncf_out.variables.has_key('obspack_num'):
-            file_obs_nums = ncf_out.get_variable('obspack_num')
-
-        # Get all obs_nums related to this file, determine their indices in the local arrays
-
-        selected_obs_nums = [num for infile, num in zip(infiles, obs_num) if infile == orig_file]
-
-
-        # Optimized data 1st: For each index, get the data and add to the file in the proper file index location
-
-        for num in selected_obs_nums:
-
-            model_index = obs_num.tolist().index(num)
-            file_index = file_obs_nums.tolist().index(num)
-
-            #var = ncf_out.variables['modeldatamismatch']   # Take from optimizer.yyyymmdd.nc file instead
-            #var[file_index] = mdm[model_index]
-
-            var = ncf_out.variables['modelsamplesmean']
-            var[file_index] = simulated[model_index, 0]
-
-            var = ncf_out.variables['modelsamplesstandarddeviation']
-            var[file_index] = simulated[model_index, 1:].std()
-
-            var = ncf_out.variables['modelsamplesensemble']
-            var[file_index] = simulated[model_index, :]
-
-        # Now forecast data too: For each index, get the data and add to the file in the proper file index location
-
-        if optimized_present:
-
-            selected_fc_obs_nums = [num for sitecode, num in zip(fc_sitecodes, fc_obs_num) if sitecode in orig_file]
-
-            for num in selected_fc_obs_nums:
-
-                model_index = fc_obs_num.tolist().index(num)
-                file_index = file_obs_nums.tolist().index(num)
-
-                var = ncf_out.variables['modeldatamismatch']
-                var[file_index] = np.sqrt(fc_r[model_index])
-
-                var = ncf_out.variables['modelsamplesmean_forecast']
-                var[file_index] = fc_simulated[model_index]
-
-                var = ncf_out.variables['modelsamplesstandarddeviation_forecast']
-                var[file_index] = fc_simulated_ens[model_index, 1:].std()
-
-                var = ncf_out.variables['modelsamplesensemble_forecast']
-                var[file_index] = fc_simulated_ens[model_index, :]
-
-                var = ncf_out.variables['totalmolefractionvariance_forecast']
-                var[file_index] = fc_hphtr[model_index]
-
-                var = ncf_out.variables['flag_forecast']
-                var[file_index] = fc_flag[model_index]
-
-
-        # close the file
-
-        status = ncf_out.close()
-
-    return None
-
-
-
-if __name__ == "__main__":
-    import logging
-    from da.tools.initexit import CycleControl
-    from da.carbondioxide.dasystem import CO2DaSystem
-
-    sys.path.append('../../')
-
-    logging.root.setLevel(logging.DEBUG)
-
-    dacycle = CycleControl(args={'rc':'../../ctdas-od-gfed2-glb6x4-obspack-full.rc'})
-    dacycle.setup()
-    dacycle.parse_times()
-
-    dasystem = CO2DaSystem('../rc/carbontracker_ct09_opfnew.rc')
-
-    dacycle.dasystem = dasystem
-
-    while dacycle['time.start'] < dacycle['time.finish']:
-
-        outfile = write_mixing_ratios(dacycle)
-
-        dacycle.advance_cycle_times()
-
-    sys.exit(0)
-
diff --git a/da/analysis/siteseries.py b/da/analysis/siteseries.py
index f86f9202..ef2b8669 100755
--- a/da/analysis/siteseries.py
+++ b/da/analysis/siteseries.py
@@ -183,7 +183,7 @@ def timehistograms_new(fig, infile):
 
     pydates = np.array([dt.datetime(1970, 1, 1) + dt.timedelta(seconds=int(d)) for d in date])
 
-    sampled = (np.ma.getmask(simulated) == False)
+    sampled = (np.ma.getmaskarray(simulated) == False)
 
     if len(sampled.nonzero()[0]) < 2: 
         logging.warning("Too few simulated values found, continuing...")
@@ -376,7 +376,7 @@ def timevssite_new(fig, infile):
     f.close()
 
     pydates = np.array([dt.datetime(1970, 1, 1) + dt.timedelta(seconds=int(d)) for d in date])
-    sampled = (np.ma.getmask(simulated) == False)
+    sampled = (np.ma.getmaskarray(simulated) == False)
 
     if len(sampled.nonzero()[0]) < 2: 
         logging.warning("Too few simulated values found, continuing...")
@@ -589,7 +589,7 @@ def residuals_new(fig, infile):
     f.close()
 
     pydates = np.array([dt.datetime(1970, 1, 1) + dt.timedelta(seconds=int(d)) for d in date])
-    sampled = (np.ma.getmask(simulated) == False)
+    sampled = (np.ma.getmaskarray(simulated) == False)
 
     if len(sampled.nonzero()[0]) < 2: 
         logging.warning("Too few simulated values found, continuing...")
diff --git a/da/baseclasses/optimizer.py b/da/baseclasses/optimizer.py
index 3575f1c7..1a0b3b6b 100755
--- a/da/baseclasses/optimizer.py
+++ b/da/baseclasses/optimizer.py
@@ -205,7 +205,7 @@ class Optimizer(object):
         savedict['units'] = "mol mol-1"
         savedict['dims'] = dimobs
         savedict['values'] = self.Hx.tolist()
-        savedict['comment'] = '%s mean mixing ratios based on %s state vector' % (type, type)
+        savedict['comment'] = '%s mean mole fractions based on %s state vector' % (type, type)
         f.add_data(savedict)
 
         savedict = io.std_savedict.copy()
@@ -214,7 +214,7 @@ class Optimizer(object):
         savedict['units'] = "mol mol-1"
         savedict['dims'] = dimobs + dimmembers
         savedict['values'] = self.HX_prime.tolist()
-        savedict['comment'] = '%s mixing ratio deviations based on %s state vector' % (type, type)
+        savedict['comment'] = '%s mole fraction deviations based on %s state vector' % (type, type)
         f.add_data(savedict)
 
         # Continue with prior only data
@@ -380,7 +380,7 @@ class Optimizer(object):
         self.X_prime[:, :] = np.dot(I, self.X_prime) - np.dot(Kw, self.HX_prime)         # HX' = I - K~ * HX'
 
 
-        # Now do the adjustments of the modeled mixing ratios using the linearized ensemble. These are not strictly needed but can be used
+        # Now do the adjustments of the modeled mole fractions using the linearized ensemble. These are not strictly needed but can be used
         # for diagnosis.
 
         part3 = np.dot(HPH, np.transpose(la.inv(sHPHR)))                           # HPH(sqrt(HPH+R))^-1
diff --git a/da/carbondioxide/obs.py b/da/carbondioxide/obs.py
index b2572b21..8c6d171a 100755
--- a/da/carbondioxide/obs.py
+++ b/da/carbondioxide/obs.py
@@ -19,7 +19,7 @@ from numpy import array, logical_and
 sys.path.append(os.getcwd())
 sys.path.append('../../')
 
-identifier = 'CarbonTracker CO2 mixing ratios'
+identifier = 'CarbonTracker CO2 mole fractions'
 version = '0.0'
 
 from da.baseclasses.obs import Observations
@@ -29,7 +29,7 @@ import da.tools.rc as rc
 ################### Begin Class CO2Observations ###################
 
 class CO2Observations(Observations):
-    """ an object that holds data + methods and attributes needed to manipulate mixing ratio values """
+    """ an object that holds data + methods and attributes needed to manipulate mole fraction values """
 
     def setup(self, dacycle):
         self.startdate = dacycle['time.sample.start']
@@ -50,9 +50,9 @@ class CO2Observations(Observations):
         self.datalist = []
 
     def add_observations(self):
-        """ Returns a MixingRatioList holding individual MixingRatioSample objects for all obs in a file
+        """ Returns a MoleFractionList holding individual MoleFractionSample objects for all obs in a file
       
-            The CarbonTracker mixing ratio files are provided as one long list of obs for all possible dates. So we can 
+            The CarbonTracker mole fraction files are provided as one long list of obs for all possible dates. So we can 
             either:
             
             (1) read all, and the subselect the data we will use in the rest of this cycle
@@ -94,11 +94,11 @@ class CO2Observations(Observations):
         logging.debug("Successfully read data from obs file (%s)" % self.obs_filename)
 
         for n in range(len(dates)): 
-            self.datalist.append(MixingRatioSample(ids[n], dates[n], sites[n], obs[n], 0.0, 0.0, 0.0, 0.0, flags[n], alts[n], lats[n], lons[n], evn[n], species[n], strategy[n], 0.0, self.obs_filename))
+            self.datalist.append(MoleFractionSample(ids[n], dates[n], sites[n], obs[n], 0.0, 0.0, 0.0, 0.0, flags[n], alts[n], lats[n], lons[n], evn[n], species[n], strategy[n], 0.0, self.obs_filename))
         logging.debug("Added %d observations to the Data list" % len(dates))
 
     def add_simulations(self, filename, silent=True):
-        """ Adds model simulated values to the mixing ratio objects """
+        """ Adds model simulated values to the mole fraction objects """
 
 
         if not os.path.exists(filename):
@@ -383,7 +383,7 @@ class CO2Observations(Observations):
         savedict['units'] = "mol mol-1"
         savedict['dims'] = dimid + dimmembers
         savedict['values'] = data.tolist()
-        savedict['comment'] = 'simulated mixing ratios based on optimized state vector'
+        savedict['comment'] = 'simulated mole fractions based on optimized state vector'
         f.add_data(savedict)
 
         data = self.getvalues('fromfile') 
@@ -419,11 +419,11 @@ class CO2Observations(Observations):
 
 
 
-################### Begin Class MixingRatioSample ###################
+################### Begin Class MoleFractionSample ###################
 
-class MixingRatioSample(object):
+class MoleFractionSample(object):
     """ 
-        Holds the data that defines a Mixing Ratio Sample in the data assimilation framework. Sor far, this includes all
+        Holds the data that defines a mole fraction Sample in the data assimilation framework. Sor far, this includes all
         attributes listed below in the __init__ method. One can additionally make more types of data, or make new
         objects for specific projects.
 
@@ -434,8 +434,8 @@ class MixingRatioSample(object):
         self.xdate = xdate             # Date of obs
         self.obs = obs               # Value observed
         self.simulated = simulated         # Value simulated by model
-        self.resid = resid             # Mixing ratio residuals
-        self.hphr = hphr              # Mixing ratio prior uncertainty from fluxes and (HPH) and model data mismatch (R)
+        self.resid = resid             # Mole fraction residuals
+        self.hphr = hphr              # Mole fraction prior uncertainty from fluxes and (HPH) and model data mismatch (R)
         self.mdm = mdm               # Model data mismatch
         self.may_localize = True           # Whether sample may be localized in optimizer
         self.may_reject = True              # Whether sample may be rejected if outside threshold
@@ -452,7 +452,7 @@ class MixingRatioSample(object):
         self.samplingstrategy = samplingstrategy
         self.fromfile = fromfile          # netcdf filename inside observation distribution, to write back later
 
-################### End Class MixingRatioSample ###################
+################### End Class MoleFractionSample ###################
 
 
 if __name__ == "__main__":
diff --git a/da/carbondioxide/obspack.py b/da/carbondioxide/obspack.py
index 35ffc495..fdf90ad6 100755
--- a/da/carbondioxide/obspack.py
+++ b/da/carbondioxide/obspack.py
@@ -23,7 +23,7 @@ import da.tools.rc as rc
 from da.baseclasses.obs import Observations
 from da.tools.general import name_convert
 
-identifier = 'CarbonTracker CO2 mixing ratios'
+identifier = 'CarbonTracker CO2 mole fractions'
 version = '0.0'
 
 
@@ -31,7 +31,7 @@ version = '0.0'
 ################### Begin Class ObsPackObservations ###################
 
 class ObsPackObservations(Observations):
-    """ an object that holds data + methods and attributes needed to manipulate mixing ratio values """
+    """ an object that holds data + methods and attributes needed to manipulate mole fraction values """
 
     def setup(self, dacycle):
         self.startdate = dacycle['time.sample.start']
@@ -51,9 +51,9 @@ class ObsPackObservations(Observations):
         self.datalist = []
 
     def add_observations(self):
-        """ Returns a MixingRatioList holding individual MixingRatioSample objects for all obs in a file
+        """ Returns a MoleFractionList holding individual MoleFractionSample objects for all obs in a file
       
-            The ObsPack mixing ratio files are provided as time series per site with all dates in sequence. 
+            The ObsPack mole fraction files are provided as time series per site with all dates in sequence. 
             We will loop over all site files in the ObsPackage, and subset each to our needs
             
         """
@@ -106,14 +106,14 @@ class ObsPackObservations(Observations):
             ncf.close()
 
             for n in range(len(dates)): 
-                self.datalist.append(MixingRatioSample(ids[n], dates[n], site, obs[n], 0.0, 0.0, 0.0, 0.0, flags[n], alts[n], lats[n], lons[n], evn[n], species, strategy, 0.0, infile))
+                self.datalist.append(MoleFractionSample(ids[n], dates[n], site, obs[n], 0.0, 0.0, 0.0, 0.0, flags[n], alts[n], lats[n], lons[n], evn[n], species, strategy, 0.0, infile))
 
             logging.debug("Added %d observations from file (%s) to the Data list" % (len(dates), ncfile))
 
         logging.info("Observations list now holds %d values" % len(self.datalist))
 
     def add_simulations(self, filename, silent=False):
-        """ Adds model simulated values to the mixing ratio objects """
+        """ Adds model simulated values to the mole fraction objects """
 
         if not os.path.exists(filename):
             msg = "Sample output filename for observations could not be found : %s" % filename
@@ -405,7 +405,7 @@ class ObsPackObservations(Observations):
         savedict['units'] = "mol mol-1"
         savedict['dims'] = dimid + dimmembers
         savedict['values'] = data.tolist()
-        savedict['comment'] = 'simulated mixing ratios based on optimized state vector'
+        savedict['comment'] = 'simulated mole fractions based on optimized state vector'
         f.add_data(savedict)
 
         data = self.getvalues('fromfile') 
@@ -430,11 +430,11 @@ class ObsPackObservations(Observations):
 
 
 
-################### Begin Class MixingRatioSample ###################
+################### Begin Class MoleFractionSample ###################
 
-class MixingRatioSample(object):
+class MoleFractionSample(object):
     """ 
-        Holds the data that defines a Mixing Ratio Sample in the data assimilation framework. Sor far, this includes all
+        Holds the data that defines a mole fraction Sample in the data assimilation framework. Sor far, this includes all
         attributes listed below in the __init__ method. One can additionally make more types of data, or make new
         objects for specific projects.
 
@@ -445,8 +445,8 @@ class MixingRatioSample(object):
         self.xdate = xdate             # Date of obs
         self.obs = obs               # Value observed
         self.simulated = simulated         # Value simulated by model
-        self.resid = resid             # Mixing ratio residuals
-        self.hphr = hphr              # Mixing ratio prior uncertainty from fluxes and (HPH) and model data mismatch (R)
+        self.resid = resid             # Mole fraction residuals
+        self.hphr = hphr              # Mole fraction prior uncertainty from fluxes and (HPH) and model data mismatch (R)
         self.mdm = mdm               # Model data mismatch
         self.may_localize = True           # Whether sample may be localized in optimizer
         self.may_reject = True              # Whether sample may be rejected if outside threshold
@@ -463,7 +463,7 @@ class MixingRatioSample(object):
         self.samplingstrategy = samplingstrategy
         self.fromfile = fromfile   # netcdf filename inside ObsPack distribution, to write back later
 
-################### End Class MixingRatioSample ###################
+################### End Class MoleFractionSample ###################
 
 
 if __name__ == "__main__":
diff --git a/da/carbondioxide/obspack_geocarbon.py b/da/carbondioxide/obspack_geocarbon.py
index c0290e41..9e015107 100755
--- a/da/carbondioxide/obspack_geocarbon.py
+++ b/da/carbondioxide/obspack_geocarbon.py
@@ -18,7 +18,7 @@ from numpy import array, logical_and
 sys.path.append(os.getcwd())
 sys.path.append('../../')
 
-identifier = 'CarbonTracker CO2 mixing ratios'
+identifier = 'CarbonTracker CO2 mole fractions'
 version = '0.0'
 
 from da.baseclasses.obs import Observations
@@ -27,7 +27,7 @@ import da.tools.rc as rc
 ################### Begin Class ObsPackObservations ###################
 
 class ObsPackObservations(Observations):
-    """ an object that holds data + methods and attributes needed to manipulate mixing ratio values """
+    """ an object that holds data + methods and attributes needed to manipulate mole fraction values """
 
     def setup(self, dacycle):
 
@@ -48,9 +48,9 @@ class ObsPackObservations(Observations):
         self.datalist = []
 
     def add_observations(self):
-        """ Returns a MixingRatioList holding individual MixingRatioSample objects for all obs in a file
+        """ Returns a MoleFractionList holding individual MoleFractionSample objects for all obs in a file
       
-            The ObsPack mixing ratio files are provided as time series per site with all dates in sequence. 
+            The ObsPack mole fraction files are provided as time series per site with all dates in sequence. 
             We will loop over all site files in the ObsPackage, and subset each to our needs
             
         """
@@ -100,14 +100,14 @@ class ObsPackObservations(Observations):
             ncf.close()
 
             for n in range(len(dates)): 
-                self.datalist.append(MixingRatioSample(obspacknum[n], dates[n], datasetname, obs[n], 0.0, 0.0, 0.0, 0.0, flags[n], alts[n], lats[n], lons[n], obspackid[n], species, 1, 0.0, infile))
+                self.datalist.append(MoleFractionSample(obspacknum[n], dates[n], datasetname, obs[n], 0.0, 0.0, 0.0, 0.0, flags[n], alts[n], lats[n], lons[n], obspackid[n], species, 1, 0.0, infile))
 
             logging.debug("Added %d observations from file (%s) to the Data list" % (len(dates), ncfile)) 
 
         logging.info("Observations list now holds %d values" % len(self.datalist))
 
     def add_simulations(self, filename, silent=False):
-        """ Adds model simulated values to the mixing ratio objects """
+        """ Adds model simulated values to the mole fraction objects """
 
 
         if not os.path.exists(filename):
@@ -445,7 +445,7 @@ class ObsPackObservations(Observations):
         savedict['units'] = "mol mol-1"
         savedict['dims'] = dimid + dimmembers
         savedict['values'] = data.tolist()
-        savedict['comment'] = 'simulated mixing ratios based on optimized state vector'
+        savedict['comment'] = 'simulated mole fractions based on optimized state vector'
         f.add_data(savedict)
 
         data = self.getvalues('fromfile') 
@@ -471,11 +471,11 @@ class ObsPackObservations(Observations):
 
 
 
-################### Begin Class MixingRatioSample ###################
+################### Begin Class MoleFractionSample ###################
 
-class MixingRatioSample(object):
+class MoleFractionSample(object):
     """ 
-        Holds the data that defines a Mixing Ratio Sample in the data assimilation framework. Sor far, this includes all
+        Holds the data that defines a mole fraction Sample in the data assimilation framework. Sor far, this includes all
         attributes listed below in the __init__ method. One can additionally make more types of data, or make new
         objects for specific projects.
 
@@ -486,8 +486,8 @@ class MixingRatioSample(object):
         self.xdate = xdate             # Date of obs
         self.obs = obs               # Value observed
         self.simulated = simulated         # Value simulated by model
-        self.resid = resid             # Mixing ratio residuals
-        self.hphr = hphr              # Mixing ratio prior uncertainty from fluxes and (HPH) and model data mismatch (R)
+        self.resid = resid             # Mole fraction residuals
+        self.hphr = hphr              # Mole fraction prior uncertainty from fluxes and (HPH) and model data mismatch (R)
         self.mdm = mdm               # Model data mismatch
         self.may_localize = True           # Whether sample may be localized in optimizer
         self.may_reject = True              # Whether sample may be rejected if outside threshold
@@ -504,7 +504,7 @@ class MixingRatioSample(object):
         self.samplingstrategy = samplingstrategy
         self.fromfile = fromfile   # netcdf filename inside ObsPack distribution, to write back later
 
-################### End Class MixingRatioSample ###################
+################### End Class MoleFractionSample ###################
 
 
 if __name__ == "__main__":
diff --git a/da/examples/das.py b/da/examples/das.py
index 31bb90ef..7ebb0f34 100755
--- a/da/examples/das.py
+++ b/da/examples/das.py
@@ -23,7 +23,7 @@ from da.carbondioxide.obs import CO2Observations
 from da.carbondioxide.optimizer import CO2Optimizer
 from da.tm5.observationoperator import TM5ObservationOperator
 from da.analysis.expand_fluxes import save_weekly_avg_1x1_data, save_weekly_avg_state_data, save_weekly_avg_tc_data, save_weekly_avg_ext_tc_data
-from da.analysis.expand_mixingratios import write_mixing_ratios
+from da.analysis.expand_molefractions import write_mole_fractions
 
 
 #################################################################################################
@@ -69,7 +69,7 @@ save_weekly_avg_1x1_data(dacycle, statevector)
 save_weekly_avg_state_data(dacycle, statevector)
 save_weekly_avg_tc_data(dacycle, statevector)
 save_weekly_avg_ext_tc_data(dacycle)
-write_mixing_ratios(dacycle)
+write_mole_fractions(dacycle)
 
 sys.exit(0)
 
diff --git a/da/examples/dasgridded.py b/da/examples/dasgridded.py
index f007ecdd..1a79e2df 100755
--- a/da/examples/dasgridded.py
+++ b/da/examples/dasgridded.py
@@ -25,7 +25,7 @@ from da.carbondioxide.optimizer import CO2Optimizer
 from da.tm5.observationoperator import TM5ObservationOperator 
 
 from da.analysis.expand_fluxes import save_weekly_avg_1x1_data, save_weekly_avg_state_data, save_weekly_avg_tc_data, save_weekly_avg_ext_tc_data
-from da.analysis.expand_mixingratios import write_mixing_ratios
+from da.analysis.expand_molefractions import write_mole_fractions
 
 #################################################################################################
 # Parse and validate the command line options, start logging
@@ -66,7 +66,7 @@ save_weekly_avg_1x1_data(dacycle, statevector)
 save_weekly_avg_state_data(dacycle, statevector)
 save_weekly_avg_tc_data(dacycle, statevector)
 save_weekly_avg_ext_tc_data(dacycle)
-write_mixing_ratios(dacycle)
+write_mole_fractions(dacycle)
 
 sys.exit(0)
 
diff --git a/da/rc/carbontracker.rc b/da/rc/carbontracker.rc
index 810b37ce..528b7064 100644
--- a/da/rc/carbontracker.rc
+++ b/da/rc/carbontracker.rc
@@ -1,22 +1,23 @@
 !!! Info for the CarbonTracker data assimilation system
 
-datadir         : /Storage/CO2/carbontracker/input/ctdas_2012/
+datadir         : /Volumes/DataRaid/CO2/carbontracker/input/ctdas_2012/ 
 
 ! For ObsPack
-obspack.input.dir   : ${datadir}/${obspack.input.id}
-obspack.input.id   : obspack_co2_1_WUR_IVAR_2012-04-13
+obspack.input.dir  : ${datadir}/obspacks/${obspack.input.id}
+obspack.input.id   : obspack_co2_1_PROTOTYPE_v1.0.3_2013-01-29
 
 ! For old carbontracker obs files
 obs.input.dir   : ${datadir}/obsnc/with_fillvalue
 obs.input.fname : obs_forecast.nc
 
 ocn.covariance  : ${datadir}/covariances/ocean_oif/oif_p3_era40.dpco2.2000.01.hdf 
-bio.covariance  : ${datadir}/covariances/olson/cov_olsonregion_001_209.nc
+bio.covariance  : ${datadir}/covariances/olson/covariance_bio_olson19.nc
 deltaco2.prefix : oif_p3_era40.dpco2
 regtype         : olson19_oif30
 nparameters     : 240
 random.seed     : 4385
-regionsfile     : ${datadir}/covariances/olson/olsonparameters.nc
+random.seed.init: ${datadir}/randomseedinit.pickle
+regionsfile     : ${datadir}/regions.nc
 
 ! Include a naming scheme for the variables
 
@@ -25,7 +26,6 @@ regionsfile     : ${datadir}/covariances/olson/olsonparameters.nc
 ! Info on the sites file used
 
 ! For ObsPack
-!obs.sites.rc        : ${PWD}/da/rc/sites_and_weights_ctdas.rc
+obs.sites.rc        : ${obspack.input.dir}/summary/sites_weights_geocarbon.rc
 ! For old CT
-obs.sites.rc        : ${datadir}/sites_and_weights_co2.ct10.rc
-
+! obs.sites.rc        : ${datadir}/sites_and_weights_co2.ct10.rc
diff --git a/da/test/test_optimizer.py b/da/test/test_optimizer.py
index 33cfc761..a08d6270 100755
--- a/da/test/test_optimizer.py
+++ b/da/test/test_optimizer.py
@@ -97,7 +97,7 @@ def serial_py_against_serial_fortran():
     plt.plot(simana, label='SerialFortran')
     plt.grid(True)
     plt.legend(loc=0)
-    plt.title('Analysis of CO2 mixing ratios')
+    plt.title('Analysis of CO2 mole fractions')
     plt.show()
 
     f.close()
@@ -194,7 +194,7 @@ def serial_vs_bulk():
     plt.figure(3)
     plt.plot(hx1, label='Serial')
     plt.plot(hx2, label='Bulk')
-    plt.title('Analysis of CO2 mixing ratios')
+    plt.title('Analysis of CO2 mole fractions')
     plt.grid(True)
     plt.legend(loc=0)
 
diff --git a/da/tm5/observationoperator.py b/da/tm5/observationoperator.py
index ef565328..10d68095 100755
--- a/da/tm5/observationoperator.py
+++ b/da/tm5/observationoperator.py
@@ -85,12 +85,38 @@ class TM5ObservationOperator(ObservationOperator):
         """
         self.dacycle = dacycle
         
-        if self.dacycle['time.restart'] == False :
-            logging.info('First time step, setting up and compiling the TM5 model before proceeding!')
-            # Modify the rc-file to reflect directory structure defined by CTDAS
-            newitems = {'my.basedir': self.dacycle['dir.exec']}
+        if self.dacycle['time.restart'] == False or self.dacycle['transition'] == True:
+            newitemsmeteo = {}
+            if self.dacycle['transition']:
+                if not (self.tm_settings[self.mysourcedirs]).find('ml91') >= 0:
+                    newdirs = self.tm_settings[self.mysourcedirs] + self.addedsourcedirs
+                else: newdirs = self.tm_settings[self.mysourcedirs]
+                # Modify the rc-file to reflect directory structure defined by CTDAS
+                # and change items for transition from 25 to 34 layers for od meteo in dec 2005
+                newitems = {'my.basedir' : self.dacycle['dir.exec'],
+                            'istart' : self.transitionvalue,
+                             'my.source.dirs' : newdirs,
+                             'build.copy.dirs' : newdirs}
+                for k, v in self.tm_settings.iteritems():
+                    if type(v) is str:
+                        if v.find('ml60') > -1:
+                            newitemsmeteo[k] = v.replace('ml60','ml91')
+                        if v.find('tropo25') > -1:
+                            newitemsmeteo[k] = v.replace('tropo25','tropo34')
+                        if v.find('ml25') > -1:
+                            newitemsmeteo[k] = v.replace('ml25','tropo34')
+                        if v.find('od_L60') > -1:
+                            newitemsmeteo[k] = 'od_L91'
+                        if k == 'my.meteo.nlev':
+                            newitemsmeteo[k] = '91'
+                logging.debug('Resetting TM5 to perform transition of od meteo from 25 to 34 levels')
+            else:        
+                logging.info('First time step, setting up and compiling the TM5 model before proceeding!')
+                # Modify the rc-file to reflect directory structure defined by CTDAS
+                newitems = {'my.basedir': self.dacycle['dir.exec']}
 
             self.modify_rc(newitems)
+            self.modify_rc(newitemsmeteo)
 
             # Create the TM5 run directory to hold a copy of the modified rc-file
 
@@ -101,6 +127,7 @@ class TM5ObservationOperator(ObservationOperator):
             self.write_rc(rcfilename)
 
             # Compile TM5 in the new directory, but only if this is a fresh start
+            logging.debug('Original rc file: %s '%(self.dacycle['da.obsoperator.rc']))
             self.compile_tm5(rcfilename)
             
             newrcfilename = os.path.join(self.tm_settings['rundir'], self.tm_settings['install.rc'])
@@ -128,6 +155,7 @@ class TM5ObservationOperator(ObservationOperator):
         """
         if self.dacycle.has_key('da.obsoperator.home'):
             os.chdir(self.dacycle['da.obsoperator.home'])
+            logging.debug('Proceeding from TM5 root dir (%s)'% self.dacycle['da.obsoperator.home'])
         else:
             tm5_dir = os.path.split(self.dacycle['da.obsoperator.rc'])[0]
             logging.warning('Guessing your TM5 root dir from the rc filename')
@@ -135,8 +163,10 @@ class TM5ObservationOperator(ObservationOperator):
             logging.warning('Proceeding from guessed TM5 root dir (%s) ' % tm5_dir)
 
             os.chdir(tm5_dir)
-
-        cmd = ['python', 'setup_tm5', '--%s' % self.dacycle.daplatform.give_queue_type(), rcfilename]
+  
+        if self.dacycle['transition']:
+            cmd = ['python', 'setup_tm5', '-n', '--%s' % self.dacycle.daplatform.give_queue_type(), rcfilename]
+        else: cmd = ['python', 'setup_tm5', '--%s' % self.dacycle.daplatform.give_queue_type(), rcfilename]
 
         logging.info('Starting the external TM5 setup script')
         logging.info('using command ... %s' % join(cmd))
@@ -177,7 +207,10 @@ class TM5ObservationOperator(ObservationOperator):
                     'output.flask': 'True'
                     }
 
-        if self.dacycle['time.restart']:  # If this is a restart from a previous cycle, the TM5 model should do a restart
+        if self.dacycle['transition']:
+            new_items[self.istartkey] = self.transitionvalue
+            logging.debug('Resetting TM5 to perform transition of od meteo from 25 to 34 levels') 
+        elif self.dacycle['time.restart']:  # If this is a restart from a previous cycle, the TM5 model should do a restart
             new_items[self.istartkey] = self.restartvalue
             logging.debug('Resetting TM5 to perform restart')
         else:
@@ -224,6 +257,9 @@ class TM5ObservationOperator(ObservationOperator):
             self.istartkey = 'istart'
             self.restartvalue = 33
             self.coldstartvalue = 9
+            self.transitionvalue = 61
+            self.mysourcedirs = 'my.source.dirs'
+            self.addedsourcedirs = '  proj/levels/ml91/trunk proj/levels/ml91/tropo34/trunk'
         else:
             self.projectkey = 'runid'
             self.rundirkey = 'rundir'
@@ -235,6 +271,7 @@ class TM5ObservationOperator(ObservationOperator):
             self.istartkey = 'istart'
             self.restartvalue = 3
             self.coldstartvalue = 9
+            self.transitionvalue = 61
 
         needed_rc_items = [
                             self.projectkey,
@@ -292,11 +329,11 @@ class TM5ObservationOperator(ObservationOperator):
                             v_new = str(v_old).replace(str(v_orig), str(v))
                             self.tm_settings[k_old] = v_new
 
-                logging.debug('Replaced tm5 rc-item %s ' % k)
+                logging.debug('Replaced tm5 rc-item %s : %s' % (k,v))
 
             else:
                 self.tm_settings[k] = v
-                logging.debug('Added new tm5 rc-item %s ' % k)
+                logging.debug('Added new tm5 rc-item %s : %s' % (k,v))
 
 
     def write_rc(self, tm5rcfilename):
diff --git a/da/tools/MixingratioToPermil.py b/da/tools/MixingratioToPermil.py
deleted file mode 100755
index 91c3f15f..00000000
--- a/da/tools/MixingratioToPermil.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env python
-# MixingratioToPermil.py
-
-"""
-Author : ivar 
-
-Revision History:
-File created on 11 May 2012.
-
-"""
-
-
-def MixingratioToPermil(filename,simulated):
-    """ Converts 13C mixing ratios to permil values"""
-    import da.tools.io4 as io
-    import logging
-    import numpy as np
-
-    pdb         = 0.011112
-
-    trlength=len(simulated[0,:])
-    memlength=trlength/2
-    simulated=simulated #*1.e6 #convert to ppm
- #   np.set_printoptions(threshold=np.nan)
- #   msg='simulated shape',simulated.shape;logging.info(msg)
- #   msg='simulated',simulated[0,0],simulated[0,40];logging.info(msg)
- #   msg='simulated',simulated ;logging.info(msg)
-    simulated=np.float64(simulated)
-    simulated[:,memlength:trlength]=1000.*((simulated[:,memlength:trlength]/simulated[:,0:memlength]/pdb)-1.)
- #   msg='simulated',simulated[0,0],simulated[0,40],memlength,trlength,pdb;logging.info(msg)
- #   msg='simulated',simulated ;logging.info(msg)
-
-
-
-
-    return simulated
-
-
-if __name__ == "__main__":
-    pass
diff --git a/da/tools/initexit.py b/da/tools/initexit.py
index 942854d8..b8eeb3e0 100755
--- a/da/tools/initexit.py
+++ b/da/tools/initexit.py
@@ -109,6 +109,7 @@ class CycleControl(dict):
         self['jobrcfilename'] = rcfile
         self['dir.da_submit'] = os.getcwd()
         self['da.crash.recover'] = '-r' in opts
+        self['transition'] = '-t' in opts
         self['verbose'] = '-v' in opts
         self.dasystem = None # to be filled later
         self.restart_filelist = [] # List of files needed for restart, to be extended later
@@ -142,12 +143,6 @@ class CycleControl(dict):
                 self[k] = to_datetime(v)
             if k in ['time.start', 'time.end', 'time.finish', 'da.restart.tstamp']:
                 self[k] = to_datetime(v)
-#            if 'time.start' in k : 
-#                self[k] = to_datetime(v)
-#            if 'time.end' in k : 
-#                self[k] = to_datetime(v)
-#            if 'time.finish' in k : 
-#                self[k] = to_datetime(v)
         for key in needed_da_items:
             if not self.has_key(key):
                 msg = 'Missing a required value in rc-file : %s' % key
@@ -252,16 +247,18 @@ class CycleControl(dict):
         logging.info("Saved the random seed generator values to file")
 
 
-
-    def read_random_seed(self):
-        filename = os.path.join(self['dir.restart'], 'randomseed_%s.pickle' % self['da.restart.tstamp'].strftime('%Y%m%d'))
+    def read_random_seed(self, first=False):
+        if first:
+            filename = self.dasystem['random.seed.init']
+            logging.info("Initialised random seed from: %s"%filename)
+        else: 
+            filename = os.path.join(self['dir.restart'], 'randomseed_%s.pickle' % self['da.restart.tstamp'].strftime('%Y%m%d'))
+            logging.info("Retrieved the random seed generator values of last cycle from file")
         f = open(filename, 'rb')
         seed = cPickle.load(f)
         np.random.set_state(seed)
         f.close()
 
-        logging.info("Retrieved the random seed generator values of last cycle from file")
-
 
     def setup(self):
         """ 
@@ -296,15 +293,20 @@ class CycleControl(dict):
             * parse_times()
             * WriteRc('jobfilename')
         """        
-        if self['time.restart']:
+        if self['transition']:
+            logging.info("Transition of filter from previous step with od meteo from 25 to 34 levels")
+            self.setup_file_structure()
+            strippedname = os.path.split(self['jobrcfilename'])[-1]
+            self['jobrcfilename'] = os.path.join(self['dir.exec'], strippedname)
+            self.read_random_seed(False)
+
+        elif self['time.restart']:
             logging.info("Restarting filter from previous step")
             self.setup_file_structure()
             strippedname = os.path.split(self['jobrcfilename'])[-1]
             self['jobrcfilename'] = os.path.join(self['dir.exec'], strippedname)
-            self.read_random_seed()
-#
-#
-        #elif not self['time.restart']:
+            self.read_random_seed(False)
+
         else: #assume that it is a fresh start, change this condition to more specific if crash recover added
             logging.info("First time step in filter sequence")
             self.setup_file_structure()
@@ -314,6 +316,8 @@ class CycleControl(dict):
 
             strippedname = os.path.split(self['jobrcfilename'])[-1]
             self['jobrcfilename'] = os.path.join(self['dir.exec'], strippedname)
+            if self.dasystem.has_key('random.seed.init'):
+                self.read_random_seed(True)
 
         self.parse_times()
         self.write_rc(self['jobrcfilename'])
@@ -327,7 +331,6 @@ class CycleControl(dict):
             * ``${da_rundir}/input``
             * ``${da_rundir}/output``
             * ``${da_rundir}/exec``
-            * ``${da_rundir}/diagnostics``
             * ``${da_rundir}/analysis``
             * ``${da_rundir}/jobs``
             * ``${da_rundir}/restart/current``
@@ -352,8 +355,6 @@ class CycleControl(dict):
         self['dir.analysis'] = os.path.join(self['dir.da_run'], 'analysis')
         self['dir.jobs'] = os.path.join(self['dir.da_run'], 'jobs')
         self['dir.restart'] = os.path.join(self['dir.da_run'], 'restart')
-        #self['dir.restart.current'] = os.path.join(self['dir.restart'], 'current')
-        #self['dir.restart.oneago'] = os.path.join(self['dir.restart'], 'one-ago')
 
         create_dirs(self['dir.da_run'])
         create_dirs(os.path.join(self['dir.exec']))
@@ -362,8 +363,6 @@ class CycleControl(dict):
         create_dirs(os.path.join(self['dir.analysis']))
         create_dirs(os.path.join(self['dir.jobs']))
         create_dirs(os.path.join(self['dir.restart']))
-        #create_dirs(os.path.join(self['dir.restart.current']))
-        #create_dirs(os.path.join(self['dir.restart.oneago']))
 
         logging.info('Succesfully created the file structure for the assimilation job')
 
@@ -522,6 +521,8 @@ class CycleControl(dict):
             jobparams = {'jobname':"j.%s" % jobid, 'jobtime':'06:00:00', 'logfile': logfile, 'errfile': logfile}
             template = self.daplatform.get_job_template(jobparams)
             execcommand = os.path.join(self['dir.da_submit'], sys.argv[0]) 
+            if '-t' in self.opts:
+                (self.opts).remove('-t') 
             template += 'python %s rc=%s %s >&%s' % (execcommand, self['da.restart.fname'], join(self.opts, ''), logfile) 
 
             # write and submit 
@@ -551,6 +552,7 @@ def parse_options():
     -v        verbose output in log files
     -h        display help
     -r        start a simulation by recovering from a previous crash
+    -t        start a simulation by transitioning from 25 to 34 layers in December 2005 (od meteo)
     ========  =======
 
     """
@@ -560,7 +562,7 @@ def parse_options():
     opts = []
     args = []
     try:                                
-        opts, args = getopt.gnu_getopt(sys.argv[1:], "-rv")
+        opts, args = getopt.gnu_getopt(sys.argv[1:], "-rvt")
     except getopt.GetoptError, msg:           
         logging.error('%s' % msg)
         sys.exit(2)      
@@ -569,6 +571,8 @@ def parse_options():
         options = options[0].lower()
         if options == '-r':
             logging.info('-r flag specified on command line: recovering from crash')
+        if options == '-t':
+            logging.info('-t flag specified on command line: transition with od from December 2005')    
         if options == '-v':
             logging.info('-v flag specified on command line: extra verbose output')
             logging.root.setLevel(logging.DEBUG)
diff --git a/da/tools/pipeline.py b/da/tools/pipeline.py
index bf40e947..39c316ef 100755
--- a/da/tools/pipeline.py
+++ b/da/tools/pipeline.py
@@ -170,7 +170,7 @@ def sample_state(dacycle, samples, statevector, obsoperator):
 
     # Before a forecast step, save all the data to a save/tmp directory so we can later recover it before the propagation step.
     # This is especially important for:
-    #  (i) The transport model restart data which holds the background mixing ratios. This is needed to run the model one cycle forward
+    #  (i) The transport model restart data which holds the background mole fractions. This is needed to run the model one cycle forward
     #  (ii) The random numbers (or the seed for the random number generator) so we can recreate the ensembles if needed
 
     #status   = dacycle.MoveSaveData(io_option='store',save_option='partial',filter=[])
@@ -286,7 +286,7 @@ def invert(dacycle, statevector, optimizer):
     diagnostics_file = os.path.join(dacycle['dir.output'], 'optimizer.%s.nc' % dacycle['time.start'].strftime('%Y%m%d'))
         
     optimizer.write_diagnostics(diagnostics_file, 'prior')
-    optimizer.set_localization('None') #WP This should go to the rc-file !!!
+    optimizer.set_localization(dacycle['da.system.localization'])
     
     if optimizer.algorithm == 'Serial':
         optimizer.serial_minimum_least_squares()
diff --git a/template.py b/template.py
index 0c9fb18b..17cd9140 100755
--- a/template.py
+++ b/template.py
@@ -26,7 +26,7 @@ from da.co2gridded.statevector import CO2GriddedStateVector
 from da.tm5.observationoperator import TM5ObservationOperator 
 
 from da.analysis.expand_fluxes import save_weekly_avg_1x1_data, save_weekly_avg_state_data, save_weekly_avg_tc_data, save_weekly_avg_ext_tc_data 
-from da.analysis.expand_mixingratios import write_mixing_ratios
+from da.analysis.expand_molefractions import write_mole_fractions
 from da.analysis.summarize_obs import summarize_obs
 
 #################################################################################################
@@ -77,7 +77,7 @@ save_weekly_avg_1x1_data(dacycle, statevector)
 save_weekly_avg_state_data(dacycle, statevector)
 save_weekly_avg_tc_data(dacycle, statevector)
 save_weekly_avg_ext_tc_data(dacycle)
-write_mixing_ratios(dacycle)
+write_mole_fractions(dacycle)
 summarize_obs(dacycle)
 
 sys.exit(0)
diff --git a/template.rc b/template.rc
index 10678a5d..08df24a4 100644
--- a/template.rc
+++ b/template.rc
@@ -3,15 +3,16 @@
 time.restart        : False
 time.start          : 2005-01-01 00:00:00
 time.finish         : 2011-01-01 00:00:00
-time.cycle          : 10
-time.nlag           : 3
+time.cycle          : 7
+time.nlag           : 5
 dir.da_run          : templaterundir
 
 
 ! Info on the DA system used
 
 da.system           : CarbonTracker
-da.system.rc        : da/rc/carbontracker_geocarbon_gridded.rc
+da.system.rc        : da/rc/carbontracker.rc
+da.system.localization : CT2007
 
 ! Info on the forward model to be used
 
-- 
GitLab