Skip to content

bgc_data_processing.core.variables.sets

Variable Ensembles.

AllVariablesTypes: TypeAlias = ExistingVar | NotExistingVar | ParsedVar | FeatureVar module-attribute

NotParsedvar: TypeAlias = ExistingVar | NotExistingVar | FeatureVar module-attribute

FromFileVariables: TypeAlias = ExistingVar | NotExistingVar module-attribute

VariableSet(*args, **kwargs)

Variable ensemble behavior implementation.

This class represents the set of both variables present in the file and variables to take in consideration (therefore to add even if empty) when loading the data.

Parameters:

Name Type Description Default
*args FromFileVariables

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods.

()
*kwargs FromFileVariables

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods. The parameter name has no importance.

{}

Raises:

Type Description
ValueError:

If multiple var object have the same name.

Source code in src/bgc_data_processing/core/variables/sets.py
51
52
53
54
55
56
57
58
59
60
61
62
def __init__(
    self,
    *args: FromFileVariables,
    **kwargs: FromFileVariables,
) -> None:
    if len(args) != len({var.name for var in args}):
        error_msg = (
            "To set multiple alias for the same variable, "
            "use Var.in_file_as([alias1, alias2])"
        )
        raise ValueError(error_msg)
    self._instantiate_from_elements([*args, *kwargs.values()])

elements: list[AllVariablesTypes] property

All variables in the ensemble.

labels: dict[str, str] property

Returns a dicitonnary mapping variable names to variables labels.

Returns:

Type Description
dict[str, str]

name : label

mapper_by_name: dict[str, FromFileVariables] property

Mapper between variables names and variables Var objects (for getitem).

Returns:

Type Description
dict[str, Var]

Mapping between names (str) and variables (Var)

__getitem__(__k)

Get variable by its name.

Parameters:

Name Type Description Default
__k str

Variable name

required

Returns:

Type Description
FromFileVariables

Corresponding variable with name __k

Source code in src/bgc_data_processing/core/variables/sets.py
77
78
79
80
81
82
83
84
85
86
87
88
89
90
def __getitem__(self, __k: str) -> FromFileVariables:
    """Get variable by its name.

    Parameters
    ----------
    __k : str
        Variable name

    Returns
    -------
    FromFileVariables
        Corresponding variable with name __k
    """
    return self.get(__k)

__iter__()

Get an iterator of all variables.

Yields:

Type Description
Iterator[FromFileVariables]

Ietrator of all element in the storer.

Source code in src/bgc_data_processing/core/variables/sets.py
 92
 93
 94
 95
 96
 97
 98
 99
100
def __iter__(self) -> Iterator[FromFileVariables]:
    """Get an iterator of all variables.

    Yields
    ------
    Iterator[FromFileVariables]
        Ietrator of all element in the storer.
    """
    return iter(self._elements)

__str__()

Convert the object to string.

Returns:

Type Description
str

All variable as strings.

Source code in src/bgc_data_processing/core/variables/sets.py
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
def __str__(self) -> str:
    """Convert the object to string.

    Returns
    -------
    str
        All variable as strings.
    """
    txt = ""
    for var in self._elements:
        if var.exist_in_dset is None:
            here_txt = "not attributed"
        elif var.exist_in_dset:
            here_txt = var.aliases
        else:
            here_txt = "not in file"
        txt += str(var) + f": {here_txt}\n"
    return txt

__len__()

Return the number of elements.

Returns:

Type Description
int

Number of elements.

Source code in src/bgc_data_processing/core/variables/sets.py
121
122
123
124
125
126
127
128
129
def __len__(self) -> int:
    """Return the number of elements.

    Returns
    -------
    int
        Number of elements.
    """
    return len(self._elements)

__eq__(__o)

Compare to object for equality.

Parameters:

Name Type Description Default
__o object

Object to compare with.

required

Returns:

Type Description
bool

True if the objects have same types and all equal variables.

Source code in src/bgc_data_processing/core/variables/sets.py
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
def __eq__(self, __o: object) -> bool:
    """Compare to object for equality.

    Parameters
    ----------
    __o : object
        Object to compare with.

    Returns
    -------
    bool
        True if the objects have same types and all equal variables.
    """
    if not isinstance(__o, VariableSet):
        return False

    has_wrong_len = len(self) != len(__o)
    self_keys = set(self.mapper_by_name.keys())
    other_keys = set(__o.mapper_by_name.keys())
    has_wrong_keys = self_keys != other_keys

    if has_wrong_len or has_wrong_keys:
        return False

    repr_eq = [repr(self[key]) == repr(__o[key]) for key in self.mapper_by_name]
    return np.all(repr_eq)

