Rui Barradas
2024-Apr-07 14:53 UTC
[R] Question regarding reservoir volume and water level
?s 13:27 de 07/04/2024, javad bayat escreveu:> Dear all; > I have a question about the water level of a reservoir, when the volume > changed or doubled. > There is a DEM file with the highest elevation 1267 m. The lowest elevation > is 1230 m. The current volume of the reservoir is 7,000,000 m3 at 1240 m. > Now I want to know what would be the water level if the volume rises to > 1250 m? or what would be the water level if the volume doubled (14,000,000 > m3)? > > Is there any way to write codes to do this in R? > I would be more than happy if anyone could help me. > Sincerely > > > > > > > >Hello, This is a simple rule of three. If you know the level l the argument doesn't need to be named but if you know the volume v then it must be named. water_level <- function(l, v, level = 1240, volume = 7e6) { if(missing(v)) { volume * l / level } else level * v / volume } lev <- 1250 vol <- 14e6 water_level(l = lev) #> [1] 7056452 water_level(v = vol) #> [1] 2480 Hope this helps, Rui Barradas -- Este e-mail foi analisado pelo software antiv?rus AVG para verificar a presen?a de v?rus. www.avg.com
Sorkin, John
2024-Apr-07 19:07 UTC
[R] Question regarding reservoir volume and water level
Aside from the fact that the original question might well be a class exercise (or homework), the question is unanswerable given the data given by the original poster. One needs to know the dimensions of the reservoir, above and below the current waterline. Are the sides, above and below the waterline smooth? Is the region currently above the waterline that can store water a mirror image of the region below the waterline? Is the region above the reservoir include a flood plane? Will the additional water go into the flood plane? The lack of required detail in the question posed by the original poster suggests that there are strong assumptions, assumptions that typically would be made in a class-room example or exercise. John John David Sorkin M.D., Ph.D. Professor of Medicine, University of Maryland School of Medicine; Associate Director for Biostatistics and Informatics, Baltimore VA Medical Center Geriatrics Research, Education, and Clinical Center; PI Biostatistics and Informatics Core, University of Maryland School of Medicine Claude D. Pepper Older Americans Independence Center; Senior Statistician University of Maryland Center for Vascular Research; Division of Gerontology and Paliative Care, 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 Cell phone 443-418-5382 ________________________________________ From: R-help <r-help-bounces at r-project.org> on behalf of Rui Barradas <ruipbarradas at sapo.pt> Sent: Sunday, April 7, 2024 10:53 AM To: javad bayat; R-help Subject: Re: [R] Question regarding reservoir volume and water level ?s 13:27 de 07/04/2024, javad bayat escreveu:> Dear all; > I have a question about the water level of a reservoir, when the volume > changed or doubled. > There is a DEM file with the highest elevation 1267 m. The lowest elevation > is 1230 m. The current volume of the reservoir is 7,000,000 m3 at 1240 m. > Now I want to know what would be the water level if the volume rises to > 1250 m? or what would be the water level if the volume doubled (14,000,000 > m3)? > > Is there any way to write codes to do this in R? > I would be more than happy if anyone could help me. > Sincerely > > > > > > > >Hello, This is a simple rule of three. If you know the level l the argument doesn't need to be named but if you know the volume v then it must be named. water_level <- function(l, v, level = 1240, volume = 7e6) { if(missing(v)) { volume * l / level } else level * v / volume } lev <- 1250 vol <- 14e6 water_level(l = lev) #> [1] 7056452 water_level(v = vol) #> [1] 2480 Hope this helps, Rui Barradas -- Este e-mail foi analisado pelo software antiv?rus AVG para verificar a presen?a de v?rus. http://www.avg.com/ ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.