Documentation ¶
Index ¶
Constants ¶
const BaseRank = 100
BaseRank is the base ranking score for sources. If a source is prefered, it should be given a score lower than BaseRank in StatsRanking. If a source is not prefered, it should be given a score higher than BaseRank in StatsRanking
Variables ¶
var StatsRanking = map[RankKey]int{
{"CensusPEP", "CensusPEPSurvey", "*"}: 0,
{"CensusACS5YearSurvey", "CensusACS5yrSurvey", "*"}: 1,
{"CensusACS5YearSurvey_AggCountry", "CensusACS5yrSurvey", "*"}: 1,
{"CensusUSAMedianAgeIncome", "CensusACS5yrSurvey", "*"}: 1,
{"USDecennialCensus_RedistrictingRelease", "USDecennialCensus", "*"}: 2,
{"EurostatData", "EurostatRegionalPopulationData", "*"}: 3,
{"WorldDevelopmentIndicators", "*", "*"}: 4,
{"IndiaCensus_Primary", "*", "*"}: 5,
{"WikipediaStatsData", "Wikipedia", "*"}: 1001,
{"HumanCuratedStats", "HumanCuratedStats", "*"}: 1002,
{"WikidataPopulation", "WikidataPopulation", "*"}: 1003,
{"BLS_LAUS", "BLSSeasonallyUnadjusted", "*"}: 0,
{"BLS_CPS", "BLSSeasonallyAdjusted", "*"}: 1,
{"EurostatData", "", "*"}: 2,
{"NYT_COVID19", "NYT_COVID19_GitHub", "*"}: 0,
{"CDC500", "AgeAdjustedPrevalence", "*"}: 0,
{"UNEnergy", "", "*"}: 0,
{"EIA_Electricity", "*", "*"}: 1,
{"NOAA_EPA_Observed_Historical_Weather", "*", "*"}: 0,
{"Copernicus_ECMWF_ERA5_Monthly", "*", "*"}: 1,
{"NASA_NEXDCP30", "NASA_Mean_CCSM4", "P1M"}: 2,
{"NASA_NEXDCP30_AggrDiffStats", "*", "P1M"}: 3,
{"NASA_NEXDCP30_StatVarSeriesAggr", "*", "P1M"}: 4,
{"NASA_WetBulbComputation_Aggregation", "NASA_Mean_HadGEM2-AO", "*"}: 0,
{"NASA_WetBulbComputation_Aggregation", "*", "*"}: 1,
{"NASA_WetBulbComputation", "NASA_Mean_HadGEM2-AO", "*"}: 2,
{"FBIHateCrimePublications", "*", "*"}: 0,
{"FBIHateCrime", "*", "*"}: 1,
}
StatsRanking is used to rank multiple source series for the same StatisticalVariable, where lower value means higher ranking.
Functions ¶
func GetMetadataScore ¶ added in v1.35.0
func GetMetadataScore(m *pb.StatMetadata) int
GetMetadataScore computes score for pb.StatMetadata
func GetScore ¶ added in v1.35.0
func GetScore(s *model.SourceSeries) int
TODO(shifucun): Remove `SourceSeries` and use pb.SourceSeries everywhere. GetScore derives the ranking score for a source series.
The score depends on ImportName and other SVObs properties, by checking the StatsRanking dict. To get the score, ImportName is required, with optional properties: - MeasurementMethod - ObservationPeriod
When there are exact match of the properties in StatsRanking, then use that score, otherwise can also match to wildcard options (indicated by *).
If no entry is found, a BaseRank is assigned to the source series.
func GetScorePb ¶ added in v1.35.0
func GetScorePb(s *pb.SourceSeries) int
GetScorePb derives the ranking score for a source series.
The score depends on ImportName and other SVObs properties, by checking the StatsRanking dict. To get the score, ImportName is required, with optional properties: - MeasurementMethod - ObservationPeriod
When there are exact match of the properties in StatsRanking, then use that score, otherwise can also match to wildcard options (indicated by *).
If no entry is found, a BaseRank is assigned to the source series.
Types ¶
type ByRank ¶
type ByRank []*model.SourceSeries
ByRank implements sort.Interface for []*SourceSeries based on the rank score.
type CohortByRank ¶
type CohortByRank []*pb.SourceSeries
CohortByRank implements sort.Interface for []*SourceSeries based on the rank score. Each source series data is keyed by the place dcid.
Note this has the same data type as SeriesByRank but is used to compare cohort instead of time series.
func (CohortByRank) Len ¶
func (a CohortByRank) Len() int
func (CohortByRank) Less ¶
func (a CohortByRank) Less(i, j int) bool
func (CohortByRank) Swap ¶
func (a CohortByRank) Swap(i, j int)
type RankKey ¶
RankKey represents keys used for ranking. Import Name should be non-empty. Can use "*" for wildcard match for MeasurementMethod and ObservationPeriod
type SeriesByRank ¶
type SeriesByRank []*pb.SourceSeries
SeriesByRank implements sort.Interface for []*SourceSeries based on the rank score. Each source series data is keyed by the observation date.
This is the protobuf version of byRank.
func (SeriesByRank) Len ¶
func (a SeriesByRank) Len() int
func (SeriesByRank) Less ¶
func (a SeriesByRank) Less(i, j int) bool
func (SeriesByRank) Swap ¶
func (a SeriesByRank) Swap(i, j int)