get(var_name)

Return the variable which name corresponds to var_name.

Parameters:

Name Type Description Default
var_name str

Name of the variable to get.

required

Returns:

Type Description
FromFileVariables

Variable with corresponding name in self._elements.

Raises:

Type Description
IncorrectVariableNameError

If var_name doesn't correspond to any name.

Source code in src/bgc_data_processing/core/variables/sets.py
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
def get(self, var_name: str) -> FromFileVariables:
    """Return the variable which name corresponds to var_name.

    Parameters
    ----------
    var_name : str
        Name of the variable to get.

    Returns
    -------
    FromFileVariables
        Variable with corresponding name in self._elements.

    Raises
    ------
    IncorrectVariableNameError
        If var_name doesn't correspond to any name.
    """
    if self.has_name(var_name=var_name):
        return self.mapper_by_name[var_name]
    error_msg = (
        f"{var_name} is not a valid variable name.Valid names are: "
        f"{list(self.mapper_by_name.keys())}"
    )
    raise IncorrectVariableNameError(error_msg)

add_var(var)

Add a new variable to self._elements.

Parameters:

Name Type Description Default
var Var

Variable to add

required

Raises:

Type Description
DuplicatedVariableNameError

If the variable name is already in the set.

Source code in src/bgc_data_processing/core/variables/sets.py
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
def add_var(self, var: FromFileVariables) -> None:
    """Add a new variable to self._elements.

    Parameters
    ----------
    var : Var
        Variable to add

    Raises
    ------
    DuplicatedVariableNameError
        If the variable name is already in the set.
    """
    if var.name in self.keys():  # noqa: SIM118
        error_msg = "A variable already exists with his name"
        raise DuplicatedVariableNameError(error_msg)
    self._elements.append(var)
    self._instantiate_from_elements(self._elements)

pop(var_name)

Remove and return the variable with the given name.

Parameters:

Name Type Description Default
var_name str

Name of the variable to remove from the ensemble.

required

Returns:

Type Description
AllVariablesTypes

Removed variable.

Source code in src/bgc_data_processing/core/variables/sets.py
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
def pop(self, var_name: str) -> AllVariablesTypes:
    """Remove and return the variable with the given name.

    Parameters
    ----------
    var_name : str
        Name of the variable to remove from the ensemble.

    Returns
    -------
    AllVariablesTypes
        Removed variable.
    """
    var_to_suppress = self.get(var_name)
    elements = [e for e in self._elements if e.name != var_name]
    self._instantiate_from_elements(elements)
    return var_to_suppress

has_name(var_name)

Check if a variable name is the nam eof one of the variables.

Parameters:

Name Type Description Default
var_name str

Name to test.

required

Returns:

Type Description
bool

True if the name is in self.keys(), False otherwise.

Source code in src/bgc_data_processing/core/variables/sets.py
221
222
223
224
225
226
227
228
229
230
231
232
233
234
def has_name(self, var_name: str) -> bool:
    """Check if a variable name is the nam eof one of the variables.

    Parameters
    ----------
    var_name : str
        Name to test.

    Returns
    -------
    bool
        True if the name is in self.keys(), False otherwise.
    """
    return var_name in self.keys()  # noqa: SIM118

keys()

Keys to use when calling self[key].

Returns:

Type Description
dict_keys

View of self.mapper_by_name keys.

Source code in src/bgc_data_processing/core/variables/sets.py
236
237
238
239
240
241
242
243
244
def keys(self) -> dict_keys:
    """Keys to use when calling self[key].

    Returns
    -------
    dict_keys
        View of self.mapper_by_name keys.
    """
    return self.mapper_by_name.keys()

FeatureVariablesSet(*args, **kwargs)

Bases: VariableSet

Ensemble of features.

This class represents the set of both variables present in the file and variables to take in consideration (therefore to add even if empty) when loading the data.

Parameters:

Name Type Description Default
*args FeatureVar

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods.

()
*kwargs FeatureVar

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods. The parameter name has no importance.

{}

Raises:

Type Description
ValueError:

If multiple var object have the same name.

