From 2000899e3da870efb4a27481a6ada13269ba0c43 Mon Sep 17 00:00:00 2001
From: MAILLER Sylvain <sylvain.mailler@lmd.polytechnique.fr>
Date: Fri, 16 Oct 2020 17:35:05 +0200
Subject: [PATCH] More flexibility in initialization

---
 toyctm/initialization.py | 7 ++++---
 toyctm/toyctm.py         | 5 ++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/toyctm/initialization.py b/toyctm/initialization.py
index 4f8021d..320e614 100644
--- a/toyctm/initialization.py
+++ b/toyctm/initialization.py
@@ -95,12 +95,13 @@ def add_3d_ini_column(localctm,spec,lon1,lat1,lon3,lat3,z1,z2,mass):
        - IniConcArray : array with shape localctm.tgrid.mass_shape"""
 
     ns=localctm.specdict[spec]
-
-    localctm.conc[ns,:,:,:]=localctm.tdgrid.columnintersect(lon1,lat1,lon3,lat1,lon3,lat3,lon1,lat3,z1,z2)
+    conctmp=localctm.tdgrid.columnintersect(lon1,lat1,lon3,lat1,lon3,lat3,lon1,lat3,z1,z2)
+    localctm.conc[ns,:,:,:]=localctm.conc[ns,:,:,:]+conctmp
    
     print('crude mass', localctm.mass(spec))
 
-    localctm.conc[ns,:,:,:]=localctm.conc[ns,:,:,:]/localctm.mass(spec)*mass            # Set to the prescribed mass value
+    if (mass is not None):
+       localctm.conc[ns,:,:,:]=localctm.conc[ns,:,:,:]/localctm.mass(spec)*mass            # Set to the prescribed mass value
 
 def add_ini_cosinebell(localctm,spec,zcenter,zwidth,mass):
     """Adds initial values field for one species."""
diff --git a/toyctm/toyctm.py b/toyctm/toyctm.py
index 75cf8d6..cf35539 100644
--- a/toyctm/toyctm.py
+++ b/toyctm/toyctm.py
@@ -225,9 +225,8 @@ class ctm:
     """
     Fills uses initializers from inidict to fill self.conc array.
     """
-    for spec in inidict:
-         print('initializing for species',spec)
-         ini=inidict[spec]
+    for k in inidict:
+         ini=inidict[k]
          ini.putinitfield(self)
          
     # Otherwise conc stays to zero
-- 
GitLab