Exemple #1
0
    def increment_incidenceEvolutionByAge(self):
        report_date_list = self.getReportDate()
        age_list = self.getAge()
        nb_cases_list = self.getNbCases()

        ## Reverse
        age_key_list = ['total'] + self.age_key_list[::-1]

        ## Initialize stock
        stock = ccm.initializeStock_dailyCounts(age_key_list)

        ## Loop over series
        for report_date, age, nb_cases in zip(report_date_list, age_list,
                                              nb_cases_list):
            ind = ccm.indexForOverall(report_date)

            try:
                stock['total'][ind] += nb_cases
            except IndexError:
                pass
            else:
                try:
                    stock[age][ind] += nb_cases
                except KeyError:
                    pass

        return stock
Exemple #2
0
    def increment_localCasePerCounty(self):
        report_date_list = self.getReportDate()
        county_list = self.getCounty()
        nb_cases_list = self.getNbCases()

        ## Initialize stock
        county_key_list = ['total'] + self.county_key_list
        stock = ccm.initializeStock_dailyCounts(county_key_list)

        ind_max = 0

        ## Loop over series
        for report_date, county, nb_cases in zip(report_date_list, county_list,
                                                 nb_cases_list):
            if 'unknown' == county:
                continue

            ind = ccm.indexForOverall(report_date)
            ind_max = max(ind_max, ind + 1)

            try:
                stock['total'][ind] += nb_cases
                stock[county][ind] += nb_cases
            except IndexError:  ## If NaN
                pass

        ind_today = ccm.getTodayOrdinal() - ccm.ISODateToOrd(ccm.ISO_DATE_REF)
        ind = max(ind_max, ind_today - 1)  ## Take the max of data date & today
        stock = {k: v[:ind] for k, v in stock.items()}

        ## Moving average
        for key in county_key_list:
            stock[key + '_avg'] = ccm.makeMovingAverage(stock[key])
        return stock
 def increment_caseByTransmission(self):
   report_date_list = self.getReportDate()
   onset_date_list = self.getOnsetDate()
   trans_list = self.getTransmission()
   link_list = self.getLink()
   
   ## Initialize stocks
   trans_key_list = ['imported', 'linked', 'unlinked', 'fleet', 'plane', 'unknown']
   stock_r = ccm.initializeStock_dailyCounts(trans_key_list)
   stock_o = ccm.initializeStock_dailyCounts(trans_key_list)
   
   ## Loop over cases
   for report_date, onset_date, trans, link in zip(report_date_list, onset_date_list, trans_list, link_list):
     if trans != trans:
       continue
     
     ## Determine column tag
     if trans == 'local':
       if link == 'unlinked':
         key = link
       else:
         key = 'linked'
     else:
       key = trans
       
     try:
       ind = ccm.indexForOverall(report_date)
       stock_r[key][ind] += 1
     except IndexError: ## If NaN
       pass
       
     ## Check if NaN
     if onset_date != onset_date:
       continue
     
     try:
       ind = ccm.indexForOverall(onset_date)
       stock_o[key][ind] += 1
     except IndexError: ## If NaN
       pass
     
   return stock_r, stock_o
 def increment_caseByDetection(self):
   report_date_list = self.getReportDate()
   onset_date_list = self.getOnsetDate()
   trans_list = self.getTransmission()
   channel_list = self.getChannel()
   
   ## Initialize data dict
   det_key_list = ['airport', 'quarantine', 'isolation', 'monitoring', 'hospital', 'overseas', 'no_data']
   stock_r = ccm.initializeStock_dailyCounts(det_key_list)
   stock_o = ccm.initializeStock_dailyCounts(det_key_list)
   
   ## Loop over cases
   for report_date, onset_date, trans, channel in zip(report_date_list, onset_date_list, trans_list, channel_list):
     if trans != trans:
       continue
     
     ## Determine column tag
     if channel != channel:
       key = 'no_data'
     else:
       key = channel
     
     try:
       ind = ccm.indexForOverall(report_date)
       stock_r[key][ind] += 1
     except IndexError: ## If NaN
       pass
       
     ## Check if NaN
     if onset_date != onset_date:
       continue
     
     try:
       ind = ccm.indexForOverall(onset_date)
       stock_o[key][ind] += 1
     except IndexError: ## If NaN
       pass
     
   return stock_r, stock_o
    def increment_deathCounts(self):
        report_date_list = self.getReportDate()

        ## Initialize stocks
        col_tag_list = ['death']
        stock = ccm.initializeStock_dailyCounts(col_tag_list)

        ## Loop over cases
        for report_date in report_date_list:
            try:
                ind = ccm.indexForOverall(report_date)
                stock['death'][ind] += 1
            except IndexError:  ## If NaN
                pass

        ## Make avg
        for key in col_tag_list:
            stock[key + '_avg'] = ccm.makeMovingAverage(stock[key])
        return stock
Exemple #6
0
    def increment_incidenceEvolutionByCounty(self):
        report_date_list = self.getReportDate()
        county_list = self.getCounty()
        nb_cases_list = self.getNbCases()

        ## Initialize stock
        county_key_list = ['total'] + self.county_key_list
        stock = ccm.initializeStock_dailyCounts(county_key_list)

        ## Loop over series
        for report_date, county, nb_cases in zip(report_date_list, county_list,
                                                 nb_cases_list):
            if 'unknown' == county:
                continue

            ind = ccm.indexForOverall(report_date)

            try:
                stock[county][ind] += nb_cases
                stock['total'][ind] += nb_cases
            except IndexError:
                pass
        return stock