lair.inversion.utils#
Utility functions for inversion module.
Functions
|
Convert a pandas DataFrame to an xarray DataArray. |
|
Integrate data over time bins. |
|
Rounds the values in a pandas Index or MultiIndex if the level's data type is a numpy floating type. |
- lair.inversion.utils.integrate_over_time_bins(data: DataFrame | Series, time_bins: IntervalIndex, time_dim: str = 'time') DataFrame | Series [source]#
Integrate data over time bins.
- Parameters:
- datapd.DataFrame | pd.Series
Data to integrate.
- time_binspd.IntervalIndex
Time bins for integration.
- time_dimstr, optional
Time dimension name, by default ‘time’
- Returns:
- pd.DataFrame | pd.Series
Integrated footprint. The bin labels are set to the left edge of the bin.
- lair.inversion.utils.round_index(index: Index | MultiIndex, decimals: int) Index | MultiIndex [source]#
Rounds the values in a pandas Index or MultiIndex if the level’s data type is a numpy floating type.
- Parameters:
- indexpd.Index | pd.MultiIndex
Input index to round.
- decimalsint
Number of decimal places to round to.
- Returns:
- pd.Index | pd.MultiIndex
Rounded index.
- lair.inversion.utils.dataframe_matrix_to_xarray(frame: DataFrame) DataArray [source]#
Convert a pandas DataFrame to an xarray DataArray.
If the DataFrame has a MultiIndex for columns, all levels of the MultiIndex are stacked into the index of the resulting DataArray.
- Parameters:
- framepd.DataFrame
DataFrame to convert.
- Returns:
- xr.DataArray
Converted DataArray.