Source code in src/bgc_data_processing/core/variables/sets.py
331
332
def __init__(self, *args: "FeatureVar", **kwargs: "FeatureVar") -> None:
    super().__init__(*args, **kwargs)

iter_constructables_features(available_vars)

Create an iterator returning constructables features.

The Iterator considers that all constructed features are available to construct the following ones.

Parameters:

Name Type Description Default
available_vars list[AllVariablesTypes]

Variable available to build the features.

required

Yields:

Type Description
Iterator[FeatureVar]

Iterator.

Raises:

Type Description
FeatureConstructionError

If all features can not be constructed.

Source code in src/bgc_data_processing/core/variables/sets.py
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
def iter_constructables_features(
    self,
    available_vars: list[AllVariablesTypes],
) -> Iterator[FeatureVar]:
    """Create an iterator returning constructables features.

    The Iterator considers that all constructed features
    are available to construct the following ones.

    Parameters
    ----------
    available_vars : list[AllVariablesTypes]
        Variable available to build the features.

    Yields
    ------
    Iterator[FeatureVar]
        Iterator.

    Raises
    ------
    FeatureConstructionError
        If all features can not be constructed.
    """
    available = available_vars.copy()
    features = self._elements.copy()
    constructables = self._get_constructable_features(features, available)
    while constructables:
        for feature in constructables:
            available.append(feature)
            yield feature
        features = [f for f in features if all(f != a for a in available)]
        constructables = self._get_constructable_features(features, available)
    if features:
        error_msg = (
            f"The following features can not be loaded: {features}. "
            "They probably depend on non loaded variables."
        )
        raise FeatureConstructionError(error_msg)

BaseRequiredVarsSet(expocode, date, year, month, day, latitude, longitude, depth, hour=None, provider=None, *args, **kwargs)

Bases: VariableSet

Storer for Variable objects with some required variables.

This class represents the set of both variables present in the file and variables to take in consideration (therefore to add even if empty) when loading the data.

Parameters:

Name Type Description Default
expocode FromFileVariables

Expocode related variable.

required
date FromFileVariables

Date related variable.

required
year FromFileVariables

Year related variable.

required
month FromFileVariables

Month related variable.

required
day FromFileVariables

Day related variable.

required
latitude FromFileVariables

Latitude related variable.

required
longitude FromFileVariables

Longitude related variable.

required
depth FromFileVariables

Depth related variable.

required
provider FromFileVariables

Provider related variable. Can be set to None to be ignored., by default None

None
hour FromFileVariables

Hour related variable. Can be set to None to be ignored., by default None

None
*args FromFileVariables

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods.

()
*kwargs FromFileVariables

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods. The parameter name has no importance.

{}

Raises:

Type Description
ValueError:

If multiple var object have the same name.

Source code in src/bgc_data_processing/core/variables/sets.py
440
441
442
443
444
445
446
447
448
449
450
451
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
484
485
486
487
488
489
490
491
492
493
494
495
496
497
def __init__(
    self,
    expocode: FromFileVariables,
    date: FromFileVariables,
    year: FromFileVariables,
    month: FromFileVariables,
    day: FromFileVariables,
    latitude: FromFileVariables,
    longitude: FromFileVariables,
    depth: FromFileVariables,
    hour: FromFileVariables | None = None,
    provider: FromFileVariables | None = None,
    *args: FromFileVariables,
    **kwargs: FromFileVariables,
) -> None:
    if len(args) != len({var.name for var in args}):
        error_msg = (
            "To set multiple alias for the same variable, "
            "use Var.in_file_as([alias1, alias2])"
        )
        raise ValueError(error_msg)
    mandatory_variables = []
    if provider is None:
        self.has_provider = False
        self.provider_var_name = None
    else:
        self.has_provider = True
        self.provider_var_name = provider.name
        mandatory_variables.append(provider)
    self.expocode_var_name = expocode.name
    mandatory_variables.append(expocode)
    self.date_var_name = date.name
    mandatory_variables.append(date)
    self.year_var_name = year.name
    mandatory_variables.append(year)
    self.month_var_name = month.name
    mandatory_variables.append(month)
    self.day_var_name = day.name
    mandatory_variables.append(day)
    if hour is None:
        self.has_hour = False
        self.hour_var_name = None
    else:
        self.has_hour = True
        self.hour_var_name = hour.name
        mandatory_variables.append(hour)
    self.latitude_var_name = latitude.name
    mandatory_variables.append(latitude)
    self.longitude_var_name = longitude.name
    mandatory_variables.append(longitude)
    self.depth_var_name = depth.name
    mandatory_variables.append(depth)
    self._elements: list[FromFileVariables | ParsedVar] = (
        mandatory_variables + list(args) + list(kwargs.values())
    )
    self._save = [var.name for var in self._elements]
    self._in_dset = [var for var in self._elements if var.exist_in_dset]
    self._not_in_dset = [var for var in self._elements if not var.exist_in_dset]

