geco-bern / rsofun

Implements the Simulating Optimal FUNctioning framework for site-scale simulations of ecosystem processes, including model calibration. It contains Fortran 90 modules for the P-model, SPLASH, and BiomeE models.
https://geco-bern.github.io/rsofun/
GNU General Public License v3.0
25 stars 28 forks source link

phydro issues #218

Open stineb opened 2 months ago

stineb commented 2 months ago

@jaideep777

I suspect that a clear separation between the model and the analysis done for your research @jaideep777 is needed. Keep only the very minimum in the {rsofun} repo such that you achieve a documentation of a very simplified example. Best is to use the data already contained in the repo (flux data for FR-Pue). All that goes beyond that and which is specific to what you did for the model calibration and evaluation on a larger set of sites should go in a separate (personal analysis) repository. Remember that our plan is to have {rsofun} on CRAN...

stineb commented 2 months ago

Points resolved (not yet all) as per PR https://github.com/geco-bern/rsofun/pull/219

stineb commented 2 months ago

Build of sensititivity_analysis.Rmd now fails with error:

> morrisOut.df <- data.frame(
+   parameter = names(par_cal_best),
+   mu.star = apply(abs(morrisOut$ee), 2, mean, na.rm = T),
+   sigma = apply(morrisOut$ee, 2, sd, na.rm = T)
+ ) %>%
+   arrange( mu.star )
Error in data.frame(parameter = names(par_cal_best), mu.star = apply(abs(morrisOut$ee),  : 
  arguments imply differing number of rows: 11, 10

Should run this again but if fails, too:

> morrisOut <- sensitivity::morris(
+   model = morris_setup$posterior$density,
+   factors = names(par_cal_best), 
+   r = 1000, 
+   design = list(type = "oat", levels = 20, grid.jump = 3), 
+   binf = par_cal_min, 
+   bsup = par_cal_max, 
+   scale = TRUE)
Warning in dunif(x, min = lower, max = upper, log = T) : NaNs produced
Error in if (out == Inf) stop("Inf encountered in prior") : 
  missing value where TRUE/FALSE needed
stineb commented 2 months ago

Can PM be used in combination with P-model-Gs? There is code that is now commented but may have to be un-commented and completed? In gpp_pmodel.mod.f90:

      if (use_pml) then
        ! We plug Pmodel/Phydro-derived gs into the PM equation to calculate T (note this is uncoupled PM-transpiration)
        ! use PFT-specific gs for this calculation: tile_fluxes(lu)%plant(pft)%gs_accl

        ! TODO: Fill this in
        ! tile_fluxes(lu)%plant(pft)%dtransp = PM_EQUATION(tile_fluxes(lu)%plant(pft)%gs_accl)

The argument using_pml is not used in subroutines of waterbal_splash.mod.f90. @jaideep777

jaideep777 commented 2 months ago

Yes, as mentioned in the comment, this is just a placeholder where the PM equation should go. It's not coded in yet. Just uncommenting won't do, because PM_EQUATION doesn't exist. It'll have to be coded.

All the PM equation calculations should be done at the PFT level, hence they are in gpp_pmodel rather than waterbal_splash

stineb commented 2 months ago

I think the PM should be applied at the LU-level (land unit-level), not PFT-level. I suggest to use the fractional plant coverage-weighted average Gs and calculate PML-ET in the waterbal module (it's fine to duplicate code that is already in photosynth_phydro.mod.f90 for now).

jaideep777 commented 2 months ago

Isn't the whole point of PM to distinguish surface properties of different vegetation types? If you want to do this only for inter-cell differences, then yes, the entire code chunk with the T calculation can be moved to waterbal_splash

stineb commented 2 months ago

The gridcell-average (or land unit-average) surface properties can be used. The model structure is adopted from LPX (and other similar models) where all PFTs have access to the same soil water and the soil water balance is done at the gridcell-level (or land-unit level). The idea is that PFTs occur tightly interspersed and are not separated into disjunct tiles. The canopy exchanges with the atmosphere and represents a mix of PFTs. I see that there will be an inconsistency when transpiration is calculated per PFT following diffusion, and then total canopy-transpiration is calculated at the gridcell-level follwoing PML. They won't add up.