standardize_time_coord#
- geobricks.standardize_time_coord(data, *, var=None, infer_from='dims', force_time_index=False, 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. Sort times in increasing order.
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’
To specify if the time coordinate should be infered from dimensions, coordinates or all variables (coordinates and data variables).
- force_time_indexbool, default False
Only for pandas.DataFrames. If True, the detected time column will be converted into the index.
- to_filebool or path (str or pathlib.Path), default False
If True and if
datais a path (str or pathlib.Path), the resulting dataset will be exported to a file with the same pathname and the suffix ‘_std_time’. Ifto_fileis 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_fileargument is used, the resulting dataset can also be exported to a file.