-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add ppfd and patm computation to CRU #70
Conversation
The code requires all four columns: year_start, year_end, as well as date_start, date_end Since it is possible to only provide two of them, the others need to be derived. The code previously was difficult to understand. This now simplifies the intent. We also add a test in the unlikely case where all four are provided, but they are inconsistent.
Previously numerous if-statements lead to replication of code. This simplifies the logic and better documents intent with code comments.
Since VPD is recomputed anyway on daily resolution it is not taken care of by `expand_clim_cru_monthly_byyr()`, i.e. it silently drops that column. More robust is if the column is kept and daily values are initialized as NA. This is done by this commit. Moreover, the data.frame() after recomputing VPD is now ungrouped, since this is less errror-prone.
…arameters and geometric relationships
…e end of function
… the end of function This reduces code duplication and is similar to how it is handled for ppfd or patm
This is not needed anymore, since vpd is now computed after downscaling in any case.
@fabern , Thanks! On your points:
May I add a point?
|
Ok, I will have a look at Below is the comparison between Note how WorldClim is only between 35 to 80% of the computed value (
|
When using the daily downscaled cloud cover from CRU to compute, the bias with WorldClim disappears. (See below 'scale' of the monthly averages is around 1.0.)
|
…RU to compute ppfd or patm.
R CMD Check warned: "ingest: possible error in all_of(siteinfo, sitename, lon, lat): unused arguments (sitename, lon, lat)"
@stineb This is now ready for review. In a nutshell this PR:
|
Thanks @fabern . We'll eventually have to remove all use of {rgdal} as the library is discontinued. This means also that we'll have to replace all use of the {raster}, now using {terra}. There might be some places left where raster is used, these should eventually be changed. |
I'm going ahead with the merge anyways. |
This PR adds computation of
ppfd
andpatm
, when ingesting CRU data.Since neither
ppfd
norpatm
are measured variables in CRU they are derived in the following way:patm
: using the elevation of the site only.calc_patm(elv, patm0 = 101325)
, which assumes normal pressure at sea levelppfd
: usingcalc_daily_solar()
,ppfd
is thus computed based on geometric relationships (sunrise, sunset, etc...) given the (time-varying up to 1'000'000 BC) orbital parameters of earth. Note that this strongly assumes sunshine fraction of1.0
, i.e. it is not only "always sunny in philadelphia" but on the whole world.1.0
could be improved by linking it to the number of wet daysmwetd
(since it is available from CRU) for which this could be set to0.0
@stineb do you think would make a difference?sf = 1 - (ccov/100)
)