You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to write a python code to calculate the receiver efficiency, following some instructions in a youtube webinar where they did the same thing.
However my python code is not working "name 'get_WFgos' is not defined"
Can anyone help me?
import numpy as np
import string
#import pylab
from math import *
import os
import glob
from time import *
#treat a single TONATIUH output file "tonatiuh_out"
def main():
#get hits and Abs matricesfor surfaces
for surfID in surfIDs:
A, H = get_Ms_4_surf( surfID, P)
if A.size> 0: np.save(outputdir + 'abss_srfID_%i' % (surfID), A)
if H.size> 0: np.save(outputdir + 'hits_srfID_%i' % (surfID), H)
I am trying to write a python code to calculate the receiver efficiency, following some instructions in a youtube webinar where they did the same thing.
However my python code is not working "name 'get_WFgos' is not defined"
Can anyone help me?
import numpy as np
import string
#import pylab
from math import *
import os
import glob
from time import *
#treat a single TONATIUH output file "tonatiuh_out"
def main():
#routine
#treats photon arrays on the shape A=[[photon 8pos]]
#and turns it into hit and absorptionmatrices to each surface
def treat_photons( photonfile, outputdir):
#photon and parameters files
photons= outputdir + photonfile + '_1.dat'
params = outputdir + photonfile + '_parameters.txt'
#surf ids & names
surfIDs = []
surfnames = []
readfile=open(params,'r')
lines=readfile.readlines()
readfile.close()
for line in lines:
try:
treat_fields = string.splitfields( line, '/')
surfIDs.append(int(treat_fields[0]))
surfname = string.splitfields(treat_fields[-1], '\n') [0]
surfnames.append(surfname)
except:pass
#get photons array
P=np.fromfile(photons,dtype='>d')
P=np.reshape(P, (-1,8)) #l photon per matrix line
print ('%i photons loaded:' % P.shape[0],)
print( strftime ('%H,%M,%S', gmtime()))
#get WFgo matrix
WFgos = get_WFgos( P )
np.save( outputdir + 'WFgos', WFgos)
#get hits and Abs matricesfor surfaces
for surfID in surfIDs:
A, H = get_Ms_4_surf( surfID, P)
if A.size> 0: np.save(outputdir + 'abss_srfID_%i' % (surfID), A)
if H.size> 0: np.save(outputdir + 'hits_srfID_%i' % (surfID), H)
print ('photons sorted:')
print (strftime('%H:%M:%S', gmtime()))
return surfIDs, surfnames
def get_statistics( surfIDs, surfnames, photonfile, outputdir, delphotons=False,):
def get8WFgos (photonsM):
#prevID ==0 and nextID !=0
M = photonsM[photonsM[:,5]==0]
M = M[M[:,6] !=0]
def get_Ms_4_surf( surfID, photonsM) :
#hits (surfID==surfID)
#startup routine
if name== "main":
main()
The text was updated successfully, but these errors were encountered: