Index: palm/trunk/SCRIPTS/palm_csd
===================================================================
--- palm/trunk/SCRIPTS/palm_csd	(revision 3944)
+++ palm/trunk/SCRIPTS/palm_csd	(revision 3955)
@@ -25,4 +25,8 @@
 # -----------------
 # $Id$
+# Bugfix in preparaing of green roofs
+# Bugfix: remove LAI for bare soils
+# 
+# 3859 2019-04-03 20:30:31Z maronga
 # Bugfix: wrong variable naming for 'y'
 # 
@@ -100,4 +104,5 @@
    global settings_lai_alpha
    global settings_lai_beta
+   global settings_veg_type_below_trees
    global ndomains
 
@@ -180,6 +185,6 @@
 
    settings_bridge_width = 3.0
-   settings_lai_roof_intensive = 0.5
-   settings_lai_roof_extensive = 1.0
+   settings_lai_roof_intensive = 2.5
+   settings_lai_roof_extensive = 0.8
    settings_season = "summer"
    settings_lai_high_default = 6.0
@@ -188,4 +193,5 @@
    settings_lai_alpha = 5.0
    settings_lai_beta = 3.0
+   settings_veg_type_below_trees = 3
    ndomains = 0
 
@@ -295,4 +301,5 @@
          settings_lai_alpha = float(config.get(read_tmp, 'lai_alpha')) 
          settings_lai_beta = float(config.get(read_tmp, 'lai_beta')) 
+         settings_veg_type_below_trees = config.get(read_tmp, 'vegetation_type_below_trees')  
 
       if ( read_tmp == 'output' ):
@@ -886,9 +893,9 @@
 
 #     assign green fraction on roofs
-      building_pars[3,:,:] = np.where( (buildings_2d != fillvalues["buildings_2d"] ) & ( green_roofs != fillvalues["building_pars"] ),1.0,fillvalues["building_pars"])
+      building_pars[3,:,:] = np.where( ( buildings_2d != fillvalues["buildings_2d"] ) & ( green_roofs != fillvalues["building_pars"] ) & ( green_roofs != 0.0 ),1,fillvalues["building_pars"] )
 
 #     assign leaf area index for vegetation on roofs
-      building_pars[4,:,:] = np.where( ( buildings_2d != fillvalues["buildings_2d"] ) & ( green_roofs == 1.0 ),settings_lai_roof_intensive,fillvalues["building_pars"])
-      building_pars[4,:,:] = np.where( ( buildings_2d != fillvalues["buildings_2d"] ) & ( green_roofs == 2.0 ),settings_lai_roof_extensive,building_pars[4,:,:])
+      building_pars[4,:,:] = np.where( ( buildings_2d != fillvalues["buildings_2d"] ) & ( green_roofs >= 0.5 ),settings_lai_roof_intensive,fillvalues["building_pars"])
+      building_pars[4,:,:] = np.where( ( buildings_2d != fillvalues["buildings_2d"] ) & ( green_roofs < 0.5 ),settings_lai_roof_extensive,building_pars[4,:,:])
    
    
@@ -1074,5 +1081,5 @@
 
 #     Remove high vegetation wherever it is replaced by a leaf area density. This should effectively remove all high vegetation pixels
-      vegetation_type = np.where((lad[0,:,:] != fillvalues["tree_data"]) & (vegetation_type != fillvalues["vegetation_type"]),3,vegetation_type)
+      vegetation_type = np.where((lad[0,:,:] != fillvalues["tree_data"]) & (vegetation_type != fillvalues["vegetation_type"]),settings_veg_type_below_trees,vegetation_type)
               
 #     If desired, remove all high vegetation. TODO: check if this is still necessary
@@ -1088,5 +1095,5 @@
 
 #     Remove lai for pixels that have no vegetation_type
-      lai_low = np.where( vegetation_type != fillvalues["vegetation_type"], lai_low, fillvalues["tree_data"])
+      lai_low = np.where( ( (vegetation_type != fillvalues["vegetation_type"]) & (vegetation_type != 1) ), lai_low, fillvalues["tree_data"])
         
 #     Overwrite lai in vegetation_parameters  
@@ -1101,4 +1108,23 @@
       
       del vegetation_type, lad, lai, patch_height, vegetation_pars, zlad
+
+
+# Final adjustment of vegetation parameters: remove LAI where a bare soil was set
+for i in range(0,ndomains): 
+   
+      vegetation_type = nc_read_from_file_2d_all(filename[i], 'vegetation_type') 
+      vegetation_pars = nc_read_from_file_3d_all(filename[i], 'vegetation_pars') 
+      lai = vegetation_pars[1,:,:]   
+      
+      
+#     Remove lai for pixels that have no vegetation_type
+      lai = np.where( ( (vegetation_type != fillvalues["vegetation_type"]) & (vegetation_type != 1) ), lai, fillvalues["tree_data"])
+        
+#     Overwrite lai in vegetation_parameters  
+      vegetation_pars[1,:,:] = np.copy(lai)
+      nc_overwrite_to_file_3d(filename[i], 'vegetation_pars', vegetation_pars) 
+      
+      del vegetation_type, lai, vegetation_pars
+
 
 # Final consistency check
