Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latent heat for ED2 #774

Open
Viskari opened this issue Apr 1, 2016 · 17 comments
Open

Latent heat for ED2 #774

Viskari opened this issue Apr 1, 2016 · 17 comments

Comments

@Viskari
Copy link

Viskari commented Apr 1, 2016

As I was going over the output from ED2 as presented by pecan, I realized that ED2 doesn't actually give out latent heat, but the amount of water evaporated and that pecan doesn't currently convert that to energy.

So I thought to ask, before I start adding anything to the code, does pecan have that conversion available? Or should I add it there myself?

@dlebauer
Copy link
Member

dlebauer commented Apr 1, 2016

I don't think so but it would probably be in / should go in
data.atmosphere/R/metutils.R
On Fri, Apr 1, 2016 at 9:42 AM Viskari [email protected] wrote:

As I was going over the output from ED2 as presented by pecan, I realized
that ED2 doesn't actually give out latent heat, but the amount of water
evaporated and that pecan doesn't currently convert that to energy.

So I thought to ask, before I start adding anything to the code, does
pecan have that conversion available? Or should I add it there myself?


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#774

@mdietze
Copy link
Member

mdietze commented Apr 1, 2016

Ok, so there's definitely an inconsistency here within model2netcdf.ED2 because on line 281 it has what appears to be the correct terms:

out <- add(getHdf5Data(ncT, 'FMEAN_VAPOR_LC_PY')+getHdf5Data(ncT, 'FMEAN_VAPOR_WC_PY')+getHdf5Data(ncT, 'FMEAN_VAPOR_GC_PY'),28,row, yrs[y]) ## Qle

but in the other version, on line 412, it only uses evaporation, which is seems wrong because LE involves both evaporation and transpiration

  out <- add(getHdf5Data(ncT, 'AVG_EVAP'),28,row, yrs[y]) ## Qle

And yes, if either or both of those are in moles or mm instead of watts you need to do the conversion: https://github.com/EDmodel/ED2/wiki/Glossary---unit-conversions

@Viskari
Copy link
Author

Viskari commented Apr 1, 2016

No, I know I need to do the conversion, I was asking is the conversion method already in pecan or do I need to add it there?

@Viskari
Copy link
Author

Viskari commented Apr 13, 2016

I am having an issue currently getting the conversion working. I think I figured out what the problem is, but I don't know how to fix it.

I created the function below in data.atmosphere/R/metutils.R and recompiled pecan, but when I call to this function in model2netcdf.ED2.R, it causes the that to crash. I assume the issue is with the param E, but how do I do it correctly?

##' Estimate latent heat from evaporated water [kg/s -> W]
##' @title Latent Heat
##' @param E Evaporation [kg/m2s]
##' @export
##' @author Toni Viskari

LHE <- function(E){
2272000*E
}

@dlebauer
Copy link
Member

@Viskari the function looks like it should work, e.g. if I put LHE(10) it comes up with 22720000. Do you have any additional information other than the fact that it crashes? What does the log say?

@dlebauer
Copy link
Member

P.S. While you are at it I would suggest adding an analogous function to go from evaporation to latent heat, as well as some tests. And perhaps use more informative names ... here are my suggestions

##' @title Convert evaporation rate to latent heat flux
##' 
##' This function converts latent heat flux given in watts from evaporation rate given in mm/s (= kg/m2/s) 
##  The latent heat of vaporization for water (lambda) is 2,264,760 J kg-1, so E * lambda = LH 
##'  @return latent heat flux (LH) in units of Watts/m2 or J/m2/s 
##' @param E Evaporation [kg/m2s]
##' @export
##' @author Toni Viskari
evaporation2latentheat <- function(E){
   LH <- 2272000 * E
   return(LH)
}

##' @title Convert latent heat flux to evaporation rate
##' 
##' This function converts evaporation rate given in mm/s (= kg/m2/s) to latent heat flux 
##  The latent heat of vaporization for water (lambda) is 2,264,760 J kg-1, so E * lambda = LH 
##'  @return Evaporation Rate in units of mm/s or kg/m2/s 
##' @param LH Latent Heat (W/m2)
##' @export
##' @author Toni Viskari, David LeBauer 
latentheat2evaporation <- function(LH){
   E = LH / 2272000
   return(E)
}

PPS Wednesdays are great days for adding new tests ... just put the lines

test_that('conversions between latent heat and evaporation work',{
  expect_equal(evaporation2latentheat(10), 10 * 2272000)
  expect_equal(latentheat2evaporation(10), 10 / 2272000)
  expect_equal(latentheat2evaporation(evaporation2latentheat(1)), 1)
})

in /modules/data.atmosphere/tests/testthat/test.metutils.R

@Viskari
Copy link
Author

Viskari commented Apr 14, 2016

I just tried to rerun, but there seems to be a database issue with our
server at the moment. When I have the runs redone, I'll put the error log
here.

On Wed, Apr 13, 2016 at 6:17 PM, David LeBauer [email protected]
wrote:

P.S. While you are at it I would suggest adding an analogous function to
go from evaporation to latent heat, as well as some tests. And perhaps use
more informative names ... here are my suggestions

