Skip to content

Commit 8eab22f

Browse files
committed
converting numpy scalars to native python float (solve numpy 1.20+ issues of gen yaml)
1 parent 63d1325 commit 8eab22f

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

solsticepy/gen_yaml.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def gen_yaml(sun, hst_pos, hst_foc, hst_aims,hst_w, hst_h
298298
iyaml+=' geometry: *pylon_g\n'
299299
iyaml+=' children: \n'
300300
iyaml+=' - name: pivot\n'
301-
iyaml+=' zx_pivot: {target: {position: %s}} \n' % ([aim_x[i],aim_y[i],aim_z[i]])
301+
iyaml+=' zx_pivot: {target: {position: %s}} \n' % ([float(aim_x[i]),float(aim_y[i]),float(aim_z[i])])
302302
iyaml+=' children: \n'
303303
iyaml+=' - name: reflect_surface\n'
304304
iyaml+=' primary: 1\n'
@@ -328,7 +328,7 @@ def gen_yaml(sun, hst_pos, hst_foc, hst_aims,hst_w, hst_h
328328
name_hst_t = 'hst_t_'+str(i)
329329
iyaml+='\n- entity:\n'
330330
iyaml+=' name: %s\n' % name_e
331-
iyaml+=' transform: { translation: %s, rotation: %s }\n' % ([hst_x[i], hst_y[i], hst_z[i]], [0, 0, 0])
331+
iyaml+=' transform: { translation: %s, rotation: %s }\n' % ([float(hst_x[i]), float(hst_y[i]), float(hst_z[i])], [0, 0, 0])
332332
iyaml+=' children: [ *%s ]\n' % name_hst_t
333333

334334
with open(outfile_yaml,'w') as f:
@@ -348,13 +348,13 @@ def flat_receiver(rec_param, hemisphere='North'):
348348
if the front surface always facing to the field is desirable
349349
(2) the position of the virtual target
350350
"""
351-
rec_w=rec_param[0]
352-
rec_h=rec_param[1]
353-
slices=rec_param[2] # it assumes equal number of slices in x and y directions
354-
x=rec_param[4]
355-
y=rec_param[5]
356-
z=rec_param[6]
357-
tilt=rec_param[7]
351+
rec_w=float(rec_param[0])
352+
rec_h=float(rec_param[1])
353+
slices=int(rec_param[2]) # it assumes equal number of slices in x and y directions
354+
x=float(rec_param[4])
355+
y=float(rec_param[5])
356+
z=float(rec_param[6])
357+
tilt=float(rec_param[7])
358358
# receiver tilt angle:
359359
# 0 is vertical
360360
# the standby posiion of a plane in solstice is normal points to the +z axis
@@ -423,13 +423,13 @@ def cylindrical_receiver(rec_param, hemisphere='North'):
423423
if the front surface always facing to the field is desirable
424424
(2) the position of the virtual target
425425
'''
426-
rec_r=rec_param[0]/2.
427-
rec_h=rec_param[1]
428-
slices=rec_param[2] # number of elements in the circumferetial direction
429-
stacks=rec_param[3] # number of elements in the vertical direction
430-
x=rec_param[4]
431-
y=rec_param[5]
432-
z=rec_param[6]
426+
rec_r=float(rec_param[0]/2.)
427+
rec_h=float(rec_param[1])
428+
slices=int(rec_param[2]) # number of elements in the circumferetial direction
429+
stacks=int(rec_param[3]) # number of elements in the vertical direction
430+
x=float(rec_param[4])
431+
y=float(rec_param[5])
432+
z=float(rec_param[6])
433433

434434
geom=''
435435
geom+='- geometry: &%s\n' % 'target_g'
@@ -492,13 +492,13 @@ def STL_receiver(rec_param, hemisphere='North'):
492492
(2) the position of the virtual target
493493
'''
494494

495-
rec_w=rec_param[0].astype(float) # for creating the virtual target
496-
rec_h=rec_param[1].astype(float)
495+
rec_w=float(rec_param[0]) # for creating the virtual target
496+
rec_h=float(rec_param[1])
497497
stlfile=rec_param[2] # directory of the stl file
498-
x=rec_param[3].astype(float)
499-
y=rec_param[4].astype(float)
500-
z=rec_param[5].astype(float)
501-
tilt=rec_param[6].astype(float) # need to figure out the initial mesh orientation
498+
x=float(rec_param[3])
499+
y=float(rec_param[4])
500+
z=float(rec_param[5])
501+
tilt=float(rec_param[6]) # need to figure out the initial mesh orientation
502502

503503
# CREATE a receiver entity from a STL file
504504
entt=''
@@ -565,11 +565,11 @@ def multi_aperture_receiver(rec_param, hemisphere='North', plot=False):
565565

566566
rec_w=rec_param[0]
567567
rec_h=rec_param[1]
568-
rec_grid_w=rec_param[2]
569-
rec_grid_h=rec_param[3]
568+
rec_grid_w=int(rec_param[2])
569+
rec_grid_h=int(rec_param[3])
570570

571571
rec_z=rec_param[4]
572-
rec_tilt=rec_param[5]
572+
rec_tilt=rec_param[5]
573573
# receiver tilt angle:
574574
# 0 is vertical
575575
# the standby posiion of a plane in solstice is normal points to the +z axis

0 commit comments

Comments
 (0)