Index: /palm/trunk/SCRIPTS/palm_csd
===================================================================
--- /palm/trunk/SCRIPTS/palm_csd	(revision 3772)
+++ /palm/trunk/SCRIPTS/palm_csd	(revision 3773)
@@ -25,4 +25,7 @@
 # -----------------
 # $Id$
+# Unspecificed changes
+# 
+# 3726 2019-02-07 18:22:49Z maronga
 # Removed some more bugs
 # 
@@ -521,8 +524,4 @@
       tmp_x1 = int( domain_x1[i] * domain_px[i] / domain_px[parent_id] ) + 1
       tmp_y1 = int( domain_y1[i] * domain_px[i] / domain_px[parent_id] ) + 1
-      print(tmp_x0)
-      print(tmp_x1)      
-      print(tmp_y0)
-      print(tmp_y1)  
 
       tmp_x = nc_read_from_file_1d(input_file_x[ii_parent[i]], "x", tmp_x0, tmp_x1)
@@ -539,4 +538,6 @@
       
 #     Shift the child terrain height according to the parent mean terrain height 
+      print("shifting: -" + str(np.mean(zt)) + " +" + str(np.mean(zt_ip)))
+      #zt = zt - np.min(zt) + np.min(zt_ip)
       zt = zt - np.mean(zt) + np.mean(zt_ip)
   
@@ -544,4 +545,5 @@
 #     Blend over the parent and child terrain height within a radius of 50 px  
       zt = blend_array_2d(zt,zt_ip,50)
+     # zt = zt_ip
    
 #  Final step: add zt array to the global array   
@@ -714,5 +716,5 @@
 
    building_type = nc_read_from_file_2d_all(filename[i], 'building_type') 
-     
+   
    vegetation_type = nc_read_from_file_2d(input_file_vegetation_type[ii[i]], 'Band1', domain_x0[i], domain_x1[i], domain_y0[i], domain_y1[i])   
    vegetation_type[vegetation_type == 255] = fillvalues["vegetation_type"]
@@ -745,11 +747,10 @@
    pavement_type = np.where((pavement_type != fillvalues["pavement_type"]) & (building_type != fillvalues["building_type"]),fillvalues["pavement_type"],pavement_type)  
 
-#  #5 Remove pavement for pixels with water
-   pavement_type = np.where((pavement_type != fillvalues["pavement_type"]) & (water_type != fillvalues["water_type"]),fillvalues["pavement_type"],pavement_type)   
-
+#  #5 Remove pavement for pixels with water.
+   pavement_type = np.where((pavement_type != fillvalues["pavement_type"]) & (water_type != fillvalues["water_type"]),fillvalues["pavement_type"],pavement_type) 
+   
 #  #6 Remove water for pixels with buildings
    water_type = np.where((water_type != fillvalues["water_type"]) & (building_type != fillvalues["building_type"]),fillvalues["water_type"],water_type) 
-  
-   
+
 #  Correct vegetation_type when a vegetation height is available and is indicative of low vegeetation
    vegetation_height = nc_read_from_file_2d(input_file_vegetation_height[ii[i]], 'Band1', domain_x0[i], domain_x1[i], domain_y0[i], domain_y1[i])   
@@ -843,5 +844,8 @@
    street_type[street_type == 255] = fillvalues["street_type"]
    street_type = np.where((street_type < 1) & (street_type != fillvalues["street_type"]),defaultvalues["street_type"],street_type)
-   
+
+   pavement_type = nc_read_from_file_2d_all(filename[i], 'pavement_type') 
+   street_type = np.where((pavement_type == fillvalues["pavement_type"]),fillvalues["street_type"],street_type) 
+
    nc_write_to_file_2d(filename[i], 'street_type', street_type, datatypes["street_type"],'y','x',fillvalues["street_type"]) 
    nc_write_attribute(filename[i], 'street_type', 'long_name', 'street type')
Index: /palm/trunk/SCRIPTS/palm_csd_files/palm_csd_canopy_generator.py
===================================================================
--- /palm/trunk/SCRIPTS/palm_csd_files/palm_csd_canopy_generator.py	(revision 3772)
+++ /palm/trunk/SCRIPTS/palm_csd_files/palm_csd_canopy_generator.py	(revision 3773)
@@ -25,4 +25,7 @@
 # -----------------
 # $Id$
+# Bugfix: conversion to integer required for indexing
+# 
+# 3668 2019-01-14 12:49:24Z maronga
 # Various improvements and bugfixes
 # 
@@ -302,6 +305,6 @@
 
 #  Define center of the tree position inside the local LAD domain
-   tree_location_x = x[nx/2]
-   tree_location_y = y[nx/2]
+   tree_location_x = x[int(nx/2)]
+   tree_location_y = y[int(nx/2)]
 
 
Index: /palm/trunk/SCRIPTS/palm_csd_files/palm_csd_tools.py
===================================================================
--- /palm/trunk/SCRIPTS/palm_csd_files/palm_csd_tools.py	(revision 3772)
+++ /palm/trunk/SCRIPTS/palm_csd_files/palm_csd_tools.py	(revision 3773)
@@ -25,4 +25,7 @@
 # -----------------
 # $Id$
+# Unspecificed changes
+# 
+# 3726 2019-02-07 18:22:49Z maronga
 # Index bound bugfix
 # 
@@ -95,5 +98,5 @@
             for k in range(1,len(k_tmp+1)):
                if k_tmp[k] > array[m,l]:
-                  array[m,l] = k_tmp[k-1]
+                  array[m,l] = k_tmp[k-1] + dz * 0.5
                   break
 
Index: /palm/trunk/SOURCE/average_3d_data.f90
===================================================================
--- /palm/trunk/SOURCE/average_3d_data.f90	(revision 3772)
+++ /palm/trunk/SOURCE/average_3d_data.f90	(revision 3773)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Added output of theta_2m*_xy_av
+! 
+! 3655 2019-01-07 16:51:22Z knoop
 ! Implementation of the PALM module interface
 ! 
@@ -436,4 +439,14 @@
              ENDIF
 
+         CASE ( 'theta_2m*' )
+             IF ( ALLOCATED( tsurf_av ) ) THEN
+                DO  i = nxlg, nxrg
+                   DO  j = nysg, nyng
+                      pt_2m_av(j,i) = pt_2m_av(j,i) / REAL( average_count_3d, KIND=wp )
+                   ENDDO
+                ENDDO
+                CALL exchange_horiz_2d( pt_2m_av, nbgp )
+             ENDIF
+             
           CASE ( 't*' )
              IF ( ALLOCATED( ts_av ) ) THEN
Index: /palm/trunk/SOURCE/sum_up_3d_data.f90
===================================================================
--- /palm/trunk/SOURCE/sum_up_3d_data.f90	(revision 3772)
+++ /palm/trunk/SOURCE/sum_up_3d_data.f90	(revision 3773)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Added output of theta_2m*_xy_av
+! 
+! 3761 2019-02-25 15:31:42Z raasch
 ! unused variables removed
 ! 
@@ -920,4 +923,33 @@
              ENDIF
 
+          CASE ( 'theta_2m*' )
+             IF ( ALLOCATED( pt_2m_av ) ) THEN    
+                DO  i = nxl, nxr
+                   DO  j = nys, nyn
+                      match_def = surf_def_h(0)%start_index(j,i) <=            &
+                                  surf_def_h(0)%end_index(j,i)
+                      match_lsm = surf_lsm_h%start_index(j,i) <=               &
+                                  surf_lsm_h%end_index(j,i)
+                      match_usm = surf_usm_h%start_index(j,i) <=               &
+                                  surf_usm_h%end_index(j,i)
+
+                      IF ( match_def )  THEN
+                         m = surf_def_h(0)%end_index(j,i)
+                         pt_2m_av(j,i) = pt_2m_av(j,i) +                       &
+                                         surf_def_h(0)%pt_2m(m)
+                      ELSEIF ( match_lsm  .AND.  .NOT. match_usm )  THEN
+                         m = surf_lsm_h%end_index(j,i)
+                        pt_2m_av(j,i) = pt_2m_av(j,i) +                       &
+                                         surf_lsm_h%pt_2m(m)
+                      ELSEIF ( match_usm )  THEN
+                         m = surf_usm_h%end_index(j,i)
+                         pt_2m_av(j,i) = pt_2m_av(j,i) +                       &
+                                         surf_usm_h%pt_2m(m)
+                      ENDIF
+                   ENDDO
+                ENDDO
+             ENDIF
+             
+             
           CASE ( 't*' )
              IF ( ALLOCATED( ts_av ) ) THEN 
