Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#python lists and reading files and plotting # just use the first 500 values from R and T as they are different lengths # i

#python lists and reading files and plotting # just use the first 500 values from R and T as they are different lengths # i get this error for reading list, and the final plot should be a straight line

################################ making R list # find R list at https://pastebin.comX2Y6TVH

import random import numpy f=open('R 77777.txt',"r") lines=f.readlines() R=[] for x in lines: R.append(x.split(' ')[0]) R = [s.rstrip() for s in R] f.close()

################################### making T list # find T list at https://pastebin.com/y2Uby5eF f=open('T 77777.txt',"r") lines=f.readlines() T=[] for x in lines: T.append(x.split(' ')[0]) T = [s.rstrip() for s in T] f.close()

################################## making a list of 1's Z=1 list_of_ones=[] for i in range(len(R)): list_of_ones.append(Z)

################################## each A = 1 - R[i] - T[i] A=[] for i in range(len(R)): A.append(list_of_ones[i] - float(R[i]) - float(T[i])) K=numpy.linspace(0,100,500) print(K) plt.plot(K, A) plt.title("K over A") plt.show()

plt.plot(K, R) plt.title( " R = Y, K = x ") plt.show()

image text in transcribed

RESTART : C:/Users/User/Desktop/photonics/photon test n stuff/copying 7a from pa per 2/test tg 3.py Traceback (most recent cal1 last): reflectivity - Y, wavelengthx File "C:/Users/User/Desktop/photonics/photon test n stuff/copying 7a from pape r 2/test fg 3.py", line 16, in R. append (Xsplit ( ' ' ) [2] ) IndexError: ist index out of range RESTART: C:/Users/User/Desktop/photonics/photon test n stuft/copying 7a from pa per 2/test g 3.py Traceback (most recent call last) File "C:/Users/User/Desktop/photonics/photon test n stuff/copying 7a from pape r 2/test fg 3.", line 39, in A.append (ist of ones-RT1]) TypeError: unsupported operand type (s) to1nt' and "str RESTART: C:/Users/User/Desktop/photonics/photon test n stuff/copying 7a from pa per 2/test fg 3.py Traceback (mo t recent call last): File "C:/Users/User/Desktop/photonics/photon test n stuff/copying 7a from pape r 2/test fg 3.py", line 39, n odule> .append { 11st of ones [1] -float {R[1]) float (T [1])) - - - Valuelrror: coild not convert string to float: 9.17973518E RESTART: C;\Users\User\Desktop\photonics\photon per 2fffgggg 3.py test n stuff\copying 7a from pa problem I) doesnt convert propperly problem 2) bad graphvalue of R doesnt keep ncreasing

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

Students also viewed these Databases questions