From a58623fcfe31277726ce9658d0e554d8573f02cf Mon Sep 17 00:00:00 2001 From: Alexander James Date: Tue, 4 Jun 2024 11:48:53 -0700 Subject: [PATCH] Mcpca doc (#570) * ensemblegeoseries docstring fix * ensmultivardecomp doc string fix * mgs docstrings * ms docstrings * mvd docstrings * doc fixes --- pyleoclim/core/ensemblegeoseries.py | 6 +-- pyleoclim/core/ensmultivardecomp.py | 64 ++++++++++------------------- pyleoclim/core/multiplegeoseries.py | 3 +- pyleoclim/core/multipleseries.py | 3 -- pyleoclim/core/multivardecomp.py | 10 ++--- pyleoclim/core/series.py | 4 +- 6 files changed, 31 insertions(+), 59 deletions(-) diff --git a/pyleoclim/core/ensemblegeoseries.py b/pyleoclim/core/ensemblegeoseries.py index a229a89a..ac8be2ae 100644 --- a/pyleoclim/core/ensemblegeoseries.py +++ b/pyleoclim/core/ensemblegeoseries.py @@ -281,11 +281,9 @@ def make_labels(self): Returns ------- time_header : str - Label for the time axis value_header : str - Label for the value axis ''' @@ -318,7 +316,7 @@ def dashboard(self, figsize=[11, 8], gs=None, plt_kwargs=None, histplt_kwargs=No hue='archiveType', marker='archiveType', size=None, scatter_kwargs=None, gridspec_kwargs=None, savefig_settings=None): - ''' + '''Dashboard that plots the trace, histogram, map, and power spectrum of the ensemble. Parameters ---------- @@ -393,7 +391,7 @@ def dashboard(self, figsize=[11, 8], gs=None, plt_kwargs=None, histplt_kwargs=No See also -------- - + pyleoclim.core.series.Series.plot : plot a timeseries pyleoclim.core.ensembleseries.EnsembleSeries.plot_envelope: Envelope plots for an ensemble diff --git a/pyleoclim/core/ensmultivardecomp.py b/pyleoclim/core/ensmultivardecomp.py index ed1aec21..b34e69f0 100644 --- a/pyleoclim/core/ensmultivardecomp.py +++ b/pyleoclim/core/ensmultivardecomp.py @@ -131,27 +131,17 @@ def modeplot(self,index=0,flip=False,plot_envelope_kwargs = None, psd_envelope_k .. jupyter-execute:: - n = 3 # number of ensembles - nn = 30 # number of noise realizations - nt = 500 - ens_list = [] - - t,v = pyleo.utils.gen_ts(model='colored_noise',nt=nt,alpha=1.0) - signal = pyleo.Series(t,v) - - for _ in range(n): - series_list = [] - lat = np.random.randint(-90,90) - lon = np.random.randint(-180,180) - for idx in range(nn): # noise - noise = np.random.randn(nt,nn)*100 - ts = pyleo.GeoSeries(time=signal.time, value=signal.value+noise[:,idx], lat=lat, lon=lon, verbose=False) - series_list.append(ts) - - ts_ens = pyleo.EnsembleSeries(series_list) - ens_list.append(ts_ens) - - mul_ens = pyleo.MulEnsGeoSeries([ts_ens]) + n = 100 # number of series + + soi = pyleo.utils.load_dataset('SOI') + soi_time_axes = [pyleo.utils.random_time_axis(n=len(soi.time)) for _ in range(n)] + soi_ens = pyleo.EnsembleGeoSeries([pyleo.GeoSeries(time=time, value=soi.value,lat=-5,lon=-85,auto_time_params=True) for time in soi_time_axes]) + + nino3 = pyleo.utils.load_dataset('NINO3') + nino3_time_axes = [pyleo.utils.random_time_axis(n=len(nino3.time)) for _ in range(n)] + nino3_ens = pyleo.EnsembleGeoSeries([pyleo.GeoSeries(time=time, value=nino3.value,lat=-5,lon=-85,auto_time_params=True) for time in nino3_time_axes]) + + mul_ens = pyleo.MulEnsGeoSeries([nino3_ens,soi_ens]) mcpca = mul_ens.mcpca(nsim=10,seed=42) mcpca.modeplot()''' @@ -328,27 +318,17 @@ def screeplot(self,clr_eig='C0', linewidth=.3, title='Screeplot', violin_kwargs .. jupyter-execute:: - n = 3 # number of ensembles - nn = 30 # number of noise realizations - nt = 500 - ens_list = [] - - t,v = pyleo.utils.gen_ts(model='colored_noise',nt=nt,alpha=1.0) - signal = pyleo.Series(t,v) - - for _ in range(n): - series_list = [] - lat = np.random.randint(-90,90) - lon = np.random.randint(-180,180) - for idx in range(nn): # noise - noise = np.random.randn(nt,nn)*100 - ts = pyleo.GeoSeries(time=signal.time, value=signal.value+noise[:,idx], lat=lat, lon=lon, verbose=False) - series_list.append(ts) - - ts_ens = pyleo.EnsembleSeries(series_list) - ens_list.append(ts_ens) - - mul_ens = pyleo.MulEnsGeoSeries([ts_ens]) + n = 100 # number of series + + soi = pyleo.utils.load_dataset('SOI') + soi_time_axes = [pyleo.utils.random_time_axis(n=len(soi.time)) for _ in range(n)] + soi_ens = pyleo.EnsembleGeoSeries([pyleo.GeoSeries(time=time, value=soi.value,lat=0,lon=0,auto_time_params=True) for time in soi_time_axes]) + + nino3 = pyleo.utils.load_dataset('NINO3') + nino3_time_axes = [pyleo.utils.random_time_axis(n=len(nino3.time)) for _ in range(n)] + nino3_ens = pyleo.EnsembleGeoSeries([pyleo.GeoSeries(time=time, value=nino3.value,lat=0,lon=0,auto_time_params=True) for time in nino3_time_axes]) + + mul_ens = pyleo.MulEnsGeoSeries([nino3_ens,soi_ens]) mcpca = mul_ens.mcpca(nsim=10,seed=42) mcpca.screeplot()''' diff --git a/pyleoclim/core/multiplegeoseries.py b/pyleoclim/core/multiplegeoseries.py index aaf1af81..b7461a42 100644 --- a/pyleoclim/core/multiplegeoseries.py +++ b/pyleoclim/core/multiplegeoseries.py @@ -82,7 +82,6 @@ def __init__(self, series_list, time_unit=None, label=None): super().__init__(series_list, time_unit, label) - # ============ MAP goes here ================ def map(self, marker='archiveType', hue='archiveType', size=None, cmap=None, edgecolor='k', projection='auto', @@ -90,7 +89,7 @@ def map(self, marker='archiveType', hue='archiveType', size=None, cmap=None, background=True, borders=False, coastline=True,rivers=False, lakes=False, land=True,ocean=True, figsize=None, fig=None, scatter_kwargs=None, gridspec_kwargs=None, legend=True, gridspec_slot=None, lgd_kwargs=None, savefig_settings=None, **kwargs): - ''' + '''Mapping of the collection of GeoSeries objects. Parameters diff --git a/pyleoclim/core/multipleseries.py b/pyleoclim/core/multipleseries.py index 357b5824..2cfab127 100644 --- a/pyleoclim/core/multipleseries.py +++ b/pyleoclim/core/multipleseries.py @@ -1932,7 +1932,6 @@ def stripes(self, cmap = 'RdBu_r', sat=1.0, ref_period=None, figsize : list a list of two integers indicating the figure size (in inches) - sat : float > 0 Controls the saturation of the colormap normalization by scaling the vmin, vmax in https://matplotlib.org/stable/tutorials/colors/colormapnorms.html default = 1.0 @@ -1941,7 +1940,6 @@ def stripes(self, cmap = 'RdBu_r', sat=1.0, ref_period=None, flag indicating whether or not the x-axis should be shown (default = False) savefig_settings : dictionary - the dictionary of arguments for plt.savefig(); some notes below: - 'path' must be specified; it can be any existing or non-existing path, @@ -1949,7 +1947,6 @@ def stripes(self, cmap = 'RdBu_r', sat=1.0, ref_period=None, - 'format' can be one of {"pdf", 'eps', 'png', ps'} The default is None. time_unit : str - the target time unit, possible inputs: { 'year', 'years', 'yr', 'yrs', diff --git a/pyleoclim/core/multivardecomp.py b/pyleoclim/core/multivardecomp.py index 47e255d8..861b45b3 100644 --- a/pyleoclim/core/multivardecomp.py +++ b/pyleoclim/core/multivardecomp.py @@ -186,12 +186,10 @@ def modeplot(self, index=0, figsize=[8, 8], fig=None, savefig_settings=None,gs=N hue='EOF', marker=None, size=None, scatter_kwargs=None, flip = False, map_kwargs=None, gridspec_kwargs=None): - ''' Dashboard visualizing the properties of a given mode, including: - 1. The temporal coefficient (PC or similar) - 2. its spectrum - 3. The loadings (EOF or similar), possibly geolocated. If the object - does not have geolocation information, a spaghetti plot of the standardized - series is displayed. + '''Dashboard visualizing the properties of a given mode. + + Includes: The temporal coefficient (PC or similar), its spectrum, and the loadings (EOF or similar), possibly geolocated. + If the object does not have geolocation information, a spaghetti plot of the standardized series is displayed. Parameters ---------- diff --git a/pyleoclim/core/series.py b/pyleoclim/core/series.py index 71b1da7f..b206a24f 100644 --- a/pyleoclim/core/series.py +++ b/pyleoclim/core/series.py @@ -457,7 +457,7 @@ def to_csv(self, metadata_header=True, path = None): ------- None - See Also + See also -------- pyleoclim.Series.from_csv @@ -513,7 +513,7 @@ def from_csv(cls, path): Series pyleoclim Series object containing data and metadata. - See Also + See also -------- pyleoclim.Series.to_csv