Example #1
0
ut.asp=asp
ut.coss=np.cos(slp)
ut.sins=np.sin(slp)

if ut.dx != ut.dy or ut.imax != ut.jmax:
  print " For dx=dy and imax=jmax only !!"
  exit()

ut.dd=ut.dx

sky=np.zeros((ut.jmax,ut.imax),dtype=np.float32)

for angle in sangle:
  print '* '+ 'angle='+str(angle)+' *' 
  sky=sky+ut.sky(dem,angle,2)/num
  

#print np.max(sky),np.min(sky)

sky[np.where(sky<0.0)]=0.0
#skyx=cv2.resize(sky,(500,500))
#cv2.imshow('sky',skyx)
#cv2.destroyWindow('sky')


ut.write_tif('skyview.tif',sky.astype(np.float32))

exit()


Example #2
0
slp = ut.slope(dem)
asp = ut.orient(dem)

ut.asp = asp
ut.coss = np.cos(slp)
ut.sins = np.sin(slp)

if ut.dx != ut.dy or ut.imax != ut.jmax:
    print " For dx=dy and imax=jmax only !!"
    exit()

ut.dd = ut.dx

sky = np.zeros((ut.jmax, ut.imax), dtype=np.float32)

for angle in sangle:
    print '* ' + 'angle=' + str(angle) + ' *'
    sky = sky + ut.sky(dem, angle, 2) / num

#print np.max(sky),np.min(sky)

sky[np.where(sky < 0.0)] = 0.0
#skyx=cv2.resize(sky,(500,500))
#cv2.imshow('sky',skyx)
#cv2.destroyWindow('sky')

ut.write_tif('skyview.tif', sky.astype(np.float32))

exit()
Example #3
0

num=param[2]
sangle=np.arange(int(num))*360.0/float(num)
print sangle

view=np.zeros((jmax,imax),dtype=np.float32)
for angle in sangle:
  command='Fortran/elv_angle '+fname2+' '+str(angle)
  print command
  t0=angle*np.pi/180.0
  cosfa=np.cos(t0-asp)
  sub.call(command,shell=True)
  f = open('angle.img','rb')
  recl = np.fromfile(f, dtype='uint32', count=1)
  tmp = np.fromfile(f, dtype='float32', count=imax*jmax) 
  recl = np.fromfile(f, dtype='uint32', count=1)
  f.close()
  tmp[tmp < 0.0] = 0.0
  tmp=tmp.reshape(jmax,imax)
  hf=np.pi/2-np.arctan(tmp)
  view=view+coss*np.sin(hf)**2+sins*cosfa*(hf-np.sin(hf)*np.cos(hf))
  
#viewx=cv2.resize(view,(500,500))
#cv2.imshow('view',viewx)

ut.write_tif('fskyview.tif',view)
  
exit()

Example #4
0
param = sys.argv

if (len(param) < 2) or (len(param) > 4):
    print " * Usage : terrain.py dem.tif => for slope and aspect"
    print "         : terrain.py dem.tif  direction => for elevation angle"
    print "         : terrain.py dem.tif  sun_el sun_az_ => for solar incident "
    exit()

dem = ut.read_tif(param[1])
print ut.dx, ut.dy, ut.imax, ut.jmax

slp = ut.slope(dem)
asp = ut.orient(dem)

if len(param) == 2:
    ut.write_tif('slope.tif', slp.astype(np.float32))
    ut.write_tif('aspect.tif', asp.astype(np.float32))
    exit()

if len(param) == 4:
    sun_el = float(param[2])
    sun_az = float(param[3])
    inc = ut.incident(dem, sun_el, sun_az)
    ut.write_tif('incident.tif', inc.astype(np.float32))
    exit()

ut.asp = asp
ut.coss = np.cos(slp)
ut.sins = np.sin(slp)

if ut.dx != ut.dy or ut.imax != ut.jmax:
Example #5
0
param=sys.argv

if (len(param) <2) or (len(param) > 4):
  print " * Usage : terrain.py dem.tif => for slope and aspect"
  print "         : terrain.py dem.tif  direction => for elevation angle"
  print "         : terrain.py dem.tif  sun_el sun_az_ => for solar incident "
  exit()

dem=ut.read_tif(param[1])
print ut.dx,ut.dy,ut.imax,ut.jmax

slp=ut.slope(dem)
asp=ut.orient(dem)

if len(param) == 2:
  ut.write_tif('slope.tif',slp.astype(np.float32))
  ut.write_tif('aspect.tif',asp.astype(np.float32))
  exit()

if len(param) == 4:
  sun_el=float(param[2])
  sun_az=float(param[3])
  inc=ut.incident(dem,sun_el,sun_az)
  ut.write_tif('incident.tif',inc.astype(np.float32))
  exit()
  

ut.asp=asp
ut.coss=np.cos(slp)
ut.sins=np.sin(slp)
Example #6
0
f.close()

num = param[2]
sangle = np.arange(int(num)) * 360.0 / float(num)
print sangle

view = np.zeros((jmax, imax), dtype=np.float32)
for angle in sangle:
    command = 'Fortran/elv_angle ' + fname2 + ' ' + str(angle)
    print command
    t0 = angle * np.pi / 180.0
    cosfa = np.cos(t0 - asp)
    sub.call(command, shell=True)
    f = open('angle.img', 'rb')
    recl = np.fromfile(f, dtype='uint32', count=1)
    tmp = np.fromfile(f, dtype='float32', count=imax * jmax)
    recl = np.fromfile(f, dtype='uint32', count=1)
    f.close()
    tmp[tmp < 0.0] = 0.0
    tmp = tmp.reshape(jmax, imax)
    hf = np.pi / 2 - np.arctan(tmp)
    view = view + coss * np.sin(hf)**2 + sins * cosfa * (
        hf - np.sin(hf) * np.cos(hf))

#viewx=cv2.resize(view,(500,500))
#cv2.imshow('view',viewx)

ut.write_tif('fskyview.tif', view)

exit()