Clim¶
- class spy4cast.meteo.Clim(ds: Dataset, type: Literal['map', 'ts'], group_season: bool = True)¶
Bases:
_Procedure,objectProcedure to create the climatology of a dataset
- Parameters:
ds (spy4cast.dataset.Dataset) – spy4cast.dataset.Dataset onto which perform the climatology
type ('map' or 'ts') –
- Perform the climatology and outputing a map by doing the mean across time
or ouputting a timeseries by doing the mean across space.
Attributes Summary
Data Matrix
Dataset introduced
Array of latitude values of the dataset passes in initialization if type is map
Array of longitude values of the dataset passes in initialization if type is map
Region applied to the matrix.
Array of years of the time variable
Type of climatology passed in initialization
Variable name
Returns the variables contained in the object (data, time, lat, lon, ...)
Methods Summary
load(prefix[, folder, zip_file, type])Load an clim object from matrices and type
plot(*[, save_fig, show_plot, halt_program, ...])Plot the climatology map or time series
Attributes Documentation
- data¶
Data Matrix
- Return type:
xarray.DataArray
- ds¶
Dataset introduced
- lat¶
Array of latitude values of the dataset passes in initialization if type is map
- Return type:
xarray.DataArray
- lon¶
Array of longitude values of the dataset passes in initialization if type is map
- Return type:
xarray.DataArray
- region¶
Region applied to the matrix.
- Return type:
Note
If type is ts and initilization from ds was not run then a default time and region region is returned
Note
If type is map and initilization from ds was not run then a default time region is returned
- time¶
Array of years of the time variable
- Return type:
xarray.DataArray
- var¶
Variable name
- Return type:
str
- var_names¶
Returns the variables contained in the object (data, time, lat, lon, …)
Methods Documentation
- classmethod load(prefix: str, folder: str = '.', zip_file: str | None = None, *, type: Literal['map', 'ts'] | None = None, **attrs: Any) Clim¶
Load an clim object from matrices and type
- Parameters:
prefix (str) – Prefix of the files containing the information for the object
folder (str) – Directory of the files
zip_file (optional, str) – If provided folder will be searched inside of the zip file, that should conatin all the data.
type ('map' or 'ts') – Type of climatology
- Return type:
- plot(*, save_fig: bool = False, show_plot: bool = False, halt_program: bool = False, cmap: str | None = None, color: Tuple[float, float, float] | None = None, folder: str = '.', name: str = 'clim.png', levels: int | ndarray[Any, dtype[float32]] | Sequence[float] | bool | None = None, ticks: ndarray[Any, dtype[float32]] | Sequence[float] | None = None, figsize: Tuple[float, float] | None = None, plot_type: Literal['contour', 'pcolor'] | None = None, central_longitude: float | None = None, xlim: Tuple[float, float] | None = None) Tuple[Tuple[Figure], Tuple[Tuple[Axes]]]¶
Plot the climatology map or time series
- Parameters:
save_fig – Saves the fig using folder and name parameters
show_plot – Shows the plot
halt_program – Only used if show_plot is True. If True shows the plot if plt.show and stops execution. Else uses fig.show and does not halt program
cmap – Colormap for the map types
color – Color of the line for ts types
folder – Directory to save fig if save_fig is True
name – Name of the fig saved if save_fig is True
levels – Levels for the climatology map
ticks – Ticks for the climatology map
figsize – Set figure size. See plt.figure
plot_type ({"contour", "pcolor"}, defaut = "pcolor") – Plot type for map. If contour it will use function ax.contourf, if pcolor ax.pcolormesh.
central_longitude (float, optional) – Longitude used to center the map
xlim (tuple[float, float], optional) – Xlim lim for the y map passed into ax.set_extent
- Returns:
figures (Tuple[plt.Figure]) – Figures objects from matplotlib. In this case just one figure
ax (Tuple[Tuple[plt.Axes]]) – Tuple of axes in figure. In this case just one axes