has_provider = False instance-attribute

provider_var_name = None instance-attribute

expocode_var_name = expocode.name instance-attribute

date_var_name = date.name instance-attribute

year_var_name = year.name instance-attribute

month_var_name = month.name instance-attribute

day_var_name = day.name instance-attribute

has_hour = False instance-attribute

hour_var_name = None instance-attribute

latitude_var_name = latitude.name instance-attribute

longitude_var_name = longitude.name instance-attribute

depth_var_name = depth.name instance-attribute

pop(var_name)

Remove and return the variable with the given name.

Parameters:

Name Type Description Default
var_name str

Name of the variable to remove from the ensemble.

required

Returns:

Type Description
AllVariablesTypes

Removed variable.

Raises:

Type Description
KeyError

If the variable is mandatory.

Source code in src/bgc_data_processing/core/variables/sets.py
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
def pop(self, var_name: str) -> AllVariablesTypes:
    """Remove and return the variable with the given name.

    Parameters
    ----------
    var_name : str
        Name of the variable to remove from the ensemble.

    Returns
    -------
    AllVariablesTypes
        Removed variable.

    Raises
    ------
    KeyError
        If the variable is mandatory.
    """
    mandatory_variables_names = [
        self.expocode_var_name,
        self.provider_var_name,
        self.date_var_name,
        self.year_var_name,
        self.month_var_name,
        self.day_var_name,
        self.hour_var_name,
        self.latitude_var_name,
        self.longitude_var_name,
        self.depth_var_name,
    ]
    if var_name in mandatory_variables_names:
        error_msg = (
            f"Variable {var_name} can not be removed since "
            "it is a mandatory variable."
        )
        raise IncorrectVariableNameError(error_msg)
    return super().pop(var_name)

LoadingVariablesSet(expocode, date, year, month, day, latitude, longitude, depth, hour=None, provider=None, *args, **kwargs)

Bases: BaseRequiredVarsSet

Storer for Var object which are going to be loaded.

This class represents the set of both variables present in the file and variables to take in consideration (therefore to add even if empty) when loading the data.

Parameters:

Name Type Description Default
expocode FromFileVariables

Expocode related variable.

required
date FromFileVariables

Date related variable.

required
year FromFileVariables

Year related variable.

required
month FromFileVariables

Month related variable.

required
day FromFileVariables

Day related variable.

required
latitude FromFileVariables

Latitude related variable.

required
longitude FromFileVariables

Longitude related variable.

required
depth FromFileVariables

Depth related variable.

required
provider FromFileVariables

Provider related variable. Can be set to None to be ignored., by default None

None
hour FromFileVariables

Hour related variable. Can be set to None to be ignored., by default None

None
*args FromFileVariables

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods.

()
*kwargs FromFileVariables

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods. The parameter name has no importance.

{}

Raises:

Type Description
ValueError:

If multiple var object have the same name.

Source code in src/bgc_data_processing/core/variables/sets.py
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
def __init__(
    self,
    expocode: FromFileVariables,
    date: FromFileVariables,
    year: FromFileVariables,
    month: FromFileVariables,
    day: FromFileVariables,
    latitude: FromFileVariables,
    longitude: FromFileVariables,
    depth: FromFileVariables,
    hour: FromFileVariables | None = None,
    provider: FromFileVariables | None = None,
    *args: FromFileVariables,
    **kwargs: FromFileVariables,
) -> None:
    super().__init__(
        expocode,
        date,
        year,
        month,
        day,
        latitude,
        longitude,
        depth,
        hour,
        provider,
        *args,
        **kwargs,
    )

in_dset: list[ExistingVar] property

List of Var object supposedly present in the dataset.

Returns:

Type Description
list[Var]

Var objects in the dataset.

corrections: dict[str, Callable] property

