Question: 2 Coding Assignment to be complete in a jupiterlab notbook in python: Finding local maxima. Throughout this assignment, you must comment your code and be
Coding Assignment to be complete in a jupiterlab notbook in python: Finding local maxima.
Throughout this assignment, you must comment your code and be sure to label the axes on all your plots. Please indicate clearly at the start of a block of code which part of the assignment it is in response to
Plot the Planck function for a temperature of T K you may use the function you defined in previous tutorials, either by pasting the code into your notebook or after Tuesdays class by importing it as a module Use a range of wavelengths plotted in nm that includes the peak of the thermal emission spectrum and sample the curve with enough points that it looks smooth.
Compute the derivative of the Planck function dBd over your range of wavelengths using a central difference scheme: f x fx h fx hh Using a step size of h nm evaluate this derivative at exactly the same wavelengths as before, and plot it on a new set of axes.
Estimate visually the wavelength where the derivative dBd crosses zero it may help to plot a straight line at y using pltaxhline Does it correspond to the wavelength where the emission spectrum peaks? Should it
Plot the Planck function you plotted in Q This time, color the points or curve so they are one color when the slope dBd is positive and another color when the slope is negative. Hint: use Boolean selection arrays! Think carefully about how to use pltplot or pltscatter to accomplish this.
Write code to find the wavelength location of the spectrums peak, peak by computing where the derivative as calculated via central difference formula above changes sign from positive to negative this method is more robust than looking for an exact zero Do the same for stars with temperatures spaced every K between and K inclusive. Plot peak as a function of temperature, and overplot the analytical result expected from Wiens Law Homework B on the same axes. Do your results roughly agree?
Load the data in the file modelKtxt available on both Canvas and Scorpius under homejdarlingastrtextfiles into two arrays, one for wavelengths and the other for fluxes. This is a model spectrum of a Sunlike star. Plot this spectrum with wavelength on the xaxis and flux on the yaxis. On the same axes, overplot the Planck function for a K object.
Calculate the derivative of this model spectrum with respect to wavelength. This time, use a forward differencing scheme and calculate the derivative slope using the GIVEN x and yvalues. The step size will now be set by the xspacing of the model spectrum. Make a plot of the model solar spectrum flux, and do what you did before: color the points where the slope is positive as one color and those where the slope is negative as another color you will want to use pltscatter this time Set the xlimits of the plot to zoom into a nm chunk of the spectrum any chunk will do so you can see what is happening.
Discuss why the method we used to find the peak of the Planck function would not work to find the peak of the actual Sunlike spectrum.
How might you fix the problem you identified in the previous question? You dont need to show the code you would write but rather, speak in pseudocode or generalities about what you might do to overcome the issue.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
