User Tools

Site Tools


calculate_mean_value_in_neighbouring_cells

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
calculate_mean_value_in_neighbouring_cells [2023/04/21 15:30] – external edit 127.0.0.1calculate_mean_value_in_neighbouring_cells [2023/04/21 16:04] (current) irladmin
Line 42: Line 42:
     # number of pixels to take into account for the neighborhood     # number of pixels to take into account for the neighborhood
     npix = int(d/pixelsize)     npix = int(d/pixelsize)
-    print SCRIPT_NAME, "Taking into account:", npix, "pixels"+    print(SCRIPT_NAME, "Taking into account:", npix, "pixels")
     input_data = getNodeByName(nodes_data, input_name)     input_data = getNodeByName(nodes_data, input_name)
     if (not input_data):     if (not input_data):
-        print SCRIPT_NAME, "ERROR Node", input_name, "is not in nodes_data"+        print(SCRIPT_NAME, "ERROR Node", input_name, "is not in nodes_data")
         return []         return []
     # create a list with only the prob of the state of interest (road)     # create a list with only the prob of the state of interest (road)
Line 59: Line 59:
          
     # check if the values are correct          # check if the values are correct     
-    print "Values:",(data_list[0:10])+    print("Values:",(data_list[0:10]))
                  
     # create 2D array from the vector (easier for edge problems)     # create 2D array from the vector (easier for edge problems)
Line 86: Line 86:
             neighb[i,j] = average                 neighb[i,j] = average    
     # check maximum and minimum     # check maximum and minimum
-    print "Maximum value of output is",neighb[~numpy.isnan(neighb)].max() +    print("Maximum value of output is",neighb[~numpy.isnan(neighb)].max()
-    print "Minimum value of output is",neighb[~numpy.isnan(neighb)].min()+    print("Minimum value of output is",neighb[~numpy.isnan(neighb)].min())
     # write the values into the node_data format      # write the values into the node_data format 
     # into a continuous node format     # into a continuous node format
Line 93: Line 93:
      # translate to 1D list      # translate to 1D list
     neighb_list = neighb.flatten().tolist()     neighb_list = neighb.flatten().tolist()
-    print "Length of outputs is:", len(neighb_list)+    print("Length of outputs is:", len(neighb_list))
          
     new_nodes_data = [{'name' : output_name, 'type': PY_CONTINUOUS, 'data': neighb_list}]     new_nodes_data = [{'name' : output_name, 'type': PY_CONTINUOUS, 'data': neighb_list}]
                  
     for i in range(CELLS_PRINTING):     for i in range(CELLS_PRINTING):
-        print "cell:", i, ":" ,  new_nodes_data[0]['data'][i]+        print("cell:", i, ":" ,  new_nodes_data[0]['data'][i])
     return new_nodes_data     return new_nodes_data
  
calculate_mean_value_in_neighbouring_cells.txt · Last modified: 2023/04/21 16:04 by irladmin