##' @title Convert evaporation rate to latent heat flux##' ##' This function converts latent heat flux given in watts from evaporation rate given in mm/s (= kg/m2/s) ## The latent heat of vaporization for water (lambda) is 2,264,760 J kg-1, so E * lambda = LH ##' @return latent heat flux (LH) in units of Watts/m2 or J/m2/s ##' @param E Evaporation [kg/m2s]##' @export##' @author Toni Viskarievaporation2latentheat <- function(E){
LH <- 2272000 * E
return(LH)
}
##' @title Convert latent heat flux to evaporation rate##' ##' This function converts evaporation rate given in mm/s (= kg/m2/s) to latent heat flux ## The latent heat of vaporization for water (lambda) is 2,264,760 J kg-1, so E * lambda = LH ##' @return Evaporation Rate in units of mm/s or kg/m2/s ##' @param LH Latent Heat (W/m2)##' @export##' @author Toni Viskari, David LeBauer latentheat2evaporation <- function(LH){
E = LH / 2272000
return(E)
}

PPS Wednesdays are great days for adding new tests ... just put the lines

test_that('conversions between latent heat and evaporation work',{
expect_equal(evaporation2latentheat(10), 10 * 2272000)
expect_equal(latentheat2evaporation(10), 10 / 2272000)
expect_equal(latentheat2evaporation(evaporation2latentheat(1)), 1)
})

in /modules/data.atmosphere/tests/testthat/test.metutils.R
https://github.com/PecanProject/pecan/blob/master/modules/data.atmosphere/tests/testthat/test.metutils.R


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#774 (comment)

@serbinsh
Copy link
Member

@Viskarihttps://github.com/Viskari Rafael changed around some hostname/IP mapping on the server which messed up PEcAn. He is changing it all back now to get it up and running again.

On Apr 13, 2016, at 8:16 PM, Viskari <[email protected]mailto:[email protected]> wrote:

I just tried to rerun, but there seems to be a database issue with our
server at the moment. When I have the runs redone, I'll put the error log
here.

On Wed, Apr 13, 2016 at 6:17 PM, David LeBauer <[email protected]mailto:[email protected]>
wrote:

P.S. While you are at it I would suggest adding an analogous function to
go from evaporation to latent heat, as well as some tests. And perhaps use
more informative names ... here are my suggestions

##' @title Convert evaporation rate to latent heat flux##' ##' This function converts latent heat flux given in watts from evaporation rate given in mm/s (= kg/m2/s) ## The latent heat of vaporization for water (lambda) is 2,264,760 J kg-1, so E * lambda = LH ##' @return latent heat flux (LH) in units of Watts/m2 or J/m2/s ##' @param E Evaporation [kg/m2s]##' @export##' @author Toni Viskarievaporation2latentheat <- function(E){
LH <- 2272000 * E
return(LH)
}
##' @title Convert latent heat flux to evaporation rate##' ##' This function converts evaporation rate given in mm/s (= kg/m2/s) to latent heat flux ## The latent heat of vaporization for water (lambda) is 2,264,760 J kg-1, so E * lambda = LH ##' @return Evaporation Rate in units of mm/s or kg/m2/s ##' @param LH Latent Heat (W/m2)##' @export##' @author Toni Viskari, David LeBauer latentheat2evaporation <- function(LH){
E = LH / 2272000
return(E)
}

PPS Wednesdays are great days for adding new tests ... just put the lines

test_that('conversions between latent heat and evaporation work',{
expect_equal(evaporation2latentheat(10), 10 * 2272000)
expect_equal(latentheat2evaporation(10), 10 / 2272000)
expect_equal(latentheat2evaporation(evaporation2latentheat(1)), 1)
})

in /modules/data.atmosphere/tests/testthat/test.metutils.R
https://github.com/PecanProject/pecan/blob/master/modules/data.atmosphere/tests/testthat/test.metutils.R


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#774 (comment)


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHubhttps://github.com//issues/774#issuecomment-209698250

@serbinsh
Copy link
Member

OK @Viskari try it now

@Viskari
Copy link
Author

Viskari commented Apr 19, 2016

Okay, got everything running now. So the problem with the function that model2netcdf is complaining about not finding it:

[1] "----- Processing year: 2000"
Error: could not find function "LHE"
Execution halted

Do I need to add some additional link to it?

@mdietze
Copy link
Member

mdietze commented Apr 19, 2016

Did you recompile PEcAn so the package is built, and did you include the package in the dependencies for the ED package?

@Viskari
Copy link
Author

Viskari commented Apr 19, 2016

I recompiled, but I hadn't added it to the dependencies. Where do you do that addition?

@mdietze
Copy link
Member

mdietze commented Apr 19, 2016

@Viskari
Copy link
Author

Viskari commented Apr 21, 2016

Okay, second question how do I do the addition? Do I just add the function name or the data module to the dependencies list?

@dlebauer
Copy link
Member

Yes

@mdietze
Copy link
Member

mdietze commented Apr 21, 2016

The package name goes in the dependencies list, not the function name

@github-actions
Copy link

This issue is stale because it has been open 365 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants