PRO idl_hw1_acp ; acp is for Aaron Paget ; The purpose of this homework is to make a cosine wave plot with ; wavelength of 2*PI for two cycles of phases 0,15,30,45,60,75,90 (degrees) ; In order to do this, I will first build an x array such that I have a ; value at every point (or degree) so it looks really good ; Here we build the x array indexed from 0 to 720 x = FINDGEN(721) ; FP indexed array x = x * 1. ; sets range to 0:720, step 1, as reals ; ; Now that we have the array built, we need to construct the cosine function ; which depends on x and the phase shift. To shift the phase to the left, ; you need to add the shift from the arguement in the cosine. ; ; For the initial case, the phaseshift will be 0 incrimenting by 15 up to 90 ; in degrees. Changing the arguement into radians is accomplished with the ; !DTOR. ; phaseshift=0. y0 = COS(x * !DTOR + phaseshift * !DTOR ) ; cosine of x in degrees ; now we create the rest of the lines phaseshift=15. y15 = COS(x * !DTOR + phaseshift * !DTOR ) ; cosine of x in degrees phaseshift=30. y30 = COS(x * !DTOR + phaseshift * !DTOR ) ; cosine of x in degrees phaseshift=45. y45 = COS(x * !DTOR + phaseshift * !DTOR ) ; cosine of x in degrees phaseshift=60. y60 = COS(x * !DTOR + phaseshift * !DTOR ) ; cosine of x in degrees phaseshift=75. y75 = COS(x * !DTOR + phaseshift * !DTOR ) ; cosine of x in degrees phaseshift=90. y90 = COS(x * !DTOR + phaseshift * !DTOR ) ; cosine of x in degrees ; ; The plots must be made. First the window is created appropiately ; and approximately the size of the sample, at least in proportional ; dimensions. Labeling the x and y coordinates gives some perspective ; with tick marks matching. ; The initial plot is made with overlays for each additional phase. ; WINDOW, XSIZE=700,YSIZE=800 PLOT, x, y0,$ XRANGE=[0,720], XSTYLE=1, YRANGE=[-1.2,1.2], YSTYLE=1, $ XTITLE='DEGREES', YTITLE='COSINE', $ XTICKINTERVAL=90, XMINOR=2, XCHARSIZE=1.5, YCHARSIZE=1.5, THICK=2, $ COLOR='00'X, BACKGROUND='ffffff'X,$; POSITION=[.1,.2,.9,.9] OPLOT, x, y15, THICK=2, COLOR='00'X, LINESTYLE=1 ; OPLOT, x, y30, THICK=2, COLOR='00'X, LINESTYLE=2 ; OPLOT, x, y45, THICK=2, COLOR='00'X, LINESTYLE=3 ; OPLOT, x, y60, THICK=2, COLOR='00'X, LINESTYLE=4 ; OPLOT, x, y75, THICK=2, COLOR='00'X, LINESTYLE=5 ; OPLOT, x, y90, THICK=2, COLOR='00'X, LINESTYLE=6 ; ; ; The legend is generated here. The legend has all of the values of the phases ; spaced along the bottom and placed appropiate to match the origional. ; XYOUTS, .14,.1,'0',/NORMAL, SIZE=1.5, COLOR=0 XYOUTS, .23,.1,'15',/NORMAL, SIZE=1.5, COLOR=0 XYOUTS, .34,.1,'30',/NORMAL, SIZE=1.5, COLOR=0 XYOUTS, .45,.1,'45',/NORMAL, SIZE=1.5, COLOR=0 XYOUTS, .57,.1,'60',/NORMAL, SIZE=1.5, COLOR=0 XYOUTS, .67,.1,'75',/NORMAL, SIZE=1.5, COLOR=0 XYOUTS, .78,.1,'90',/NORMAL, SIZE=1.5, COLOR=0 XYOUTS, .5,.91,'COSINE WAVE WITH PHASES',/NORMAL, ALIGN=.5, SIZE=1.9, COLOR=0 ; ; In order to make the lines appear on the bottom as a legend, a new plot ; is generated. Two arrays are built for initial sampling and positioning ; as well as avoiding the use of a /NODATA command. ; A plot is made in a position close to the bottom of the page. ; x1=FINDGEN(721)-20 y1=FINDGEN(721)*0. PLOT, x1(20:41),y1,$ XRANGE=[-20,721], XSTYLE=5, YRANGE=[-1.5,1.5], YSTYLE=5, $ THICK=2,/NOERASE,XTHICK=0,YTHICK=1, $ COLOR=0, BACKGROUND='ffffff'X ,$; POSITION=[.05,.06,.9,.15], LINESTYLE=7 ; ; The lines are generated for the legend on this new plot ; OPLOT, [0,40], [0.0,0.0], COLOR=0, THICK=2, LINESTYLE=0 OPLOT, [90,130], [0,0], COLOR=0, THICK=2, LINESTYLE=1 OPLOT, [180,220], [0,0], COLOR=0, THICK=2, LINESTYLE=2 OPLOT, [280,320], [0,0], COLOR=0, THICK=2, LINESTYLE=3 OPLOT, [380,420], [0,0], COLOR=0, THICK=2, LINESTYLE=4 OPLOT, [475,515], [0,0], COLOR=0, THICK=2, LINESTYLE=5 OPLOT, [565,605], [0,0], COLOR=0, THICK=2, LINESTYLE=6 ; ; Por fin. Ya cumplimos el proposito de la tarea. ; (Finally. Now we are done with the purpose of the homework.) ; You never indicated which language to comment in. ; maybe german next time. ; END