def fluxTrans(intens, flx, lambdas, cosTheta, radius, iFirstTheta, numTransThetas, rPlanet): #print("iFirstTheta ", iFirstTheta, " numTransThetas ", numTransThetas,\ # " rPlanet ", rPlanet) #//console.log("Entering flux3"); logTiny = -49.0 tiny = math.exp(logTiny) logPi = math.log(math.pi) numLams = len(lambdas) numThetas = len(cosTheta[0]) fluxTransSpec = [[[numpy.double(0.0) for i in range(numTransThetas)] for k in range(numLams)] for j in range(2)] #Earth-radii to solar radii: rPlanet = numpy.double(rPlanet) rPlanet = rPlanet * Useful.rEarth() / Useful.rSun() #dPlanet = 2.0 * rPlanet #print("dPlanet ", dPlanet) #subtract off flux eclipsed by transiting planet: #thisImpct = rPlanet #Default ##Can it really be this simple??: logOmega = math.log(math.pi) + (numpy.double(2.0) * (math.log(rPlanet) - math.log(radius))) #omega = math.exp(logOmega) #print("omega ", omega) helper = 0.0 logHelper = 0.0 for it in range(iFirstTheta, numThetas): for il in range(numLams): #Subtracting the very small from the very large - let's be sophisticated about it: logHelper = logPi + math.log( intens[il][it]) + logOmega - flx[1][il] helper = numpy.double(1.0) - math.exp(logHelper) #if (fluxTransSpec[0][il][it-iFirstTheta] > tiny): fluxTransSpec[1][il][it - iFirstTheta] = flx[1][il] + math.log(helper) #if (il == 150): # print("logHelper ", logHelper, " helper ", helper, " logFluxTransSpec ", logFluxTransSpec) fluxTransSpec[0][il][it - iFirstTheta] = math.exp( fluxTransSpec[1][il][it - iFirstTheta]) #if (il == 150): # print("fluxTransSpec 2 ", fluxTransSpec[0][il][it-iFirstTheta]) #plt.plot(cosTheta[1][iFirstTheta: iFirstTheta+numTransThetas],\ # ) return fluxTransSpec
def TransLight2(radius, cosTheta, vTrans, iFirstTheta, numTransThetas, impct): #Safety first: tiny = numpy.double(1.0e-49) logTiny = math.log(tiny) if (impct >= radius): #There is no eclipse (transit) return #thetaMinRad is also the minimum theta of the eclipse path chord, in RAD thetaMinRad = math.asin(impct / radius) #cos(theta) *decreases* with increasing theta in Quadrant I: cosThetaMax = math.cos(thetaMinRad) #Compute array of distances traveled, r, along semi-chord from position of #minimum impact parameter #12D array of length number-of-eclipse-thetas transit = [0.0 for i in range(numTransThetas)] #test = [0.0 for i in range(numThetas)] thisImpct = numpy.double(0.0) for i in range(numTransThetas): #print("i ", i) thisTheta = math.acos(cosTheta[1][i + iFirstTheta]) thisImpct = radius * math.sin(thisTheta) #test[i+iFirstTheta] = math.exp(logRatio) # impact parameter corresponding to this theta: thisB = radius * math.sin(thisTheta) # linear distance travelled along transit semi-path in solar radii transit[i] = math.sqrt(thisB**2 - impct**2) transit[i] = transit[i] * Useful.rSun() #RSun to cm #row 1 is Times at which successive annuli are eclipsed, in s: #Ephemeris zero point at transit mid-point transit[i] = transit[i] / vTrans #print("i ", i, " i+iFirstTheta ", i+iFirstTheta, " transit[1] ", transit[1][i+iFirstTheta]) return transit