Closed dlebauer closed 8 years ago
Sorry for the delayed response on this. I'm not sure I understand the technical challenge. I do think that rethinking biome classification is in order, but will require a bit of rearranging of some parameters, so it's not a very simple task. Lets talk about it today. I'll need to spend some time looking into it.
I need to work on this issue more, but wanted to modify this previous post because I realize that my previous posts here were off track.
1- I agree that SYNMAP is a good starting place. I think we should use it as the first cut for determining which ecosystem types may be present in a given location. 2-I think we'll need to complement SYNMAP with something else because its categories don't all map very well onto biome data that we have. One possibility may be FAO ecozones (which we have already procured for this project) because it is a fairly standard way of defining biomes-- used by IPCC and others. This gives the advantage of easy comparison with policy and existing values that could be used as defaults (e.g., IPCC 2006 guidance on national GHG inventories).
What I need to work on is figuring out the best biome categories for default values and how these can map to SYNMAP.
David, does this generally sounds like a good working plan?
The following are instructions for the revised biomes mapping. The new vegetation types will be associated with revised default values, which I will provide. Please contact me if you have any questions.
The new biomes mapping scheme will draw upon several maps:
Each of these maps will be associated to major vegetation types as indicated in the file VegTypeAssociations.csv. (in Box/gcs/Revised Biomes Mapping (2016)). Those vegetation types are as follows:
New biome default values will be described/ tracked in issue #64
Can someone either upload SynMap to box or provide a link to it?
I don't see it on Box right now, and the download link I found through google just downloads a file saying that the service is unavailable.
Thanks.
I added it in the "Map to be added to Calculator" folder in the box. It is called Hurtt_SYNMAP_Global_HD_2010.nc Let me know if this is not what you needed. Valentine
First thanks @ValentineHerr for adding the synmap!
Also - I'm not entirely sure I understand what needs to happen here. I'm not really familiar with biome data in general, but I think what I've parse together is the following:
0
or a 1
).1
for the selected lat/lon pair.Just a thought - this will potentially be slower, since (in R at least) you can only get one variable at a time, so we'll have to get the value for each variable as ~12 separate calls to the file. An alternative would be to set the biome as a dimension, and then for a given lat/lon we could query the netcdf file once and return a vector of 0/1
values that correspond to the biome dimension and create the list from that.
If I'm missing a step or if I have the configuration wrong please let me know. Thanks.
I can't advise on the best way to program this. Are my instructions on the desired functionality clear?
Okay, as of commit 94bf9b5, a working example of biome loading is here. The calculation of said biomes doesn't work yet because various changes in the biome_defaults have to be taken into account in the calculator, but at least you can see the biome selection process.
It would probably be good to walk through this with someone so that we can address any potential errors. Also see the notes below. Needed (see major notes for more info):
create_pkg_data.R
script, and copy the files from inst/extdata
to the ghgvc directory above, but that's not really needed.OM_SOM
, and will be easy to add in the HWSD lookup once I know where it is. I couldn't figure it out from previous code/files. Maybe @dlebauer knows?if
statements to determine which biomes to load, but the mapping is not one-to-one, so I can't reverse engineer without duplicate value entries in the csv file. This is a problem because calculating the biophysical value under the new method depends on the IBIS value, but in map_vegtypes.csv, the lookup is based on name instead of value. If someone can add the values that go with each name, the rest is donelon, lat, ...
. Did we create the gez file and if so is it worth reordering to follow that convention? For now I've hacked the ghgvcR get_ncdf()
function in netcdf.R to work around it.Thanks. I will review thoroughly as soon as possible and provide feedback as I go. If it would be helpful to walk through with me via phone or videoconference, I could be available most of the afternoon or evening starting in about half an hour.
Regarding the two major needs,
@ValentineHerr created the FAO/gez file and may be able to help with that.
@potterzot
Besides IBIS, are the other rules for revised biome mapping fully implemented in this version? That is, is it ready for review?
I believe so. Let me summarize how it works in the code:
If any of those steps are wrong, just let me know and it's not worth reviewing. If they all look right, then it's ready for review, bearing in mind (1) the HWSD values aren't in yet, and (2) the IBIS values aren't in yet.
Nicholas Potter http://potterzot.com 9C73 3AAA 6D99 86F1 F8F4 601D 298F 8713 1BE6 5941
On Mon, Aug 22, 2016 at 10:10 AM, Kristina Anderson-Teixeira < notifications@github.com> wrote:
Besides IBIS, are the other rules for revised biome mapping fully implemented in this version? That is, is it ready for review?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ebimodeling/ghgvc/issues/59#issuecomment-241481841, or mute the thread https://github.com/notifications/unsubscribe-auth/AAdIbmqi1lLfj9ZrvcWcJBm2MIy2Y2Srks5qidgbgaJpZM4CY1kM .
Steps 1 and 5 require modification. 1) Use synmap, KOPPEN, FAO, IBIS, and RAMANKUTTY values to lookup vegetation types (map_vegtypes.csv). There will be multiple options. The use of multiple map layers increases the probability of listing all of the important potential vegetation types for that location. Note that Ramankutty lookup is already implemented. See issue #82.
5) Calculate OM_SOM based on vegetation type (for natural ecosystem types or pasture, if SYNMAP="Cropland", 0.43 * hwsd, else 0.3*hwsd. for crops, OM_SOM=0)
Okay, awesome. So just to clarify, you'd like me to concatenate all of the vegetation types available from all of the synmap, koppen, fao, ibis, ramankutty values to create the list of vegetation types for which to lookup biomes?
Also - @dlebauer, I also don't know where the ramankutty map file is. So the things I need to fill the above are:
I think that's it.
Also, I think there's maybe a copy/paste error here:
5) Calculate OM_SOM based on vegetation type (for natural ecosystem types or pasture, if SYNMAP="Cropland", 0.43 * hwsd, else 0.3*hwsd. for crops, OM_SOM=0)
Is the only difference the addition of for crops, OM_SOM = 0? If so was already the case so it's all set.
Yes, that is correct.
On 5), the difference is the addition of "for natural ecosystem types or pasture, if..." and "for crops, ...". It sounds like it may all be correct already.
t_oc is the %SOM in the top 0-30 cm layer; s_oc is %SOM in the 30-70 cm layer
The variable you want SOC = t_oc * 0.3 + s_oc * 0.7
NO; we do not want %SOM, we want SOC in units of total mass (tons C ha-1 to 1 m). I believe the file has the variables SOCSUB and SOCTOP. So we want SOC=SOCSUB + SOCTOP. @ValentineHerr can look at the file to verify the variable name.
We must be looking at different files - the hwsd.nc file has %SOM as mentioned above and bulk density in units of kg / dm3. With appropriate conversions we can compute the SOC as tons C ha-1 to 1 m. Let me know if you want me to work out the conversion, but the first step will be:
t_oc * 0.3 * t_ref_bulk+ s_oc * 0.7 * s_ref_bulk
Percent cover for different crops is here:
netcdf/GCS/Crops/Brazil/Sugarcane/brazil_sugc_fractional_10yr_avg.nc netcdf/GCS/Crops/Brazil/Soybean/brazil_soyb_fractional_10yr_avg.nc netcdf/GCS/Crops/US/SpringWheat/fractioncover/fswh_2.7_us.0.5deg.nc netcdf/GCS/Crops/US/Corn/fractioncover/fcorn_2.7_us.0.5deg.nc netcdf/GCS/Crops/US/Soybean/fractioncover/fsoy_2.7_us.0.5deg.nc
I don't see cover for pasture
Actually I think pasture fractional cover is in
netcdf/GCS/Pasture2000_5min.nc
Does that sound right? Are these the Ramankutty files?
Regarding SOC, working out the conversion may be easiest. I believe @ValentineHerr has been using a file with units of t/ha (if not we need to fix our calculations, Valentine).
Pasture2000_5min.nc sounds right for the Ramankutty files. Is there a crops one too?
The other files you listed are specific crop types We also want generic cropland from Ramankutty.
Are brazil_sugc_fractional_10yr_avg.nc and brazil_soyb_fractional_10yr_avg.nc working? @dlebauer, this relates to a question I sent you this AM via email.
This is how to compute SOC from the hwsd.nc file:
X <- (% SOM in top * top bulk density * % of soil profile in top) + (% SOM in subsoil * subsoil bulk density * % of soil profile in subsoil) SOC = X kg / dm3 * (10 dm / m) * (1,000,000 dm2 / ha) * (1 ton / 1000 kg)
SOC <- (t_oc * 0.3 * t_ref_bulk+ s_oc * 0.7 * s_ref_bulk) * 10000
I think they are working, will have to defer to @potterzot
Are brazil_sugc_fractional_10yr_avg.nc and brazil_soyb_fractional_10yr_avg.nc working? @dlebauer, this relates to a question I sent you this AM via email.
Short answer: yes. More details: Specific crops are still handled in the way they used to be. The way it is handled is:
There is some additional specific logic that applies to certain crops, but that's the process. The new biome mapping only applies to native ecosystems and generic pasture and cropland codes: c(AP1, AP2, C1, C2)
.
What is the additional specific logic that applies to sugarcane and soy in Brazil? Earlier, there was trouble getting the sugarcane (and soy?) map to work, and a hack was created whereby these were assigned by state (not desirable).
I don't know how the map values were created, so there could be something in that that assigns by state, but in terms of the logic after reading the map value, the specifics are:
BR Sugarcane
BR Soy
Actual code
if (!is.na(res$braz_sugarcane_num) &
res$braz_sugarcane_num > 0.01 &
res$braz_sugarcane_num < 110.0) {
biome_data$agroecosystem_eco["BR_sugarcane"] <- name_indexed_ecosystems["BR sugarcane"]
biome_data$agroecosystem_eco[["BR_sugarcane"]]$latent <- custom
biome_data$agroecosystem_eco[["BR_sugarcane"]]$sw_radiative_forcing <- custom
}
if (res$braz_fractional_soybean_num == 1 &
!is.na(res$br_sugc_latent_heat_flux_diff)) {
biome_data$agroecosystem_eco["BR_soy"] <- name_indexed_ecosystems["BR soy"]
biome_data$agroecosystem_eco[["BR_soy"]]$latent <- custom
biome_data$agroecosystem_eco[["BR_soy"]]$sw_radiative_forcing <- custom
}
Okay, a minimal working example is up. I believe it only works with selecting one natural ecosystem. Agriculture systems don't work at the moment because of the below.
Question: The format of the original biome defaults json file has source abbreviations like:
{..., F_N2O = {"s000" = ["0.02927426"]}, ...}
Because the new biome defaults are in a csv file, they have the format:
{..., F_N2O = ["0.02927426"], ...}
Essentially one level removed, with no "s000" key. This is a key for the source of the data from what I can tell. Right now this causes problems because the app will parse either one or the other, but not both. Do you want me to:
a. convert all to the format that includes the "s000" b. convert all to the format that does not include "s000" c. add logic to the app to allow for both formats?
I don't recognize "s000" notation - if it is not needed, please convert to the format that does not include it
The demo is a complete working demo now, excepting the new issues that were created today and the remaining things below.
Here's the current list of stuff that needs to be done for this issue:
sw_radiative_forcing
, latent
, and sensible
. These need to be implemented.NA
in R.The soil carbon numbers are wrong (way too high); most values should be SOC= 50-250 t C ha-1. Then the variable that goes into the calculator is "vulnerable soil organic matter", OM_SOM=SOC/.58*0.3 (or 0.43 when SYNMAP = crops). The .58 converts from C to organic matter (in retrospect, a stupid convention in my code!) and the 0.3 or 0.43 defines the fraction of that SOM that is vulnerable. Also, you need to be sure to convert % to fraction before applying David's formula. So here's a revised formula:
SOC <- (t_oc/100 * 0.3 * t_ref_bulk+ s_oc/100 * 0.7 * s_ref_bulk) * 10000 OM_SOM<- SOC /0.58 * 0.3 (or 0.43).
Regarding this, " have not seen a list of biome names for each biome code like T1, T3, S1, etc... Right now I'm using vegetation types, but this means multiple different biomes will show up in the app as "Broadleaf Evergreen Forest", for example. If we have a list of names and codes for each biome, it would be easy to change this to reflect the specific biome name."... I intentionally chose to define forest type based only on the tree type; I think that makes it easier for users who wouldn't find the biome names very meaningful. So this item is fine.
Regarding this: "the Revised Biome Mapping docx file has this item: " There are a few biome types for which default values do not (yet) exist, as indicated by “NaN”. For these, the calculator should give an error message. Something like: “Insufficient data for this vegetation type in this location. Please enter values manually or de-select this ecosystem type." This is probably not something that it makes sense for me to do. Right now these values are coded as NA in R."... Would it be complicated to make an error message pop up if the user tries to check the box? The error message can read, "Insufficient data for this vegetation type in this location. Please enter values manually or select a different ecosystem type."
Regarding this, " there are not currently instructions for other "MAP" biome settings, for sw_radiative_forcing, latent, and sensible. These need to be implemented."…
Basically, these will be treated exactly the same as they were in the previous version, with the exception that they now apply only some of the time to the natural vegetation types (trees, savanna, shrubs, grassland). The basic logic is: if [selected ecosystem type]==[IBIS vegetation type at selected location], include the biophysical forcings (sw_radiative_forcing, latent). else, no data available.
These maps (or at least most of them) are already loaded in the calculator, and I do not know what they are called. Perhaps @dlebauer can help. The variable definitions and formulas below describe the calculations you will need:
R_net- net radiation or sw radiative forcing, in W/m2.
LE- latent heat, in W/m2
For both, we have paired maps for vegetation (e.g., Natural Vegetation and Natural Vegetation_Bare). There are maps for natural vegetation, maize, soy, sugarcane, switchgrass, and miscanthus.
∆R_net= R_natural vegetation - Rnet bare (will usually be a negative number) ∆LE= LE natural vegetation - LE bare
for both, the number that goes into the calculator is converted as follows: ∆R_net /51007200000 x 1000000000 ∆LE /51007200000 x 1000000000
I’m not familiar with all the inner workings of the calculator, so I hope this all makes sense. Let me know if you have any questions.
I added the IBIS values in map_vegtypes.csv. Let me know if that works.
About the Soil carbon units. Units seem to be in t ha-1 according to instructions that I have about the layers. Also the values stored don't look like percentages. The files I am talking about are:
@ValentineHerr I don't recall where those files came from, but I was referring to the file hwsd.nc produced by MsTMIP. That should be easier because it has all of the necessary data in a single file.
Closing this issue, I think it is done.
We currently have the following maps for biome-type (in netcdf/GCS/biomes):
Options
References
For reference, this is Hurtt's Land Use[ 1] map harmonized with the Synergetic Land Cover Map (SYNMAP)[2]". For reference on the combination of these see [3] .