Mapping between variables keys and correcting functions.

Returns:

Type Description
dict[str, Callable]

Mapping.

to_remove_if_all_nan: list[str] property

Return the list of keys to inspect when removing rows.

This is suited when seeking for rows to delete when many given variables are NaN.

Returns:

Type Description
list[str]

List of keys to use.

to_remove_if_any_nan: list[str] property

Return the list of keys to inspect when removing rows.

This is suited when seeking for rows to delete when at least one given variable is NaN.

Returns:

Type Description
list[str]

List of keys to use.

StoringVariablesSet(expocode, date, year, month, day, latitude, longitude, depth, hour=None, provider=None, *args, **kwargs)

Bases: BaseRequiredVarsSet

Storer for Var object which are going to be stored.

This class represents the set of both variables present in the file and variables to take in consideration (therefore to add even if empty) when loading the data.

Parameters:

Name Type Description Default
expocode FromFileVariables

Expocode related variable.

required
date FromFileVariables

Date related variable.

required
year FromFileVariables

Year related variable.

required
month FromFileVariables

Month related variable.

required
day FromFileVariables

Day related variable.

required
latitude FromFileVariables

Latitude related variable.

required
longitude FromFileVariables

Longitude related variable.

required
depth FromFileVariables

Depth related variable.

required
provider FromFileVariables

Provider related variable. Can be set to None to be ignored., by default None

None
hour FromFileVariables

Hour related variable. Can be set to None to be ignored., by default None

None
*args FromFileVariables

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods.

()
*kwargs FromFileVariables

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods. The parameter name has no importance.

{}

Raises:

Type Description
ValueError:

If multiple var object have the same name.

Source code in src/bgc_data_processing/core/variables/sets.py
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
def __init__(
    self,
    expocode: FromFileVariables,
    date: FromFileVariables,
    year: FromFileVariables,
    month: FromFileVariables,
    day: FromFileVariables,
    latitude: FromFileVariables,
    longitude: FromFileVariables,
    depth: FromFileVariables,
    hour: FromFileVariables | None = None,
    provider: FromFileVariables | None = None,
    *args: FromFileVariables,
    **kwargs: FromFileVariables,
) -> None:
    super().__init__(
        expocode,
        date,
        year,
        month,
        day,
        latitude,
        longitude,
        depth,
        hour,
        provider,
        *args,
        **kwargs,
    )
    self._save = [var.name for var in self._elements]

saving_variables: SavingVariablesSet property

Order of the variables to save.

set_saving_order(var_names=None)

Set the saving order for the variables.

Parameters:

Name Type Description Default
var_names list[str] | None

List of variable names => saving variables sorted., by default None

None

Raises:

Type Description
ValueError

If a variable name is not one of the variables'.

Source code in src/bgc_data_processing/core/variables/sets.py
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
def set_saving_order(self, var_names: list[str] | None = None) -> None:
    """Set the saving order for the variables.

    Parameters
    ----------
    var_names : list[str] | None, optional
        List of variable names => saving variables sorted., by default None

    Raises
    ------
    ValueError
        If a variable name is not one of the variables'.
    """
    if var_names is None:
        return
    new_save = deepcopy(var_names)
    self._save = new_save

SavingVariablesSet(expocode, date, year, month, day, latitude, longitude, depth, hour=None, provider=None, save_order=None, *args, **kwargs)

Bases: BaseRequiredVarsSet

Storer for Var object which are going to be saved.

This class represents the set of both variables present in the file and variables to take in consideration (therefore to add even if empty) when loading the data.

Parameters:

Name Type Description Default
expocode FromFileVariables

Expocode related variable.

required
date FromFileVariables

Date related variable.

required
year FromFileVariables

Year related variable.

required
month FromFileVariables

Month related variable.

required
day FromFileVariables

Day related variable.

required
latitude FromFileVariables

Latitude related variable.

required
longitude FromFileVariables

Longitude related variable.

required
depth FromFileVariables

Depth related variable.

required
hour FromFileVariables

Hour related variable. Can be set to None to be ignored., by default None

None
provider FromFileVariables

Provider related variable. Can be set to None to be ignored., by default None

None
save_order list[AllVariablesTypes] | None

Default saving order. Order of the variables if None., by default None

None
*args FromFileVariables

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods.

()
*kwargs FromFileVariables

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods. The parameter name has no importance.

{}

