pwd
'/Users/ud4/repos/GitHub/FATESFACE'
from IPython.display import Image, display
display(Image(filename='/Users/ud4/Downloads/PIDs.png',width=800))
display(Image(filename='/Users/ud4/Downloads/BiomassVsPIDs.png',width=800))
print ("Source : Knox 2023 (under review; https://d197for5662m48.cloudfront.net/documents/publicationstatus/129549/preprint_pdf/4892791c8be5504aff47afd6065937b7.pdf)")
Source : Knox 2023 (under review; https://d197for5662m48.cloudfront.net/documents/publicationstatus/129549/preprint_pdf/4892791c8be5504aff47afd6065937b7.pdf)
PID | Kp | Kd |
---|---|---|
A | 0.0005 | 0.1 |
B | 0.0005 | 0.005 |
C | 0.0001 | 0.01 |
D | 0.001 | 0.1 |
E | 0.001 | 0.5 |
F | 0.005 | 0.1 |
G | 0.005 | 0.5 |
H | 0.001 | 1.0 |
Figure Set 1: FATES_NPP (for C-only at that site and RD/ECA)
Figure Set 2: FATES_NPP
Figure Set 3: FATES_STOREC
Figure Set 3: FATES_STOREC_TF
Figure Set 4: FATES_STOREN
Figure Set 4: FATES_STOREN_TF
Figure Set 5: FATES_STOREC_TF / FATES_STOREN_TF
Figure Set 3: FATES_L2FR
Figure Set 6: FATES_FROOTC_ALLOC / FATES_LEAFC_ALLOC
Figure Set 7: FATES_FROOTC / FATES_LEAFC
Figure Set 7: FATES_FROOTC
Figure Set 7: FATES_LEAFC
Figure Set 8: FATES_NO3UPTAKE
Figure Set 8: FATES_NH4UPTAKE
Figure Set 9: NET_NMIN
Figure Set 9: GROSS_NMIN
Figure Set10: SMIN_NO3_LEACHED
Figure Set10: DENIT
import os,glob
import xarray as xr
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pyreadr # to read .rds files
import datetime as dt
np.set_printoptions(suppress=True)
path_in = "/Users/ud4/FATESMDS_analysis/outputs/runs/tests_alp/230309/"
# RD only
fnames={}
fnames["DUK_PIDA_Conly_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0615_Base_PIDA_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0615_Base_PIDA_AgBgW_US-DUK_trans.nc"
fnames["ORN_PIDA_Conly_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0615_Base_PIDA_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0615_Base_PIDA_AgBgW_US-ORN_trans.nc"
fnames["DUK_PIDB_Conly"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDB_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDB_AgBgW_US-DUK_trans.nc"
fnames["ORN_PIDB_Conly"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDB_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDB_AgBgW_US-ORN_trans.nc"
fnames["DUK_PIDC_Conly"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDC_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDC_AgBgW_US-DUK_trans.nc"
fnames["ORN_PIDC_Conly"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDC_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDC_AgBgW_US-ORN_trans.nc"
fnames["DUK_PIDD_Conly"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDD_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDD_AgBgW_US-DUK_trans.nc"
fnames["ORN_PIDD_Conly"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDD_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDD_AgBgW_US-ORN_trans.nc"
fnames["DUK_PIDA_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0615_Base_PIDA_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0615_Base_PIDA_AgBgW_RD_US-DUK_trans.nc"
fnames["ORN_PIDA_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0615_Base_PIDA_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0615_Base_PIDA_AgBgW_RD_US-ORN_trans.nc"
fnames["DUK_PIDB_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDB_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDB_AgBgW_RD_US-DUK_trans.nc"
fnames["ORN_PIDB_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDB_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDB_AgBgW_RD_US-ORN_trans.nc"
#"ORN_PIDC_RD" : Simulation missing *Running
fnames["DUK_PIDC_Conly_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDC_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDC_AgBgW_US-DUK_trans.nc"
#fnames["ORN_PIDC_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDC_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDC_AgBgW_RD_US-DUK_trans.nc"
fnames["DUK_PIDC_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDC_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDC_AgBgW_RD_US-DUK_trans.nc"
#fnames["ORN_PIDC_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDC_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDC_AgBgW_RD_US-DUK_trans.nc"
fnames["DUK_PIDD_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDD_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDD_AgBgW_RD_US-DUK_trans.nc"
fnames["ORN_PIDD_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDD_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0614_Base_PIDD_AgBgW_RD_US-ORN_trans.nc"
#fnames["DUK_PIDC_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDC_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDC_AgBgW_RD_US-DUK_trans.nc"
fnames["ORN_PIDC_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDE_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDE_AgBgW_RD_US-ORN_trans.nc"
fnames["DUK_PIDF_Conly_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDF_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDF_AgBgW_US-DUK_trans.nc"
fnames["ORN_PIDF_Conly_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDF_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDF_AgBgW_US-ORN_trans.nc"
fnames["DUK_PIDF_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDF_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDF_AgBgW_RD_US-DUK_trans.nc"
fnames["ORN_PIDF_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDF_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDF_AgBgW_RD_US-ORN_trans.nc"
fnames["DUK_PIDG_Conly_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDG_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDG_AgBgW_US-DUK_trans.nc"
fnames["ORN_PIDG_Conly_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDG_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDG_AgBgW_US-ORN_trans.nc"
fnames["DUK_PIDG_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDG_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDG_AgBgW_RD_US-DUK_trans.nc"
fnames["ORN_PIDG_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDG_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDG_AgBgW_RD_US-ORN_trans.nc"
fnames["DUK_PIDH_Conly_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDH_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDH_AgBgW_US-DUK_trans.nc"
fnames["ORN_PIDH_Conly_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDH_AgBgW_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDH_AgBgW_US-ORN_trans.nc"
fnames["DUK_PIDH_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDH_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDH_AgBgW_RD_US-DUK_trans.nc"
fnames["ORN_PIDH_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDH_AgBgW_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r0621_Base_PIDH_AgBgW_RD_US-ORN_trans.nc"
# AgBgW
fnames["DUK_PIDE_Conly_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0707_Base_PIDE_AgBgW_processed/Bharat_AW_Nalloc_mf0df100_r0707_Base_PIDE_AgBgW_US-DUK_trans.nc"
fnames["DUK_PIDE_RD_AgBgW"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0707_Base_PIDE_AgBgW_RD_processed/Bharat_AW_Nalloc_mf0df100_r0707_Base_PIDE_AgBgW_RD_US-DUK_trans.nc"
# BgW only
fnames["DUK_PIDE_Conly_BgW"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0629_PIDE_BgW_processed/Bharat_AW_Nalloc_mf0df100_r0629_PIDE_BgW_US-DUK_trans.nc"
fnames["ORN_PIDE_Conly_BgW"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0629_PIDE_BgW_processed/Bharat_AW_Nalloc_mf0df100_r0629_PIDE_BgW_US-ORN_trans.nc"
fnames["DUK_PIDE_RD_BgW"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0629_PIDE_BgW_RD_processed/Bharat_AW_Nalloc_mf0df100_r0629_PIDE_BgW_RD_US-DUK_trans.nc"
fnames["ORN_PIDE_RD_BgW"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0629_PIDE_BgW_RD_processed/Bharat_AW_Nalloc_mf0df100_r0629_PIDE_BgW_RD_US-ORN_trans.nc"
# RootW only
fnames["DUK_PIDE_Conly_RootW"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0629_PIDE_RootW_processed/Bharat_AW_Nalloc_mf0df100_r0629_PIDE_RootW_US-DUK_trans.nc"
fnames["ORN_PIDE_Conly_RootW"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0629_PIDE_RootW_processed/Bharat_AW_Nalloc_mf0df100_r0629_PIDE_RootW_US-ORN_trans.nc"
fnames["DUK_PIDE_RD_RootW"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0629_PIDE_RootW_RD_processed/Bharat_AW_Nalloc_mf0df100_r0629_PIDE_RootW_RD_US-DUK_trans.nc"
fnames["ORN_PIDE_RD_RootW"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0629_PIDE_RootW_RD_processed/Bharat_AW_Nalloc_mf0df100_r0629_PIDE_RootW_RD_US-ORN_trans.nc"
# default is CN 53
fnames["DUK_PIDE_Conly_AgBgW_CN55"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN55_processed/Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN55_US-DUK_trans.nc"
fnames["ORN_PIDE_Conly_AgBgW_CN55"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN55_processed/Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN55_US-ORN_trans.nc"
fnames["DUK_PIDE_Conly_AgBgW_CN35"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN35_processed/Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN35_US-DUK_trans.nc"
fnames["ORN_PIDE_Conly_AgBgW_CN35"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN35_processed/Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN35_US-ORN_trans.nc"
# default is CN 53
fnames["DUK_PIDE_Conly_AgBgW_CN55"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN55_processed/Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN55_US-DUK_trans.nc"
fnames["ORN_PIDE_Conly_AgBgW_CN55"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN55_processed/Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN55_US-ORN_trans.nc"
fnames["DUK_PIDE_RD_AgBgW_CN55"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN55_RD_processed/Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN55_RD_US-DUK_trans.nc"
#fnames["ORN_PIDE_RD_AgBgW_CN55"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN55_RD_processed/Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN55_RD_US-ORN_trans.nc"
fnames["DUK_PIDE_Conly_AgBgW_CN35"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN35_processed/Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN35_US-DUK_trans.nc"
fnames["ORN_PIDE_Conly_AgBgW_CN35"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN35_processed/Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN35_US-ORN_trans.nc"
fnames["DUK_PIDE_RD_AgBgW_CN35"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN35_RD_processed/Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN35_RD_US-DUK_trans.nc"
fnames["ORN_PIDE_RD_AgBgW_CN35"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN35_RD_processed/Bharat_AW_Nalloc_mf0df100_r0628_Base_PIDE_AgBgW_CN35_RD_US-ORN_trans.nc"
#fnames["DUK_PIDzero_RD"] = : Simulation missing *Running
#fnames["ORN_PIDzero_RD"] = f"{path_in}Bharat_AW_Nalloc_api25e3sm_mf0df100_r06122_Base_PIDzero_RD_processed/Bharat_AW_Nalloc_api25e3sm_mf0df100_r06122_Base_PIDzero_RD_US-ORN_trans.nc"
# This is for testing_vals.txt
#fnames["DUK_PIDE_RD_AgBgW_testing"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0726_l2fr_PIDE_CN53_AgBgW_RD_processed/Bharat_AW_Nalloc_mf0df100_r0726_l2fr_PIDE_CN53_AgBgW_RD_US-DUK_trans.nc"
# AgBgW 200 year spinups
# PID C
fnames["DUK_PIDC_Conly_AgBgW_CN53"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDC_CN53_AgBgW_processed/Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDC_CN53_AgBgW_US-DUK_trans.nc"
fnames["DUK_PIDC_RD_AgBgW_CN53"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDC_CN53_AgBgW_RD_processed/Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDC_CN53_AgBgW_RD_US-DUK_trans.nc"
#PID E
fnames["DUK_PIDE_Conly_AgBgW_CN53"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDE_CN53_AgBgW_processed/Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDE_CN53_AgBgW_US-DUK_trans.nc"
fnames["DUK_PIDE_RD_AgBgW_CN53"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDE_CN53_AgBgW_RD_processed/Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDE_CN53_AgBgW_RD_US-DUK_trans.nc"
#PID G
fnames["DUK_PIDG_Conly_AgBgW_CN53"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDG_CN53_AgBgW_processed/Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDG_CN53_AgBgW_US-DUK_trans.nc"
fnames["DUK_PIDG_RD_AgBgW_CN53"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDG_CN53_AgBgW_RD_processed/Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDG_CN53_AgBgW_RD_US-DUK_trans.nc"
#PID H
fnames["DUK_PIDH_Conly_AgBgW_CN53"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDH_CN53_AgBgW_processed/Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDH_CN53_AgBgW_US-DUK_trans.nc"
fnames["DUK_PIDH_RD_AgBgW_CN53"] = f"{path_in}Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDH_CN53_AgBgW_RD_processed/Bharat_AW_Nalloc_mf0df100_r0815_l2fr_PIDH_CN53_AgBgW_RD_US-DUK_trans.nc"
# Other global attributes for plots
logging_year= 1855
ds = {}
for idx, key in enumerate(fnames.keys()):
print (key)
ds[key] = xr.open_mfdataset(fnames[key],decode_times=True)
for idx, key in enumerate(ds.keys()):
ds[key]['time'] = pd.to_datetime(ds[key].time.values.astype(str))
DUK_PIDA_Conly_AgBgW ORN_PIDA_Conly_AgBgW DUK_PIDB_Conly ORN_PIDB_Conly DUK_PIDC_Conly ORN_PIDC_Conly DUK_PIDD_Conly ORN_PIDD_Conly DUK_PIDA_RD_AgBgW ORN_PIDA_RD_AgBgW DUK_PIDB_RD_AgBgW ORN_PIDB_RD_AgBgW DUK_PIDC_Conly_AgBgW DUK_PIDC_RD_AgBgW DUK_PIDD_RD_AgBgW ORN_PIDD_RD_AgBgW ORN_PIDC_RD_AgBgW DUK_PIDF_Conly_AgBgW ORN_PIDF_Conly_AgBgW DUK_PIDF_RD_AgBgW ORN_PIDF_RD_AgBgW DUK_PIDG_Conly_AgBgW ORN_PIDG_Conly_AgBgW DUK_PIDG_RD_AgBgW ORN_PIDG_RD_AgBgW DUK_PIDH_Conly_AgBgW ORN_PIDH_Conly_AgBgW DUK_PIDH_RD_AgBgW ORN_PIDH_RD_AgBgW DUK_PIDE_Conly_AgBgW DUK_PIDE_RD_AgBgW DUK_PIDE_Conly_BgW ORN_PIDE_Conly_BgW DUK_PIDE_RD_BgW ORN_PIDE_RD_BgW DUK_PIDE_Conly_RootW ORN_PIDE_Conly_RootW DUK_PIDE_RD_RootW ORN_PIDE_RD_RootW DUK_PIDE_Conly_AgBgW_CN55 ORN_PIDE_Conly_AgBgW_CN55 DUK_PIDE_Conly_AgBgW_CN35 ORN_PIDE_Conly_AgBgW_CN35 DUK_PIDE_RD_AgBgW_CN55 DUK_PIDE_RD_AgBgW_CN35 ORN_PIDE_RD_AgBgW_CN35 DUK_PIDC_Conly_AgBgW_CN53 DUK_PIDC_RD_AgBgW_CN53 DUK_PIDE_Conly_AgBgW_CN53 DUK_PIDE_RD_AgBgW_CN53 DUK_PIDG_Conly_AgBgW_CN53 DUK_PIDG_RD_AgBgW_CN53 DUK_PIDH_Conly_AgBgW_CN53 DUK_PIDH_RD_AgBgW_CN53
sims = "ORN_PIDB_RD_AgBgW"
sims = "DUK_PIDB_RD_AgBgW"
sims = "DUK_PIDC_RD_AgBgW"
#sims = "DUK_PIDD_RD_AgBgW"
#sims = "ORN_PIDD_RD_AgBgW"
#sims = "DUK_PIDE_RD_AgBgW"
#sims = "ORN_PIDE_RD_AgBgW"
#sims = "DUK_PIDF_RD_AgBgW"
#sims = "ORN_PIDF_RD_AgBgW"
#sims = "DUK_PIDG_RD_AgBgW"
#sims = "ORN_PIDH_RD_AgBgW"
#sims = "DUK_PIDH_RD_AgBgW"
#sims = "DUK_PIDE_Conly_BgW"
#sims = "ORN_PIDE_Conly_BgW"
#sims = "DUK_PIDE_RD_BgW"
#sims = "ORN_PIDE_RD_BgW"
#sims = "DUK_PIDE_Conly_RootW"
#sims = "ORN_PIDE_Conly_RootW"
#sims = "DUK_PIDE_RD_RootW"
#sims = "ORN_PIDE_RD_RootW"
#sims = "DUK_PIDE_RD_AgBgW_CN55"
#sims = "ORN_PIDE_RD_AgBgW_CN55" # Not available
#sims = "DUK_PIDE_RD_AgBgW_CN35"
#sims = "ORN_PIDE_RD_AgBgW_CN35"
sims = "DUK_PIDE_RD_AgBgW_testing"
sims = "DUK_PIDC_RD_AgBgW_CN53"
sims = "DUK_PIDE_RD_AgBgW_CN53"
#sims = "DUK_PIDG_RD_AgBgW_CN53"
# Logging happened on Jan 1, 1855
# Start Date Index
idx_start_date = 4*365+1
idx_logging = 5*365+1
# For multiple variables on a same plot upto 5 years after logging
Yrs_Next = 5 # upto 5 years after logging
print ("\nAll Plots >>>>>>")
fig, axs = plt.subplots(9,1 , figsize=(15,30), dpi=400)
# Subplot 1 >>>
idx_ax = 0
var = "FATES_NPP"
# C-only
try:
sim_conly = sims.replace("RD", "Conly")
if sims == "DUK_PIDE_RD_AgBgW_testing" :
sim_conly = "DUK_PIDE_Conly_AgBgW"
except:
sim_conly = "DUK_PIDE_Conly_AgBgW"
key=sim_conly
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, ts_data, label = var + " C-only")
# RD
key=sims
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, ts_data, label = var )
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
axs[idx_ax].set_title(f"{key} Daily Logging + 5 years\n",fontsize=16)
axs[idx_ax].axhline(y = 0, color = 'r',lw=1, alpha=.1)
print(key)
# Subplot 1 <<<
# Subplot 2 >>>
idx_ax = 1
vars_plot = (
"""
FATES_STOREC_TF
FATES_STOREC
"""
).split('\n')
vars_plot = vars_plot[1:-1]
var = vars_plot[0]
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, ts_data, label = var, color='b')
axs[idx_ax].set_ylabel (f"{var}({ds[key][var].units})", color='b')
ax_tmp = axs[idx_ax].twinx()
var = vars_plot[1]
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.plot(ts_data.time,ts_data,'k.', label = var, alpha=.3)
ax_tmp.legend(loc = 5)
ax_tmp.set_ylabel (f"{var}({ds[key][var].units})")
ax_tmp.axhline(y = 0, color = 'r',lw=1, alpha=.1)
# Subplot 2 <<<
# Subplot 3 >>>
idx_ax = 2
vars_plot = (
"""
FATES_STOREN_TF
FATES_STOREN
"""
).split('\n')
vars_plot = vars_plot[1:-1]
var = vars_plot[0]
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, ts_data, label = var, color='b')
axs[idx_ax].set_ylabel (f"{var}({ds[key][var].units})", color='b')
ax_tmp = axs[idx_ax].twinx()
var = vars_plot[1]
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.plot(ts_data.time,ts_data,'k.', label = var, alpha=.3)
ax_tmp.set_ylabel (f"{var}({ds[key][var].units})")
ax_tmp.legend(loc = 5)
ax_tmp.axhline(y = 0, color = 'r',lw=1, alpha=.1)
# Subplot 3 <<<
# Subplot 4 >>>
idx_ax = 3
ts_data = (ds[key]["FATES_STOREC_TF"]/ds[key]["FATES_STOREN_TF"])[idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, ts_data, label = "FATES_STOREC_TF/FATES_STOREN_TF", color='b')
axs[idx_ax].set_ylabel (f"FATES_STOREC_TF/FATES_STOREN_TF", color='b')
ax_tmp = axs[idx_ax].twinx()
ts_data = (ds[key]["FATES_STOREC"]/ds[key]["FATES_STOREN"])[idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.plot(ts_data.time, ts_data, 'k.', label = "FATES_STOREC/FATES_STOREN")
ax_tmp.legend(loc = 5)
ax_tmp.set_ylabel (f"{var}({ds[key][var].units})")
# Subplot 4 <<<
# Subplot 5 >>>
idx_ax = 4
ts_data = (ds[key]["FATES_FROOT_ALLOC"]/ds[key]["FATES_LEAF_ALLOC"])[idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, ts_data, label = "FATES_FROOT_ALLOC/FATES_LEAF_ALLOC", color='b')
axs[idx_ax].set_ylabel (f"FATES_FROOT_ALLOC/FATES_LEAF_ALLOC", color='b')
ax_tmp = axs[idx_ax].twinx()
var = "FATES_L2FR"
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.plot(ts_data.time, ts_data, 'k.', label = var)
ax_tmp.set_ylabel (f"{var}({ds[key][var].units})")
ax_tmp.legend(loc = 5)
# Subplot 5 <<<
# Subplot 6 >>>
idx_ax = 5
vars_plot = (
"""
FATES_LEAFC
FATES_FROOTC
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, ts_data, label = var )
axs[idx_ax].set_ylabel (f"{var}({ds[key][var].units})", color='orange')
ax_tmp = axs[idx_ax].twinx()
ts_data = (ds[key]["FATES_FROOTC"]/ds[key]["FATES_LEAFC"])[idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.plot(ts_data.time, ts_data, 'k.', label = "FATES_FROOTC/FATES_LEAFC")
ax_tmp.set_ylabel (f"FATES_FROOTC/FATES_LEAFC")
ax_tmp.legend(loc = 5)
ax_tmp.set_ylabel (f"Unitless")
# Subplot 6 <<<
# Subplot 7 >>>
idx_ax = 6
vars_plot = (
"""
FATES_NO3UPTAKE
FATES_NH4UPTAKE
"""
).split('\n')
vars_plot = vars_plot[1:-1]
var = vars_plot[0]
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, ts_data, label = var, color='b')
axs[idx_ax].set_ylabel (f"{var}({ds[key][var].units})", color='b')
axs[idx_ax].axhline(y = 0, color = 'r',lw=1, alpha=.1)
ax_tmp = axs[idx_ax].twinx()
var = vars_plot[1]
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.plot(ts_data.time,ts_data,'k.', label = var)
ax_tmp.set_ylabel (f"{var}({ds[key][var].units})")
ax_tmp.legend(loc = 5)
# Subplot 7 <<<
# Subplot 8 >>>
idx_ax = 7
vars_plot = (
"""
GROSS_NMIN
NET_NMIN
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
axs[idx_ax].axhline(y = 0, color = 'r',lw=1, alpha=.1)
# Subplot 8 <<<
# Subplot 9 >>>
idx_ax = 8
vars_plot = (
"""
SMIN_NO3_LEACHED
DENIT
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
axs[idx_ax].axhline(y = 0, color = 'r',lw=1, alpha=.1)
# Subplot 9 <<<
print(key)
for i in range(len(axs)):
axs[i].legend()
axs[i].axvline(x = dt.date(1855,1,1), color = 'g',lw=5, alpha=.1)
#fig.savefig('./Plots/' + f'{key}_daily.pdf',bbox_inches='tight')
#fig.savefig('./Plots/' + f'{key}_daily.png',bbox_inches='tight')
All Plots >>>>>> DUK_PIDE_RD_AgBgW_CN53
/Users/ud4/opt/anaconda3/envs/pyces/lib/python3.9/site-packages/dask/core.py:121: RuntimeWarning: invalid value encountered in true_divide
DUK_PIDE_RD_AgBgW_CN53
Hint:
'''
cx_int = cx_int + cx_logratio
! Reset the integrator if its sign changes
if( abs(cx_logratio)>nearzero .and. abs(cx0)>nearzero) then
if( abs(cx_logratio/abs(cx_logratio) - cx0/abs(cx0)) > nearzero ) then
cx_int = cx_logratio
end if
end if
dcxdt_ratio = cx_logratio-cx0
ema_dcxdt = pid_drv_wgt*dcxdt_ratio + (1._r8-pid_drv_wgt)*ema_dcxdt
cx0 = cx_logratio
'''
# PID Params
#E|0.001|0.5
print (sims.split('_')[1])
if sims.split('_')[1] == 'PIDE':
pid_kp = 0.001
pid_kd = 0.5
pid_ki = 0.0
if sims.split('_')[1] == 'PIDH':
pid_kp = 0.001
pid_kd = 1.0
pid_ki = 0.0
if sims.split('_')[1] == 'PIDC':
pid_kp = 0.0001
pid_kd = 0.01
pid_ki = 0.0
if sims.split('_')[1] == 'PIDF':
pid_kp = 0.005
pid_kd = 0.1
pid_ki = 0.0
if sims.split('_')[1] == 'PIDG':
pid_kp = 0.005
pid_kd = 0.5
pid_ki = 0.0
carbon_nitrogen = True
carbon_phosphorus = True
if carbon_nitrogen == True:
c2x = "CN"
if carbon_phosphorus == True:
c2x = "CP"
if carbon_nitrogen ==True and carbon_phosphorus == True:
c2x = "CNP"
PIDE
def SafeLog(val):
# As defined in PRTAllometricCNPMod
safelog_min = 0.001
safelog_max = 1000
clipped_val = np.clip(val, safelog_min, safelog_max)
logval = np.log(clipped_val)
return logval
if c2x == "CN" and c2x != "CP":
print ("case1")
cn_ratio = (ds[key]["FATES_STOREC_TF"]/ds[key]["FATES_STOREN_TF"])[idx_start_date:idx_start_date+Yrs_Next*365]
cx_logratio_ar = SafeLog(cn_ratio)
if c2x != "CN" and c2x == "CP":
print ("case2")
cp_ratio = (ds[key]["FATES_STOREC_TF"]/ds[key]["FATES_STOREP_TF"])[idx_start_date:idx_start_date+Yrs_Next*365]
cx_logratio_ar = SafeLog(cp_ratio)
if c2x == "CNP":
print ("case3")
cn_ratio = (ds[key]["FATES_STOREC_TF"]/ds[key]["FATES_STOREN_TF"])[idx_start_date:idx_start_date+Yrs_Next*365]
cp_ratio = (ds[key]["FATES_STOREC_TF"]/ds[key]["FATES_STOREP_TF"])[idx_start_date:idx_start_date+Yrs_Next*365]
#cx_logratio_ar = SafeLog(cn_ratio)
#keeping priority if CN Ratio only
#cx_logratio_ar = SafeLog(cn_ratio) # fcn
cx_logratio_ar = SafeLog(cp_ratio) # fcn
cx_logratio_ar = np.ravel(cx_logratio_ar)
#cx_logratio_ar = np.insert(cx_logratio_ar, 0, 0) # adding first value as 0
#derivative
dcxdt_ratio_mat = cx_logratio_ar[1:] - cx_logratio_ar[:-1]
case3
ts_data_l2fr = ds[key]['FATES_L2FR'][idx_start_date:idx_start_date+Yrs_Next*365]
ts = ts_data_l2fr.values
delta_l2fr_model = ts[1:] - ts[:-1]
delta_l2fr_model[:,0][0]
ema_dcxdt_init = (delta_l2fr_model[:,0][0] - pid_kp*dcxdt_ratio_mat[0])/pid_kd
ema_dcxdt_init
-2.3075759410858154e-05
#integration
pid_drv_wgt = 1/20. # n-day smoothing of the derivative of the process function in the PID controller
cx_int = cx_logratio_ar[0]#0
cx0 = cx_logratio_ar[0]#0.
ema_dcxdt = ema_dcxdt_init #cx_logratio_ar[0]*(pid_drv_wgt)#0.
#cx_logratio_ar = cx_logratio_ar[1:] # removing the zero that we added earlier
nearzero = 1e-30
cx_int_ar = []
dcxdt_ratio_ar = []
ema_dcxdt_ar = []
for idx, cx_logratio in enumerate (cx_logratio_ar[1:]):
cx_int = cx_int + cx_logratio
#Reset the integrator if its sign changes
if abs(cx_logratio)> nearzero and abs(cx0)> nearzero :
if abs(cx_logratio/abs(cx_logratio) - cx0/abs(cx0)) > nearzero :
cx_int = cx_logratio
dcxdt_ratio = cx_logratio-cx0
ema_dcxdt = pid_drv_wgt*dcxdt_ratio + (1.-pid_drv_wgt)*ema_dcxdt
cx0 = cx_logratio
if idx == 1: print (dcxdt_ratio,ema_dcxdt)
cx_int_ar.append(cx_int)
dcxdt_ratio_ar.append(dcxdt_ratio)
ema_dcxdt_ar.append(ema_dcxdt)
cx_int_ar = np.array(cx_int_ar)
dcxdt_ratio_ar = np.array(dcxdt_ratio_ar)
ema_dcxdt_ar = np.array(ema_dcxdt_ar)
# Repeating the first value twice in the begining
cx_int_ar = np.insert(cx_int_ar,0,cx_int_ar[0])
dcxdt_ratio_ar = np.insert(dcxdt_ratio_ar,0,dcxdt_ratio_ar[0])
ema_dcxdt_ar = np.insert(ema_dcxdt_ar,0,ema_dcxdt_ar[0])
-7.382035e-05 -3.280245766043663e-05
# Sanity check
sum(dcxdt_ratio_ar[1:] == dcxdt_ratio_mat)
1824
l2fr_delta_ar = []
for idx in range(len(cx_logratio_ar[1:])):
cx_logratio = cx_logratio_ar[idx]
cx_int = cx_int_ar[idx]
ema_dcxdt = ema_dcxdt_ar [idx]
l2fr_delta = pid_kp*cx_logratio + pid_ki*cx_int + pid_kd*ema_dcxdt
l2fr_delta_ar.append(l2fr_delta)
l2fr_delta_ar = np.array(l2fr_delta_ar)
# Repeating the first value twice in the begining
l2fr_delta_ar = np.insert(l2fr_delta_ar,0,l2fr_delta_ar[0])
The variables that are calcuated based on the C/C' and N/N'
Other variables are directly ploted from model variables (except l2fr_delta_model, which is just the difference of FATES_L2FR one month apart
fig, axs = plt.subplots(10,1 , figsize=(15,40), dpi=400)
idx_ax = 0
#FATES_LEAFC
vars_plot = (
"""
FATES_LEAFC
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
axs[idx_ax].set_title(f"{key} Daily Logging + 5 years (PID control parameters) \n",fontsize=16)
axs[idx_ax].axhline(y = 0, color = 'k',ls ='--', lw=1, alpha=.3)
#ax_tmp = axs[idx_ax].twinx()
#ts_data = (ds[key]["FATES_FROOTC"]/ds[key]["FATES_LEAFC"])[idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
#ax_tmp.plot(ts_data.time, ts_data, 'k+', label = "FATES_FROOTC/FATES_LEAFC", markersize = 4, alpha =.1)
#ax_tmp.legend(loc = 5)
#ax_tmp.set_ylabel (f"Unitless")
# Subplot >>>
idx_ax = 1 + idx_ax
ts_data = (ds[key]["FATES_STOREC"]/ds[key]["FATES_STOREC_TF"])[idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, ts_data, label = "FATES_STOREC_TARGET", alpha=.3)
axs[idx_ax].set_ylabel (f"FATES_STOREC({ds[key]['FATES_STOREC'].units})")
ax_tmp = axs[idx_ax].twinx()
ts_data = (ds[key]["FATES_STOREN"]/ds[key]["FATES_STOREN_TF"])[idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.plot(ts_data.time,ts_data,'r+', label = "FATES_STOREN_TARGET", alpha=.1, markersize = 6)
ax_tmp.legend(loc = 5)
ax_tmp.set_ylabel (f"{'FATES_STOREN'}({ds[key]['FATES_STOREN'].units})", color='r')
ax_tmp.axhline(y = 0, color = 'k',ls ='--', lw=1, alpha=.3)
# Subplot 2 <<<
# Subplot >>>
idx_ax = 1 + idx_ax
ts_data = (ds[key]["FATES_STOREC_TF"])[idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, ts_data, label = "FATES_STOREC_TF", alpha=.3)
axs[idx_ax].set_ylabel (f"FATES_STOREC_TF({ds[key]['FATES_STOREC_TF'].units})")
ax_tmp = axs[idx_ax].twinx()
ts_data = (ds[key]["FATES_STOREN_TF"])[idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.plot(ts_data.time,ts_data,'r+', label = "FATES_STOREN_TF", alpha=.1, markersize = 6)
ax_tmp.legend(loc = 5)
ax_tmp.set_ylabel (f"{'FATES_STOREN_TF'}({ds[key]['FATES_STOREN_TF'].units})", color='r')
ax_tmp.axhline(y = 0, color = 'k',ls ='--', lw=1, alpha=.3)
# Subplot <<<
# Subplot >>>
idx_ax = 1 + idx_ax
key=sims
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].plot(ts_data.time, cx_logratio_ar, label = "SafeLog(FATES Store TF C:N* or $F_{CN}$*" )
axs[idx_ax].axhline(y = 0, color = 'k',ls ='--', lw=1, alpha=.3)
# Subplot <<<
# Subplot >>>
idx_ax = 1 + idx_ax
axs[idx_ax].plot(ts_data.time, ema_dcxdt_ar, label = "Smoothened Derivative of Log(C:N) or $dF_{CN}$*" )
axs[idx_ax].axhline(y = 0, color = 'r',lw=1, alpha=.1)
#ax_tmp = axs[idx_ax].twinx()
#ax_tmp.plot(ts_data.time, pid_kd * ema_dcxdt_ar, 'r+', label = "pid_kd * ema_dcxdt_ar", markersize = 4, alpha =.1 )
#ax_tmp.legend(loc = 5)
# Subplot <<<
# Subplot >>>
idx_ax = 1 + idx_ax
axs[idx_ax].plot(ts_data.time, cx_int_ar, label = "Integral of Log(C:N)* or $\int$$F_{CN}$*" )
axs[idx_ax].axhline(y = 0, color = 'k',ls ='--', lw=1, alpha=.3)
# Subplot <<<
# Subplot >>>
idx_ax = 1 + idx_ax
KpxFcn = pid_kp * cx_logratio_ar
KdxDerivative = pid_kd * ema_dcxdt_ar
KixIntegral = pid_ki * cx_int_ar
print (f"pid_kp : {pid_kp}\n pid_kd : {pid_kd}\n pid_ki : {pid_ki} ")
axs[idx_ax].plot(ts_data.time, KpxFcn, label = r"Kp$\times$ $F_{CN}$*" )
axs[idx_ax].plot(ts_data.time, KdxDerivative, label = r"Kd $\times$ $dF_{CN}$*" )
axs[idx_ax].plot(ts_data.time, KixIntegral, label = r"Ki $\times$ $\int$$F_{CN}$*" )
axs[idx_ax].axhline(y = 0, color = 'k',ls ='--', lw=1, alpha=.3)
# Subplot <<<
# Subplot >>>
idx_ax = 1 + idx_ax
KpxFcn_prop = np.abs(pid_kp * cx_logratio_ar)/np.sum(np.abs((KpxFcn,KdxDerivative,KixIntegral)),axis=0)
KdxDerivative_prop = pid_kd * ema_dcxdt_ar/np.sum(np.abs((KpxFcn,KdxDerivative,KixIntegral)),axis=0)
KixIntegral_prop = pid_ki * cx_int_ar/np.sum(np.abs((KpxFcn,KdxDerivative,KixIntegral)),axis=0)
print (f"pid_kp : {pid_kp}\n pid_kd : {pid_kd}\n pid_ki : {pid_ki} ")
axs[idx_ax].plot(ts_data.time, KpxFcn_prop, label = r"(Kp $\times$ $F_{CN}$)/$\Sigma$|Kp$\times$ $F_{CN}$ + Kd $\times$ $dF_{CN}$ + Ki $\times$ $\int$$F_{CN}$|*" )
axs[idx_ax].plot(ts_data.time, KdxDerivative_prop, label = r"(Kd $\times$ $dF_{CN}$/$\Sigma$|Kp$\times$ $F_{CN}$ + Kd $\times$ $dF_{CN}$ + Ki $\times$ $\int$$F_{CN}$|*" )
axs[idx_ax].plot(ts_data.time, KixIntegral_prop, label = r"(Ki $\times$ $\int$$F_{CN}$/$\Sigma$|Kp$\times$ $F_{CN}$ + Kd $\times$ $dF_{CN}$ + Ki $\times$ $\int$$F_{CN}$|*" )
axs[idx_ax].axhline(y = 0, color = 'k',ls ='--', lw=1, alpha=.3)
# Subplot <<<
# Subplot >>>
idx_ax = 1 + idx_ax
axs[idx_ax].plot(ts_data.time, l2fr_delta_ar, label = r"$\Delta$ L2FR*" )
axs[idx_ax].axhline(y = 0, color = 'k',ls ='--', lw=1, alpha=.3)
axs[idx_ax].set_ylabel (r"$\Delta$ L2FR*")
ax_tmp = axs[idx_ax].twinx()
ts_data_l2fr = ds[key]['FATES_L2FR'][idx_start_date:idx_start_date+Yrs_Next*365]
ts = ts_data_l2fr.values
delta_l2fr_model = ts[1:] - ts[:-1]
ax_tmp.plot(ts_data_l2fr.time[:-1], delta_l2fr_model,'r+', label = "$\Delta$ FATES_L2FR", alpha=.1, markersize = 6)
ax_tmp.set_ylabel ("$\Delta$ FATES_L2FR", color='r')
ax_tmp.legend(loc = 5)
# Subplot <<<
# Subplot >>>
idx_ax = 1 + idx_ax
L2FR_ar = l2fr_delta_ar.cumsum()
axs[idx_ax].plot(ts_data.time, L2FR_ar, label = "L2FR*" )
axs[idx_ax].axhline(y = 0, color = 'k',ls ='--', lw=1, alpha=.3)
axs[idx_ax].set_ylabel (r"L2FR*")
ax_tmp = axs[idx_ax].twinx()
ts_data_l2fr = ds[key]['FATES_L2FR'][idx_start_date:idx_start_date+Yrs_Next*365]
ax_tmp.plot(ts_data_l2fr.time, ts_data_l2fr,'r+', label = "FATES_L2FR", alpha=.1, markersize = 6)
ax_tmp.set_ylabel (f"{'FATES_L2FR'}({ts_data_l2fr.units})", color='r')
for i in range(len(axs)):
axs[i].legend()
axs[i].axvline(x = dt.date(1855,1,1), color = 'g',lw=5, alpha=.1)
pid_kp : 0.001 pid_kd : 0.5 pid_ki : 0.0 pid_kp : 0.001 pid_kd : 0.5 pid_ki : 0.0
CNPAdjustFRootTargets
in the file parteh/PRTAllometricCNPMod.F90
¶852 print*, 'sinkhole',trim(dateTimeString) ,cx_logratio, cp_ratio, cn_ratio, cx_int, &
853 dcxdt_ratio, ema_dcxdt, cx0, l2fr_delta, l2fr, store_c_max, store_c_act, &
854 store_nut_max, store_nut_act, l2fr_min, store_N_max, store_N_act, &
855 store_P_max, store_P_act, dbh
filenames_sim_out = glob.glob(f"{path_in}*{sims.split('_')[1]}*r0815_l2fr.txt")
f"{path_in}*{sims.split('_')[1]}*l2fr.txt"
'/Users/ud4/FATESMDS_analysis/outputs/runs/tests_alp/230309/*PIDE*l2fr.txt'
filenames_sim_out
['/Users/ud4/FATESMDS_analysis/outputs/runs/tests_alp/230309/PIDE_AgBgW_r0815_l2fr.txt']
cols = ['timex', 'cx_logratio', 'cp_ratio', 'cn_ratio', 'cx_int',
'dcxdt_ratio', 'ema_dcxdt', 'cx0', 'l2fr_delta', 'l2fr',
'store_c_max', 'store_c_act', 'store_nut_max', 'store_nut_act', 'l2fr_min',
'store_N_max', 'store_N_act', 'store_P_max', 'store_P_act','dbh' ]
df_vals = pd.read_csv(filenames_sim_out[0], header=None, delim_whitespace=True)
df_vals.columns = cols
# removing the leading string from first column
df_vals['timex'] = df_vals['timex'].str.replace('sinkhole','')
df_vals['timex'] = df_vals['timex'].str.replace('_01:00:00','')
df_vals['timex'] = pd.to_datetime(df_vals['timex'])
# since there are many cohorts per time step, categorizing every cohort with a unique value
df_vals['timex_code'] = pd.factorize(df_vals['timex'])[0]
print (f"Sanity Check: {((2007-1850)+1)*365} should be equal to {df_vals['timex_code'].values[-1]+1}")
df_vals.head(30)
Sanity Check: 57670 should be equal to 57670
timex | cx_logratio | cp_ratio | cn_ratio | cx_int | dcxdt_ratio | ema_dcxdt | cx0 | l2fr_delta | l2fr | ... | store_c_act | store_nut_max | store_nut_act | l2fr_min | store_N_max | store_N_act | store_P_max | store_P_act | dbh | timex_code | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1850-01-01 | 0.005064 | 0.301533 | 1.005077 | 0.210445 | -0.054423 | -0.000028 | 0.005064 | -0.000009 | 1.095973 | ... | 0.077632 | 0.000037 | 0.000124 | 0.01 | 0.000581 | 0.000579 | 0.000037 | 0.000124 | 0.420343 | 0 |
1 | 1850-01-01 | 0.051128 | 0.314833 | 1.052458 | 8.961558 | 0.000047 | 0.002254 | 0.051128 | 0.001178 | 1.096093 | ... | 0.354534 | 0.000170 | 0.000541 | 0.01 | 0.002652 | 0.002526 | 0.000170 | 0.000541 | 1.260175 | 0 |
2 | 1850-01-01 | 0.046834 | 0.325405 | 1.047949 | 11.192051 | 0.000036 | 0.002066 | 0.046834 | 0.001080 | 1.089553 | ... | 0.449704 | 0.000215 | 0.000663 | 0.01 | 0.003364 | 0.003218 | 0.000215 | 0.000663 | 1.418662 | 0 |
3 | 1850-01-01 | 0.043951 | 0.331549 | 1.044931 | 13.153907 | 0.000033 | 0.001940 | 0.043951 | 0.001014 | 1.097291 | ... | 0.575620 | 0.000276 | 0.000833 | 0.01 | 0.004307 | 0.004132 | 0.000276 | 0.000833 | 1.639079 | 0 |
4 | 1850-01-01 | 0.043578 | 0.331084 | 1.044542 | 15.690123 | 0.000030 | 0.001927 | 0.043578 | 0.001007 | 1.109394 | ... | 0.802835 | 0.000384 | 0.001164 | 0.01 | 0.006008 | 0.005765 | 0.000384 | 0.001164 | 2.113495 | 0 |
5 | 1850-01-01 | -0.131557 | 0.400458 | 0.876730 | -476.175880 | -0.000045 | -0.000055 | -0.131557 | -0.000159 | 0.568981 | ... | 4.331559 | 0.002076 | 0.005193 | 0.01 | 0.032432 | 0.037059 | 0.002076 | 0.005193 | 7.578809 | 0 |
6 | 1850-01-01 | -0.049303 | 0.402707 | 0.951893 | -538.296367 | -0.000056 | -0.000090 | -0.049303 | -0.000095 | 0.546068 | ... | 4.911223 | 0.002354 | 0.005854 | 0.01 | 0.036775 | 0.038699 | 0.002354 | 0.005854 | 8.440737 | 0 |
7 | 1850-01-01 | -0.029937 | 0.410434 | 0.970507 | -27.676863 | -0.000152 | -0.000118 | -0.029937 | -0.000089 | 0.492146 | ... | 7.973890 | 0.003822 | 0.009326 | 0.01 | 0.059720 | 0.061625 | 0.003822 | 0.009326 | 12.336457 | 0 |
8 | 1850-01-01 | -0.015884 | 0.416215 | 0.984241 | -0.945525 | -0.000183 | -0.000103 | -0.015884 | -0.000068 | 0.459286 | ... | 9.630522 | 0.004617 | 0.011107 | 0.01 | 0.072135 | 0.073388 | 0.004617 | 0.011107 | 14.165410 | 0 |
9 | 1850-01-01 | -0.011338 | 0.423231 | 0.988726 | -0.591771 | -0.000242 | -0.000086 | -0.011338 | -0.000054 | 0.414310 | ... | 12.814510 | 0.006144 | 0.014534 | 0.01 | 0.095997 | 0.097207 | 0.006144 | 0.014534 | 17.685659 | 0 |
10 | 1850-01-01 | -0.006984 | 0.428147 | 0.993040 | -0.247770 | -0.000289 | -0.000072 | -0.006984 | -0.000043 | 0.380355 | ... | 15.993722 | 0.007669 | 0.017931 | 0.01 | 0.119825 | 0.120795 | 0.007669 | 0.017931 | 21.150987 | 0 |
11 | 1850-01-01 | -0.004379 | 0.431685 | 0.995630 | -0.133788 | -0.000327 | -0.000059 | -0.004379 | -0.000034 | 0.355197 | ... | 18.951112 | 0.009088 | 0.021072 | 0.01 | 0.141993 | 0.142758 | 0.009088 | 0.021072 | 24.327432 | 0 |
12 | 1850-01-01 | -0.002037 | 0.436695 | 0.997965 | -0.049192 | -0.000360 | -0.000037 | -0.002037 | -0.000020 | 0.328578 | ... | 22.568927 | 0.010824 | 0.024807 | 0.01 | 0.169119 | 0.169613 | 0.010824 | 0.024807 | 27.663828 | 0 |
13 | 1850-01-01 | 0.003940 | 0.435603 | 1.003948 | 0.049908 | -0.000040 | 0.000048 | 0.003940 | 0.000028 | 0.342166 | ... | 22.707987 | 0.010860 | 0.025022 | 0.01 | 0.169694 | 0.169640 | 0.010860 | 0.025022 | 27.737284 | 0 |
14 | 1850-01-01 | 0.003861 | 0.432713 | 1.003869 | 0.049000 | -0.000049 | 0.000047 | 0.003861 | 0.000027 | 0.357951 | ... | 26.658589 | 0.012751 | 0.029572 | 0.01 | 0.199233 | 0.199169 | 0.012751 | 0.029572 | 31.527688 | 0 |
15 | 1850-01-01 | 0.003722 | 0.425453 | 1.003729 | 0.047056 | -0.000055 | 0.000046 | 0.003722 | 0.000027 | 0.404618 | ... | 31.619161 | 0.015126 | 0.035673 | 0.01 | 0.236340 | 0.236263 | 0.015126 | 0.035673 | 35.834512 | 0 |
16 | 1850-01-01 | 0.003583 | 0.417352 | 1.003590 | 0.045088 | -0.000063 | 0.000046 | 0.003583 | 0.000027 | 0.456650 | ... | 38.734927 | 0.018532 | 0.044549 | 0.01 | 0.289570 | 0.289473 | 0.018532 | 0.044549 | 41.933798 | 0 |
17 | 1850-01-01 | 0.003483 | 0.410182 | 1.003489 | 0.043633 | -0.000071 | 0.000046 | 0.003483 | 0.000026 | 0.501011 | ... | 46.976063 | 0.022478 | 0.054972 | 0.01 | 0.351216 | 0.351095 | 0.022478 | 0.054972 | 48.964977 | 0 |
18 | 1850-01-01 | 0.003239 | 0.399452 | 1.003244 | 0.040154 | -0.000080 | 0.000045 | 0.003239 | 0.000026 | 0.579734 | ... | 63.499278 | 0.030392 | 0.076304 | 0.01 | 0.474872 | 0.474705 | 0.030392 | 0.076304 | 61.493041 | 0 |
19 | 1850-01-01 | 0.003101 | 0.398677 | 1.003106 | 0.038211 | -0.000089 | 0.000045 | 0.003101 | 0.000025 | 0.585416 | ... | 77.968838 | 0.037322 | 0.093873 | 0.01 | 0.583161 | 0.582956 | 0.037322 | 0.093873 | 72.136593 | 0 |
20 | 1850-01-01 | 0.002766 | 0.408346 | 1.002770 | 0.033589 | -0.000121 | 0.000043 | 0.002766 | 0.000024 | 0.517005 | ... | 132.786417 | 0.063583 | 0.156087 | 0.01 | 0.993488 | 0.993147 | 0.063583 | 0.156087 | 109.328455 | 0 |
21 | 1850-01-02 | 0.004089 | 0.063792 | 1.004098 | 0.004089 | 0.004089 | 0.000204 | 0.004089 | 0.000106 | 1.093242 | ... | 0.076292 | 0.000037 | 0.000575 | 0.01 | 0.000570 | 0.000570 | 0.000037 | 0.000575 | 0.390915 | 1 |
22 | 1850-01-02 | 0.003230 | 0.055868 | 1.003236 | 0.213675 | -0.001833 | -0.000118 | 0.003230 | -0.000056 | 1.095917 | ... | 0.077645 | 0.000037 | 0.000667 | 0.01 | 0.000581 | 0.000580 | 0.000037 | 0.000667 | 0.420343 | 1 |
23 | 1850-01-02 | 0.049864 | 0.061733 | 1.051128 | 9.011422 | -0.001264 | 0.002078 | 0.049864 | 0.001089 | 1.097182 | ... | 0.354602 | 0.000170 | 0.002757 | 0.01 | 0.002652 | 0.002530 | 0.000170 | 0.002757 | 1.260175 | 1 |
24 | 1850-01-02 | 0.045692 | 0.066879 | 1.046752 | 11.237743 | -0.001143 | 0.001906 | 0.045692 | 0.000999 | 1.090552 | ... | 0.449783 | 0.000215 | 0.003228 | 0.01 | 0.003364 | 0.003223 | 0.000215 | 0.003228 | 1.418662 | 1 |
25 | 1850-01-02 | 0.042871 | 0.070109 | 1.043803 | 13.196778 | -0.001080 | 0.001789 | 0.042871 | 0.000938 | 1.098228 | ... | 0.575715 | 0.000276 | 0.003942 | 0.01 | 0.004307 | 0.004137 | 0.000276 | 0.003942 | 1.639079 | 1 |
26 | 1850-01-02 | 0.042489 | 0.069867 | 1.043404 | 15.732612 | -0.001090 | 0.001776 | 0.042489 | 0.000931 | 1.110325 | ... | 0.802969 | 0.000384 | 0.005517 | 0.01 | 0.006008 | 0.005772 | 0.000384 | 0.005517 | 2.113495 | 1 |
27 | 1850-01-02 | -0.131408 | 0.124802 | 0.876860 | -476.307288 | 0.000149 | -0.000045 | -0.131408 | -0.000154 | 0.568827 | ... | 4.332912 | 0.002076 | 0.016667 | 0.01 | 0.032437 | 0.037066 | 0.002076 | 0.016667 | 7.579625 | 1 |
28 | 1850-01-02 | -0.049189 | 0.127502 | 0.952002 | -538.345556 | 0.000114 | -0.000080 | -0.049189 | -0.000089 | 0.545979 | ... | 4.912668 | 0.002354 | 0.018497 | 0.01 | 0.036779 | 0.038707 | 0.002354 | 0.018497 | 8.441489 | 1 |
29 | 1850-01-02 | -0.029852 | 0.137455 | 0.970589 | -27.706715 | 0.000085 | -0.000108 | -0.029852 | -0.000084 | 0.492062 | ... | 7.975883 | 0.003822 | 0.027854 | 0.01 | 0.059724 | 0.061636 | 0.003822 | 0.027854 | 12.337055 | 1 |
30 rows × 21 columns
print (f"Maximum Cohorts: {max(np.unique(df_vals['timex_code'], return_counts=1)[1])}")
Maximum Cohorts: 32
plt.figure(figsize=(15,6))
plt.plot(np.unique(df_vals['timex'], return_counts=1)[0], np.unique(df_vals['timex_code'], return_counts=1)[1])
plt.ylabel("Number of cohorts", fontsize =14)
plt.axvline(x = dt.date(1855,1,1), color = 'r',lw=5, alpha=.2)
plt.title( "Cohorts Vs Time (daily)\n", fontsize = 16)
Text(0.5, 1.0, 'Cohorts Vs Time (daily)\n')
ts_data = ds[key]["FATES_NPP"]
#ts_data
plt.figure(figsize=(15,6))
plt.scatter(x=ts_data.time, y=ts_data, s=2)
plt.title( "FATES_NPP_Daily\n", fontsize = 16)
plt.figure(figsize=(15,6))
ts_data = ts_data.groupby("time.year").mean('time')
plt.scatter(x=ts_data.year, y=ts_data)
plt.title( "FATES_NPP Annual Mean\n", fontsize = 16)
Text(0.5, 1.0, 'FATES_NPP Annual Mean\n')
# Set the date range you want to subset between
start_date = '1854-01-01'
end_date = '1859-01-01'
# Create a boolean mask based on the date range
mask = (df_vals['timex'] >= start_date) & (df_vals['timex'] <= end_date)
# Subset the DataFrame based on the boolean mask
subset_df = df_vals[mask]
print (f"Maximum Cohorts: {max(np.unique(subset_df['timex_code'], return_counts=1)[1])}")
Maximum Cohorts: 30
# Plotting based on the cohort index
# initializing the cohort index to -1
subset_df['cohort_id'] = -1
# for every time step assign a unique index in the cohort id
for _, grp in subset_df.groupby('timex'):
subset_df.loc[grp.index, "cohort_id"] = range(len(grp))
/var/folders/f1/01gxw8vn74q_x_rf_p5ztryjr405zq/T/ipykernel_28297/3966830711.py:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy /Users/ud4/opt/anaconda3/envs/pyces/lib/python3.9/site-packages/pandas/core/indexing.py:1773: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
# Which CMAP coloring to chose
cmap_select = 'Wistia'
fig, axs = plt.subplots(13,1 , figsize=(20,50), dpi=100)
idx_ax = 0
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['dbh'],
marker='.', label = 'dbh', c=subset_df['dbh'],
cmap=cmap_select, s=5)
axs[idx_ax].set_title(f"{key} \n",fontsize=16)
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_act'],
marker='.', label = 'store_c_act', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_max'],
marker='.', label = 'store_c_max', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
'''
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_act']/subset_df['store_c_max'],
marker='.', label = 'store_c_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_nut_act'],
marker='.', label = 'store_nut_act', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_nut_max'],
marker='.', label = 'store_nut_max', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_N_act']/subset_df['store_N_max'],
marker='.', label = 'store_N_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_P_act']/subset_df['store_P_max'],
marker='.', label = 'store_P_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cn_ratio'],
marker='.', label = 'cn_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cp_ratio'],
marker='.', label = 'cp_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx_logratio'],
marker='.', label = 'cx_logratio',
c=subset_df['dbh'], cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['dcxdt_ratio'],
marker='o', label = 'dcxdt_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=15)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['ema_dcxdt'],
marker='.', label = 'ema_dcxdt', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx0'],
marker='.', label = 'cx0', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx_int'],
marker='.', label = 'cx_int', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['l2fr_delta'],
marker='.', label = 'l2fr_delta',
c=subset_df['dbh'], cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['l2fr'],
marker='.', label = 'l2fr', c=subset_df['dbh'],
cmap=cmap_select, s=5)
for i in range(len(axs)):
axs[i].legend(loc=5, fontsize=14)
axs[i].axvline(x = dt.date(1855,1,1), color = 'r',lw=5, alpha=.1)
# Which CMAP coloring to chose
cmap_select = 'tab20b'
fig, axs = plt.subplots(13,1 , figsize=(20,50), dpi=100)
idx_ax = 0
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['dbh'],
marker='.', label = 'dbh', c=subset_df['dbh'],
cmap=cmap_select, s=5)
axs[idx_ax].set_title(f"{key} \n",fontsize=16)
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_act'],
marker='.', label = 'store_c_act', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_max'],
marker='.', label = 'store_c_max', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
'''
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_act']/subset_df['store_c_max'],
marker='.', label = 'store_c_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_nut_act'],
marker='.', label = 'store_nut_act', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_nut_max'],
marker='.', label = 'store_nut_max', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_N_act']/subset_df['store_N_max'],
marker='.', label = 'store_N_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_P_act']/subset_df['store_P_max'],
marker='.', label = 'store_P_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cn_ratio'],
marker='.', label = 'cn_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cp_ratio'],
marker='.', label = 'cp_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx_logratio'],
marker='.', label = 'cx_logratio',
c=subset_df['dbh'], cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['dcxdt_ratio'],
marker='o', label = 'dcxdt_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=15)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['ema_dcxdt'],
marker='.', label = 'ema_dcxdt', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx0'],
marker='.', label = 'cx0', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx_int'],
marker='.', label = 'cx_int', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['l2fr_delta'],
marker='.', label = 'l2fr_delta',
c=subset_df['dbh'], cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['l2fr'],
marker='.', label = 'l2fr', c=subset_df['dbh'],
cmap=cmap_select, s=5)
for i in range(len(axs)):
axs[i].legend(loc=5, fontsize=14)
axs[i].axvline(x = dt.date(1855,1,1), color = 'r',lw=5, alpha=.1)
# Set the date range you want to subset between
start_date = '1854-01-01'
end_date = '1894-01-01'
# Create a boolean mask based on the date range
mask = (df_vals['timex'] >= start_date) & (df_vals['timex'] <= end_date)
# Subset the DataFrame based on the boolean mask
subset_df = df_vals[mask]
print (f"Maximum Cohorts: {max(np.unique(subset_df['timex_code'], return_counts=1)[1])}")
Maximum Cohorts: 32
# Which CMAP coloring to chose
cmap_select = 'viridis'
fig, axs = plt.subplots(13,1 , figsize=(20,50), dpi=100)
idx_ax = 0
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['dbh'],
marker='.', label = 'dbh', c=subset_df['dbh'],
cmap=cmap_select, s=5)
axs[idx_ax].set_title(f"{key} {start_date} - {end_date} \n",fontsize=16)
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_act'],
marker='.', label = 'store_c_act', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_max'],
marker='.', label = 'store_c_max', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
'''
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_act']/subset_df['store_c_max'],
marker='.', label = 'store_c_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_nut_act'],
marker='.', label = 'store_nut_act', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_nut_max'],
marker='.', label = 'store_nut_max', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_N_act']/subset_df['store_N_max'],
marker='.', label = 'store_N_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_P_act']/subset_df['store_P_max'],
marker='.', label = 'store_P_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cn_ratio'],
marker='.', label = 'cn_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cp_ratio'],
marker='.', label = 'cp_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx_logratio'],
marker='.', label = 'cx_logratio',
c=subset_df['dbh'], cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['dcxdt_ratio'],
marker='o', label = 'dcxdt_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=15)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['ema_dcxdt'],
marker='.', label = 'ema_dcxdt', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx0'],
marker='.', label = 'cx0', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx_int'],
marker='.', label = 'cx_int', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['l2fr_delta'],
marker='.', label = 'l2fr_delta',
c=subset_df['dbh'], cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['l2fr'],
marker='.', label = 'l2fr', c=subset_df['dbh'],
cmap=cmap_select, s=5)
for i in range(len(axs)):
axs[i].legend(loc=5, fontsize=14)
axs[i].axvline(x = dt.date(1855,1,1), color = 'r',lw=5, alpha=.1)
# Set the date range you want to subset between
start_date = '1855-01-02'
end_date = '1894-01-01'
# Create a boolean mask based on the date range
mask = (df_vals['timex'] >= start_date) & (df_vals['timex'] <= end_date)
# Subset the DataFrame based on the boolean mask
subset_df = df_vals[mask]
print (f"Maximum Cohorts: {max(np.unique(subset_df['timex_code'], return_counts=1)[1])}")
Maximum Cohorts: 32
# Which CMAP coloring to chose
cmap_select = 'viridis'
fig, axs = plt.subplots(13,1 , figsize=(20,50), dpi=100)
idx_ax = 0
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['dbh'],
marker='.', label = 'dbh', c=subset_df['dbh'],
cmap=cmap_select, s=5)
axs[idx_ax].set_title(f"{key} {start_date} - {end_date} \n",fontsize=16)
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_act'],
marker='.', label = 'store_c_act', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_max'],
marker='.', label = 'store_c_max', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
'''
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_act']/subset_df['store_c_max'],
marker='.', label = 'store_c_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_nut_act'],
marker='.', label = 'store_nut_act', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_nut_max'],
marker='.', label = 'store_nut_max', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_N_act']/subset_df['store_N_max'],
marker='.', label = 'store_N_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_P_act']/subset_df['store_P_max'],
marker='.', label = 'store_P_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cn_ratio'],
marker='.', label = 'cn_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cp_ratio'],
marker='.', label = 'cp_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx_logratio'],
marker='.', label = 'cx_logratio',
c=subset_df['dbh'], cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['dcxdt_ratio'],
marker='o', label = 'dcxdt_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=15)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['ema_dcxdt'],
marker='.', label = 'ema_dcxdt', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx0'],
marker='.', label = 'cx0', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx_int'],
marker='.', label = 'cx_int', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['l2fr_delta'],
marker='.', label = 'l2fr_delta',
c=subset_df['dbh'], cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['l2fr'],
marker='.', label = 'l2fr', c=subset_df['dbh'],
cmap=cmap_select, s=5)
for i in range(len(axs)):
axs[i].legend(loc=5, fontsize=14)
axs[i].axvline(x = dt.date(1855,1,1), color = 'r',lw=5, alpha=.1)
# Which CMAP coloring to chose
cmap_select = 'Wistia'
fig, axs = plt.subplots(13,1 , figsize=(20,50), dpi=100)
idx_ax = 0
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['dbh'],
marker='.', label = 'dbh', c=subset_df['dbh'],
cmap=cmap_select, s=5)
axs[idx_ax].set_title(f"{key} {start_date} - {end_date} \n",fontsize=16)
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_act'],
marker='.', label = 'store_c_act', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_max'],
marker='.', label = 'store_c_max', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
'''
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_c_act']/subset_df['store_c_max'],
marker='.', label = 'store_c_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_nut_act'],
marker='.', label = 'store_nut_act', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_nut_max'],
marker='.', label = 'store_nut_max', c=subset_df['cohort_id'],
cmap=cmap_select, s=5)
'''
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_N_act']/subset_df['store_N_max'],
marker='.', label = 'store_N_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['store_P_act']/subset_df['store_P_max'],
marker='.', label = 'store_P_TF', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cn_ratio'],
marker='.', label = 'cn_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cp_ratio'],
marker='.', label = 'cp_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx_logratio'],
marker='.', label = 'cx_logratio',
c=subset_df['dbh'], cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['dcxdt_ratio'],
marker='o', label = 'dcxdt_ratio', c=subset_df['dbh'],
cmap=cmap_select, s=15)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['ema_dcxdt'],
marker='.', label = 'ema_dcxdt', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx0'],
marker='.', label = 'cx0', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['cx_int'],
marker='.', label = 'cx_int', c=subset_df['dbh'],
cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['l2fr_delta'],
marker='.', label = 'l2fr_delta',
c=subset_df['dbh'], cmap=cmap_select, s=5)
idx_ax = idx_ax +1
axs[idx_ax].scatter(x=subset_df['timex'], y=subset_df['l2fr'],
marker='.', label = 'l2fr', c=subset_df['dbh'],
cmap=cmap_select, s=5)
for i in range(len(axs)):
axs[i].legend(loc=5, fontsize=14)
axs[i].axvline(x = dt.date(1855,1,1), color = 'r',lw=5, alpha=.1)
# Checking if the l2fr values (sum over all cohorts) from the print are same as l2fr variable output
max_vals = 5000
sum_l2fr = df_vals.groupby('timex_code')['l2fr'].sum().reset_index()[:max_vals]
mean_l2fr = df_vals.groupby('timex_code')['l2fr'].mean().reset_index()[:max_vals]
min_l2fr = df_vals.groupby('timex_code')['l2fr'].min().reset_index()[:max_vals]
max_l2fr = df_vals.groupby('timex_code')['l2fr'].max().reset_index()[:max_vals]
# Reading daily l2fr files FATES output
#list_of_d_files= glob.glob(f"/Users/ud4/FATESMDS_analysis/outputs/runs/tests_alp/230309/run/Bharat_AW_Nalloc_mf0df100_r0725_Test_PIDE_AgBgW_RD_US-DUK_I20TRELMFATES.elm.h0.*.nc")
#ds_FATES_daily = xr.open_mfdataset(f"/Users/ud4/FATESMDS_analysis/outputs/runs/tests_alp/230309/run/Bharat_AW_Nalloc_mf0df100_r0725_Test_PIDE_AgBgW_RD_US-DUK_I20TRELMFATES.elm.h0.*.nc")
#sum_l2fr['l2fr'].plot()
fig1, ax = plt.subplots(figsize=(30, 6))
scatter = ax.scatter(x=range(len(sum_l2fr['l2fr'])), y = sum_l2fr['l2fr'], c=sum_l2fr['l2fr'], cmap='viridis', marker='o', label = 'sum_l2fr')
plt.legend()
<matplotlib.legend.Legend at 0x179077760>
#mean_l2fr['l2fr'].plot()
fig1, ax = plt.subplots(figsize=(30, 6))
scatter = ax.scatter(x=range(len(mean_l2fr['l2fr'])), y = mean_l2fr['l2fr'], c=mean_l2fr['l2fr'], cmap='viridis', marker='o', label = 'mean_l2fr')
plt.legend()
<matplotlib.legend.Legend at 0x180b7b7f0>
#min_l2fr['l2fr'].plot()
fig, ax = plt.subplots(figsize=(30, 6))
scatter = ax.scatter(x=range(len(min_l2fr['l2fr'])), y = min_l2fr['l2fr'], c=min_l2fr['l2fr'], cmap='viridis', marker='o', label = 'min_l2fr')
plt.legend()
<matplotlib.legend.Legend at 0x192ec5a00>
#max_l2fr['l2fr'].plot()
fig, ax = plt.subplots(figsize=(30, 6))
scatter = ax.scatter(x=range(len(max_l2fr['l2fr'])), y = max_l2fr['l2fr'], c=max_l2fr['l2fr'], cmap='viridis', marker='o', label = 'max_l2fr')
plt.legend()
<matplotlib.legend.Legend at 0x18017fd30>
fig, ax = plt.subplots(figsize=(30, 6))
scatter = ax.scatter(ds[key]['FATES_L2FR'].time, ds[key]['FATES_L2FR'], c=ds[key]['FATES_L2FR'], cmap='viridis', marker='o', label = 'FATES_L2FR_yrly')
plt.legend()
<matplotlib.legend.Legend at 0x190feac10>
ts_data_l2fr = ds[key]['FATES_L2FR'][idx_start_date:idx_start_date+Yrs_Next*365]
fig, ax = plt.subplots(figsize=(30, 6))
scatter = ax.scatter(ts_data_l2fr.time, ts_data_l2fr, c=ts_data_l2fr, cmap='viridis', marker='o', label = 'FATES_L2FR_Daily')
plt.legend()
ax.axvline(x = dt.date(1855,1,1), color = 'r',lw=5, alpha=.1)
<matplotlib.lines.Line2D at 0x18974e550>
print ("\nAll Plots >>>>>>")
idx_start_date = 5*365 # Jan 1, 1855
# For multiple variables on a same plot upto 5 years after logging
Yrs_Next = 5 # upto 5 years after logging
fig, axs = plt.subplots(9,1 , figsize=(15,30), dpi=400)
# Subplot 1 >>>
idx_ax = 0
var = "FATES_NPP"
# C-only
sim_conly = sims.replace("RD", "Conly")
if sims == "DUK_PIDE_RD_AgBgW_testing" :
sim_conly = "DUK_PIDE_Conly_AgBgW"
key=sim_conly
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].scatter(ts_data.time, ts_data, marker=".", label = var + " C-only",alpha=.2)
# RD
key=sims
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].scatter(ts_data.time, ts_data, marker=".", label = var ,alpha=.2)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
axs[idx_ax].set_title(f"{key} Daily Logging + 5 years (Scatter) \n",fontsize=16)
axs[idx_ax].axhline(y = 0, color = 'r',lw=1, alpha=.1)
print(key)
# Subplot 1 <<<
# Subplot 2 >>>
idx_ax = 1
vars_plot = (
"""
FATES_STOREC_TF
FATES_STOREC
"""
).split('\n')
vars_plot = vars_plot[1:-1]
var = vars_plot[0]
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].scatter(ts_data.time, ts_data, marker=".", label = var,alpha=.2)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
ax_tmp = axs[idx_ax].twinx()
var = vars_plot[1]
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.scatter(ts_data.time,ts_data,marker=".", color='k', label = var, alpha=.3)
ax_tmp.legend(loc = 5)
ax_tmp.set_ylabel (f"{var}({ds[key][var].units})")
ax_tmp.axhline(y = 0, color = 'r',lw=1, alpha=.1)
# Subplot 2 <<<
# Subplot 3 >>>
idx_ax = 2
vars_plot = (
"""
FATES_STOREN_TF
FATES_STOREN
"""
).split('\n')
vars_plot = vars_plot[1:-1]
var = vars_plot[0]
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].scatter(ts_data.time, ts_data, marker=".", label = var,alpha=.2)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
ax_tmp = axs[idx_ax].twinx()
var = vars_plot[1]
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.scatter(ts_data.time,ts_data, marker=".", color='k',label = var, alpha=.3)
ax_tmp.set_ylabel (f"{var}({ds[key][var].units})")
ax_tmp.legend(loc = 5)
ax_tmp.axhline(y = 0, color = 'r',lw=1, alpha=.1)
# Subplot 3 <<<
# Subplot 4 >>>
idx_ax = 3
ts_data = (ds[key]["FATES_STOREC_TF"]/ds[key]["FATES_STOREN_TF"])[idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].scatter(ts_data.time, ts_data, label = "FATES_STOREC_TF/FATES_STOREN_TF",alpha=.2)
axs[idx_ax].set_ylabel (f"FATES_STOREC_TF/FATES_STOREN_TF")
ax_tmp = axs[idx_ax].twinx()
ts_data = (ds[key]["FATES_STOREC"]/ds[key]["FATES_STOREN"])[idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.scatter(ts_data.time, ts_data, marker=".", color='k', label = "FATES_STOREC/FATES_STOREN",alpha=.2)
ax_tmp.legend(loc = 5)
ax_tmp.set_ylabel (f"FATES_STOREC/FATES_STOREN")
# Subplot 4 <<<
# Subplot 5 >>>
idx_ax = 4
ts_data = (ds[key]["FATES_FROOT_ALLOC"]/ds[key]["FATES_LEAF_ALLOC"])[idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].scatter(ts_data.time, ts_data, label = "FATES_FROOT_ALLOC/FATES_LEAF_ALLOC",alpha=.2)
axs[idx_ax].set_ylabel (f"FATES_FROOT_ALLOC/FATES_LEAF_ALLOC")
ax_tmp = axs[idx_ax].twinx()
ts_data = ds[key]["FATES_L2FR"][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.scatter(ts_data.time, ts_data, marker=".", color='k', label = "FATES_L2FR",alpha=.2)
ax_tmp.set_ylabel (f"{ds[key]['FATES_L2FR'].units}")
ax_tmp.legend(loc = 5)
# Subplot 5 <<<
# Subplot 6 >>>
idx_ax = 5
vars_plot = (
"""
FATES_LEAFC
FATES_FROOTC
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].scatter(ts_data.time, ts_data, label = var,alpha=.2)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
ax_tmp = axs[idx_ax].twinx()
ts_data = (ds[key]["FATES_FROOTC"]/ds[key]["FATES_LEAFC"])[idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.scatter(ts_data.time, ts_data, marker=".", color='k', label = "FATES_FROOTC/FATES_LEAFC",alpha=.2)
ax_tmp.legend(loc = 5)
ax_tmp.set_ylabel (f"Unitless")
# Subplot 6 <<<
# Subplot 7 >>>
idx_ax = 6
vars_plot = (
"""
FATES_NO3UPTAKE
FATES_NH4UPTAKE
"""
).split('\n')
vars_plot = vars_plot[1:-1]
var = vars_plot[0]
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].scatter(ts_data.time, ts_data, label = var,alpha=.2)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
axs[idx_ax].axhline(y = 0, color = 'r',lw=1, alpha=.1)
ax_tmp = axs[idx_ax].twinx()
var = vars_plot[1]
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
ax_tmp.scatter(ts_data.time,ts_data, marker=".", color='k', label = var,alpha=.2)
ax_tmp.set_ylabel (f"{var}({ds[key][var].units})")
ax_tmp.legend(loc = 5)
# Subplot 7 <<<
# Subplot 8 >>>
idx_ax = 7
vars_plot = (
"""
GROSS_NMIN
NET_NMIN
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].scatter(ts_data.time, ts_data, label = var,alpha=.2)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
axs[idx_ax].axhline(y = 0, color = 'r',lw=1, alpha=.1)
# Subplot 8 <<<
# Subplot 9 >>>
idx_ax = 8
vars_plot = (
"""
SMIN_NO3_LEACHED
DENIT
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var][idx_start_date:idx_start_date+Yrs_Next*365] # Daily data range from logging date to next five years
axs[idx_ax].scatter(ts_data.time, ts_data, label = var,alpha=.2)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
axs[idx_ax].axhline(y = 0, color = 'r',lw=1, alpha=.1)
# Subplot 9 <<<
print(key)
for i in range(len(axs)):
axs[i].legend()
axs[i].axvline(x = dt.date(1855,1,1), color = 'g',lw=5, alpha=.1)
#fig.savefig('./Plots/' + f'{key}_Scatter_daily.pdf',bbox_inches='tight')
#fig.savefig('./Plots/' + f'{key}_Scatter_daily.png',bbox_inches='tight')
All Plots >>>>>> DUK_PIDE_RD_AgBgW_CN53
/Users/ud4/opt/anaconda3/envs/pyces/lib/python3.9/site-packages/dask/core.py:121: RuntimeWarning: invalid value encountered in true_divide
DUK_PIDE_RD_AgBgW_CN53
print ("\nAll Plots >>>>>>")
# For multiple variables on a same plot
fig, axs = plt.subplots(9,1 , figsize=(15,30), dpi=400)
# Subplot 1 >>>
idx_ax = 0
var = "FATES_NPP"
# C-only
sim_conly = sims.replace("RD", "Conly")
if sims == "DUK_PIDE_RD_AgBgW_testing" :
sim_conly = "DUK_PIDE_Conly_AgBgW"
key=sim_conly
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var + " C-only")
# RD
key=sims
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var )
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
axs[idx_ax].set_title(f"{key} Annual Mean\n",fontsize=16)
# Subplot 1 <<<
# Subplot 2 >>>
idx_ax = 1
vars_plot = (
"""
FATES_STOREC_TF
FATES_STOREC
"""
).split('\n')
vars_plot = vars_plot[1:-1]
var = vars_plot[0]
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
ax_tmp = axs[idx_ax].twinx()
var = vars_plot[1]
ts_data = ds[key][var].groupby("time.year").mean('time')
ax_tmp.plot(ts_data.year,ts_data,'k+', label = var)
ax_tmp.legend(loc = 5)
ax_tmp.set_ylabel (f"{var}({ds[key][var].units})")
ax_tmp.axhline(y = 0, color = 'r',lw=1, alpha=.1)
# Subplot 2 <<<
# Subplot 3 >>>
idx_ax = 2
vars_plot = (
"""
FATES_STOREN_TF
FATES_STOREN
"""
).split('\n')
vars_plot = vars_plot[1:-1]
var = vars_plot[0]
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
ax_tmp = axs[idx_ax].twinx()
var = vars_plot[1]
ts_data = ds[key][var].groupby("time.year").mean('time')
ax_tmp.plot(ts_data.year,ts_data,'k+', label = var)
ax_tmp.set_ylabel (f"{var}({ds[key][var].units})")
ax_tmp.legend(loc = 5)
ax_tmp.axhline(y = 0, color = 'r',lw=1, alpha=.1)
# Subplot 3 <<<
# Subplot 4 >>>
idx_ax = 3
ts_data = (ds[key]["FATES_STOREC_TF"]/ds[key]["FATES_STOREN_TF"]).groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = "FATES_STOREC_TF/FATES_STOREN_TF")
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
ax_tmp = axs[idx_ax].twinx()
ts_data = (ds[key]["FATES_STOREC"]/ds[key]["FATES_STOREN"]).groupby("time.year").mean('time')
ax_tmp.plot(ts_data.year, ts_data, 'k+', label = "FATES_STOREC/FATES_STOREN")
ax_tmp.legend(loc = 5)
ax_tmp.set_ylabel (f"{var}({ds[key][var].units})")
# Subplot 4 <<<
# Subplot 5 >>>
idx_ax = 4
ts_data = (ds[key]["FATES_FROOT_ALLOC"]/ds[key]["FATES_LEAF_ALLOC"]).groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = "FATES_FROOT_ALLOC/FATES_LEAF_ALLOC")
#axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
ax_tmp = axs[idx_ax].twinx()
ts_data = ds[key]["FATES_L2FR"].groupby("time.year").mean('time')
ax_tmp.plot(ts_data.year, ts_data,'k+', label = "FATES_L2FR")
ax_tmp.set_ylabel (f"{ds[key]['FATES_L2FR'].units}")
ax_tmp.legend(loc = 5)
# Subplot 5 <<<
# Subplot 6 >>>
idx_ax = 5
vars_plot = (
"""
FATES_LEAFC
FATES_FROOTC
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
ax_tmp = axs[idx_ax].twinx()
ts_data = (ds[key]["FATES_FROOTC"]/ds[key]["FATES_LEAFC"]).groupby("time.year").mean('time')
ax_tmp.plot(ts_data.year, ts_data, 'k+', label = "FATES_FROOTC/FATES_LEAFC")
ax_tmp.legend(loc = 1)
ax_tmp.set_ylabel (f"Unitless")
# Subplot 6 <<<
# Subplot 7 >>>
idx_ax = 6
vars_plot = (
"""
FATES_NO3UPTAKE
FATES_NH4UPTAKE
"""
).split('\n')
vars_plot = vars_plot[1:-1]
var = vars_plot[0]
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
ax_tmp = axs[idx_ax].twinx()
var = vars_plot[1]
ts_data = ds[key][var].groupby("time.year").mean('time')
ax_tmp.plot(ts_data.year,ts_data,'k+', label = var)
ax_tmp.legend(loc = 5)
# Subplot 7 <<<
# Subplot 8 >>>
idx_ax = 7
vars_plot = (
"""
GROSS_NMIN
NET_NMIN
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
# Subplot 8 <<<
# Subplot 9 >>>
idx_ax = 8
vars_plot = (
"""
SMIN_NO3_LEACHED
DENIT
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
# Subplot 9 <<<
for i in range(len(axs)):
axs[i].legend()
axs[i].axvline(x = logging_year, color = 'r',lw=5, alpha=.2)
#fig.savefig('./Plots/' + f'{key}.pdf',bbox_inches='tight')
#fig.savefig('./Plots/' + f'{key}.png',bbox_inches='tight')
All Plots >>>>>>
/Users/ud4/opt/anaconda3/envs/pyces/lib/python3.9/site-packages/dask/core.py:121: RuntimeWarning: invalid value encountered in true_divide
#print(breakit)
print ("\nFigure Set 1 >>>>>>")
# For multiple variables on a same plot
# C-only
sim_conly = sims.replace("RD", "Conly")
if sims == "DUK_PIDE_RD_AgBgW_testing" :
sim_conly = "DUK_PIDE_Conly_AgBgW"
key=sim_conly
#key=sims
vars_plot = (
"""
FATES_GPP
FATES_AUTORESP
FATES_NPP
"""
).split('\n')
vars_plot = vars_plot[1:-1]
ymin = 9e20
ymax = -9e20
sum_ts = 0
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
sum_ts= sum_ts + ts_data
ts_data.plot(figsize=(20,3))
if np.min(ts_data.values) < ymin:
ymin = np.min(ts_data.values)
if np.max(ts_data.values) > ymax:
ymax = np.max(ts_data.values)
plt.title(f"{ds[key][var].long_name} ({var}) - {key} - AnnualSUM | Units: {ds[key][var].units}")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.axvline(x = 1996, color = 'g',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(.2e-6,1.5e-6)
if i_var != len(vars_plot)-1 :
plt.xticks([])
plt.xlabel(None)
fig = plt.figure(figsize=(20,9))
plt.title (f"Common Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = var)
plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.close(fig)
fig1 = plt.figure(figsize=(20,9))
plt.title (f"Fractional Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data/sum_ts, label = var)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.close(fig1)
#plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
Figure Set 1 >>>>>>
<matplotlib.lines.Line2D at 0x17c49a280>
ts_data.year
<xarray.DataArray 'year' (year: 148)> array([1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997]) Coordinates: * year (year) int64 1850 1851 1852 1853 1854 ... 1993 1994 1995 1996 1997
array([1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997])
array([1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997])
print ("\nFigure Set 2 >>>>>>")
# For multiple variables on a same plot
#sims = "ORN_PIDE_RD_AgBgW" # Difined at the top
key=sims
vars_plot = (
"""
FATES_GPP
FATES_AUTORESP
FATES_NPP
"""
).split('\n')
vars_plot = vars_plot[1:-1]
ymin = 9e20
ymax = -9e20
sum_ts = 0
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
sum_ts= sum_ts + ts_data
ts_data.plot(figsize=(20,3))
if np.min(ts_data.values) < ymin:
ymin = np.min(ts_data.values)
if np.max(ts_data.values) > ymax:
ymax = np.max(ts_data.values)
plt.title(f"{ds[key][var].long_name} ({var}) - {key} - AnnualSUM | Units: {ds[key][var].units}")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.axvline(x = 1996, color = 'g',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(.2e-6,1.5e-6)
if i_var != len(vars_plot)-1 :
plt.xticks([])
plt.xlabel(None)
fig = plt.figure(figsize=(20,9))
plt.title (f"Common Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = var)
plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig1 = plt.figure(figsize=(20,9))
plt.title (f"Fractional Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data/sum_ts, label = var)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
Figure Set 2 >>>>>>
<matplotlib.lines.Line2D at 0x17bdbaee0>
print ("\nFigure Set 3 >>>>>>")
# For multiple variables on a same plot
#sims = "ORN_PIDE_RD_AgBgW" # Difined at the top
key=sims
vars_plot = (
"""
FATES_STOREC
FATES_STOREC_TF
"""
).split('\n')
vars_plot = vars_plot[1:-1]
ymin = 9e20
ymax = -9e20
sum_ts = 0
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
sum_ts= sum_ts + ts_data
ts_data.plot(figsize=(20,3))
if np.min(ts_data.values) < ymin:
ymin = np.min(ts_data.values)
if np.max(ts_data.values) > ymax:
ymax = np.max(ts_data.values)
plt.title(f"{ds[key][var].long_name} ({var}) - {key} - AnnualSUM | Units: {ds[key][var].units}")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.axvline(x = 1996, color = 'g',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(.2e-6,1.5e-6)
if i_var != len(vars_plot)-1 :
plt.xticks([])
plt.xlabel(None)
fig = plt.figure(figsize=(20,9))
plt.title (f"Common Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
if var == "FATES_L2FR" : continue
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = var)
plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig1 = plt.figure(figsize=(20,9))
plt.title (f"Fractional Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data/sum_ts, label = var)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig2 = plt.figure(figsize=(20,9))
plt.title (f"Ratio Plot for simulation {key}", fontsize=15)
#for i_var,var in enumerate(vars_plot):
if True:
ts_data = (ds[key]["FATES_STOREC"]/ds[key]["FATES_STOREC_TF"]).groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = "FATES_STOREC/FATES_STOREC_TF")
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.title(f"{key}: FATES_STOREC/FATES_STOREC_TF")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
Figure Set 3 >>>>>>
<matplotlib.lines.Line2D at 0x17a3cc490>
print ("\nFigure Set 4 >>>>>>")
# For multiple variables on a same plot
#sims = "ORN_PIDE_RD_AgBgW" # Difined at the top
key=sims
vars_plot = (
"""
FATES_STOREN
FATES_STOREN_TF
"""
).split('\n')
vars_plot = vars_plot[1:-1]
ymin = 9e20
ymax = -9e20
sum_ts = 0
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
sum_ts= sum_ts + ts_data
ts_data.plot(figsize=(20,3))
if np.min(ts_data.values) < ymin:
ymin = np.min(ts_data.values)
if np.max(ts_data.values) > ymax:
ymax = np.max(ts_data.values)
plt.title(f"{ds[key][var].long_name} ({var}) - {key} - AnnualSUM | Units: {ds[key][var].units}")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.axvline(x = 1996, color = 'g',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(.2e-6,1.5e-6)
if i_var != len(vars_plot)-1 :
plt.xticks([])
plt.xlabel(None)
fig = plt.figure(figsize=(20,9))
plt.title (f"Common Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
if var == "FATES_L2FR" : continue
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = var)
plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig1 = plt.figure(figsize=(20,9))
plt.title (f"Fractional Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data/sum_ts, label = var)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig2 = plt.figure(figsize=(20,9))
plt.title (f"Ratio Plot for simulation {key}", fontsize=15)
#for i_var,var in enumerate(vars_plot):
if True:
ts_data = (ds[key]["FATES_STOREN"]/ds[key]["FATES_STOREN_TF"]).groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = "FATES_STOREN/FATES_STOREN_TF")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.title(f"{key}: FATES_STOREN/FATES_STOREN_TF")
Figure Set 4 >>>>>>
print ("\nFigure Set 5 >>>>>>")
# For multiple variables on a same plot
#sims = "ORN_PIDE_RD_AgBgW" # Difined at the top
key=sims
vars_plot = (
"""
FATES_STOREC_TF
FATES_STOREN_TF
"""
).split('\n')
vars_plot = vars_plot[1:-1]
ymin = 9e20
ymax = -9e20
sum_ts = 0
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
sum_ts= sum_ts + ts_data
ts_data.plot(figsize=(20,3))
if np.min(ts_data.values) < ymin:
ymin = np.min(ts_data.values)
if np.max(ts_data.values) > ymax:
ymax = np.max(ts_data.values)
plt.title(f"{ds[key][var].long_name} ({var}) - {key} - AnnualSUM | Units: {ds[key][var].units}")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.axvline(x = 1996, color = 'g',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(.2e-6,1.5e-6)
if i_var != len(vars_plot)-1 :
plt.xticks([])
plt.xlabel(None)
fig = plt.figure(figsize=(20,9))
plt.title (f"Common Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
if var == "FATES_L2FR" : continue
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = var)
plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig1 = plt.figure(figsize=(20,9))
plt.title (f"Fractional Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data/sum_ts, label = var)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig2 = plt.figure(figsize=(20,9))
plt.title (f"Ratio Plot for simulation {key}", fontsize=15)
#for i_var,var in enumerate(vars_plot):
if True:
ts_data = (ds[key]["FATES_STOREC_TF"]/ds[key]["FATES_STOREN_TF"]).groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = "FATES_STOREC_TF/FATES_STOREN_TF")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.title(f"{key}: FATES_STOREC_TF/FATES_STOREN_TF")
fig3 = plt.figure(figsize=(20,9))
plt.title (f"Ratio Plot for simulation {key}", fontsize=15)
#for i_var,var in enumerate(vars_plot):
if True:
ts_data = (ds[key]["FATES_STOREC"]/ds[key]["FATES_STOREN"]).groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = "FATES_STOREC/FATES_STOREN")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.title(f"{key}: FATES_STOREC/FATES_STOREN")
Figure Set 5 >>>>>>
print ("\nFigure Set 6 >>>>>>")
# For multiple variables on a same plot
#sims = "ORN_PIDE_RD_AgBgW" # Difined at the top
key=sims
'''
vars_plot = [
"FATES_CROOT_ALLOC",
"FATES_FROOT_ALLOC",
"FATES_FROOT_ALLOC",
"FATES_SEED_ALLOC",
"FATES_STEM_ALLOC",
"FATES_STORE_ALLOC"
]
'''
vars_plot = (
"""
FATES_CROOT_ALLOC
FATES_FROOT_ALLOC
FATES_FROOT_ALLOC
FATES_SEED_ALLOC
FATES_STEM_ALLOC
FATES_STORE_ALLOC
"""
).split('\n')
vars_plot = vars_plot[1:-1]
ymin = 9e20
ymax = -9e20
sum_ts = 0
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
sum_ts= sum_ts + ts_data
ts_data.plot(figsize=(20,3))
if np.min(ts_data.values) < ymin:
ymin = np.min(ts_data.values)
if np.max(ts_data.values) > ymax:
ymax = np.max(ts_data.values)
plt.title(f"{ds[key][var].long_name} ({var}) - {key} - AnnualSUM | Units: {ds[key][var].units}")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.axvline(x = 1996, color = 'g',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(.2e-6,1.5e-6)
if i_var != len(vars_plot)-1 :
plt.xticks([])
plt.xlabel(None)
fig = plt.figure(figsize=(20,9))
plt.title (f"Common Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = var)
plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig1 = plt.figure(figsize=(20,9))
plt.title (f"Fractional Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data/sum_ts, label = var)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig2 = plt.figure(figsize=(20,9))
plt.title (f"Ratio Plot for simulation {key}", fontsize=15)
#for i_var,var in enumerate(vars_plot):
if True:
ts_data = (ds[key]["FATES_FROOT_ALLOC"]/ds[key]["FATES_LEAF_ALLOC"]).groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = "FATES_FROOT_ALLOC/FATES_LEAF_ALLOC")
ts_data = ds[key]["FATES_L2FR"].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = "FATES_L2FR")
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.title(f"{key}: FATES_FROOT_ALLOC/FATES_LEAF_ALLOC")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
Figure Set 6 >>>>>>
/Users/ud4/opt/anaconda3/envs/pyces/lib/python3.9/site-packages/dask/core.py:121: RuntimeWarning: invalid value encountered in true_divide
<matplotlib.lines.Line2D at 0x1969a7760>
print ("\nFigure Set 7 >>>>>>")
# For multiple variables on a same plot
#sims = "ORN_PIDE_RD_AgBgW" # Difined at the top
key=sims
vars_plot = (
"""
FATES_LEAFC
FATES_FROOTC
"""
).split('\n')
vars_plot = vars_plot[1:-1]
ymin = 9e20
ymax = -9e20
sum_ts = 0
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
sum_ts= sum_ts + ts_data
ts_data.plot(figsize=(20,3))
if np.min(ts_data.values) < ymin:
ymin = np.min(ts_data.values)
if np.max(ts_data.values) > ymax:
ymax = np.max(ts_data.values)
plt.title(f"{ds[key][var].long_name} ({var}) - {key} - AnnualSUM | Units: {ds[key][var].units}")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.axvline(x = 1996, color = 'g',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(.2e-6,1.5e-6)
if i_var != len(vars_plot)-1 :
plt.xticks([])
plt.xlabel(None)
fig = plt.figure(figsize=(20,9))
plt.title (f"Common Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
if var == "FATES_L2FR" : continue
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = var)
plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig1 = plt.figure(figsize=(20,9))
plt.title (f"Fractional Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data/sum_ts, label = var)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig2 = plt.figure(figsize=(20,9))
plt.title (f"Ratio Plot for simulation {key}", fontsize=15)
#for i_var,var in enumerate(vars_plot):
if True:
ts_data = (ds[key]["FATES_FROOTC"]/ds[key]["FATES_LEAFC"]).groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = "FATES_FROOTC/FATES_LEAFC")
ts_data = ds[key]["FATES_L2FR"].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = "FATES_L2FR")
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.title(f"{key}: FATES_FROOTC/FATES_LEAFC")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
Figure Set 7 >>>>>>
<matplotlib.lines.Line2D at 0x1964a3880>
print ("\nFigure Set 8 >>>>>>")
# For multiple variables on a same plot
#sims = "ORN_PIDE_RD_AgBgW" # Difined at the top
key=sims
vars_plot = (
"""
FATES_NO3UPTAKE
FATES_NH4UPTAKE
"""
).split('\n')
vars_plot = vars_plot[1:-1]
ymin = 9e20
ymax = -9e20
sum_ts = 0
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
sum_ts= sum_ts + ts_data
ts_data.plot(figsize=(20,3))
if np.min(ts_data.values) < ymin:
ymin = np.min(ts_data.values)
if np.max(ts_data.values) > ymax:
ymax = np.max(ts_data.values)
plt.title(f"{ds[key][var].long_name} ({var}) - {key} - AnnualSUM | Units: {ds[key][var].units}")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.axvline(x = 1996, color = 'g',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(.2e-6,1.5e-6)
if i_var != len(vars_plot)-1 :
plt.xticks([])
plt.xlabel(None)
fig = plt.figure(figsize=(20,9))
plt.title (f"Common Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
if var == "FATES_L2FR" : continue
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = var)
plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig1 = plt.figure(figsize=(20,9))
plt.title (f"Fractional Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data/sum_ts, label = var)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
Figure Set 8 >>>>>>
<matplotlib.lines.Line2D at 0x182fea6a0>
### *Figure Set 9*
print ("\nFigure Set 9 >>>>>>")
# For multiple variables on a same plot
#sims = "ORN_PIDE_RD_AgBgW" # Difined at the top
key=sims
vars_plot = (
"""
GROSS_NMIN
NET_NMIN
"""
).split('\n')
vars_plot = vars_plot[1:-1]
ymin = 9e20
ymax = -9e20
sum_ts = 0
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
sum_ts= sum_ts + ts_data
ts_data.plot(figsize=(20,3))
if np.min(ts_data.values) < ymin:
ymin = np.min(ts_data.values)
if np.max(ts_data.values) > ymax:
ymax = np.max(ts_data.values)
plt.title(f"{ds[key][var].long_name} ({var}) - {key} - AnnualSUM | Units: {ds[key][var].units}")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.axvline(x = 1996, color = 'g',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(.2e-6,1.5e-6)
if i_var != len(vars_plot)-1 :
plt.xticks([])
plt.xlabel(None)
fig = plt.figure(figsize=(20,9))
plt.title (f"Common Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
if var == "FATES_L2FR" : continue
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = var)
plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig1 = plt.figure(figsize=(20,9))
plt.title (f"Fractional Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data/sum_ts, label = var)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
Figure Set 9 >>>>>>
<matplotlib.lines.Line2D at 0x1857ac340>
print ("\nFigure Set 10 >>>>>>")
# For multiple variables on a same plot
#sims = "ORN_PIDE_RD_AgBgW" # Difined at the top
key=sims
vars_plot = (
"""
SMIN_NO3_LEACHED
DENIT
"""
).split('\n')
vars_plot = vars_plot[1:-1]
ymin = 9e20
ymax = -9e20
sum_ts = 0
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
sum_ts= sum_ts + ts_data
ts_data.plot(figsize=(20,3))
if np.min(ts_data.values) < ymin:
ymin = np.min(ts_data.values)
if np.max(ts_data.values) > ymax:
ymax = np.max(ts_data.values)
plt.title(f"{ds[key][var].long_name} ({var}) - {key} - AnnualSUM | Units: {ds[key][var].units}")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.axvline(x = 1996, color = 'g',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(.2e-6,1.5e-6)
if i_var != len(vars_plot)-1 :
plt.xticks([])
plt.xlabel(None)
fig = plt.figure(figsize=(20,9))
plt.title (f"Common Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
if var == "FATES_L2FR" : continue
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = var)
plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig1 = plt.figure(figsize=(20,9))
plt.title (f"Fractional Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data/sum_ts, label = var)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
Figure Set 10 >>>>>>
<matplotlib.lines.Line2D at 0x17e59d820>
# For multiple variables on a same plot
#sims = "ORN_PIDE_RD_AgBgW" # Difined at the top
key=sims
vars_plot = (
"""
FATES_FROOTC
FATES_LEAFC
FATES_NONSTRUCTC
FATES_REPROC
FATES_SAPWOODC
FATES_STOREC
FATES_STRUCTC
FATES_VEGC
"""
).split('\n')
vars_plot = vars_plot[1:-1]
ymin = 9e20
ymax = -9e20
sum_ts = 0
for i_var,var in enumerate(vars_plot):
print(var)
ts_data = ds[key][var].groupby("time.year").mean('time')
sum_ts= sum_ts + ts_data
ts_data.plot(figsize=(20,3))
if np.min(ts_data.values) < ymin:
ymin = np.min(ts_data.values)
if np.max(ts_data.values) > ymax:
ymax = np.max(ts_data.values)
plt.title(f"{ds[key][var].long_name} ({var}) - {key} - AnnualSUM | Units: {ds[key][var].units}")
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
#plt.axvline(x = 1996, color = 'g',lw=5, label = 'logging year', alpha=.2)
#plt.ylim(.2e-6,1.5e-6)
if i_var != len(vars_plot)-1 :
plt.xticks([])
plt.xlabel(None)
fig = plt.figure(figsize=(20,9))
plt.title (f"Common Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data, label = var)
plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
fig1 = plt.figure(figsize=(20,9))
plt.title (f"Fractional Plot for simulation {key}", fontsize=15)
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
plt.plot(ts_data.year, ts_data/sum_ts, label = var)
#plt.ylim(ymin*.95,ymax*1.05)
plt.legend(fontsize=14)
plt.axvline(x = logging_year, color = 'r',lw=5, label = 'logging year', alpha=.2)
FATES_FROOTC FATES_LEAFC FATES_NONSTRUCTC FATES_REPROC FATES_SAPWOODC FATES_STOREC FATES_STRUCTC FATES_VEGC
<matplotlib.lines.Line2D at 0x193bf9c40>
Subplot 1: FATES_NPP (for C-only at that site and RD/ECA) Subplot 1: FATES_NPP Subplot 2: FATES_STOREC Subplot 2: FATES_STOREC_TF Subplot 3: FATES_STOREN Subplot 3: FATES_STOREN_TF Subplot 4: FATES_STOREC_TF / FATES_STOREN_TF Subplot 5: FATES_FROOTC_ALLOC / FATES_LEAFC_ALLOC Subplot 5: FATES_L2FR Subplot 6: FATES_FROOTC / FATES_LEAFC Subplot 6: FATES_FROOTC Subplot 6: FATES_LEAFC Subplot 7: FATES_NO3UPTAKE Subplot 7: FATES_NH4UPTAKE Subplot 8: NET_NMIN Subplot 8: GROSS_NMIN Subplot 9: SMIN_NO3_LEACHED Subplot 9: DENIT
print ("\nAll Plots >>>>>>")
# For multiple variables on a same plot
fig, axs = plt.subplots(9,1 , figsize=(15,30), dpi=400)
# Subplot 1 >>>
idx_ax = 0
var = "FATES_NPP"
# C-only
sim_conly = sims.replace("RD", "Conly")
if sims == "DUK_PIDE_RD_AgBgW_testing" :
sim_conly = "DUK_PIDE_Conly_AgBgW"
key=sim_conly
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var + " C-only")
# RD
key=sims
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var )
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
axs[idx_ax].set_title(f"{key}\n",fontsize=16)
# Subplot 1 <<<
# Subplot 2 >>>
idx_ax = 1
vars_plot = (
"""
FATES_STOREC_TF
FATES_STOREC
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
# Subplot 2 <<<
# Subplot 3 >>>
idx_ax = 2
vars_plot = (
"""
FATES_STOREN_TF
FATES_STOREN
"""
).split('\n')
vars_plot = vars_plot[1:-1]
var = vars_plot[0]
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var)
ax_tmp = axs[idx_ax].twinx()
var = vars_plot[1]
ts_data = ds[key][var].groupby("time.year").mean('time')
ax_tmp.plot(ts_data.year,ts_data,'k+', label = var)
ax_tmp.legend(loc = 5)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
# Subplot 3 <<<
# Subplot 4 >>>
idx_ax = 3
ts_data = (ds[key]["FATES_STOREC_TF"]/ds[key]["FATES_STOREN_TF"]).groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = "FATES_STOREC_TF/FATES_STOREN_TF")
ax_tmp = axs[idx_ax].twinx()
ts_data = (ds[key]["FATES_STOREC"]/ds[key]["FATES_STOREN"]).groupby("time.year").mean('time')
ax_tmp.plot(ts_data.year, ts_data, 'k+', label = "FATES_STOREC/FATES_STOREN")
ax_tmp.legend(loc = 5)
# Subplot 4 <<<
# Subplot 5 >>>
idx_ax = 4
ts_data = (ds[key]["FATES_FROOT_ALLOC"]/ds[key]["FATES_LEAF_ALLOC"]).groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = "FATES_FROOT_ALLOC/FATES_LEAF_ALLOC")
ts_data = ds[key]["FATES_L2FR"].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = "FATES_L2FR")
# Subplot 5 <<<
# Subplot 6 >>>
idx_ax = 5
vars_plot = (
"""
FATES_LEAFC
FATES_FROOTC
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
ax_tmp = axs[idx_ax].twinx()
ts_data = (ds[key]["FATES_FROOTC"]/ds[key]["FATES_LEAFC"]).groupby("time.year").mean('time')
ax_tmp.plot(ts_data.year, ts_data, 'k+', label = "FATES_FROOTC/FATES_LEAFC")
ax_tmp.legend(loc = 1)
# Subplot 6 <<<
# Subplot 7 >>>
idx_ax = 6
vars_plot = (
"""
FATES_NO3UPTAKE
FATES_NH4UPTAKE
"""
).split('\n')
vars_plot = vars_plot[1:-1]
var = vars_plot[0]
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
ax_tmp = axs[idx_ax].twinx()
var = vars_plot[1]
ts_data = ds[key][var].groupby("time.year").mean('time')
ax_tmp.plot(ts_data.year,ts_data,'k+', label = var)
ax_tmp.legend(loc = 5)
# Subplot 7 <<<
# Subplot 8 >>>
idx_ax = 7
vars_plot = (
"""
GROSS_NMIN
NET_NMIN
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
# Subplot 8 <<<
# Subplot 9 >>>
idx_ax = 8
vars_plot = (
"""
SMIN_NO3_LEACHED
DENIT
"""
).split('\n')
vars_plot = vars_plot[1:-1]
for i_var,var in enumerate(vars_plot):
ts_data = ds[key][var].groupby("time.year").mean('time')
axs[idx_ax].plot(ts_data.year, ts_data, label = var)
axs[idx_ax].set_ylabel (f"{ds[key][var].units}")
# Subplot 9 <<<
for i in range(len(axs)):
axs[i].legend()
axs[i].axvline(x = logging_year, color = 'r',lw=5, alpha=.2)
#fig.savefig('./Plots/' + f'{key}.pdf',bbox_inches='tight')
#fig.savefig('./Plots/' + f'{key}.png',bbox_inches='tight')
All Plots >>>>>>
/Users/ud4/opt/anaconda3/envs/pyces/lib/python3.9/site-packages/dask/core.py:121: RuntimeWarning: invalid value encountered in true_divide
pwd
'/Users/ud4/repos/GitHub/FATESFACE'
import datetime
current_time = datetime.datetime.now()
formatted_time = current_time.strftime("%H:%M:%S")
print("Formatted time:", formatted_time)
Formatted time: 14:11:28
print (f"Successful run at {formatted_time} {key}")
Successful run at 14:11:28 DUK_PIDE_RD_AgBgW_CN53