import arcpy
import pandas as pd
import numpy as np
################
# SET PARAMETERS
################
# input layout
input_layout = arcpy.GetParameterAsText(0)
rotor_diameter = int(arcpy.GetParameterAsText(1)) # rotor
rayon = rotor_diameter/2 # rayon
H = arcpy.GetParameter(2) # hub
t = 8766 # nbe
version = arcpy.GetParameter(9) # choix
corr_ = arcpy.GetParameter(10) # premier de la vitesse
corr_v = arcpy.GetParameter(11) # second de la vitesse
corr_pr_1 = arcpy.GetParameter(12) # premier de la production
corr_pr_2 = arcpy.GetParameter(13) # second de la production
if version_s=="G2019":
# input density raster
input_raster_gwa_density_50 = r"\\wi_050m_g201910.tif" # t50m
input_raster_gwa_density_100 = r"\\w_p100m_g201910.tif" # 100m
input_raster_gwa_density_200 = r"\\wind_p200m_g201910.tif" # 200m
# inpuraster
input_raster_g_sped_50 = r"\\fra_wind_speed050m_g201910.tif" # Wd at 50m
input_raster_g_sped_100 = r"\\wind_speed100m_g201910.tif" # Wd at 100m
input_raster_g_sed_200 = r"\\fra_wind_speed200m_g201910.tif" # Wd at 200m
#################
# table en sortie
#################
# output d table
output_table_g_y_50 = r"\\output_table_g_dy_50" # output table with value at 50m
output_table_g_d_100 = r"\\output_table_g_dy_100" # output table with value at 100m
output_table_g_ity_200 = r"\\output_table_gwa_density_200" # output table with value at 200m
# output
output_table_gwa_speed_50 = r"\\output_table_gd_50" # output 50m
output_table_gwa_speed_100 = r"\\output_table_gd_100" # output at 100m
output_table_gwa_speed_200 = r"\\output_table_gd_200" # output at 200m
###################
# create empty list
###################
list_x_2154 = []
list_y_2154 = []
list_x_4326 = []
list_y_4326 = []
list_50_1 = [] # list of t
list_50_2 = [] # density for each t
list_50_3 = [] # production for each t wit
list_50_3_1 = [] # production for each t
list_50_4 = [] # list with wd at 50m
list_50_5 = [] # list with wat 100m
list_50_x = [] # list with x values frd speed
list_50_y = [] # list with y values fd speed
list_50_cp = [] # list with cp values frd speed
list_100_1 = [] # list of t
list_100_2 = [] # dey for each t
list_100_3 = [] # production for each te without cor
list_100_3_1 = [] # prn for each t
list_100_4 = [] # list witheed at 100m
list_100_x = [] # list with x valuwind speed
list_100_y = [] # list with y vaspeed
list_100_cp = [] # list with cp valund speed
list_Hx_1 = [] # list of tur
list_Hx_2 = [] # densne
list_Hx_3 = [] # prodrection
list_Hx_3_1 = [] # pro turbine
list_Hx_4 = [] # list witht WS
list_Hx_5 = [] # list with00m
list_H_x = [] # list withind speed
list_H_y = [] # list with yind speed
list_H_cp = [] # list with ######
# GET XY COORDINATES FROM INPUT LAYOUT
######################################
# for loop in Lambert 93
for row in arcpy.da.SearchCursor(input_layout, ["SHAPE@XY"], spatial_reference=arcpy.SpatialReference("RGF 1993 Lambert-93")):
# Get x,y coordinates of each point feature
x, y = row[0]
list_x_2154.append(round(x,2))
list_y_2154.append(round(y,2))
# for loop in WGS84
for row in arcpy.da.SearchCursor(input_layout, ["SHAPE@XY"], spatial_reference=arcpy.SpatialReference("WGS 1984")):
# Get x,y coordinates of each point feature
x, y = row[0]
list_x_4326.append(round(x,8))
list_y_4326.append(round(y,8))
##################################
# SCRIPT WITH HUB HEIGHT CONDITION
##################################
if H==50:
############
#
############
# get d sd value at 50m for each t
arcpy.sa.ExtractValuesToPoints(input_layout, in0, outpeed_50, "NONE", "VALUE_ONLY")
# search field in the new table
search_speed_50 = arcpy.SearchCursor(outpeed_50)
fieeed_50 = 'RASTERVALU'
if version_atlas=="G19":
# bo tolist
i=0 # initialize index=0
for row in search_speed_50:
list_50_4.append(round(row.getValue(fieleed_50),2 ))
Vh_gwa = round(row.getValue(fieleed_50), 2)
Vh_corr = corr_vitesse_1 * Vh_gwa + corr_vitesse_2
list_Vh_corr.append(round(Vh_corr,2))
list_Vh_gwa.append(round(Vh_gwa,2))
list_50_x.append(round(0.00001672 * Vh_corr**2 - 0.00043812 * Vh_corr + 0.0025185, 8))
list_50_y.append(round(0.00079672 * Vh_corr**3 - 0.02622527 * Vh_corr**2 + 0.27293475 * Vh_corr - 0.5657615, 8))
list_50_cp.append(round(list_50_x[i] * rotor_diameter + list_50_y[i], 8))
#coeff_corr_prod = corr_production_1 * Vh_corr + corr_production_2
#list_coeff_corr_prod.append(round(coeff_corr_prod, 8))
i = i+1 # index + 1
# get wind speed value at 100m for each turbine
arcpy.sa.ExtractValuesToPoints(input_layout, inputed_100, outped_100, "NONE", "VALUE_ONLY")
# search field in the new table
search_speed_100 = arcpy.SearchCursor(outpeed_100)
field_value_speed_100 = 'RASTERVALU'
# boucle in each turbine and append field value tolist
for row in search_speed_100:
list_50_5.append(round(row.getValue(field_value_speed_100),2))
# get A value at 50m
arcpy.sa.ExtractValuesToPoints(input_layout, input_ray_50, osity_50, "NONE", "VALUE_ONLY")
# search field in the new table
search_density_50 = arcpy.SearchCursor(outpsity_50)
field_t = 'nuine'
field_value_density = 'RASTERVALU'
# boucle in each turbine and append field value tolist
i=0 # initialize index=0
for row in search_density_50:
list_50_1.append(row.getValue(field_t))
list_50_2.append(int(row.getValue(field_value_density)))
list_50_3.append(int(row.getValue(field_value_density) * math.pi*rayon*rayon * list_50_cp[i] * t / 1000000)) #prod/turbine without correction
list_50_3_1.append(int(row.getValue(field_value_density) * math.pi*rayon*rayon * list_50_cp[i] * corr_production_1 * t / 1000000)) #prod/turbine
i = i+1
# set parameter and sum the list to get production
arcpy.SetParameter(4, str(sum(list_50_3_1))+" MWh")
arcpy.SetParameter(7, str(sum(list_50_3))+" MWh")
arcpy.SetParameter(3,str(round(sum(list_Vh_corr)/len(list_Vh_corr),2))+" m/s at "+str(H)+"m")
arcpy.SetParameter(6,str(round(sum(list_Vh_gwa)/len(list_Vh_corr),2))+" m/s at "+str(H)+"m")
########
# RESULT
########
dataframe = pd.DataFrame(
{'a_turbine': list_50_1,
'b_rotor_diameter': roter,
'c_hub_height': H,
'd_tip_height': H + (roteter/2),
'e_density_50m': list_50_2,
'f_wind_speed_gwa_50m': list_50_4,
'g_wind_speed_corr_50m': list_Vh_corr,
'h_wind_speed_gwa_100m': list_50_5,
'i_list_x': list_50_x,
'j_list_y': list_50_y,
'k_list_cp': list_50_cp,
'l_production_sans_correction_': list_50_3,
'l1_production_mwh': list_50_3_1,
#'m_coeff_corr_prod': list_cd,
'n_x_l93': list_x_2154,
'o_y_l93': list_y_2154,
'p_longitude': list_x_4326,
'q_latitude': list_y_4326
})
arcpy.SetParameter(5, r'in_memory/Tableau')
else:
arcpy.SetParameter(14, "Hub height must be between 50m and 200m")
Hello, I have a script in python with which I perform calculations on data that is on layers (feature layer published on acgis company), when I add the widget add the laout from a shapefile I have this error message:
Invalid return value: in_memory \ Table
Failed.
Can please tell me where the problem is and / or what part to modify on the python code.
Thanks for your time and help.