r_net.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<stdlib.h>
  4. #define PI 3.1415927
  5. double r_net(double bbalb, double ndvi, double tempk, double dtair,
  6. double e0, double tsw, double doy, double utc,
  7. double sunzangle)
  8. {
  9. /* Tsw = atmospheric transmissivity single-way (~0.7 -) */
  10. /* DOY = Day of Year */
  11. /* utc = UTC time of sat overpass */
  12. /* sunzangle = sun zenith angle at sat. overpass */
  13. /* tair = air temperature (approximative, or met.station) */
  14. double Kin = 0.0, Lin = 0.0, Lout = 0.0, Lcorr = 0.0, result = 0.0;
  15. double temp = 0.0, ds = 0.0, e_atm = 0.0, delta = 0.0;
  16. double tsw_for_e_atm = 0.7; /*Special tsw, consider it a coefficient */
  17. /* Atmospheric emissivity (Bastiaanssen, 1995) */
  18. e_atm = 1.08 * pow(-log(tsw), 0.265);
  19. /* Atmospheric emissivity (Pawan, 2004) */
  20. /* e_atm = 0.85 * pow(-log(tsw),0.09); */
  21. /* ds = 1.0 + 0.01672 * sin(2*PI*(doy-93.5)/365); */
  22. ds = 1.0 / pow((1 + 0.033 * cos(2 * PI * doy / 365)), 2);
  23. delta = 0.4093 * sin((2 * PI * doy / 365) - 1.39);
  24. /* Kin is the shortwave incoming radiation */
  25. Kin = 1358.0 * (cos(sunzangle * PI / 180) * tsw / (ds * ds));
  26. /* Lin is incoming longwave radiation */
  27. Lin = (e_atm) * 5.67 * pow(10, -8) * pow((tempk - dtair), 4);
  28. /* Lout is surface grey body emission in Longwave spectrum */
  29. Lout = e0 * 5.67 * pow(10, -8) * pow(tempk, 4);
  30. /* Lcorr is outgoing longwave radiation "reflected" by the emissivity */
  31. Lcorr = (1.0 - e0) * Lin;
  32. result = (1.0 - bbalb) * Kin + Lin - Lout - Lcorr;
  33. return result;
  34. }