Raises:

Type Description
ValueError:

If multiple var object have the same name.

Source code in src/bgc_data_processing/core/variables/sets.py
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
def __init__(
    self,
    expocode: FromFileVariables,
    date: FromFileVariables,
    year: FromFileVariables,
    month: FromFileVariables,
    day: FromFileVariables,
    latitude: FromFileVariables,
    longitude: FromFileVariables,
    depth: FromFileVariables,
    hour: FromFileVariables | None = None,
    provider: FromFileVariables | None = None,
    save_order: list[AllVariablesTypes] | None = None,
    *args: FromFileVariables,
    **kwargs: FromFileVariables,
) -> None:
    super().__init__(
        expocode,
        date,
        year,
        month,
        day,
        latitude,
        longitude,
        depth,
        hour,
        provider,
        *args,
        **kwargs,
    )
    if save_order is None:
        self._save = [var.name for var in self._elements.copy()]
    else:
        self._save = save_order

save_labels: list[str | tuple[str]] property

Sorting order to use when saving data.

Returns:

Type Description
list[str | tuple[str]]

List of columns keys to pass as df[self.save_sort] to sort data.

save_names: list[str | tuple[str]] property

Sorted names of variables to use for saving.

Returns:

Type Description
list[str | tuple[str]]

List of columns keys to pass as df[self.save_sort] to sort data.

name_save_format: str property

String line to use as formatting for name and unit rows.

Returns:

Type Description
str

Format string

value_save_format: str property

String line to use as formatting for value rows.

Returns:

Type Description
str

Format string"

set_saving_order(var_names=None)

Set the saving order for the variables.

Parameters:

Name Type Description Default
var_names list[str] | None

List of variable names => saving variables sorted., by default None

None

Raises:

Type Description
ValueError

If a variable name is not one of the variables'.

Source code in src/bgc_data_processing/core/variables/sets.py
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
def set_saving_order(self, var_names: list[str] | None = None) -> None:
    """Set the saving order for the variables.

    Parameters
    ----------
    var_names : list[str] | None, optional
        List of variable names => saving variables sorted., by default None

    Raises
    ------
    ValueError
        If a variable name is not one of the variables'.
    """
    if var_names is None:
        return
    self._save = deepcopy(var_names)

SourceVariableSet(expocode, date, year, month, day, latitude, longitude, depth, hour=None, provider=None, *args, **kwargs)

Bases: BaseRequiredVarsSet

Ensemble of variables.

This class represents the set of both variables present in the file and variables to take in consideration (therefore to add even if empty) when loading the data.

Parameters:

Name Type Description Default
expocode FromFileVariables

Expocode related variable.

required
date FromFileVariables

Date related variable.

required
year FromFileVariables

Year related variable.

required
month FromFileVariables

Month related variable.

required
day FromFileVariables

Day related variable.

required
latitude FromFileVariables

Latitude related variable.

required
longitude FromFileVariables

Longitude related variable.

required
depth FromFileVariables

Depth related variable.

required
provider FromFileVariables

Provider related variable. Can be set to None to be ignored., by default None

None
hour FromFileVariables

Hour related variable. Can be set to None to be ignored., by default None

None
*args FromFileVariables

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods.

()
*kwargs FromFileVariables

Var objects to represent the variables stored by the object. It is better if these Var object have been instanciated using .not_here or .here_as methods. The parameter name has no importance.

{}

Raises:

Type Description
ValueError:

If multiple var object have the same name.

Source code in src/bgc_data_processing/core/variables/sets.py
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
def __init__(
    self,
    expocode: FromFileVariables,
    date: FromFileVariables,
    year: FromFileVariables,
    month: FromFileVariables,
    day: FromFileVariables,
    latitude: FromFileVariables,
    longitude: FromFileVariables,
    depth: FromFileVariables,
    hour: FromFileVariables | None = None,
    provider: FromFileVariables | None = None,
    *args: FromFileVariables,
    **kwargs: FromFileVariables,
) -> None:
    super().__init__(
        expocode,
        date,
        year,
        month,
        day,
        latitude,
        longitude,
        depth,
        hour,
        provider,
        *args,
        **kwargs,
    )

features: FeatureVariablesSet property

FeatureVar list.

loading_variables: LoadingVariablesSet property

Ensembles of variables to load.

storing_variables: StoringVariablesSet property

Ensemble of variables to store.