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"
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 + 'absssrfID%i' % (surfID), A)
if H.size> 0: np.save(outputdir + 'hitssrfID%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 + 'absssrfID%i' % (surfID), A) if H.size> 0: np.save(outputdir + 'hitssrfID%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
def get_Ms_4_surf( surfID, photonsM) :
hits (surfID==surfID)
startup routine
if name== "main": main()