API¶
ReconJob¶
- class LMRt.reconjob.ReconJob(configs=None, proxydb=None, prior=None, obs=None)¶
Reconstruction Job
- General rule of loading parameters: load from the YAML first if available, then update with the parameters in the function calling,
so the latter has a higher priority
- crop_prior(domain_range=None, verbose=False)¶
Take a smaller domain for reconstruction
- domain_rangelist
[lat_min, lat_max, lon_min, lon_max]
- gen_Xb(recon_vars=None, verbose=False)¶
Generate Xb
- gen_Ye(proxy_frac=None, nens=None, verbose=False, seed=0)¶
Generate Ye
- load_configs(cfg_path=None, job_dirpath=None, verbose=False)¶
Load the configuration YAML file
self.configs will be updated
- cfg_pathstr
the path of a configuration YAML file
- load_obs(path_dict=None, varname_dict=None, verbose=False, anom_period=None)¶
Load instrumental observations fields
- path_dict: dict
a dict of environmental variables
- varname_dict: dict
a dict to map variable names, e.g. {‘tas’: ‘sst’} means ‘tas’ is named ‘sst’ in the input NetCDF file
- load_prior(path_dict=None, varname_dict=None, verbose=False, anom_period=None)¶
Load model prior fields
- path_dict: dict
a dict of environmental variables
- varname_dict: dict
a dict to map variable names, e.g. {‘tas’: ‘sst’} means ‘tas’ is named ‘sst’ in the input NetCDF file
- load_proxydb(path=None, verbose=False, load_df_kws=None)¶
Load the proxy database
self.proxydb will be updated
- proxydb_pathstr
if given, should point to a pickle file with a Pandas DataFrame underlying
ReconRes¶
ReconSeries¶
- class LMRt.reconres.ReconSeries(series_list)¶
- plot(lgd_kws=None, **kws)¶
Plot multiple timeseries on the same axis
- figsizelist, optional
Size of the figure. The default is [10, 4].
- markerstr, optional
marker type. The default is None.
- markersizefloat, optional
marker size. The default is None.
- colorsa list of, or one, Python supported color code (a string of hex code or a tuple of rgba values)
Colors for plotting. If None, the plotting will cycle the ‘tab10’ colormap; if only one color is specified, then all curves will be plotted with that single color; if a list of colors are specified, then the plotting will cycle that color list.
- cmapstr
The colormap to use when “colors” is None.
- normmatplotlib.colors.Normalize like
The nomorlization for the colormap. If None, a linear normalization will be used.
- linestylestr, optional
Line style. The default is None.
- linewidthfloat, optional
The width of the line. The default is None.
- xlabelstr, optional
x-axis label. The default is None.
- ylabelstr, optional
y-axis label. The default is None.
- titlestr, optional
Title. The default is None.
- legendbool, optional
Wether the show the legend. The default is True.
- plot_kwargsdict, optional
Plot parameters. The default is None.
- lgd_kwargsdict, optional
Legend parameters. The default is None.
- savefig_settingsdictionary, optional
the dictionary of arguments for plt.savefig(); some notes below: - “path” must be specified; it can be any existed or non-existed path,
with or without a suffix; if the suffix is not given in “path”, it will follow “format”
“format” can be one of {“pdf”, “eps”, “png”, “ps”} The default is None.
- axmatplotlib.ax, optional
The matplotlib axis onto which to return the figure. The default is None.
- mutebool, optional
if True, the plot will not show; recommend to turn on when more modifications are going to be made on ax
- invert_xaxisbool, optional
if True, the x-axis of the plot will be inverted
fig, ax
ReconField¶
ProxyRecord¶
- class LMRt.proxy.ProxyRecord(pid, lat, lon, time, value, ptype, psm_name=None, psm=None, time_name='Time', value_name=None, time_unit='yr', value_unit=None, label=None, prior_value=None, prior_time=None, obs_value=None, obs_time=None, seasonality=None, ye_time=None, ye_value=None)¶
- copy()¶
Make a copy of the Series object
- Series
A copy of the Series object
- forward_psm()¶
Forward modeling: calculate ye using the PSM according to self.psm
- plot(plot_Ye=True, **kws)¶
Plot the timeseries
- figsizelist
a list of two integers indicating the figure size
- markerstr
e.g., ‘o’ for dots See [matplotlib.markers](https://matplotlib.org/3.1.3/api/markers_api.html) for details
- markersizefloat
the size of the marker
- colorstr, list
the color for the line plot e.g., ‘r’ for red See [matplotlib colors] (https://matplotlib.org/3.2.1/tutorials/colors/colors.html) for details
- linestylestr
e.g., ‘–’ for dashed line See [matplotlib.linestyles](https://matplotlib.org/3.1.0/gallery/lines_bars_and_markers/linestyles.html) for details
- linewidthfloat
the width of the line
- labelstr
the label for the line
- xlabelstr
the label for the x-axis
- ylabelstr
the label for the y-axis
- titlestr
the title for the figure
- zorderint
The default drawing order for all lines on the plot
- legend{True, False}
plot legend or not
- invert_xaxisbool, optional
if True, the x-axis of the plot will be inverted
- plot_kwargsdict
the dictionary of keyword arguments for ax.plot() See [matplotlib.pyplot.plot](https://matplotlib.org/3.1.3/api/_as_gen/matplotlib.pyplot.plot.html) for details
- lgd_kwargsdict
the dictionary of keyword arguments for ax.legend() See [matplotlib.pyplot.legend](https://matplotlib.org/3.1.3/api/_as_gen/matplotlib.pyplot.legend.html) for details
- alphafloat
Transparency setting
- savefig_settingsdict
the dictionary of arguments for plt.savefig(); some notes below: - “path” must be specified; it can be any existed or non-existed path,
with or without a suffix; if the suffix is not given in “path”, it will follow “format”
“format” can be one of {“pdf”, “eps”, “png”, “ps”}
- axmatplotlib.axis, optional
the axis object from matplotlib See [matplotlib.axes](https://matplotlib.org/api/axes_api.html) for details.
- mute{True,False}
if True, the plot will not show; recommend to turn on when more modifications are going to be made on ax
- figmatplotlib.figure
the figure object from matplotlib See [matplotlib.pyplot.figure](https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.figure.html) for details.
- axmatplotlib.axis
the axis object from matplotlib See [matplotlib.axes](https://matplotlib.org/api/axes_api.html) for details.
When ax is passed, the return will be ax only; otherwise, both fig and ax will be returned.
pyleoclim.utils.plotting.savefig : saving figure in Pyleoclim
Plot the SOI record
Change the line color
- Save the figure. Two options available:
Within the plotting command
After the figure has been generated
- seasonalize(season=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], make_year_mm_nan=False, inplace=False)¶
Seasonalize the proxy record
ProxyDatabase¶
- class LMRt.proxy.ProxyDatabase(records=None, source=None)¶
- add(records, inplace=False, verbose=False)¶
Add a list of records into the database
- filter_dt(dt=1, inplace=False)¶
Filter the proxy database according to temporal resolution
- filter_pids(pids, inplace=False)¶
Filter the proxy database according to given pids
- filter_ptype(ptype_list, inplace=False)¶
Filter the proxy database according to given ptype list
- ptype_listlist
a list of ptype’s
- get_var_from_ds(seasonalized_ds, ptype_season, ds_type=None, verbose=False)¶
Get environmental variables from prior
- load_df(df, pid_column='paleoData_pages2kID', lat_column='geo_meanLat', lon_column='geo_meanLon', time_column='year', value_column='paleoData_values', proxy_type_column='paleoData_proxy', archive_type_column='archiveType', value_name_column='paleoData_variableName', value_unit_column='paleoData_units', ptype_season=None, ptype_psm=None, verbose=False)¶
Load database from a Pandas DataFrame
- dfPandas DataFrame
a Pandas DataFrame include at least lat, lon, time, value, proxy_type
- ptype_psmdict
a mapping from ptype to psm
- remove(pids, inplace=False, verbose=False)¶
Remove a list of records from the database regardless existing or not
- seasonalize(ptype_season, inplace=False)¶
Filter the proxy database according to given ptype list
- ptype_seasondict
a dict of seasonality for each proxy type
Field¶
- class LMRt.gridded.Field(name, time, lat, lon, value, source=None)¶
- crop(domain_range, inplace=False)¶
Crop the domain for reconstruction
- domain_rangelist
[lat_min, lat_max, lon_min, lon_max] for a square domain or [lat_min, lat_max] to crop the lats only
- seasonalize(season=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], make_year_mm_nan=True, inplace=False)¶
Seasonalize the field
Dataset¶
- class LMRt.gridded.Dataset(fields=None)¶
- crop(domain_range, inplace=False)¶
Crop the domain for reconstruction
- domain_rangelist
[lat_min, lat_max, lon_min, lon_max] for a square domain or [lat_min, lat_max] to crop the lats only
- load_nc(path_dict, anom_period=None, varname_dict=None, inplace=False)¶
Load a NetCDF file that assumed to include time, lat, lon, value
- varname_dict: dict
a dict to map variable names, e.g. {‘tas’: ‘tempanomaly’} means ‘tas’ is named ‘tempanomaly’ in the input NetCDF file
PSMs¶
- class LMRt.psm.Linear(proxy_time, proxy_value, obs_tas_time, obs_tas_value, prior_tas_time=None, prior_tas_value=None)¶
- class LMRt.psm.Bilinear(proxy_time, proxy_value, obs_tas_time, obs_tas_value, obs_pr_time, obs_pr_value, prior_tas_time=None, prior_tas_value=None, prior_pr_time=None, prior_pr_value=None)¶