Arrays 未定义RemoteRef,尽管手动定义了它-Julia

Arrays 未定义RemoteRef,尽管手动定义了它-Julia,arrays,parallel-processing,julia,Arrays,Parallel Processing,Julia,我使用的是Julia版本0.6.2,在第15行遇到一个错误,指出RemoteRef未定义。然而,当我尝试定义它时,例如RemoteRef{Channel{Any}}(x,y,z)我仍然会得到相同的错误@spawn还用于稍后将其链接到CAN中的另一个函数,而fetch()也用于将其链接回CAN中。这在版本0.4.7上使用,但我正在尝试更新代码 我尝试手动将RemoteRef添加到repository.Refs列表中,但似乎不起作用 有人能洞察这个问题吗?多谢各位 Pkg.add("DataFra

我使用的是Julia版本0.6.2,在第15行遇到一个错误,指出RemoteRef未定义。然而,当我尝试定义它时,例如
RemoteRef{Channel{Any}}(x,y,z)
我仍然会得到相同的错误
@spawn
还用于稍后将其链接到CAN中的另一个函数,而
fetch()
也用于将其链接回CAN中。这在版本0.4.7上使用,但我正在尝试更新代码

我尝试手动将RemoteRef添加到repository.Refs列表中,但似乎不起作用

有人能洞察这个问题吗?多谢各位

 Pkg.add("DataFrames")
 Pkg.clone("git://github.com/wkearn/RasterIO.jl")
 Pkg.build("RasterIO")

using DataFrames
using RasterIO

output_file = "point_irradiance.asc"
dtm_file = "///dtm.tif"
dsm_file = "///dsm.tif"
buildings_file = "///build.asc"
extent_file = "///extent.dat"
lamps_file = "////pen_light.csv"
lamp_easting = 3
lamp_northing = 4
lamp_height = 2

@everywhere function lightdist(xdist,ydist,zdist)
    xyzdist = sqrt(xdist^2+ydist^2+zdist^2)
    return (1/(xyzdist^2))
end

function create_point_irradiance()    
    # Read in locations of street maps


    lamps = convert(Matrix, readtable(lamps_file))

    extent = convert(Matrix, DataFrames.readtable(extent_file))
    xindex = collect(extent[1,1]:1:(extent[1,2]-1))
    yindex = collect(extent[1,4]:-1:(extent[1,3]+1))
    xindexmax, = size(xindex)
    yindexmax, = size(yindex)

    nlamps, = size(lamps)
    nlamps = nlamps
    nprocs = 3
    chunk = div(nlamps, nprocs)
    references = Array(RemoteRef, nprocs)

    for core in 1:nprocs
        if (core == 1)
            from = 1
        else
            from = (chunk * (core - 1)) + 1
        end
        if (core == nprocs)
            to = nlamps
        else
            to = chunk * core
        end
        references[core] = @spawn calculate_shadow(lamps[from:to, :], dtm_file, dsm_file, buildings_file, xindex, yindex, xindexmax, yindexmax, lamp_easting, lamp_northing, lamp_height)
    end

    point_irradiance = fill(0.0, (yindexmax, xindexmax))

    for core in 1:nprocs
        point_irradiance += fetch(references[core])
    end

    writedlm(output_file, point_irradiance, " ")

    function add_headers(f::IOStream)
        return string("NCOLS ", xindexmax, "\n",
                      "NROWS ", yindexmax, "\n",
                      "XLLCORNER ", extent[1,1], "\n",
                      "YLLCORNER ", extent[1,3], "\n",
                      "CELLSIZE 2 \n",
                      "NODATA_VALUE -9999\n",
                      readall(f))
    end
    content = open(add_headers, output_file);
    f = open(output_file, "w")
    write(f, content)
    close(f)
end

@everywhere function calculate_shadow(lamps, dtm_file, dsm_file, buildings_file, xindex, yindex, xindexmax, yindexmax, lamp_easting, lamp_northing, lamp_height)

    ext = 100
    lamp_ext = 100
    absorbance = 0.1
    sensor_ht = 2.5

    dtmR = RasterIO.openraster(dtm_file, UInt32(0))
    dtm = transpose(RasterIO.fetch(dtmR, 1))
    RasterIO.closeraster(dtmR)

    dsmR = RasterIO.openraster(dsm_file, UInt32(0))
    dsm = transpose(RasterIO.fetch(dsmR, 1))
    RasterIO.closeraster(dsmR)

    buildingsR = RasterIO.openraster(buildings_file, convert(UInt32, 0))
    buildings = transpose(RasterIO.fetch(buildingsR, 1))
    RasterIO.closeraster(buildingsR)

    # Produce raster of structures (buildings, trees, hedges, etc)
    surf = dsm - dtm

    buildings = [if (buildings[ydim, xdim] == 0)
                 0
                 else
                 surf[ydim, xdim]
                 end
                 for ydim =1:yindexmax, xdim=1:xindexmax]

    hard_surf = dtm + buildings
    soft_surf = surf - buildings

    # release memory
    dsm = 0
    surf = 0
    buildings = 0

    point_irradiance = fill(0.0, size(hard_surf))

    for lamp in 1:size(lamps, 1)
        x = lamps[lamp,lamp_easting]
        y = lamps[lamp,lamp_northing]
        z = lamps[lamp,lamp_height]

        Xmax = xindex[xindexmax, 1]
        Xmin = xindex[1, 1]
        Ymin = yindex[yindexmax, 1]
        Ymax = yindex[1, 1]

        if ((x <= (Xmax+ext)) & (x>= (Xmin-ext)) & (y<=(Ymax+ext)) & (y>=(Ymin-ext)))
            row = find(yindex .== min(max(y,Ymin),Ymax))[1]
            col = find(xindex .== max(min(x,Xmax),Xmin))[1]
            col_min = max(col-ext,1)
            col_max = min(col+ext, xindexmax)
            col_lamp = col-col_min
            row_min = max(row-ext, 1)
            row_max = min(row+ext, yindexmax)
            row_lamp = row-row_min
            nrows = row_max-row_min
            ncols = col_max-col_min

            hard_block = hard_surf[row_min:(row_min + nrows - 1),col_min:(col_min + ncols - 1)]
            soft_block = soft_surf[row_min:(row_min + nrows - 1),col_min:(col_min + ncols - 1)]
            terrain_block = dtm[row_min:(row_min + nrows - 1),col_min:(col_min + ncols - 1)]

            point_irrad = fill(0.0, size(hard_block))

            if (ncols==200&nrows==200)
                for xx in 1:ncols
                    for yy in 1:nrows
                        xdist = col_lamp-xx
                        ydist = row_lamp-yy
                        xydist = sqrt(xdist^2+ydist^2)
                        zdist = (terrain_block[row_lamp,col_lamp]+z)-(terrain_block[yy,xx]+sensor_ht)
                        xyzdist = sqrt(xydist^2+zdist^2)
                        dist = floor(xydist+0.5)
                        if (xydist<=lamp_ext)
                            if (zdist>0)
                                shadow = 1
                                shading = 0
                                if(dist>0)
                                    for d in 1:dist
                                        if (hard_block[round(Int, yy+(ydist)*(d/dist)),round(Int, xx+(xdist)*(d/dist))] >= (terrain_block[yy,xx]+sensor_ht+(d/dist)*zdist))

                                            shadow = 0
                                        end
                                        if(soft_block[round(Int, yy+(ydist)*(d/dist)),round(Int, (xx+(xdist)*(d/dist)))] >= (terrain_block[yy,xx]+sensor_ht+(d/dist)*zdist))
                                            shading = shading + xyzdist/xydist
                                        end
                                        end

                                    end
                                    res = (1/(10^(absorbance*shading)))*shadow*lightdist(xdist,ydist,zdist)
                                    real_y = yy + row_min - 1
                                    real_x = xx + col_min - 1
                                    point_irradiance[real_y, real_x] = point_irradiance[real_y, real_x] + ((1/(10^(absorbance*shading)))*shadow*lightdist(xdist,ydist,zdist))
                                end
                                end
                            end
                        end
                    end
                end
            end
            return point_irradiance
end

@time create_point_irradiance()
Pkg.add(“数据帧”)
包装克隆(“git://github.com/wkearn/RasterIO.jl")
软件包构建(“光栅”)
使用数据帧
使用光栅
输出文件=“点辐照度.asc”
dtm_文件=“///dtm.tif”
dsm_file=“///dsm.tif”
建筑物文件=“///build.asc”
extent_file=“///extent.dat”
灯文件=“///pen\u light.csv”
灯东距=3
灯北距=4
灯的高度=2
@everywhere函数光域(xdist、ydist、zdist)
xyzdist=sqrt(xdist^2+ydist^2+zdist^2)
报税表(1/(xyzdist^2))
结束
函数create_point_辐照度()
#阅读街道地图的位置
lamps=转换(矩阵,可读(lamps_文件))
区段=转换(矩阵、数据帧.可读取(区段文件))
xindex=collect(区段[1,1]:1:(区段[1,2]-1))
yindex=collect(区段[1,4]:-1:(区段[1,3]+1))
xindexmax,=尺寸(xindex)
yindex max,=尺寸(yindex)
nlamps,=尺寸(灯)
nlamps=nlamps
NPROC=3
区块=分区(nlamps、NPROC)
引用=数组(RemoteRef,NPROC)
对于1:NPROC中的核心
如果(核心==1)
from=1
其他的
from=(块*(核心-1))+1
结束
如果(核心==NPROC)
to=毫安
其他的
to=块*核心
结束
参考文献[core]=@spawn计算阴影(灯[from:to,:],dtm_文件,dsm_文件,建筑物_文件,xindex,yindex,xindexmax,yindexmax,灯东,灯北,灯高)
结束
点_辐照度=填充(0.0,(yindexmax,xindexmax))
对于1:NPROC中的核心
点_辐照度+=取数(参考[核心])
结束
writedlm(输出文件,点辐照度,“”)
函数add_头(f::IOStream)
返回字符串(“NCOLS”,xindexmax,“\n”,
“NROWS”,yindexmax,“\n”,
“XLLCORNER”,区段[1,1],“\n”,
“角”,范围[1,3],“\n”,
“手机大小2\n”,
“NODATA_值-9999\n”,
readall(f))
结束
内容=打开(添加标题,输出文件);
f=打开(输出文件“w”)
写(f,内容)
关闭(f)
结束
@everywhere函数计算阴影(灯、dtm_文件、dsm_文件、建筑物_文件、xindex、yindex、xindexmax、yindexmax、灯东距、灯北距、灯高)
ext=100
灯外部=100
吸光度=0.1
传感器\u ht=2.5
dtmR=RasterIO.openraster(dtm_文件,UInt32(0))
dtm=转置(RasterIO.fetch(dtmR,1))
光栅闭合光栅(dtmR)
dsmR=RasterIO.openraster(dsm_文件,UInt32(0))
dsm=转置(RasterIO.fetch(dsmR,1))
光栅闭合光栅(dsmR)
buildingsR=RasterIO.openraster(建筑物文件,转换(UInt32,0))
建筑物=转置(RasterIO.fetch(buildingsR,1))
光栅关闭光栅(buildingsR)
#制作结构光栅(建筑物、树木、树篱等)
surf=dsm-dtm
建筑物=[if(建筑物[ydim,xdim]==0)
0
其他的
冲浪[ydim,xdim]
结束
对于ydim=1:yindexmax,xdim=1:xindexmax]
硬浪=dtm+建筑物
软冲浪=冲浪-建筑物
#释放内存
dsm=0
冲浪=0
建筑物=0
点辐照度=填充(0.0,大小(硬表面))
对于1号灯具:尺寸(灯具,1)
x=灯[灯,灯东]
y=灯[灯,灯北]
z=灯[灯,灯高度]
Xmax=xindex[xindexmax,1]
Xmin=xindex[1,1]
Ymin=yindex[yindexmax,1]
Ymax=yindex[1,1]
如果((x=(Xmin-ext))和(y=(Ymin-ext)))
行=查找(yindex.==min(max(y,Ymin),Ymax))[1]
col=find(xindex.==max(min(x,Xmax,Xmin))[1]
col_min=最大值(col ext,1)
col_max=min(col+ext,xindexmax)
col_灯=col-col_最小值
行\最小值=最大值(行外部,1)
行_max=min(行+外部,yindexmax)
行灯=行最小值
nrows=行最大值-行最小值
ncols=列最大值-列最小值
硬块=硬块[row_min:(row_min+nrows-1),col_min:(col_min+ncols-1)]
软块=软块[行最小值:(行最小值+nrows-1),列最小值:(列最小值+ncols-1)]
地形块=dtm[行最小值:(行最小值+nrows-1),列最小值:(列最小值+ncols-1)]
点=填充(0.0,尺寸(硬块))
如果(ncols==200和nrows==200)
对于1中的xx:ncol
1:nrows中的yy
xdist=col_灯-xx
ydist=行_灯-yy
xydist=sqrt(xdist^2+ydist^2)
zdist=(地形块[行灯,柱灯]+z)-(地形块[yy,xx]+传感器]
xyzdist=sqrt(xydist^2+zdist^2)
距离=地板(xydist+0.5)
if(xydist0)
阴影=1
着色=0
如果(距离>0)
对于1:dist中的d
如果(硬块[round(Int,yy+(ydist)*(d/dist)),round(Int,xx+(xdist)*(d/dist))]>=(地形块[yy,xx]+传感器(ht+(d/dist)*zdist))
阴影=0
结束
if(软块[ro