gfdlvitals.extensions module
Pandas class extension for gfdlvitals
- class gfdlvitals.extensions.Timeseries(f, var, scale=1.0, multiply_by_area=False, legacy_land=False, start=None, end=None)
Bases:
objectTimeseries class object
- Parameters:
f (str, path-like) – Input SQLite file
var (str) – Variable to extract
scale (float, optional) – Scale data by this factor, by default 1.0
multiply_by_area (bool, optional) – Multiply variable by cell area before returning, by default False
legacy_land (bool, optional) – Read legacy version of the land SQLite files, by default False
start (int, optional) – Specify start year, by default None
end (int, optional) – Specify end year, by default None
- property data
- property t
- class gfdlvitals.extensions.VitalsDataFrame(data=None, index: Axes | None = None, columns: Axes | None = None, dtype: Dtype | None = None, copy: bool | None = None)
Bases:
DataFramePandas class extension for holding the Vitals data
- Parameters:
pd (pandas.DataFrame) – Input Pandas DataFrame object
- Returns:
Class extension object
- Return type:
- areasum()
Returns the area integrated variable based on the cell_measure method
- build_netrad_toa()
Constructs netrad_toa from component terms if available
- Parameters:
self (VitalsDataFrame)
- Return type:
- detrend(reference=None, order=1, anomaly=True, return_coefs=False)
Detrend VitalsDataFrame object
- Parameters:
reference (gfdlvitals.DataFrame, optional) – Reference VitalsDataFrame, by default None
order (int, optional) – Polynomial order to use for fitting, by default 1
anomaly (bool, optional) – Results as anomalies from the fit, by default True
return_coefs (bool, optional) – Return polynomial fit coeffiecients, by default False
- Returns:
Extended dataset
- Return type:
self
- extend(maxlen)
Extend VitalsDataFrame to a set length and pad with NaNs
- Parameters:
maxlen (int) – New length of the VitalsDataFrame
- Returns:
Extended dataset
- Return type:
self
- smooth(window, extrap=False)
Apply a smoother to the dataset
- Parameters:
window (int) – Smoothing filter length
extrap (bool, optional) – Extrapolate data on the ends, by default False
- Returns:
Smoothed dataset
- Return type:
self
- trend(order=1)
Fits a trend to the VitalsDataFrame object
- Parameters:
order (int, optional) – Polynomial order to use for fitting, by default 1
- Returns:
Fitted trend dataset
- Return type:
self
- ttest(df2)
Performs t-test between two instances of VitalsDataFrame
- Parameters:
df2 (VitalsDataFrame) – Comparison data set
- Returns:
Contains p-values for variables common between the two VitalsDataFrames
- Return type:
pandas.DataFrame
- gfdlvitals.extensions.open_db(dbfile, variables=None, yearshift=0.0, legacy_land=False, start=None, end=None)
Function to read sqlite dbfile
- gfdlvitals.extensions.reformat_time_axis(ax=None)
Reformats x-axis labels to YYYY format
- Parameters:
ax (matplotlob.pyplot.figure.axis, optional) – axis object to be reformatted, by default None
- gfdlvitals.extensions.ttest_ind_auto(arr1, arr2, axis=0)
Performs a t-test that adjusts the degrees of freedom based on the autocorrelation of the dataset. See Krasting et al. 2013 for more details DOI: 10.1175/JCLI-D-12-00832.1
- Parameters:
arr1 (numpy.ndarray) – First array of data points
arr2 (numpy.ndarray) – Second array of data points
axis (int, optional) – Axis to perform t-test, by default 0
- Returns:
t-statistic, probability, arr1 autocorrelation, arr2 autocorrelation
- Return type:
tuple