pwd
'/Users/ud4/repos/GitHub/FATESFACE/Jupyter_Notebooks'
import re
import pandas as pd
import matplotlib.pyplot as plt
Reading the logs of the print file for the data in the file components/elm/src/external_models/fates/biogeochem/EDPhysiologyMod.F90
phenology
in the file EDPhysiologyMod.F90
for cold deciduous only¶ print*,'sinkhole_phenology', model_day_int,temp_in_C,ncdstart,gddstart, currentSite%nchilldays, gdd_threshold,ncolddays, &
currentSite%grow_deg_days, currentSite%cleafoffdate, currentSite%cndaysleafoff,currentSite%cleafondate,currentSite%cndaysleafon
print*,'sinkhole_phenology_def',phen_cstat_iscold,phen_cstat_nevercold,phen_cstat_notcold
!LEAF ON: COLD DECIDUOUS. Needs to
!1) have exceeded the growing degree day threshold
!2) The leaves should not be on already
!3) There should have been at least one chilling day in the counting period.
! this prevents tropical or warm climate plants that are "cold-deciduous"
! from ever re-flushing after they have reached their maximum age (thus
! preventing them from competing
print*,'sinkhole_phenology_LOn1', model_day_int,currentSite%cstatus,ED_val_phen_mindayson,currentSite%grow_deg_days,gdd_threshold,currentSite%nchilldays,currentSite%cleafondate
if ( any(currentSite%cstatus == [phen_cstat_iscold,phen_cstat_nevercold]) .and. &
(currentSite%grow_deg_days > gdd_threshold) .and. &
(currentSite%cndaysleafoff > ED_val_phen_mindayson) .and. &
(currentSite%nchilldays >= 1)) then
currentSite%cstatus = phen_cstat_notcold ! Set to not-cold status (leaves can come on)
currentSite%cleafondate = model_day_int
currentSite%cndaysleafon = 0
currentSite%grow_deg_days = 0._r8 ! zero GDD for the rest of the year until counting season begins.
if ( debug ) write(fates_log(),*) 'leaves on'
endif !GDD
print*,'sinkhole_phenology_LOn2', model_day_int,currentSite%cstatus, currentSite%cleafondate,currentSite%grow_deg_days
!LEAF OFF: COLD THRESHOLD
!Needs to:
!1) have exceeded the number of cold days threshold
!2) have exceeded the minimum leafon time.
!3) The leaves should not be off already
!4) The day of simulation should be larger than the counting period.
print*,'sinkhole_phenology_LOff1', model_day_int,currentSite%cstatus,num_vegtemp_mem,ED_val_phen_ncolddayslim,ED_val_phen_mindayson,currentSite%cndaysleafon
if ( (currentSite%cstatus == phen_cstat_notcold) .and. &
(model_day_int > num_vegtemp_mem) .and. &
(ncolddays > ED_val_phen_ncolddayslim) .and. &
(currentSite%cndaysleafon > ED_val_phen_mindayson) )then
currentSite%grow_deg_days = 0._r8 ! The equations for Botta et al
! are for calculations of
! first flush, but if we dont
! clear this value, it will cause
! leaves to flush later in the year
currentSite%cstatus = phen_cstat_iscold ! alter status of site to 'leaves off'
currentSite%cleafoffdate = model_day_int ! record leaf off date
currentSite%cndaysleafoff = 0
if ( debug ) write(fates_log(),*) 'leaves off'
endif
print*,'sinkhole_phenology_LOff2', model_day_int,currentSite%cstatus , currentSite%grow_deg_days,currentSite%cndaysleafoff
! LEAF OFF: COLD LIFESPAN THRESHOLD
! NOTE: Some areas of the planet will never generate a cold day
! and thus %nchilldays will never go from zero to 1. The following logic
! when coupled with this fact will essentially prevent cold-deciduous
! plants from re-emerging in areas without at least some cold days
print*,'sinkhole_phenology_LOff_th', model_day_int,currentSite%cstatus, currentSite%cndaysleafoff,currentSite%cleafoffdate
if( (currentSite%cstatus == phen_cstat_notcold) .and. &
(currentSite%cndaysleafoff > 400)) then ! remove leaves after a whole year,
! when there is no 'off' period.
currentSite%grow_deg_days = 0._r8
currentSite%cstatus = phen_cstat_nevercold ! alter status of site to imply that this
! site is never really cold enough
! for cold deciduous
currentSite%cleafoffdate = model_day_int ! record leaf off date
currentSite%cndaysleafoff = 0
if ( debug ) write(fates_log(),*) 'leaves off'
endif
print*,'sinkhole_phenology_LOff_th2', model_day_int,currentSite%cstatus,currentSite%grow_deg_days ,currentSite%cndaysleafoff
path_in_logs = "/Users/ud4/repos/GitHub/FATESFACE/Print_Logs"
file_name = "Phenology_log_r240313.txt"
file_name = "Phenology_log_r240313_phen500.txt"
with open(f'{path_in_logs}/{file_name}', 'r') as infile:
data = infile.read()
# How long do you want the simulation plots?
max_r_years = 30
max_line_idx = max_r_years*365*8 # 30 years * 364 days * 8 freq output per day
# Split data into lines
lines = data.split('\n')
# Initialize a dictionary of dataframes
dfs = {}
# Iterate over lines and create dataframes based on the first item i.e. print header
for line_idx, line in enumerate(lines):
parts = line.split()
key = parts[0]
if key not in dfs:
dfs[key] = []
dfs[key].append(parts)
if line_idx>max_line_idx:
break
max_line_idx
87600
column_names = {}
column_names ['sinkhole_phenology'] = ['Name', 'Model_Day', 'temp_in_C', 'ncdstart','gddstart', 'nchilldays', 'gdd_threshold','ncolddays', 'grow_deg_days', 'cleafoffdate', 'cndaysleafoff','cleafondate','cndaysleafon']
column_names ['sinkhole_phenology_def'] = ['Name', 'phen_cstat_iscold', 'phen_cstat_nevercold', 'phen_cstat_notcold']
column_names ['sinkhole_phenology_LOn1'] = ['Name', 'Model_Day', 'cstatus', 'ED_val_phen_mindayson','grow_deg_days','gdd_threshold','nchilldays','cleafondate']
column_names ['sinkhole_phenology_LOn2'] = ['Name', 'Model_Day', 'cstatus', 'cleafondate','grow_deg_days']
column_names ['sinkhole_phenology_LOff1'] = ['Name', 'Model_Day', 'cstatus', 'num_vegtemp_mem','ED_val_phen_ncolddayslim','ED_val_phen_mindayson','cndaysleafon']
column_names ['sinkhole_phenology_LOff2'] = ['Name', 'Model_Day', 'cstatus', 'grow_deg_days','cndaysleafoff']
column_names ['sinkhole_phenology_LOff_th'] = ['Name', 'Model_Day', 'cstatus', 'cndaysleafoff','cleafoffdate']
column_names ['sinkhole_phenology_LOff_th2'] = ['Name', 'Model_Day', 'cstatus', 'grow_deg_days','cndaysleafoff']
dict_of_dataframes = {}
# Create dataframes from lists of lists
for key, values in dfs.items():
df = pd.DataFrame(values,columns=column_names[key])
print(f"Dataframe for {key}:")
print(df)
print()
dict_of_dataframes[key] = df
Dataframe for sinkhole_phenology: Name Model_Day temp_in_C ncdstart gddstart \ 0 sinkhole_phenology 1 15.000000000000057 270 1 1 sinkhole_phenology 2 -0.12143019246548192 270 1 2 sinkhole_phenology 3 1.8371444335781462 270 1 3 sinkhole_phenology 4 12.345837344257973 270 1 4 sinkhole_phenology 5 16.943634897538857 270 1 ... ... ... ... ... ... 10946 sinkhole_phenology 10947 -6.0792380233093013 270 1 10947 sinkhole_phenology 10948 -4.8304985940314964 270 1 10948 sinkhole_phenology 10949 -6.6510489921105318 270 1 10949 sinkhole_phenology 10950 -7.7996488142381963 270 1 10950 sinkhole_phenology 10951 -8.5057785375904018 270 1 nchilldays gdd_threshold ncolddays grow_deg_days \ 0 0 570.00000000000000 9 0.0000000000000000 1 1 563.65179393196922 9 0.0000000000000000 2 2 557.36675356970989 9 0.0000000000000000 3 2 557.36675356970989 8 0.0000000000000000 4 2 557.36675356970989 7 0.0000000000000000 ... ... ... ... ... 10946 43 347.02480243347594 10 0.0000000000000000 10947 44 342.89523665104423 10 0.0000000000000000 10948 45 338.80676073469141 10 0.0000000000000000 10949 46 334.75896583341876 10 0.0000000000000000 10950 47 330.75144716436307 10 0.0000000000000000 cleafoffdate cndaysleafoff cleafondate cndaysleafon 0 299 67 99 267 1 299 68 99 268 2 299 69 99 269 3 299 70 99 270 4 299 71 99 271 ... ... ... ... ... 10946 10905 42 10649 298 10947 10905 43 10649 299 10948 10905 44 10649 300 10949 10905 45 10649 301 10950 10905 46 10649 302 [10951 rows x 13 columns] Dataframe for sinkhole_phenology_def: Name phen_cstat_iscold phen_cstat_nevercold \ 0 sinkhole_phenology_def 1 0 1 sinkhole_phenology_def 1 0 2 sinkhole_phenology_def 1 0 3 sinkhole_phenology_def 1 0 4 sinkhole_phenology_def 1 0 ... ... ... ... 10946 sinkhole_phenology_def 1 0 10947 sinkhole_phenology_def 1 0 10948 sinkhole_phenology_def 1 0 10949 sinkhole_phenology_def 1 0 10950 sinkhole_phenology_def 1 0 phen_cstat_notcold 0 2 1 2 2 2 3 2 4 2 ... ... 10946 2 10947 2 10948 2 10949 2 10950 2 [10951 rows x 4 columns] Dataframe for sinkhole_phenology_LOn1: Name Model_Day cstatus ED_val_phen_mindayson \ 0 sinkhole_phenology_LOn1 1 2 90.000000000000000 1 sinkhole_phenology_LOn1 2 2 90.000000000000000 2 sinkhole_phenology_LOn1 3 2 90.000000000000000 3 sinkhole_phenology_LOn1 4 2 90.000000000000000 4 sinkhole_phenology_LOn1 5 2 90.000000000000000 ... ... ... ... ... 10945 sinkhole_phenology_LOn1 10946 1 90.000000000000000 10946 sinkhole_phenology_LOn1 10947 1 90.000000000000000 10947 sinkhole_phenology_LOn1 10948 1 90.000000000000000 10948 sinkhole_phenology_LOn1 10949 1 90.000000000000000 10949 sinkhole_phenology_LOn1 10950 1 90.000000000000000 grow_deg_days gdd_threshold nchilldays cleafondate 0 0.0000000000000000 570.00000000000000 0 99 1 0.0000000000000000 563.65179393196922 1 99 2 0.0000000000000000 557.36675356970989 2 99 3 0.0000000000000000 557.36675356970989 2 99 4 0.0000000000000000 557.36675356970989 2 99 ... ... ... ... ... 10945 0.0000000000000000 351.19587104200622 42 10649 10946 0.0000000000000000 347.02480243347594 43 10649 10947 0.0000000000000000 342.89523665104423 44 10649 10948 0.0000000000000000 338.80676073469141 45 10649 10949 0.0000000000000000 334.75896583341876 46 10649 [10950 rows x 8 columns] Dataframe for sinkhole_phenology_LOn2: Name Model_Day cstatus cleafondate \ 0 sinkhole_phenology_LOn2 1 2 99 1 sinkhole_phenology_LOn2 2 2 99 2 sinkhole_phenology_LOn2 3 2 99 3 sinkhole_phenology_LOn2 4 2 99 4 sinkhole_phenology_LOn2 5 2 99 ... ... ... ... ... 10945 sinkhole_phenology_LOn2 10946 1 10649 10946 sinkhole_phenology_LOn2 10947 1 10649 10947 sinkhole_phenology_LOn2 10948 1 10649 10948 sinkhole_phenology_LOn2 10949 1 10649 10949 sinkhole_phenology_LOn2 10950 1 10649 grow_deg_days 0 0.0000000000000000 1 0.0000000000000000 2 0.0000000000000000 3 0.0000000000000000 4 0.0000000000000000 ... ... 10945 0.0000000000000000 10946 0.0000000000000000 10947 0.0000000000000000 10948 0.0000000000000000 10949 0.0000000000000000 [10950 rows x 5 columns] Dataframe for sinkhole_phenology_LOff1: Name Model_Day cstatus num_vegtemp_mem \ 0 sinkhole_phenology_LOff1 1 2 10 1 sinkhole_phenology_LOff1 2 2 10 2 sinkhole_phenology_LOff1 3 2 10 3 sinkhole_phenology_LOff1 4 2 10 4 sinkhole_phenology_LOff1 5 2 10 ... ... ... ... ... 10945 sinkhole_phenology_LOff1 10946 1 10 10946 sinkhole_phenology_LOff1 10947 1 10 10947 sinkhole_phenology_LOff1 10948 1 10 10948 sinkhole_phenology_LOff1 10949 1 10 10949 sinkhole_phenology_LOff1 10950 1 10 ED_val_phen_ncolddayslim ED_val_phen_mindayson cndaysleafon 0 5.0000000000000000 90.000000000000000 267 1 5.0000000000000000 90.000000000000000 268 2 5.0000000000000000 90.000000000000000 269 3 5.0000000000000000 90.000000000000000 270 4 5.0000000000000000 90.000000000000000 271 ... ... ... ... 10945 5.0000000000000000 90.000000000000000 297 10946 5.0000000000000000 90.000000000000000 298 10947 5.0000000000000000 90.000000000000000 299 10948 5.0000000000000000 90.000000000000000 300 10949 5.0000000000000000 90.000000000000000 301 [10950 rows x 7 columns] Dataframe for sinkhole_phenology_LOff2: Name Model_Day cstatus grow_deg_days \ 0 sinkhole_phenology_LOff2 1 2 0.0000000000000000 1 sinkhole_phenology_LOff2 2 2 0.0000000000000000 2 sinkhole_phenology_LOff2 3 2 0.0000000000000000 3 sinkhole_phenology_LOff2 4 2 0.0000000000000000 4 sinkhole_phenology_LOff2 5 2 0.0000000000000000 ... ... ... ... ... 10945 sinkhole_phenology_LOff2 10946 1 0.0000000000000000 10946 sinkhole_phenology_LOff2 10947 1 0.0000000000000000 10947 sinkhole_phenology_LOff2 10948 1 0.0000000000000000 10948 sinkhole_phenology_LOff2 10949 1 0.0000000000000000 10949 sinkhole_phenology_LOff2 10950 1 0.0000000000000000 cndaysleafoff 0 67 1 68 2 69 3 70 4 71 ... ... 10945 41 10946 42 10947 43 10948 44 10949 45 [10950 rows x 5 columns] Dataframe for sinkhole_phenology_LOff_th: Name Model_Day cstatus cndaysleafoff cleafoffdate 0 sinkhole_phenology_LOff_th 1 2 67 299 1 sinkhole_phenology_LOff_th 2 2 68 299 2 sinkhole_phenology_LOff_th 3 2 69 299 3 sinkhole_phenology_LOff_th 4 2 70 299 4 sinkhole_phenology_LOff_th 5 2 71 299 ... ... ... ... ... ... 10945 sinkhole_phenology_LOff_th 10946 1 41 10905 10946 sinkhole_phenology_LOff_th 10947 1 42 10905 10947 sinkhole_phenology_LOff_th 10948 1 43 10905 10948 sinkhole_phenology_LOff_th 10949 1 44 10905 10949 sinkhole_phenology_LOff_th 10950 1 45 10905 [10950 rows x 5 columns] Dataframe for sinkhole_phenology_LOff_th2: Name Model_Day cstatus grow_deg_days \ 0 sinkhole_phenology_LOff_th2 1 2 0.0000000000000000 1 sinkhole_phenology_LOff_th2 2 2 0.0000000000000000 2 sinkhole_phenology_LOff_th2 3 2 0.0000000000000000 3 sinkhole_phenology_LOff_th2 4 2 0.0000000000000000 4 sinkhole_phenology_LOff_th2 5 2 0.0000000000000000 ... ... ... ... ... 10945 sinkhole_phenology_LOff_th2 10946 1 0.0000000000000000 10946 sinkhole_phenology_LOff_th2 10947 1 0.0000000000000000 10947 sinkhole_phenology_LOff_th2 10948 1 0.0000000000000000 10948 sinkhole_phenology_LOff_th2 10949 1 0.0000000000000000 10949 sinkhole_phenology_LOff_th2 10950 1 0.0000000000000000 cndaysleafoff 0 67 1 68 2 69 3 70 4 71 ... ... 10945 41 10946 42 10947 43 10948 44 10949 45 [10950 rows x 5 columns]
# Making the columns as floats except of the 1st
for key in dict_of_dataframes.keys():
for k in dict_of_dataframes[key].columns[1:]:
dict_of_dataframes[key][k] = dict_of_dataframes[key][k].astype(float)
dict_of_dataframes['sinkhole_phenology'].head()
Name | Model_Day | temp_in_C | ncdstart | gddstart | nchilldays | gdd_threshold | ncolddays | grow_deg_days | cleafoffdate | cndaysleafoff | cleafondate | cndaysleafon | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | sinkhole_phenology | 1.0 | 15.000000 | 270.0 | 1.0 | 0.0 | 570.000000 | 9.0 | 0.0 | 299.0 | 67.0 | 99.0 | 267.0 |
1 | sinkhole_phenology | 2.0 | -0.121430 | 270.0 | 1.0 | 1.0 | 563.651794 | 9.0 | 0.0 | 299.0 | 68.0 | 99.0 | 268.0 |
2 | sinkhole_phenology | 3.0 | 1.837144 | 270.0 | 1.0 | 2.0 | 557.366754 | 9.0 | 0.0 | 299.0 | 69.0 | 99.0 | 269.0 |
3 | sinkhole_phenology | 4.0 | 12.345837 | 270.0 | 1.0 | 2.0 | 557.366754 | 8.0 | 0.0 | 299.0 | 70.0 | 99.0 | 270.0 |
4 | sinkhole_phenology | 5.0 | 16.943635 | 270.0 | 1.0 | 2.0 | 557.366754 | 7.0 | 0.0 | 299.0 | 71.0 | 99.0 | 271.0 |
dict_of_dataframes['sinkhole_phenology_def'].head()
Name | phen_cstat_iscold | phen_cstat_nevercold | phen_cstat_notcold | |
---|---|---|---|---|
0 | sinkhole_phenology_def | 1.0 | 0.0 | 2.0 |
1 | sinkhole_phenology_def | 1.0 | 0.0 | 2.0 |
2 | sinkhole_phenology_def | 1.0 | 0.0 | 2.0 |
3 | sinkhole_phenology_def | 1.0 | 0.0 | 2.0 |
4 | sinkhole_phenology_def | 1.0 | 0.0 | 2.0 |
dict_of_dataframes['sinkhole_phenology_LOn1'].head()
Name | Model_Day | cstatus | ED_val_phen_mindayson | grow_deg_days | gdd_threshold | nchilldays | cleafondate | |
---|---|---|---|---|---|---|---|---|
0 | sinkhole_phenology_LOn1 | 1.0 | 2.0 | 90.0 | 0.0 | 570.000000 | 0.0 | 99.0 |
1 | sinkhole_phenology_LOn1 | 2.0 | 2.0 | 90.0 | 0.0 | 563.651794 | 1.0 | 99.0 |
2 | sinkhole_phenology_LOn1 | 3.0 | 2.0 | 90.0 | 0.0 | 557.366754 | 2.0 | 99.0 |
3 | sinkhole_phenology_LOn1 | 4.0 | 2.0 | 90.0 | 0.0 | 557.366754 | 2.0 | 99.0 |
4 | sinkhole_phenology_LOn1 | 5.0 | 2.0 | 90.0 | 0.0 | 557.366754 | 2.0 | 99.0 |
dict_of_dataframes['sinkhole_phenology_LOn2'].head()
Name | Model_Day | cstatus | cleafondate | grow_deg_days | |
---|---|---|---|---|---|
0 | sinkhole_phenology_LOn2 | 1.0 | 2.0 | 99.0 | 0.0 |
1 | sinkhole_phenology_LOn2 | 2.0 | 2.0 | 99.0 | 0.0 |
2 | sinkhole_phenology_LOn2 | 3.0 | 2.0 | 99.0 | 0.0 |
3 | sinkhole_phenology_LOn2 | 4.0 | 2.0 | 99.0 | 0.0 |
4 | sinkhole_phenology_LOn2 | 5.0 | 2.0 | 99.0 | 0.0 |
dict_of_dataframes['sinkhole_phenology_LOff1'].head()
Name | Model_Day | cstatus | num_vegtemp_mem | ED_val_phen_ncolddayslim | ED_val_phen_mindayson | cndaysleafon | |
---|---|---|---|---|---|---|---|
0 | sinkhole_phenology_LOff1 | 1.0 | 2.0 | 10.0 | 5.0 | 90.0 | 267.0 |
1 | sinkhole_phenology_LOff1 | 2.0 | 2.0 | 10.0 | 5.0 | 90.0 | 268.0 |
2 | sinkhole_phenology_LOff1 | 3.0 | 2.0 | 10.0 | 5.0 | 90.0 | 269.0 |
3 | sinkhole_phenology_LOff1 | 4.0 | 2.0 | 10.0 | 5.0 | 90.0 | 270.0 |
4 | sinkhole_phenology_LOff1 | 5.0 | 2.0 | 10.0 | 5.0 | 90.0 | 271.0 |
dict_of_dataframes['sinkhole_phenology_LOff2'].head()
Name | Model_Day | cstatus | grow_deg_days | cndaysleafoff | |
---|---|---|---|---|---|
0 | sinkhole_phenology_LOff2 | 1.0 | 2.0 | 0.0 | 67.0 |
1 | sinkhole_phenology_LOff2 | 2.0 | 2.0 | 0.0 | 68.0 |
2 | sinkhole_phenology_LOff2 | 3.0 | 2.0 | 0.0 | 69.0 |
3 | sinkhole_phenology_LOff2 | 4.0 | 2.0 | 0.0 | 70.0 |
4 | sinkhole_phenology_LOff2 | 5.0 | 2.0 | 0.0 | 71.0 |
dict_of_dataframes['sinkhole_phenology_LOff_th'].head()
Name | Model_Day | cstatus | cndaysleafoff | cleafoffdate | |
---|---|---|---|---|---|
0 | sinkhole_phenology_LOff_th | 1.0 | 2.0 | 67.0 | 299.0 |
1 | sinkhole_phenology_LOff_th | 2.0 | 2.0 | 68.0 | 299.0 |
2 | sinkhole_phenology_LOff_th | 3.0 | 2.0 | 69.0 | 299.0 |
3 | sinkhole_phenology_LOff_th | 4.0 | 2.0 | 70.0 | 299.0 |
4 | sinkhole_phenology_LOff_th | 5.0 | 2.0 | 71.0 | 299.0 |
dict_of_dataframes['sinkhole_phenology_LOff_th2'].head()
Name | Model_Day | cstatus | grow_deg_days | cndaysleafoff | |
---|---|---|---|---|---|
0 | sinkhole_phenology_LOff_th2 | 1.0 | 2.0 | 0.0 | 67.0 |
1 | sinkhole_phenology_LOff_th2 | 2.0 | 2.0 | 0.0 | 68.0 |
2 | sinkhole_phenology_LOff_th2 | 3.0 | 2.0 | 0.0 | 69.0 |
3 | sinkhole_phenology_LOff_th2 | 4.0 | 2.0 | 0.0 | 70.0 |
4 | sinkhole_phenology_LOff_th2 | 5.0 | 2.0 | 0.0 | 71.0 |
# Plotting
df_key = "sinkhole_phenology"
df_key_col = "temp_in_C"
plt.figure(figsize=(25,6))
plt.plot(dict_of_dataframes[f"{df_key}"].index, dict_of_dataframes[f"{df_key}"][f"{df_key_col}"], marker='o', linestyle='-')
plt.xlabel('Index')
plt.ylabel(f'{df_key_col}')
plt.title(f'{df_key_col} vs. Index')
plt.grid(True)
for i in range(max_r_years):
plt.axvline(x = i*365, color = 'k',lw=5, alpha=.1)
if i%5==0:
plt.text(i*365,-10, int(i))
plt.show()
# Plotting
df_key = "sinkhole_phenology"
df_key_col = "temp_in_C"
for i in range(max_r_years):
plt.figure(figsize=(35,6))
if i>=1:
plt.plot(dict_of_dataframes[f"{df_key}"].index[i*365:(i+1)*365], dict_of_dataframes[f"{df_key}"][f"{df_key_col}"][i*365:(i+1)*365], marker='o', linestyle='-')
else:
plt.plot(dict_of_dataframes[f"{df_key}"].index[i*365:(i+1)*365], dict_of_dataframes[f"{df_key}"][f"{df_key_col}"][i*365:(i+1)*365], marker='o', linestyle='-')
zero_indices = dict_of_dataframes[df_key][(dict_of_dataframes[df_key][df_key_col] <= 0) & (dict_of_dataframes[df_key].index >= i * 365) & (dict_of_dataframes[df_key].index < (i + 1) * 365)].index
for idx in zero_indices:
plt.axvline(x=idx, color='red', linestyle='--')
plt.xlabel('Index')
plt.ylabel(f'{df_key_col}')
plt.title(f'{df_key_col} vs. Index for {i+1} Year')
plt.grid(True)
#for i in range(max_r_years):
# plt.axvline(x = i*365, color = 'k',lw=5, alpha=.1)
# if i%5==0:
# plt.text(i*365,-10, int(i))
#plt.show()
/var/folders/f1/01gxw8vn74q_x_rf_p5ztryjr405zq/T/ipykernel_96077/2109787684.py:6: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). plt.figure(figsize=(35,6))
import matplotlib.pyplot as plt
# Assuming ict_of_dataframes is a dictionary of dataframes
# Define the number of rows and columns for subplots
df_key = "sinkhole_phenology"
num_rows = len(dict_of_dataframes[f'{df_key}'].columns[1:]) # Number of rows for subplots
num_cols = 1 # Number of columns for subplots
# Create a figure and axes for subplots
fig, axes = plt.subplots(num_rows, num_cols, figsize=(25, 35))
# Iterate over dataframes and plot each one on a separate subplot
for idx, df_key_col in enumerate(dict_of_dataframes[f'{df_key}'].columns[1:]):
axes[idx].plot(dict_of_dataframes[f"{df_key}"].index, dict_of_dataframes[f"{df_key}"][f"{df_key_col}"], marker='o', linestyle='-', label=key)
axes[idx].set_ylabel(f'{df_key_col}')
axes[idx].set_title(f'{df_key_col} vs. Index')
axes[idx].grid(True)
#axes[row_idx].legend()
axes[idx].tick_params(axis='x', which='both', bottom=False, labelbottom=False)
for i in range(max_r_years):
axes[idx].axvline(x = i*365, color = 'k',lw=5, alpha=.1)
if (i%5==0) and (idx not in [2,3]):
axes[idx].text(i*365,-10, int(i))
axes[idx].set_xlabel('Index')
# Adjust layout
plt.tight_layout()
plt.subplots_adjust(hspace=0.1)
plt.show()
import matplotlib.pyplot as plt
# Assuming ict_of_dataframes is a dictionary of dataframes
# Define the number of rows and columns for subplots
df_key = "sinkhole_phenology_LOn1"
num_rows = len(dict_of_dataframes[f'{df_key}'].columns[1:]) # Number of rows for subplots
num_cols = 1 # Number of columns for subplots
# Create a figure and axes for subplots
fig, axes = plt.subplots(num_rows, num_cols, figsize=(25, 35))
# Iterate over dataframes and plot each one on a separate subplot
for idx, df_key_col in enumerate(dict_of_dataframes[f'{df_key}'].columns[1:]):
axes[idx].plot(dict_of_dataframes[f"{df_key}"].index, dict_of_dataframes[f"{df_key}"][f"{df_key_col}"], marker='o', linestyle='-', label=key)
axes[idx].set_ylabel(f'{df_key_col}')
axes[idx].set_title(f'{df_key_col} vs. Index')
axes[idx].grid(True)
#axes[row_idx].legend()
axes[idx].tick_params(axis='x', which='both', bottom=False, labelbottom=False)
for i in range(max_r_years):
axes[idx].axvline(x = i*365, color = 'k',lw=5, alpha=.1)
if (i%5==0) and (idx not in [2]):
axes[idx].text(i*365,0, int(i))
axes[idx].set_xlabel('Index')
# Adjust layout
plt.tight_layout()
plt.subplots_adjust(hspace=0.1)
plt.show()
import matplotlib.pyplot as plt
# Assuming ict_of_dataframes is a dictionary of dataframes
# Define the number of rows and columns for subplots
df_key = "sinkhole_phenology_LOn2"
num_rows = len(dict_of_dataframes[f'{df_key}'].columns[1:]) # Number of rows for subplots
num_cols = 1 # Number of columns for subplots
# Create a figure and axes for subplots
fig, axes = plt.subplots(num_rows, num_cols, figsize=(25, 20))
# Iterate over dataframes and plot each one on a separate subplot
for idx, df_key_col in enumerate(dict_of_dataframes[f'{df_key}'].columns[1:]):
axes[idx].plot(dict_of_dataframes[f"{df_key}"].index, dict_of_dataframes[f"{df_key}"][f"{df_key_col}"], marker='o', linestyle='-', label=key)
axes[idx].set_ylabel(f'{df_key_col}')
axes[idx].set_title(f'{df_key_col} vs. Index')
axes[idx].grid(True)
#axes[row_idx].legend()
axes[idx].tick_params(axis='x', which='both', bottom=False, labelbottom=False)
for i in range(max_r_years):
axes[idx].axvline(x = i*365, color = 'k',lw=5, alpha=.1)
if (i%5==0) and (idx not in []):
axes[idx].text(i*365,0, int(i))
axes[idx].set_xlabel('Index')
# Adjust layout
plt.tight_layout()
plt.subplots_adjust(hspace=0.1)
plt.show()
import matplotlib.pyplot as plt
# Assuming ict_of_dataframes is a dictionary of dataframes
# Define the number of rows and columns for subplots
df_key = "sinkhole_phenology_LOff1"
num_rows = len(dict_of_dataframes[f'{df_key}'].columns[1:]) # Number of rows for subplots
num_cols = 1 # Number of columns for subplots
# Create a figure and axes for subplots
fig, axes = plt.subplots(num_rows, num_cols, figsize=(25, 25))
# Iterate over dataframes and plot each one on a separate subplot
for idx, df_key_col in enumerate(dict_of_dataframes[f'{df_key}'].columns[1:]):
axes[idx].plot(dict_of_dataframes[f"{df_key}"].index, dict_of_dataframes[f"{df_key}"][f"{df_key_col}"], marker='o', linestyle='-', label=key)
axes[idx].set_ylabel(f'{df_key_col}')
axes[idx].set_title(f'{df_key_col} vs. Index')
axes[idx].grid(True)
#axes[row_idx].legend()
axes[idx].tick_params(axis='x', which='both', bottom=False, labelbottom=False)
for i in range(max_r_years):
axes[idx].axvline(x = i*365, color = 'k',lw=5, alpha=.1)
if (i%5==0) and (idx not in [2,3,4]):
axes[idx].text(i*365,0, int(i))
axes[idx].set_xlabel('Index')
# Adjust layout
plt.tight_layout()
plt.subplots_adjust(hspace=0.1)
plt.show()
import matplotlib.pyplot as plt
# Assuming ict_of_dataframes is a dictionary of dataframes
# Define the number of rows and columns for subplots
df_key = "sinkhole_phenology_LOff2"
num_rows = len(dict_of_dataframes[f'{df_key}'].columns[1:]) # Number of rows for subplots
num_cols = 1 # Number of columns for subplots
# Create a figure and axes for subplots
fig, axes = plt.subplots(num_rows, num_cols, figsize=(25, 20))
# Iterate over dataframes and plot each one on a separate subplot
for idx, df_key_col in enumerate(dict_of_dataframes[f'{df_key}'].columns[1:]):
axes[idx].plot(dict_of_dataframes[f"{df_key}"].index, dict_of_dataframes[f"{df_key}"][f"{df_key_col}"], marker='o', linestyle='-', label=key)
axes[idx].set_ylabel(f'{df_key_col}')
axes[idx].set_title(f'{df_key_col} vs. Index')
axes[idx].grid(True)
#axes[row_idx].legend()
axes[idx].tick_params(axis='x', which='both', bottom=False, labelbottom=False)
for i in range(max_r_years):
axes[idx].axvline(x = i*365, color = 'k',lw=5, alpha=.1)
if (i%5==0) and (idx not in []):
axes[idx].text(i*365,0, int(i))
axes[idx].set_xlabel('Index')
# Adjust layout
plt.tight_layout()
plt.subplots_adjust(hspace=0.1)
plt.show()
import matplotlib.pyplot as plt
# Assuming ict_of_dataframes is a dictionary of dataframes
# Define the number of rows and columns for subplots
df_key = "sinkhole_phenology_LOff_th"
num_rows = len(dict_of_dataframes[f'{df_key}'].columns[1:]) # Number of rows for subplots
num_cols = 1 # Number of columns for subplots
# Create a figure and axes for subplots
fig, axes = plt.subplots(num_rows, num_cols, figsize=(25, 20))
# Iterate over dataframes and plot each one on a separate subplot
for idx, df_key_col in enumerate(dict_of_dataframes[f'{df_key}'].columns[1:]):
axes[idx].plot(dict_of_dataframes[f"{df_key}"].index, dict_of_dataframes[f"{df_key}"][f"{df_key_col}"], marker='o', linestyle='-', label=key)
axes[idx].set_ylabel(f'{df_key_col}')
axes[idx].set_title(f'{df_key_col} vs. Index')
axes[idx].grid(True)
#axes[row_idx].legend()
axes[idx].tick_params(axis='x', which='both', bottom=False, labelbottom=False)
for i in range(max_r_years):
axes[idx].axvline(x = i*365, color = 'k',lw=5, alpha=.1)
if (i%5==0) and (idx not in []):
axes[idx].text(i*365,0, int(i))
axes[idx].set_xlabel('Index')
# Adjust layout
plt.tight_layout()
plt.subplots_adjust(hspace=0.1)
plt.show()
# when did the status change?
dict_of_dataframes[f"{df_key}"]["cstatus"][dict_of_dataframes[f"{df_key}"]["cstatus"]==0].head()
Series([], Name: cstatus, dtype: float64)
import matplotlib.pyplot as plt
# Assuming ict_of_dataframes is a dictionary of dataframes
# Define the number of rows and columns for subplots
df_key = "sinkhole_phenology_LOff_th2"
num_rows = len(dict_of_dataframes[f'{df_key}'].columns[1:]) # Number of rows for subplots
num_cols = 1 # Number of columns for subplots
# Create a figure and axes for subplots
fig, axes = plt.subplots(num_rows, num_cols, figsize=(25, 20))
# Iterate over dataframes and plot each one on a separate subplot
for idx, df_key_col in enumerate(dict_of_dataframes[f'{df_key}'].columns[1:]):
axes[idx].plot(dict_of_dataframes[f"{df_key}"].index, dict_of_dataframes[f"{df_key}"][f"{df_key_col}"], marker='o', linestyle='-', label=key)
axes[idx].set_ylabel(f'{df_key_col}')
axes[idx].set_title(f'{df_key_col} vs. Index')
axes[idx].grid(True)
#axes[row_idx].legend()
axes[idx].tick_params(axis='x', which='both', bottom=False, labelbottom=False)
for i in range(max_r_years):
axes[idx].axvline(x = i*365, color = 'k',lw=5, alpha=.1)
if (i%5==0) and (idx not in []):
axes[idx].text(i*365,0, int(i))
axes[idx].set_xlabel('Index')
# Adjust layout
plt.tight_layout()
plt.subplots_adjust(hspace=0.1)
plt.show()
What happend a day before that led to state change?
index = 7293
print(f"index:{index}")
print(f"cstatus: {dict_of_dataframes[f'sinkhole_phenology_LOff_th']['cstatus'][index]}")
print ("That means the state is 'phen_cstat_notcold' state and leaves are allowed to flush")
print(f"grow_deg_days: {dict_of_dataframes[f'sinkhole_phenology_LOn1']['grow_deg_days'][index]}")
print(f"gdd_threshold: {round(dict_of_dataframes[f'sinkhole_phenology_LOn1']['gdd_threshold'][index],3)}")
print(f"cleafondate: {dict_of_dataframes[f'sinkhole_phenology_LOn1']['cleafondate'][index]}")
print(f"nchilldays: {dict_of_dataframes[f'sinkhole_phenology_LOn1']['nchilldays'][index]}")
print(f"cndaysleafon: {dict_of_dataframes[f'sinkhole_phenology_LOff1']['cndaysleafon'][index]}")
print(f"temp_in_C: {round(dict_of_dataframes[f'sinkhole_phenology']['temp_in_C'][index],3)}")
print(f"ncdstart: {round(dict_of_dataframes[f'sinkhole_phenology']['ncdstart'][index],3)}")
print (f"Nov 1 after 19 years {365*19+270}")
print(f"gddstart: {round(dict_of_dataframes[f'sinkhole_phenology']['gddstart'][index],3)}")
print (f"Jan 1 after 19 years {365*19+1}")
print (f"Jan 1 after 20 years {365*20+1}")
print(f"ncolddays: {round(dict_of_dataframes[f'sinkhole_phenology']['ncolddays'][index],3)}")
print(f"cleafoffdate: {round(dict_of_dataframes[f'sinkhole_phenology']['cleafoffdate'][index],3)}")
print(f"cndaysleafoff: {round(dict_of_dataframes[f'sinkhole_phenology']['cndaysleafoff'][index],3)}")
print(f"cleafondate: {round(dict_of_dataframes[f'sinkhole_phenology']['cleafondate'][index],3)}")
print(f"cndaysleafon: {round(dict_of_dataframes[f'sinkhole_phenology']['cndaysleafon'][index],3)}")
index:7293 cstatus: 1.0 That means the state is 'phen_cstat_notcold' state and leaves are allowed to flush grow_deg_days: 0.0 gdd_threshold: 509.286 cleafondate: 7005.0 nchilldays: 10.0 cndaysleafon: 289.0 temp_in_C: 3.063 ncdstart: 270.0 Nov 1 after 19 years 7205 gddstart: 1.0 Jan 1 after 19 years 6936 Jan 1 after 20 years 7301 ncolddays: 6.0 cleafoffdate: 6890.0 cndaysleafoff: 404.0 cleafondate: 7005.0 cndaysleafon: 289.0
index = 7294
print(f"index:{index}")
print(f"cstatus: {dict_of_dataframes[f'sinkhole_phenology_LOff_th']['cstatus'][index]}")
print ("That means the state is 'phen_cstat_notcold' state and leaves are allowed to flush")
print(f"grow_deg_days: {dict_of_dataframes[f'sinkhole_phenology_LOn1']['grow_deg_days'][index]}")
print(f"gdd_threshold: {round(dict_of_dataframes[f'sinkhole_phenology_LOn1']['gdd_threshold'][index],3)}")
print(f"cleafondate: {dict_of_dataframes[f'sinkhole_phenology_LOn1']['cleafondate'][index]}")
print(f"nchilldays: {dict_of_dataframes[f'sinkhole_phenology_LOn1']['nchilldays'][index]}")
print(f"cndaysleafon: {dict_of_dataframes[f'sinkhole_phenology_LOff1']['cndaysleafon'][index]}")
print(f"temp_in_C: {round(dict_of_dataframes[f'sinkhole_phenology']['temp_in_C'][index],3)}")
print(f"ncdstart: {round(dict_of_dataframes[f'sinkhole_phenology']['ncdstart'][index],3)}")
print (f"Nov 1 after 19 years {365*19+270}")
print(f"gddstart: {round(dict_of_dataframes[f'sinkhole_phenology']['gddstart'][index],3)}")
print (f"Jan 1 after 19 years {365*19+1}")
print (f"Jan 1 after 20 years {365*20+1}")
print(f"ncolddays: {round(dict_of_dataframes[f'sinkhole_phenology']['ncolddays'][index],3)}")
print(f"cleafoffdate: {round(dict_of_dataframes[f'sinkhole_phenology']['cleafoffdate'][index],3)}")
print(f"cndaysleafoff: {round(dict_of_dataframes[f'sinkhole_phenology']['cndaysleafoff'][index],3)}")
print(f"cleafondate: {round(dict_of_dataframes[f'sinkhole_phenology']['cleafondate'][index],3)}")
print(f"cndaysleafon: {round(dict_of_dataframes[f'sinkhole_phenology']['cndaysleafon'][index],3)}")
index:7294 cstatus: 1.0 That means the state is 'phen_cstat_notcold' state and leaves are allowed to flush grow_deg_days: 0.0 gdd_threshold: 503.542 cleafondate: 7005.0 nchilldays: 11.0 cndaysleafon: 290.0 temp_in_C: -1.408 ncdstart: 270.0 Nov 1 after 19 years 7205 gddstart: 1.0 Jan 1 after 19 years 6936 Jan 1 after 20 years 7301 ncolddays: 7.0 cleafoffdate: 7294.0 cndaysleafoff: 1.0 cleafondate: 7005.0 cndaysleafon: 290.0