Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fzhu2e committed Apr 22, 2023
1 parent c2a06a6 commit e5a56a5
Show file tree
Hide file tree
Showing 26 changed files with 425 additions and 587 deletions.
19 changes: 17 additions & 2 deletions cfr/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import copy
from tqdm import tqdm
from collections import OrderedDict
from datetime import datetime
import matplotlib.pyplot as plt
from matplotlib import gridspec
import cartopy.crs as ccrs
Expand Down Expand Up @@ -146,6 +147,11 @@ class ProxyRecord:
def __init__(self, pid=None, time=None, value=None, lat=None, lon=None, elev=None, ptype=None, tags=None,
value_name=None, value_unit=None, time_name=None, time_unit=None, seasonality=None):
self.pid = pid
if time is not None:
if len(time) == 1:
time = [time]
if not utils.is_numeric(time):
time = utils.datetime2year_float(time)
self.time = time
self.value = value
self.lat = lat
Expand Down Expand Up @@ -463,16 +469,25 @@ def get_pseudo(self, psm=None, signal=None, calibrate=True,
time_max = np.min([proxy_time_max, pseudo_time_max])
mask_proxy = (self.time>=time_min)&(self.time<=time_max)
mask_pseudo = (self.pseudo.time>=time_min)&(self.pseudo.time<=time_max)
if verbose:
utils.p_header(f'>>> timespan: ({time_min}, {time_max})')


value = self.pseudo.value

if match_var:
value = value / np.nanstd(value[mask_pseudo]) * np.nanstd(self.value[mask_proxy])
if verbose: utils.p_success(f'>>> Variance matched.')
if verbose:
utils.p_header(f'>>> Var(proxy)={np.nanvar(self.value[mask_proxy])}')
utils.p_header(f'>>> Var(pseudoproxy)={np.nanvar(value[mask_pseudo])}')
utils.p_success(f'>>> Variance matched.')

if match_mean:
value = value - np.nanmean(value[mask_pseudo]) + np.nanmean(self.value[mask_proxy])
if verbose: utils.p_success(f'>>> Mean matched.')
if verbose:
utils.p_header(f'>>> Mean(proxy)={np.nanmean(self.value[mask_proxy])}')
utils.p_header(f'>>> Mean(pseudoproxy)={np.nanmean(value[mask_pseudo])}')
utils.p_success(f'>>> Mean matched.')

self.pseudo.value = value

Expand Down
1 change: 1 addition & 0 deletions cfr/psm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from turtle import color
import numpy as np
import pandas as pd
from datetime import datetime
from scipy import integrate, signal, stats
from tqdm import tqdm
from multiprocessing import cpu_count
Expand Down
6 changes: 5 additions & 1 deletion cfr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,4 +648,8 @@ def colored_noise_2regimes(alpha1, alpha2, f_break, t, f0=None, m=None, seed=Non
sin_func = np.sin(2*np.pi*k*f0*t[j] + theta)
y[j] = np.sum(coeff*sin_func)

return y
return y

def is_numeric(obj):
attrs = ['__add__', '__sub__', '__mul__', '__truediv__', '__pow__']
return all(hasattr(obj, attr) for attr in attrs)
Binary file modified docs/_images/notebooks_pp2k-dashboards_11_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/notebooks_pp2k-dashboards_13_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/notebooks_pp2k-dashboards_15_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/notebooks_pp2k-dashboards_5_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/notebooks_pp2k-dashboards_7_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/notebooks_pp2k-dashboards_9_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/notebooks_pp2k-ppe-pda_34_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/notebooks_pp2k-ppe-pda_38_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/notebooks_pp2k-ppe-pda_40_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions docs/_sources/notebooks/pp2k-dashboards.ipynb

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions docs/_sources/notebooks/pp2k-pdb-load-viz.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1231,16 +1231,12 @@
"One may ask \"How do I know the proxy IDs?\"\n",
"\n",
"A `cfr.ProxyDatabase` object also comes with a `.plotly()` method that can help us check **proxy IDs** on an interactive map.\n",
"\n",
"The below cell cannot be rendered on a webpage, but should execute in a local Jupyter notebook.\n",
"It should display an interactive map, and by hovering the mouse over each site marker, one may check the metadata of a specific site, including:\n",
"It will display an interactive map, and by hovering the mouse over each site marker, one may check the metadata of a specific site, including:\n",
"\n",
"- pid (proxy ID)\n",
"- ptype\n",
"- lat\n",
"- lon\n",
"\n",
"Take a try by yourself!"
"- lon"
]
},
{
Expand Down
Loading

0 comments on commit e5a56a5

Please sign in to comment.