HW3 2020 1 Biophysical Ecology, BIOL/ATMOS/GEO 5495 Name___________________________ Homework 3 Fall 2020 Due: Friday Sep 11, before 12 noon, submitted on Canvas Do your work on other pages and attach...

I need help with the code for R studio


HW3 2020 1 Biophysical Ecology, BIOL/ATMOS/GEO 5495 Name___________________________ Homework 3 Fall 2020 Due: Friday Sep 11, before 12 noon, submitted on Canvas Do your work on other pages and attach them to this one as a single pdf. You can do this either by typing or (clear) writing by hand, but you must turn it in electronically. Scan or take a legible photo of your handwritten sheets. To receive credit, you must SHOW your work, not just the answers. ALWAYS include units when answers have units. Most students in this class require help with homework assignments. Please feel free to ask if you need it. 1) (20 pts) The attached plots show radiative energy balance components for a grassland site in southern Arizona. Each of the 4 plots is a single day from midnight to midnight. Radiation gain by the grassland surface is positive in sign. The symbols and lines do not match in the different graphs. a) There are 4 different days shown, representing summer/clear (day 233 – the days are not labeled), summer/cloudy (day 229), winter/clear (day 339), and winter/cloudy (day 346) conditions. Identify which plot is which by labeling them “summer/clear” etc. b) On each plot, label these components: incoming shortwave (Sin), outgoing shortwave (Sout), incoming longwave (Lin), outgoing longwave (Lout), net radiation (Rnet) c) Estimate the radiative temperatures of the grassland and the atmosphere on each day at hour 20 (8pm). If you’re not given a necessary quantity, look it up and be clear what you use. d) Estimate the albedo (shortwave reflectivity) on each day at noon. e) Which of the winter nights has more radiative input from the atmosphere, cloudy or sunny? How do you think this might affect air temperature? 2) (20 pts) a) How much radiant energy will an 80 cm2 cactus pad receive in an hour from a 35 °C peccary standing next to it at night? Assume the cactus pad is perpendicular to the peccary, and only one side of the cactus receives or emits energy. Ignore all other sources of energy (radiation from the sky, ground, etc.). Your answer should be in units of energy (Joules). b) If the cactus surface temperature is 30 °C, calculate the net radiation of the cactus pad on the side facing the peccary. Assume an emissivity for the peccary of 1.0, and absorptivity for the cactus of 0.98. 3) (15 pts) This problem involves using R interactively. You’ll need to spend a little time typing things into the Console Window (and reading Help) to answer these questions. No programming is necessary for this problem, just interactive use of R. Begin with this command (> denotes the prompt in the Console Window). Pay close attention to the parentheses (or you can cut and paste this into the Console). > x <- rbind(c(1,="" 3,="" 4,="" 5,="" 7),="" c(5,="" 6,="" 10,="" 9,="" 11),="" c(10,="" 23,="" 23,="" 1,="" 3))="" then="" type=""> x to view the matrix x that you’ve created. Resize the command window as necessary so you can see all of what you need to. Verify you typed it in correctly by making sure it looks like this: > x 2 [,1] [,2] [,3] [,4] [,5] [1,] 1 3 4 5 7 [2,] 5 6 10 9 11 [3,] 10 23 23 1 3 If not, retype the command above until you get it right. The “rbind” command combines vectors into matrices, treating each vector as a row (it binds rows together top to bottom). The “c” command combines elements, in this case to create the initial vectors which rbind uses as rows. Try using “c” on its own: > rowVec <- c(1,="" 3,="" 4,="" 5,="" 7)="" then:=""> rowVec [1] 1 3 4 5 7 Then type in the commands below, take a look at (and write down) the response in the command window, and then explain in words what the command is doing. For example, if the command is > x[2:nrow(x), 1:3] then your answer to this problem should be: [,1] [,2] [,3] [1,] 5 6 10 [2,] 10 23 23 This command retrieves the subset of x defined by rows 2 and 3 (the number of rows in x) and columns 1- 3. The result is a 2x3 matrix (2 rows x 3 columns). Note that some of your answers will be matrices that have defined numbers of rows and columns, as above. Make sure that you write the answer down correctly so that the number of rows and columns, and the value of the element indexed are clear. If it’s unclear what a command means, look it up in the help. > help(nrow) Here are the commands. Note that not all of them involve the original matrix x. a) x[ ,5] b) x[1, ] c) x[2,3:4] d) x[1:2,2:5] e) length(x[1, ]) f) length(x[ ,1]) g) sum(x[2, ]) h) mean(x[ ,ncol(x)]) i) max(x) j) min(x) 3 k) round(3.75) l) floor(3.75) m) z <- 3.0e8="" n)="" zz=""><- pi o) log(25) 4) (15 pts) explain in words what each of the following r commands does (note that most of these listed here would require arguments to be typed in the command window, so you’re better off going to the help files.) read.table write.table print("i am happy") rm par c rbind sin exp line plot lines points cos acos important! for all r-coding problems in this class (including the one below), to receive full credit you must turn in 1) a copy of your program (the .r file), with your name commented at the top of the code. you must appropriately comment your program – this is important so we can understand what you are doing. extensive comments are very helpful for programming in general and you should get in the habit of using lots of comments. 2) any output required for the problem (usually a plot), with your name on it at the top of the plot using the “title” command. see lab2_student.r on the website for an example of how to place a title on a plot and other plotting commands. 3) your plots should always include appropriate labeling, including • a title with your name • axis labels, with units • a legend when more than one variable is plotted • unique plot symbols or line types when more than one variable is plotted. • anything else necessary to answer the question you are asked (for example, handwritten text describing your interpretation of the data in a plot, etc). 5) (25 pts) for this problem, use equations 4.1 and 4.5 from this file: bonan_ecological_climatology_3rd_edition_ch4_only.pdf which describe some aspects of earth/sun geometry. the reading will provide more detail. it does not include an equation for the solar declination angle (d), so use this one: d = -23.44*cos( (day+10) / 365 ) 4 here, "day" corresponds to day of year, 1 to 365. the factor of 10 shifts from the winter solstice (dec 21) to jan 1 (first day of calendar year). this is the same everywhere on earth (defined by earth-sun geometry). a) first, plot (using r, don't sketch) the solar declination angle as a function of day of year, from 1 to 365. hint: your answer will look exactly like figure 4.3. the declination angle is depicted in figure 4.2. note! trigonometric functions in r use an argument of radians, so you will need to convert appropriately between degrees and radians. next, calculate the following solar parameters for your birthday in moab (38.61 n, 109.53 w). ignore the influence of the mountains. if you don't want to reveal your birthday, then use halloween. these are latitude-dependent. b) solar altitude (not declination) angle at solar noon (solar noon has hour angle h = 0) c) daylength d) what is your birthday? (we need this to grade) e) using r, plot the altitude angle of the sun at solar noon for missoula, montana (lat/long 46.9 n and 114.0 w) as a function of day of year (1 to 365). 0 5 10 15 20 25 -600 -400 -200 0 200 400 600 hour of day en er gy fl ux d en si ty (w /m 2) 0 5 10 15 20 25 -600 -400 -200 0 200 400 600 800 hour of day en er gy fl ux d en si ty (w /m 2) 0 5 10 15 20 25 -600 -400 -200 0 200 400 600 800 1000 1200 hour of day en er gy fl ux d en si ty (w /m 2) 0 5 10 15 20 25 -400 -300 -200 -100 0 100 200 300 400 hour of day en er gy fl ux d en si ty (w /m 2) davework sticky note this is the plot for problem 1 pi="" o)="" log(25)="" 4)="" (15="" pts)="" explain="" in="" words="" what="" each="" of="" the="" following="" r="" commands="" does="" (note="" that="" most="" of="" these="" listed="" here="" would="" require="" arguments="" to="" be="" typed="" in="" the="" command="" window,="" so="" you’re="" better="" off="" going="" to="" the="" help="" files.)="" read.table="" write.table="" print("i="" am="" happy")="" rm="" par="" c="" rbind="" sin="" exp="" line="" plot="" lines="" points="" cos="" acos="" important!="" for="" all="" r-coding="" problems="" in="" this="" class="" (including="" the="" one="" below),="" to="" receive="" full="" credit="" you="" must="" turn="" in="" 1)="" a="" copy="" of="" your="" program="" (the="" .r="" file),="" with="" your="" name="" commented="" at="" the="" top="" of="" the="" code.="" you="" must="" appropriately="" comment="" your="" program="" –="" this="" is="" important="" so="" we="" can="" understand="" what="" you="" are="" doing.="" extensive="" comments="" are="" very="" helpful="" for="" programming="" in="" general="" and="" you="" should="" get="" in="" the="" habit="" of="" using="" lots="" of="" comments.="" 2)="" any="" output="" required="" for="" the="" problem="" (usually="" a="" plot),="" with="" your="" name="" on="" it="" at="" the="" top="" of="" the="" plot="" using="" the="" “title”="" command.="" see="" lab2_student.r="" on="" the="" website="" for="" an="" example="" of="" how="" to="" place="" a="" title="" on="" a="" plot="" and="" other="" plotting="" commands.="" 3)="" your="" plots="" should="" always="" include="" appropriate="" labeling,="" including="" •="" a="" title="" with="" your="" name="" •="" axis="" labels,="" with="" units="" •="" a="" legend="" when="" more="" than="" one="" variable="" is="" plotted="" •="" unique="" plot="" symbols="" or="" line="" types="" when="" more="" than="" one="" variable="" is="" plotted.="" •="" anything="" else="" necessary="" to="" answer="" the="" question="" you="" are="" asked="" (for="" example,="" handwritten="" text="" describing="" your="" interpretation="" of="" the="" data="" in="" a="" plot,="" etc).="" 5)="" (25="" pts)="" for="" this="" problem,="" use="" equations="" 4.1="" and="" 4.5="" from="" this="" file:="" bonan_ecological_climatology_3rd_edition_ch4_only.pdf="" which="" describe="" some="" aspects="" of="" earth/sun="" geometry.="" the="" reading="" will="" provide="" more="" detail.="" it="" does="" not="" include="" an="" equation="" for="" the="" solar="" declination="" angle="" (d),="" so="" use="" this="" one:="" d="-23.44*cos(" (day+10)="" 365="" )="" 4="" here,="" "day"="" corresponds="" to="" day="" of="" year,="" 1="" to="" 365.="" the="" factor="" of="" 10="" shifts="" from="" the="" winter="" solstice="" (dec="" 21)="" to="" jan="" 1="" (first="" day="" of="" calendar="" year).="" this="" is="" the="" same="" everywhere="" on="" earth="" (defined="" by="" earth-sun="" geometry).="" a)="" first,="" plot="" (using="" r,="" don't="" sketch)="" the="" solar="" declination="" angle="" as="" a="" function="" of="" day="" of="" year,="" from="" 1="" to="" 365.="" hint:="" your="" answer="" will="" look="" exactly="" like="" figure="" 4.3.="" the="" declination="" angle="" is="" depicted="" in="" figure="" 4.2.="" note!="" trigonometric="" functions="" in="" r="" use="" an="" argument="" of="" radians,="" so="" you="" will="" need="" to="" convert="" appropriately="" between="" degrees="" and="" radians.="" next,="" calculate="" the="" following="" solar="" parameters="" for="" your="" birthday="" in="" moab="" (38.61="" n,="" 109.53="" w).="" ignore="" the="" influence="" of="" the="" mountains.="" if="" you="" don't="" want="" to="" reveal="" your="" birthday,="" then="" use="" halloween.="" these="" are="" latitude-dependent.="" b)="" solar="" altitude="" (not="" declination)="" angle="" at="" solar="" noon="" (solar="" noon="" has="" hour="" angle="" h="0)" c)="" daylength="" d)="" what="" is="" your="" birthday?="" (we="" need="" this="" to="" grade)="" e)="" using="" r,="" plot="" the="" altitude="" angle="" of="" the="" sun="" at="" solar="" noon="" for="" missoula,="" montana="" (lat/long="" 46.9="" n="" and="" 114.0="" w)="" as="" a="" function="" of="" day="" of="" year="" (1="" to="" 365).="" 0="" 5="" 10="" 15="" 20="" 25="" -600="" -400="" -200="" 0="" 200="" 400="" 600="" hour="" of="" day="" en="" er="" gy="" fl="" ux="" d="" en="" si="" ty="" (w="" m="" 2)="" 0="" 5="" 10="" 15="" 20="" 25="" -600="" -400="" -200="" 0="" 200="" 400="" 600="" 800="" hour="" of="" day="" en="" er="" gy="" fl="" ux="" d="" en="" si="" ty="" (w="" m="" 2)="" 0="" 5="" 10="" 15="" 20="" 25="" -600="" -400="" -200="" 0="" 200="" 400="" 600="" 800="" 1000="" 1200="" hour="" of="" day="" en="" er="" gy="" fl="" ux="" d="" en="" si="" ty="" (w="" m="" 2)="" 0="" 5="" 10="" 15="" 20="" 25="" -400="" -300="" -200="" -100="" 0="" 100="" 200="" 300="" 400="" hour="" of="" day="" en="" er="" gy="" fl="" ux="" d="" en="" si="" ty="" (w="" m="" 2)="" davework="" sticky="" note="" this="" is="" the="" plot="" for="" problem="">
Oct 26, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here