standardize_time_coord#

geobricks.standardize_time_coord(data, *, var=None, infer_from='dims', to_file=False)[source]#

Use a standard time variable as the temporal coordinate. Standardize its names into ‘time’. If not the main time coordinate, swap it with the main time coordinate.

Parameters#

datapath (str or pathlib.Path), or variable (xarray.Dataset, xarray.DataArray, geopandas.GeoDataFrame or pandas.DataFrame)

Data whose temporal coordinate should be renamed.

varstr, optional

Variable to rename into ‘time’. If not specified, the variable that will be renamed into ‘time’ will be inferred from the detected time coordinate(s).

infer_from{‘dims’, ‘coords’, ‘all’}, default ‘dims’

Only used for xarray variables. To specify if the time coordinate should be infered from dimensions, coordinates or all variables (coordinates and data variables).

to_filebool or path (str or pathlib.Path), default False

If True and if data is a path (str or pathlib.Path), the resulting dataset will be exported to a file with the same pathname and the suffix ‘_std_time’. If to_file is a path, the resulting dataset will be exported to this specified filepath.

Returns#

geopandas.GeoDataFrame, xarray.Dataset or pandas.DataFrame

Data with the modified name for the temporal coordinate. The variable type will be accordingly to the variable type of input data.

If to_file argument is used, the resulting dataset can also be exported to a file.