On 05/01/17 13:29, S. P. Molnar wrote: > Fortran II using punched paper tape. Yes, am a rather elderly . . .).
You are not the only one, there are at least 2 more of us on this list that started in that era... > short program to change frequency to wavelength for a plot of > ultraviolet spectra. I have attached a pdf of the program. This is a text list so attachments usually get stripped off. Please post the code in the body of the email using plain text formatting. > To change the frequency to wave length I did the following: > > p=1/1e7 p = 1e-7 > wave_length = p*np.array(frequency) I don't really use numpy so don't know what that line does. But assuming it applies the multiplication to each array element I'd probably use: wave_lengths = [p*f for f in frequencies] or possibly wave_lengths = map(lambda f: p*f, frequencies) where frequencies was a tuple/list of frequency values. However... > (The relationship between wavelength and frequency is: wavelength = > 1.0e7/frequency, where 1e7 is the speed of light) That formula doesn't look like the one you use above if my guess is correct. That would look like: wave_length = [1e7/f for f in frequencies] ie positive exponent and division instead of multiplication > Apparently what I have managed to do is divide each element of the frequency > list by 1/1e7. > > What I want to do is divide 1e7 by each element of the freqquency list. > How di I do this? Rearrange the equation and use division instead of multiplication I think that by calculating 1/p you have made things much more complicated - unless there is some subtle arithmetic magic going on that I'm missing? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor