sup3r.preprocessing.collections.stats.StatsCollection#

class StatsCollection(containers, means=None, stds=None)[source]#

Bases: Collection

Extended collection object with methods for computing means and stds and saving these to files.

Note

We write stats as float64 because float32 is not json serializable

Parameters:
  • containers (List[Rasterizer]) – List of containers to compute stats for.

  • means (str | dict | None) – Usually a file path for saving results, or None for just calculating stats and not saving. Can also be a dict, which will just get returned as the “result”.

  • stds (str | dict | None) – Usually a file path for saving results, or None for just calculating stats and not saving. Can also be a dict, which will just get returned as the “result”.

Methods

check_shared_attr(attr)

Check if all containers have the same value for attr.

get_means(means)

Dictionary of means for each feature, computed across all data handlers.

get_stds(stds)

Dictionary of standard deviations for each feature, computed across all data handlers.

normalize(containers)

Normalize container data with computed stats.

post_init_log([args_dict])

Log additional arguments after initialization.

save_stats(stds, means)

Save stats to json files.

wrap(data)

Return a Sup3rDataset object or tuple of such.

Attributes

container_weights

Get weights used to sample from different containers based on relative sizes

data

Return underlying data.

features

Get all features contained in data.

shape

Get shape of underlying data.

get_means(means)[source]#

Dictionary of means for each feature, computed across all data handlers.

get_stds(stds)[source]#

Dictionary of standard deviations for each feature, computed across all data handlers.

save_stats(stds, means)[source]#

Save stats to json files.

normalize(containers)[source]#

Normalize container data with computed stats.

check_shared_attr(attr)#

Check if all containers have the same value for attr. If they do the collection effectively inherits those attributes.

property container_weights#

Get weights used to sample from different containers based on relative sizes

property data#

Return underlying data.

Returns:

Sup3rDataset

See also

wrap()

property features#

Get all features contained in data.

post_init_log(args_dict=None)#

Log additional arguments after initialization.

property shape#

Get shape of underlying data.

wrap(data)#

Return a Sup3rDataset object or tuple of such. This is a tuple when the .data attribute belongs to a Collection object like BatchHandler. Otherwise this is Sup3rDataset object, which is either a wrapped 2-tuple or 1-tuple (e.g. len(data) == 2 or len(data) == 1). This is a 2-tuple when .data belongs to a dual container object like DualSampler and a 1-tuple otherwise.