Skip to content

bgc_data_processing.tracers

Plotting objects.

BasePlot(storer, constraints)

Bases: ABC

Base class to plot data from a storer.

Parameters:

Name Type Description Default
storer Storer

Storer to plot data of.

required
constraints Constraints
Constraint slicer.
required

Initiate Base class to plot data from a storer.

Parameters:

Name Type Description Default
storer Storer

Storer to plot data of.

required
constraints Constraints
Constraint slicer.
required
Source code in src/bgc_data_processing/tracers.py
42
43
44
45
46
47
48
49
50
51
52
53
54
def __init__(self, storer: "Storer", constraints: "Constraints") -> None:
    """Initiate Base class to plot data from a storer.

    Parameters
    ----------
    storer : Storer
        Storer to plot data of.
    constraints: Constraints
            Constraint slicer.
    """
    self._storer = constraints.apply_constraints_to_storer(storer)
    self._variables = storer.variables
    self._constraints = constraints

show(title=None, suptitle=None, **kwargs) abstractmethod

Plot method.

Parameters:

Name Type Description Default
title str

Specify a title to change from default., by default None

None
suptitle str

Specify a suptitle to change from default., by default None

None
*kwargs

Additional parameters to pass to self._build_to_new_figure.

{}
Source code in src/bgc_data_processing/tracers.py
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
@abstractmethod
@with_verbose(trigger_threshold=0, message="Showing Figure.")
def show(
    self,
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Plot method.

    Parameters
    ----------
    title : str, optional
        Specify a title to change from default., by default None
    suptitle : str, optional
        Specify a suptitle to change from default., by default None
    *kwargs: dict
        Additional parameters to pass to self._build_to_new_figure.
    """
    self._build_to_new_figure(
        title=title,
        suptitle=suptitle,
        **kwargs,
    )
    plt.show()
    plt.close()

save(save_path, title=None, suptitle=None, **kwargs) abstractmethod

Figure saving method.

Parameters:

Name Type Description Default
save_path str

Path to save the output image.

required
title str

Specify a title to change from default., by default None

None
suptitle str

Specify a suptitle to change from default., by default None

None
*kwargs

Additional parameters to pass to self._build_to_new_figure.

{}
Source code in src/bgc_data_processing/tracers.py
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
@abstractmethod
@with_verbose(trigger_threshold=0, message="Saving figure in [save_path]")
def save(
    self,
    save_path: str,
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Figure saving method.

    Parameters
    ----------
    save_path : str
        Path to save the output image.
    title : str, optional
        Specify a title to change from default., by default None
    suptitle : str, optional
        Specify a suptitle to change from default., by default None
    *kwargs: dict
        Additional parameters to pass to self._build_to_new_figure.
    """
    self._build_to_new_figure(
        title=title,
        suptitle=suptitle,
        **kwargs,
    )
    plt.savefig(save_path)

plot_to_axes(ax, *args, **kwargs) abstractmethod

Plot data to the given axes.

Parameters:

Name Type Description Default
ax Axes | GeoAxes

Axes to plot the data on.

required
*args

Additional parameters for the axes plotting method.

()
*kwargs

Additional parameters for the axes plotting method.

{}

Returns:

Type Description
Axes | GeoAxes

Axes were the data is plotted on.

Source code in src/bgc_data_processing/tracers.py
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
@abstractmethod
def plot_to_axes(
    self,
    ax: "Axes | GeoAxes",
    *args,
    **kwargs,
) -> "Axes | GeoAxes":
    """Plot data to the given axes.

    Parameters
    ----------
    ax : Axes | GeoAxes
        Axes to plot the data on.
    *args: list
        Additional parameters for the axes plotting method.
    *kwargs: dict
        Additional parameters for the axes plotting method.

    Returns
    -------
    Axes | GeoAxes
        Axes were the data is plotted on.
    """

DensityPlotter(storer, constraints=None)

Bases: BasePlot

Base class for tracing on earthmaps.

Parameters:

Name Type Description Default
storer Storer

Data Storer containing data to plot.

required
constraints Constraints | None
Constraint slicer.
None

Instanciate base class for tracing on earthmaps.

Parameters:

Name Type Description Default
storer Storer

Data Storer containing data to plot.

required
constraints Constraints | None
Constraint slicer.
None
Source code in src/bgc_data_processing/tracers.py
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
def __init__(
    self,
    storer: "Storer",
    constraints: Constraints | None = None,
) -> None:
    """Instanciate base class for tracing on earthmaps.

    Parameters
    ----------
    storer : Storer
        Data Storer containing data to plot.
    constraints: Constraints | None
            Constraint slicer.
    """
    if constraints is None:
        constraints = Constraints()
    super().__init__(storer=storer, constraints=constraints)
    self._lat_bin: int | float = self.__default_lat_bin
    self._lon_bin: int | float = self.__default_lon_bin
    self._depth_density: bool = self.__default_depth_density
    self._lat_map_min = np.nan
    self._lat_map_max = np.nan
    self._lon_map_min = np.nan
    self._lon_map_max = np.nan
    depth_var_name = self._variables.depth_var_name
    depth_var_label = self._variables.get(depth_var_name).label
    self._data = self._storer.data.sort_values(depth_var_label, ascending=False)
    self._grouping_columns = self._get_grouping_columns(self._variables)

__default_lat_bin: int | float = 1 class-attribute instance-attribute

__default_lon_bin: int | float = 1 class-attribute instance-attribute

__default_depth_density: bool = True class-attribute instance-attribute

set_bins_size(bins_size)

Set the bin sizes.

Parameters:

Name Type Description Default
bins_size int | float | Iterable[int | float]

Bins size, if tuple, first for latitude, second for longitude. If float or int, size is applied for both latitude and longitude. Unit is supposed to be degree.

required
Source code in src/bgc_data_processing/tracers.py
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
def set_bins_size(
    self,
    bins_size: int | float | Iterable[int | float],
) -> None:
    """Set the bin sizes.

    Parameters
    ----------
    bins_size : int | float | Iterable[int  |  float]
        Bins size, if tuple, first for latitude, second for longitude.
        If float or int, size is applied for both latitude and longitude.
        Unit is supposed to be degree.
    """
    if isinstance(bins_size, Iterable):
        self._lat_bin = bins_size[0]
        self._lon_bin = bins_size[1]
    else:
        self._lat_bin = bins_size
        self._lon_bin = bins_size

set_density_type(consider_depth)

Set the self._depth_density value.

Parameters:

Name Type Description Default
consider_depth bool

Whether to consider all value in the water for density mapping.

required
Source code in src/bgc_data_processing/tracers.py
362
363
364
365
366
367
368
369
370
def set_density_type(self, consider_depth: bool) -> None:
    """Set the self._depth_density value.

    Parameters
    ----------
    consider_depth : bool
        Whether to consider all value in the water for density mapping.
    """
    self._depth_density = consider_depth

set_map_boundaries(latitude_min=np.nan, latitude_max=np.nan, longitude_min=np.nan, longitude_max=np.nan)

Define the boundaries of the map.

(different from the boundaries of the plotted data).

Parameters:

Name Type Description Default
latitude_min int | float

Minimum latitude, by default np.nan

nan
latitude_max int | float

Maximal latitude, by default np.nan

nan
longitude_min int | float

Mnimal longitude, by default np.nan

nan
longitude_max int | float

Maximal longitude, by default np.nan

nan
Source code in src/bgc_data_processing/tracers.py
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
def set_map_boundaries(
    self,
    latitude_min: int | float = np.nan,
    latitude_max: int | float = np.nan,
    longitude_min: int | float = np.nan,
    longitude_max: int | float = np.nan,
) -> None:
    """Define the boundaries of the map.

    (different from the boundaries of the plotted data).

    Parameters
    ----------
    latitude_min : int | float, optional
        Minimum latitude, by default np.nan
    latitude_max : int | float, optional
        Maximal latitude, by default np.nan
    longitude_min : int | float, optional
        Mnimal longitude, by default np.nan
    longitude_max : int | float, optional
        Maximal longitude, by default np.nan
    """
    if not np.isnan(latitude_min):
        self._lat_map_min = latitude_min
    if not np.isnan(latitude_max):
        self._lat_map_max = latitude_max
    if not np.isnan(longitude_min):
        self._lon_map_min = longitude_min
    if not np.isnan(longitude_max):
        self._lon_map_max = longitude_max

save(save_path, variable_name, title=None, suptitle=None, **kwargs)

Plot the colormesh for the given variable.

Parameters:

Name Type Description Default
save_path str

Path to save the figure at.

required
variable_name str

Name of the variable to plot.

required
title str | None

Title for the figure, if set to None, automatically created. , by default None.

None
suptitle str | None

Suptitle for the figure, if set to None, automatically created. , by default None.

None
**kwargs

Additional arguments to pass to plt.pcolor.

{}
Source code in src/bgc_data_processing/tracers.py
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
def save(
    self,
    save_path: str,
    variable_name: str,
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Plot the colormesh for the given variable.

    Parameters
    ----------
    save_path: str
        Path to save the figure at.
    variable_name : str
        Name of the variable to plot.
    title: str, optional
        Title for the figure, if set to None, automatically created.
        , by default None.
    suptitle: str, optional
        Suptitle for the figure, if set to None, automatically created.
        , by default None.
    **kwargs
        Additional arguments to pass to plt.pcolor.
    """
    super().save(
        save_path=save_path,
        variable_name=variable_name,
        title=title,
        suptitle=suptitle,
        **kwargs,
    )

show(variable_name, title=None, suptitle=None, **kwargs)

Plot the colormesh for the given variable.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to plot.

required
title str | None

Title for the figure, if set to None, automatically created. , by default None.

None
suptitle str | None

Suptitle for the figure, if set to None, automatically created. , by default None.

None
**kwargs

Additional arguments to pass to plt.pcolor.

{}
Source code in src/bgc_data_processing/tracers.py
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
def show(
    self,
    variable_name: str,
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Plot the colormesh for the given variable.

    Parameters
    ----------
    variable_name : str
        Name of the variable to plot.
    title: str, optional
        Title for the figure, if set to None, automatically created.
        , by default None.
    suptitle: str, optional
        Suptitle for the figure, if set to None, automatically created.
        , by default None.
    **kwargs
        Additional arguments to pass to plt.pcolor.
    """
    super().show(
        variable_name=variable_name,
        title=title,
        suptitle=suptitle,
        **kwargs,
    )

plot_to_axes(variable_name, ax, **kwargs)

Build the plot to given axes.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to plot.

required
ax GeoAxes

GeoAxes (from cartopy) to plot the data to.

required
**kwargs

Additional arguments to pass to plt.pcolormesh.

{}

Returns:

Type Description
tuple[GeoAxes, Collection]

Axes, Colorbar.

Source code in src/bgc_data_processing/tracers.py
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
def plot_to_axes(
    self,
    variable_name: str,
    ax: "GeoAxes",
    **kwargs,
) -> tuple["GeoAxes", "Collection"]:
    """Build the plot to given axes.

    Parameters
    ----------
    variable_name : str
        Name of the variable to plot.
    ax : GeoAxes
        GeoAxes (from cartopy) to plot the data to.
    **kwargs
        Additional arguments to pass to plt.pcolormesh.

    Returns
    -------
    tuple[GeoAxes, Collection]
        Axes, Colorbar.
    """
    return self._build_to_geoaxes(
        variable_name=variable_name,
        ax=ax,
        **kwargs,
    )

get_df(variable_name)

Return the density of the given variable on the bins.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to bin.

required

Returns:

Type Description
Dataframe

Three columns dataframe : longitude, latitude and variable density. The column names are the same as in the original DataFrame.

Source code in src/bgc_data_processing/tracers.py
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
@with_verbose(trigger_threshold=1, message="Meshing [variable_name] data.")
def get_df(
    self,
    variable_name: str,
) -> pd.DataFrame:
    """Return the density of the given variable on the bins.

    Parameters
    ----------
    variable_name : str
        Name of the variable to bin.

    Returns
    -------
    pd.Dataframe
        Three columns dataframe : longitude, latitude and variable density.
         The column names are the same as in the original DataFrame.
    """
    if variable_name == "all":
        label = "all"
    else:
        label = self._variables.get(variable_name).label
    lon_label = self._variables.get(self._variables.longitude_var_name).label
    lat_label = self._variables.get(self._variables.latitude_var_name).label
    df = self._group(
        var_key=label,
        lat_key=lat_label,
        lon_key=lon_label,
    )
    if df.empty:
        return pd.DataFrame(columns=[lon_label, lat_label, label])
    longis_2d, latis_2d, values_2d = self._mesh(
        df=df,
        label=label,
    )
    # Ravel the arrays to concatenate them in a single dataframe
    lons = longis_2d.ravel()
    lats = latis_2d.ravel()
    vals = values_2d.ravel()
    data = {lon_label: lons, lat_label: lats, label: vals}
    transformed_df = pd.DataFrame.from_dict(data)
    return transformed_df[~transformed_df[label].isna()]

EvolutionProfile(storer, constraints=None)

Bases: BasePlot

Class to plot the evolution of data on a given area.

Parameters:

Name Type Description Default
storer Storer

Storer to map data of.

required
constraints Constraints | None

Constraint slicer.

None

Class to plot the evolution of data on a given area.

Parameters:

Name Type Description Default
storer Storer

Storer to map data of.

required
constraints Constraints | None
Constraint slicer.
None
Source code in src/bgc_data_processing/tracers.py
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
def __init__(
    self,
    storer: "Storer",
    constraints: Constraints | None = None,
) -> None:
    """Class to plot the evolution of data on a given area.

    Parameters
    ----------
    storer : Storer
        Storer to map data of.
    constraints: Constraints|None
            Constraint slicer.
    """
    if constraints is None:
        constraints = Constraints()
    super().__init__(storer, constraints)
    self._interval: str = self.__default_interval
    self._interval_length: int = self.__default_interval_length
    self._depth_interval: int | float = self.__default_depth_interval
    self._depth_col = self._variables.get(self._variables.depth_var_name).label
    self._date_col = self._variables.get(self._variables.date_var_name).label

__default_interval: str = 'day' class-attribute instance-attribute

__default_interval_length: int = 10 class-attribute instance-attribute

__default_depth_interval: int = 100 class-attribute instance-attribute

__default_depth_max: int = 0 class-attribute instance-attribute

reset_intervals()

Reset interval parameters to the default ones.

Source code in src/bgc_data_processing/tracers.py
736
737
738
739
740
def reset_intervals(self) -> None:
    """Reset interval parameters to the default ones."""
    self._interval = self.__default_interval
    self._interval_length = self.__default_interval_length
    self._depth_interval = self.__default_depth_interval

reset_parameters()

Reset all boundaries and intervals to default values.

Source code in src/bgc_data_processing/tracers.py
742
743
744
def reset_parameters(self) -> None:
    """Reset all boundaries and intervals to default values."""
    self.reset_intervals()

set_depth_interval(depth_interval=np.nan)

Set the depth interval value.

This represents the vertical resolution of the final plot.

Parameters:

Name Type Description Default
depth_interval int | float | list[int | float]

Depth interval values, if numeric, interval resolution, if instance of list, list of depth bins to use., by default np.nan

nan
Source code in src/bgc_data_processing/tracers.py
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
def set_depth_interval(
    self,
    depth_interval: int | float | list[int | float] = np.nan,
) -> None:
    """Set the depth interval value.

    This represents the vertical resolution of the final plot.

    Parameters
    ----------
    depth_interval : int | float | list[int|float], optional
        Depth interval values, if numeric, interval resolution, if instance of list,
        list of depth bins to use., by default np.nan
    """
    if isinstance(depth_interval, list) or (not np.isnan(depth_interval)):
        self._depth_interval = depth_interval

set_date_intervals(interval, interval_length=None)

Set the date interval parameters.

This represent the horizontal resolution of the final plot.

Parameters:

Name Type Description Default
interval str

Interval resolution, can be "day", "week", "month", "year" or "custom".

required
interval_length int

Only useful if the resolution interval is "custom". Represents the interval length, in days., by default None

None
Source code in src/bgc_data_processing/tracers.py
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
def set_date_intervals(
    self,
    interval: str,
    interval_length: int | None = None,
) -> None:
    """Set the date interval parameters.

    This represent the horizontal resolution of the final plot.

    Parameters
    ----------
    interval : str
        Interval resolution, can be "day", "week", "month", "year" or "custom".
    interval_length : int, optional
        Only useful if the resolution interval is "custom". \
        Represents the interval length, in days., by default None
    """
    self._interval = interval
    if interval_length is not None:
        self._interval_length = interval_length

show(variable_name, title=None, suptitle=None, **kwargs)

Plot the figure of data density evolution in a givemn area.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to plot.

required
title str

Specify a title to change from default., by default None

None
suptitle str

Specify a suptitle to change from default., by default None

None
**kwargs

Additional arguments to pass to plt.pcolor.

{}
Source code in src/bgc_data_processing/tracers.py
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
def show(
    self,
    variable_name: str,
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Plot the figure of data density evolution in a givemn area.

    Parameters
    ----------
    variable_name : str
        Name of the variable to plot.
    title : str, optional
        Specify a title to change from default., by default None
    suptitle : str, optional
        Specify a suptitle to change from default., by default None
    **kwargs
        Additional arguments to pass to plt.pcolor.
    """
    super().show(
        variable_name=variable_name,
        title=title,
        suptitle=suptitle,
        **kwargs,
    )

save(save_path, variable_name, title=None, suptitle=None, **kwargs)

Save the figure of data density evolution in a givemn area.

Parameters:

Name Type Description Default
save_path str

Path to save the output image.

required
variable_name str

Name of the variable to plot.

required
title str

Specify a title to change from default., by default None

None
suptitle str

Specify a suptitle to change from default., by default None

None
**kwargs

Additional arguments to pass to plt.pcolor.

{}
Source code in src/bgc_data_processing/tracers.py
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
def save(
    self,
    save_path: str,
    variable_name: str,
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Save the figure of data density evolution in a givemn area.

    Parameters
    ----------
    save_path : str
        Path to save the output image.
    variable_name : str
        Name of the variable to plot.
    title : str, optional
        Specify a title to change from default., by default None
    suptitle : str, optional
        Specify a suptitle to change from default., by default None
    **kwargs
        Additional arguments to pass to plt.pcolor.
    """
    super().save(
        save_path=save_path,
        variable_name=variable_name,
        title=title,
        suptitle=suptitle,
        **kwargs,
    )

plot_to_axes(variable_name, ax, **kwargs)

Plot the data on a given axes.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to plot the data of.

required
ax Axes

Axes to plot the data on.

required
**kwargs

Additional arguments to pass to plt.pcolormesh.

{}

Returns:

Type Description
tuple[Axes, Collection]

Axes, colorbar

Source code in src/bgc_data_processing/tracers.py
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
def plot_to_axes(
    self,
    variable_name: str,
    ax: "Axes",
    **kwargs,
) -> tuple["Axes", "Collection"]:
    """Plot the data on a given axes.

    Parameters
    ----------
    variable_name : str
        Name of the variable to plot the data of.
    ax : Axes
        Axes to plot the data on.
    **kwargs:
        Additional arguments to pass to plt.pcolormesh.

    Returns
    -------
    tuple[Axes, Collection]
        Axes, colorbar
    """
    return self._build_to_axes(
        variable_name=variable_name,
        ax=ax,
        **kwargs,
    )

TemperatureSalinityDiagram(storer, constraints, salinity_field, temperature_field, ptemperature_field)

Bases: BasePlot

Class to plot a Temperature-Salinity Diagram.

Parameters:

Name Type Description Default
storer Storer

Storer to map data of.

required
constraints Constraints

Constraint slicer.

required
temperature_field str

Name of the temperature field in storer (column name).

required
salinity_field str

Name of the salinity field in storer (column name).

required
Source code in src/bgc_data_processing/tracers.py
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
def __init__(
    self,
    storer: "Storer",
    constraints: "Constraints",
    salinity_field: str,
    temperature_field: str,
    ptemperature_field: str,
) -> None:
    super().__init__(storer, constraints)
    self.salinity_field = salinity_field
    self.temperature_field = temperature_field
    self.ptemperature_field = ptemperature_field

salinity_field = salinity_field instance-attribute

temperature_field = temperature_field instance-attribute

ptemperature_field = ptemperature_field instance-attribute

show(title=None, suptitle=None, **kwargs)

Plot the Temperature-Salinity diagram.

Parameters:

Name Type Description Default
title str

Specify a title to change from default., by default None

None
suptitle str

Specify a suptitle., by default None

None
**kwargs

Additional arguments to pass to plt.pcolor.

{}
Source code in src/bgc_data_processing/tracers.py
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
def show(
    self,
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Plot the Temperature-Salinity diagram.

    Parameters
    ----------
    title : str, optional
        Specify a title to change from default., by default None
    suptitle : str, optional
        Specify a suptitle., by default None
    **kwargs
        Additional arguments to pass to plt.pcolor.
    """
    super().show(title=title, suptitle=suptitle, **kwargs)

save(save_path, title=None, suptitle=None, **kwargs)

Save the figure of Temperature-Salinity Diagram.

Parameters:

Name Type Description Default
save_path str

Path to save the output image.

required
title str

Specify a title to change from default., by default None

None
suptitle str

Specify a suptitle to change from default., by default None

None
**kwargs

Additional arguments to pass to plt.scatter.

{}
Source code in src/bgc_data_processing/tracers.py
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
def save(
    self,
    save_path: str,
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Save the figure of Temperature-Salinity Diagram.

    Parameters
    ----------
    save_path : str
        Path to save the output image.
    title : str, optional
        Specify a title to change from default., by default None
    suptitle : str, optional
        Specify a suptitle to change from default., by default None
    **kwargs
        Additional arguments to pass to plt.scatter.
    """
    super().save(save_path=save_path, title=title, suptile=suptitle, **kwargs)

plot_to_axes(ax, **kwargs)

Plot the data on a given axes.

Parameters:

Name Type Description Default
ax Axes

Axes to plot the data on.

required
**kwargs

Additional arguments to pass to plt.scatter.

{}

Returns:

Type Description
tuple[Axes, Collection]

Axes, colorbar

Source code in src/bgc_data_processing/tracers.py
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
def plot_to_axes(self, ax: "Axes", **kwargs) -> tuple["Axes", "PathCollection"]:
    """Plot the data on a given axes.

    Parameters
    ----------
    ax : Axes
        Axes to plot the data on.
    **kwargs:
        Additional arguments to pass to plt.scatter.

    Returns
    -------
    tuple[Axes, Collection]
        Axes, colorbar
    """
    return self._build_to_axes(
        ax=ax,
        **kwargs,
    )

VariableBoxPlot(storer, constraints)

Bases: BasePlot

Class to draw box plots for a given variable.

Parameters:

Name Type Description Default
storer Storer

Storer to map the data of.

required
constraints Constraints

Constraints slicer.

required
Source code in src/bgc_data_processing/tracers.py
1336
1337
def __init__(self, storer: "Storer", constraints: "Constraints") -> None:
    super().__init__(storer, constraints)

period_mapping: dict[str, str] = {'year': '%Y', 'month': '%Y-%m', 'week': '%Y-%W', 'day': '%Y-%m-%d'} class-attribute

show(variable_name, period, title=None, suptitle=None, **kwargs)

Plot method.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to plot.

required
period str

Period on which to plot each boxplot.

required
title str

Specify a title to change from default., by default None

None
suptitle str

Specify a suptitle to change from default., by default None

None
*kwargs

Additional parameters to pass to plt.boxplot.

{}
Source code in src/bgc_data_processing/tracers.py
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
def show(
    self,
    variable_name: str,
    period: str,
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Plot method.

    Parameters
    ----------
    variable_name: str
        Name of the variable to plot.
    period: str
        Period on which to plot each boxplot.
    title : str, optional
        Specify a title to change from default., by default None
    suptitle : str, optional
        Specify a suptitle to change from default., by default None
    *kwargs: dict
        Additional parameters to pass to plt.boxplot.
    """
    super().show(
        variable_name=variable_name,
        period=period,
        title=title,
        suptitle=suptitle,
        **kwargs,
    )

save(variable_name, period, save_path, title=None, suptitle=None, **kwargs)

Figure saving method.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to plot.

required
period str

Period on which to plot each boxplot.

required
save_path str

Path to save the ouput image.

required
title str | None

Specify a title to change from default., by default None

None
suptitle str | None

Add a suptitle to the figure., by default None

None
**kwargs

Addictional parameters to pass to plt.boxplot.

{}
Source code in src/bgc_data_processing/tracers.py
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
def save(
    self,
    variable_name: str,
    period: str,
    save_path: str,
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Figure saving method.

    Parameters
    ----------
    variable_name : str
        Name of the variable to plot.
    period : str
        Period on which to plot each boxplot.
    save_path : str
        Path to save the ouput image.
    title : str | None, optional
        Specify a title to change from default., by default None
    suptitle : str | None, optional
        Add a suptitle to the figure., by default None
    **kwargs: dict
        Addictional parameters to pass to plt.boxplot.
    """
    return super().save(
        save_path=save_path,
        variable_name=variable_name,
        period=period,
        title=title,
        suptitle=suptitle,
        **kwargs,
    )

plot_to_axes(variable_name, period, ax, **kwargs)

Plot the data to the given axes.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to plot.

required
period str

Period on which to plot each boxplot.

required
ax Axes

Axes to plot the data on.

required
**kwargs

Additional parameters to pass to plt.boxplot.

{}

Returns:

Type Description
Axes

Axes where the data is plotted on.

Source code in src/bgc_data_processing/tracers.py
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
def plot_to_axes(
    self,
    variable_name: str,
    period: str,
    ax: "Axes",
    **kwargs,
) -> "Axes":
    """Plot the data to the given axes.

    Parameters
    ----------
    variable_name : str
        Name of the variable to plot.
    period : str
        Period on which to plot each boxplot.
    ax : Axes
        Axes to plot the data on.
    **kwargs: dict
        Additional parameters to pass to plt.boxplot.

    Returns
    -------
    Axes
        Axes where the data is plotted on.
    """
    return self._build_to_axes(
        variable_name=variable_name,
        period=period,
        ax=ax,
        **kwargs,
    )

WaterMassVariableComparison(storer, constraints, pressure_var_name, ptemperature_var_name, salinity_var_name, sigma_t_var_name)

Bases: BasePlot

Class to draw a pressure vs variable comparison of water masses.

Parameters:

Name Type Description Default
storer Storer

Storer to map the data of.

required
constraints Constraints

Constraints slicer.

required
pressure_var_name str

Name of the pressure variable.

required
ptemperature_var_name str

Potential temperature variable name.

required
salinity_var_name str

Salinity variable name.

required
sigma_t_var_name str

Sigma-t variable name.

required
Source code in src/bgc_data_processing/tracers.py
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
def __init__(
    self,
    storer: "Storer",
    constraints: "Constraints",
    pressure_var_name: str,
    ptemperature_var_name: str,
    salinity_var_name: str,
    sigma_t_var_name: str,
) -> None:
    super().__init__(storer, constraints)
    self.pressure_var = self._variables.get(pressure_var_name)
    self.ptemp_var = self._variables.get(ptemperature_var_name)
    self.salty_var = self._variables.get(salinity_var_name)
    self.sigma_t_var = self._variables.get(sigma_t_var_name)

pressure_var = self._variables.get(pressure_var_name) instance-attribute

ptemp_var = self._variables.get(ptemperature_var_name) instance-attribute

salty_var = self._variables.get(salinity_var_name) instance-attribute

sigma_t_var = self._variables.get(sigma_t_var_name) instance-attribute

show(variable_name, wmasses, title=None, suptitle=None, **kwargs)

Plot method.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to plot.

required
wmasses list[WaterMass]

List all water masses.

required
title str

Specify a title to change from default., by default None

None
suptitle str

Specify a suptitle to change from default., by default None

None
*kwargs

Additional parameters to pass to plt.scatter.

{}
Source code in src/bgc_data_processing/tracers.py
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
def show(
    self,
    variable_name: str,
    wmasses: list["WaterMass"],
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Plot method.

    Parameters
    ----------
    variable_name: str
        Name of the variable to plot.
    wmasses : list[WaterMass]
        List all water masses.
    title : str, optional
        Specify a title to change from default., by default None
    suptitle : str, optional
        Specify a suptitle to change from default., by default None
    *kwargs: dict
        Additional parameters to pass to plt.scatter.
    """
    super().show(
        variable_name=variable_name,
        wmasses=wmasses,
        title=title,
        suptitle=suptitle,
        **kwargs,
    )

save(variable_name, wmasses, save_path, title=None, suptitle=None, **kwargs)

Figure saving method.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to plot.

required
wmasses list[WaterMass]

List all water masses.

required
save_path str

Path to save the ouput image.

required
title str | None

Specify a title to change from default., by default None

None
suptitle str | None

Add a suptitle to the figure., by default None

None
**kwargs

Addictional parameters to pass to plt.scatter.

{}
Source code in src/bgc_data_processing/tracers.py
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
def save(
    self,
    variable_name: str,
    wmasses: list["WaterMass"],
    save_path: str,
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Figure saving method.

    Parameters
    ----------
    variable_name : str
        Name of the variable to plot.
    wmasses : list[WaterMass]
        List all water masses.
    save_path : str
        Path to save the ouput image.
    title : str | None, optional
        Specify a title to change from default., by default None
    suptitle : str | None, optional
        Add a suptitle to the figure., by default None
    **kwargs: dict
        Addictional parameters to pass to plt.scatter.
    """
    super().save(
        variable_name=variable_name,
        wmasses=wmasses,
        save_path=save_path,
        title=title,
        suptitle=suptitle,
        **kwargs,
    )

plot_to_axes(variable_name, wmasses, ax, **kwargs)

Plot the data to the given axes.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to plot.

required
wmasses list[WaterMass]

List all water masses.

required
ax Axes

Axes to plot the data on.

required
**kwargs

Additional parameters to pass to plt.scatter.

{}

Returns:

Type Description
Axes

Axes where the data is plotted on.

Source code in src/bgc_data_processing/tracers.py
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
def plot_to_axes(
    self,
    variable_name: str,
    wmasses: list["WaterMass"],
    ax: "Axes",
    **kwargs,
) -> "Axes":
    """Plot the data to the given axes.

    Parameters
    ----------
    variable_name : str
        Name of the variable to plot.
    wmasses : list[WaterMass]
        List all water masses.
    ax : Axes
        Axes to plot the data on.
    **kwargs: dict
        Additional parameters to pass to plt.scatter.

    Returns
    -------
    Axes
        Axes where the data is plotted on.
    """
    return self._build_to_axes(
        variable_name=variable_name,
        wmasses=wmasses,
        ax=ax,
        **kwargs,
    )

VariableHistogram(storer, constraints)

Bases: BasePlot

Class to draw histogram for a given variable.

Parameters:

Name Type Description Default
storer Storer

Storer to map the data of.

required
constraints Constraints

Constraints slicer.

required
Source code in src/bgc_data_processing/tracers.py
1801
1802
def __init__(self, storer: "Storer", constraints: "Constraints") -> None:
    super().__init__(storer, constraints)

bin_number: int = 100 class-attribute instance-attribute

show(variable_name, title=None, suptitle=None, **kwargs)

Plot method.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to plot.

required
title str

Specify a title to change from default., by default None

None
suptitle str

Specify a suptitle to change from default., by default None

None
*kwargs

Additional parameters to pass to plt.hist.

{}
Source code in src/bgc_data_processing/tracers.py
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
def show(
    self,
    variable_name: str,
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Plot method.

    Parameters
    ----------
    variable_name: str
        Name of the variable to plot.
    title : str, optional
        Specify a title to change from default., by default None
    suptitle : str, optional
        Specify a suptitle to change from default., by default None
    *kwargs: dict
        Additional parameters to pass to plt.hist.
    """
    super().show(
        variable_name=variable_name,
        title=title,
        suptitle=suptitle,
        **kwargs,
    )

save(variable_name, save_path, title=None, suptitle=None, **kwargs)

Figure saving method.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to plot.

required
save_path str

Path to save the ouput image.

required
title str | None

Specify a title to change from default., by default None

None
suptitle str | None

Add a suptitle to the figure., by default None

None
**kwargs

Addictional parameters to pass to plt.hist.

{}
Source code in src/bgc_data_processing/tracers.py
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
def save(
    self,
    variable_name: str,
    save_path: str,
    title: str | None = None,
    suptitle: str | None = None,
    **kwargs,
) -> None:
    """Figure saving method.

    Parameters
    ----------
    variable_name : str
        Name of the variable to plot.
    save_path : str
        Path to save the ouput image.
    title : str | None, optional
        Specify a title to change from default., by default None
    suptitle : str | None, optional
        Add a suptitle to the figure., by default None
    **kwargs: dict
        Addictional parameters to pass to plt.hist.
    """
    return super().save(
        save_path=save_path,
        variable_name=variable_name,
        title=title,
        suptitle=suptitle,
        **kwargs,
    )

plot_to_axes(variable_name, ax, **kwargs)

Plot the data to the given axes.

Parameters:

Name Type Description Default
variable_name str

Name of the variable to plot.

required
ax Axes

Axes to plot the data on.

required
**kwargs

Additional parameters to pass to plt.hist.

{}

Returns:

Type Description
Axes

Axes where the data is plotted on.

Source code in src/bgc_data_processing/tracers.py
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
def plot_to_axes(
    self,
    variable_name: str,
    ax: "Axes",
    **kwargs,
) -> "Axes":
    """Plot the data to the given axes.

    Parameters
    ----------
    variable_name : str
        Name of the variable to plot.
    ax : Axes
        Axes to plot the data on.
    **kwargs: dict
        Additional parameters to pass to plt.hist.

    Returns
    -------
    Axes
        Axes where the data is plotted on.
    """
    return self._build_to_axes(
        variable_name=variable_name,
        ax=ax,
        **kwargs,
    )