MCPcopy Create free account
hub / github.com/NatLabRockies/windtools / _get_slice

Function _get_slice

windtools/plotting.py:1712–1733  ·  view source on GitHub ↗

Return cross-section of dataset

(df,key,dim)

Source from the content-addressed store, hash-verified

1710
1711
1712def _get_slice(df,key,dim):
1713 """
1714 Return cross-section of dataset
1715 """
1716 if key is None:
1717 return df
1718
1719 # Get dimension level and axis
1720 level, axis = _get_dim(df,dim)
1721
1722 # Requested dimension is an index
1723 if axis==0:
1724 if isinstance(df.index,pd.MultiIndex):
1725 return df.xs(key,level=level)
1726 else:
1727 return df.loc[df.index==key]
1728 # Requested dimension is a column
1729 elif axis==1:
1730 return df.loc[df[level]==key]
1731 # Requested dimension not available, return dataframe
1732 else:
1733 return df
1734
1735
1736def _get_field(df,fieldname):

Callers 3

plot_profileFunction · 0.85
plot_spectrumFunction · 0.85

Calls 1

_get_dimFunction · 0.85

Tested by

no test coverage detected