Correct use of lambda functions for exponential of variable #118
|
Hello! I am using the "Magnus-Tetens" formula for calculating the saturation vapor pressure to use it in subsequent calculations of relative humidity. The formula is: ew = 6.112 e(17.67 t/(243.5 + t)) I am using the lambda function in nctoolkit for the calculation. The way I wrote the formula is: ds.assign(es=lambda x: 6.112exp((x.T_c17.67)/(x.T_c+243.5))) with T_c being the column for Temperature in my netCDF. What I would like to ask is if I am properly using the lambda function for the calculation. Is it okay to call x.T_c twice in two different sections of the formula? I appreciate your guidance on this! |
Answered by
robertjwilson
Aug 13, 2024
Replies: 1 comment 1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @JairoVS. That is totally OK.
assignwill be able to use anything within the lambda function, so long as it evaluates to a number. So you could replace the constants with Python variables, for example.