> ## Documentation Index
> Fetch the complete documentation index at: https://scope3-s2s.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculations

# Detailed walkthrough of calculations

## Entity Definitions

### Channels

| Channel    | Description                                    |
| ---------- | ---------------------------------------------- |
| `web`      | Website that is not primarily social or CTV    |
| `app`      | Mobile app that is not primarily social or CTV |
| `social`   | A social platform (Snapchat, Facebook, etc)    |
| `ctv-bvod` | A TV-like streaming platform                   |
| `audio`    | Audio content (podcasts, streaming music)      |
| `dooh`     | Digital out of home - billboards, transit, etc |

### Device Types

| Device type     | Description                                 |
| --------------- | ------------------------------------------- |
| `phone`         | A phone                                     |
| `tablet`        | A tablet                                    |
| `pc`            | A pc with a monitor or a laptop             |
| `tv`            | A TV                                        |
| `smart-speaker` | A smart speaker - Amazon Echo or equivalent |

### Network Types

| Network type | Description                 |
| ------------ | --------------------------- |
| `mobile`     | A mobile network (3G/4G/5G) |
| `fixed`      | A fixed network (broadband) |

### Video Player

| Field               | Description                                                              |
| ------------------- | ------------------------------------------------------------------------ |
| `size_bytes`        | Size of the javascript/html for a video player if present                |
| `buffering_seconds` | Video player buffering - if player preloads content, leave blank         |
| `download_trigger`  | What starts the content download - impression, view (ie lazy load), play |

### [Ad Format](./creative#terminology-placements-ad-formats-creatives-and-assets)

| Field                    | Description                                                                                  |
| ------------------------ | -------------------------------------------------------------------------------------------- |
| `rendered_width_pixels`  | Width of the creative when rendered. Leave blank for responsive (will assume screen width)   |
| `rendered_height_pixels` | Height of the creative when rendered. Leave blank for responsive (will assume screen height) |
| `image_sizes`            | Array of image dimensions (eg `["300x250", "70x70"]`)                                        |
| `audio_duration_seconds` | Audio duration (if applicable)                                                               |
| `video_duration_seconds` | Video duration (if applicable)                                                               |
| `video_player`           | Video player used to render video (if applicable)                                            |
| `other_assets_bytes`     | Metadata, text, html, etc                                                                    |
| `ad_platforms`           | Ad serving, verification, and measurement ad platforms wrapping or embedded in the ad format |
| `is_3p_served`           | Does this ad format expect/support the creative to be served by a third party ad server      |

#### Sample Ad Formats:

300x250 programmatic banner

```
image_sizes = ['300x250']
rendered_width_pixels = 300,
rendered_height_pixels = 250
is_3p_served = true
```

30 second audio inserted into a podcast

```
audio_duration_seconds = 30
is_3p_served = false
```

15 second outstream video

```
video_duration_seconds = 15;
video_player = 'default',
rendered_width_pixels = 500,
rendered_height_pixels = 400
is_3p_served = true
```

Native product carousel

```
  image_sizes = ['400x400','400x400','400x400'],
  other_assets_bytes = 7321,
  rendered_height_pixels = 600,
  rendered_width_pixels = 450
  is_3p_served = false
```

### Property

| Field                                           | Required | Description                                                                                    |
| ----------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------- |
| `channels`                                      | Yes      | The channel(s) of this property                                                                |
| `average_seconds_per_session_excluding_ads`     | Yes      | The average length of a session on this property excluding ads (eg 44 min of a 60 min TV show) |
| `average_imps_per_session`                      | Yes      | The average number of impressions per session                                                  |
| `average_data_kb_per_session_excluding_ads`     | Yes      | The average number of KB transferred during a session excluding ads                            |
| `ad_funded_percentage`                          | Yes      | 0-100 The percentage of content funded by advertising (eg 50)                                  |
| `allocated_adjusted_corporate_emissions_kgco2e` | Yes      | This property's share of corporate emissions                                                   |
| `total_sessions`                                | Yes      | Number of sessions in the same time period as corporate emissions                              |
| `organization_model_quality`                    | Yes      | Parent organization model quality (1-5)                                                        |
| `model_quality`                                 | Yes      | Model quality (1-5)                                                                            |

### Ad Platform

| Field                                                 | Description                                                                                 |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `emissions_per_creative_request_per_geo_gco2_per_imp` | Adjusted, allocated emissions per creative request by continent (NAMER, LATAM, EMEA, JAPAC) |
| `emissions_per_bid_request_per_geo_gco2_per_imp`      | Adjusted, allocated emissions per bid request by continent (NAMER, LATAM, EMEA, JAPAC)      |
| `emissions_per_rtdp_request_per_geo_gco2_per_imp`     | Adjusted, allocated emissions per rtdp request by continent (NAMER, LATAM, EMEA, JAPAC)     |
| `bidders`                                             | Array of ad platforms that are sent bid requests                                            |
| `real_time_data_providers`                            | Array of ad platforms that are sent real-time data requests (not propagated)                |
| `distribution_rate_by_bidder_by_country`              | Traffic shaping data for each bidder by country (eg `'xandr.com', 'US', 0.58`)              |
| `average_bid_request_size`                            | Average size of a client-side bid request                                                   |
| `sends_client_side_requests`                          | Does this platform send client-side bid requests (eg prebid client)                         |
| `model_quality`                                       | Model quality (1-5)                                                                         |

### Placement

| Field          | Description                               |
| -------------- | ----------------------------------------- |
| `ad_platforms` | The ad platforms called by this placement |

### Delivery Row

| Field                                      | Description                                                                                                 |
| ------------------------------------------ | ----------------------------------------------------------------------------------------------------------- |
| `impressions`                              | The number of impressions counted (required for all channels other than DOOH)                               |
| `views`                                    | The number of views counted                                                                                 |
| `plays`                                    | The number of plays (required for DOOH)                                                                     |
| `utc_datetime`                             | Date and time, in UTC, when impressions were delivered                                                      |
| `country`                                  | The country where the impression was delivered                                                              |
| `region`                                   | The region of the country where the impression was delivered                                                |
| `channel`                                  | See [channels](#channels)                                                                                   |
| `device_type`                              | See [device types](#device-types)                                                                           |
| `network_type`                             | See [network types](#network-types)                                                                         |
| `property`                                 | See [property](#property)                                                                                   |
| `creative_ad_format`                       | Either a basic or vendor-provided ad format                                                                 |
| `creative_ad_platforms`                    | Ad serving, verification, and measurement ad platforms wrapping or embedded in the creative                 |
| `creative_total_image_data_transfer_bytes` | Total bytes for the data transfer for the image itself for all impressions, ideally measured by the CDN     |
| `creative_image_sizes`                     | Array of image sizes included in the creative                                                               |
| `creative_total_audio_data_transfer_bytes` | Total bytes for the data transfer for the core audio asset for all impressions, ideally measured by the CDN |
| `creative_audio_duration_seconds`          | Average audio duration in seconds for a single impression                                                   |
| `creative_total_video_data_transfer_bytes` | Total bytes for the data transfer for the core video asset for all loads, ideally measured by the CDN       |
| `creative_video_vast_bytes`                | Average size of VAST/VPAID wrapper for the video in bytes for a single load                                 |
| `creative_video_bitrate_kbps`              | Video bitrate *as delivered* in kilobits per second                                                         |
| `creative_video_size_bytes`                | Average video size *as delivered* in bytes for a single load                                                |
| `creative_video_duration_seconds`          | Video duration in seconds                                                                                   |
| `creative_video_view_time_seconds`         | Average time, in seconds, that a video is viewed                                                            |
| `creative_video_view_rate`                 | Average percentage of a video that is viewed                                                                |
| `creative_time_in_view_seconds`            | Time that the creative was visible on the device                                                            |

## Defaults

### Conventional model data transfer by network type

From [SRIxAD database 2.1](https://github.com/SRISyndicatRegiesInternet/SRIxAD-DigitalCampaignsCarbonFramework/releases/download/v2.1.0/Referentiel.SRI.x.AD.-.V2.1_partage.zip), original source ADEME\_220830\_v1.4

```
default_usage_kwh_per_gb:
  scope3:
    fixed:  0.03
    mobile: 0.14
  sri:
    fixed:  0.0687
    mobile: 0.236
default_network_embodied_emissions_gco2e_per_kb:
  scope3:
    fixed:  0.00000443
    mobile: 0.00000797
  sri:
    fixed:  0.00000443
    mobile: 0.00000797
default_server_to_server_kwh_per_gb: 0.00401
default_server_to_server_embodied_emissions_gco2e_per_kb: 0.000000136
```

### Power model data transfer by network type

From [Carbon impact of video streaming (Carbon Trust)](https://ctprodstorageaccountp.blob.core.windows.net/prod-drupal-files/documents/resource/public/Carbon-impact-of-video-streaming.pdf), Table 5; and calculated [here](./data_transfer#fixed-network)

```
default_baseload_watts:
  fixed:     9.55
  mobile:    1.2
default_dynamic_watts_per_mbps:
  fixed:    0.030
  mobile:    1.53
```

### Mobile to fixed ratios by country

From [ITU Data Hub](https://datahub.itu.int/) (2022 data)

```
default_percent_mobile:
  scope3: 23.6
  sri:    10.0
default_percent_mobile_by_country:
  scope3:
    ZA: 30.945
    AO: 59.384
    AL: 15.375
    DZ: 27.683
    AD: 1.624
    AM: 8.904
    SA: 55.143
    AU: 11.427
    AT: 38.885
    AZ: 29.787
    BR: 11.294
    BS: 25.756
    BE: 4.46
    BJ: 99.73
    BD: 34.15
    BH: 46.29
    BY: 22.182
    BW: 42.206
    BT: 99.456
    BG: 9.644
    CA: 2.685
    CL: 16.549
    CN: 15.037
    CO: 55.086
    LK: 63.568
    CM: 23.455
    KM: 99.676
    CV: 26.441
    CI: 52.974
    CR: 8.896
    CU: 63.572
    CY: 7.472
    DE: 5.257
    DJ: 36.67
    DK: 12.428
    ES: 9.105
    EG: 14.608
    EC: 9.798
    ET: 45.337
    FI: 48.403
    GB: 5.12
    GH: 83.523
    GQ: 99.999
    GR: 9.203
    HK: 11.514
    HN: 51.493
    HU: 13.125
    HR: 23.663
    IT: 17.54
    IN: 70.092
    ID: 25.742
    IE: 14.068
    IR: 67.887
    IQ: 1.815
    IS: 14.286
    JP: 15.825
    JM: 2.789
    JO: 35.178
    KE: 36.757
    KR: 9.753
    KW: 87.288
    LI: 1.625
    LS: 68.523
    LV: 31.858
    MU: 11.724
    MC: 9.054
    MG: 45.951
    MX: 6.249
    MY: 45.208
    MV: 6.198
    MN: 39.596
    MA: 36.417
    MW: 98.678
    NI: 48.681
    NG: 99.252
    NZ: 3.535
    PF: 17.987
    OM: 15.759
    PK: 59.667
    PL: 11.498
    PT: 6.065
    QA: 18.195
    RO: 10.538
    RW: 33.068
    RU: 27.984
    SN: 61.616
    SC: 22.059
    SM: 7.767
    ST: 11.867
    CH: 17.121
    SI: 4.378
    CZ: 6.277
    TG: 17.266
    TH: 33.423
    TT: 6.831
    TN: 15.891
    TR: 18.092
    TZ: 98.33
    AE: 8.167
    UG: 93.327
    UY: 13.111
    UZ: 32.197
    VE: 7.724
    VN: 11.054
    VU: 80.578
    YE: 11.392
    RS: 16.372
    ZW: 33.026
    GE: 10.404
    KZ: 42.651
    KG: 74.85
    SK: 10.929
    MK: 9.11
    TW: 30.249
    ME: 16.701
    US: 5.0
    FR: 10.0

```

### Video player characteristics

Based on actual data transfer of [https://vjs.zencdn.net/8.10.0/video.min.js](https://vjs.zencdn.net/8.10.0/video.min.js) on February 23, 2024

```
default_video_player_size_bytes: 192205
default_video_player_download_trigger:
  web:      'impression'
  app:      'impression'
  ctv-bvod: 'impression'
  streaming-video: 'impression'
  dooh:     'play'
  social:   'impression'
```

### Media size

Based on [YouTube recommendations](https://support.google.com/youtube/answer/1722171), [Wikipedia](https://en.wikipedia.org/wiki/JPEG)

```
default_image_compression_ratio:   10
default_non_primary_video_bitrate_kbps: 2500
default_video_bitrate_kbps:
  phone:           2500
  tablet:          5000
  pc:              8000
  tv:              8000
default_audio_bitrate_kbps:
  phone:            160
  tablet:           160
  pc:               160
  tv:               160
  smart-speaker:    160
```

### Device size

From common devices (Quad HD 27” monitor, iPhone 13, Nexus 5X, iPad Air 1/2, iPad 2/3, Nexus 9, 1080P TV)

```
default_device_width:
  phone:  1080
  tablet: 1536
  pc:     2560
  tv:     1920
default_device_height:
  phone:  1920
  tablet: 2048
  pc:     1440
  tv:     1080
```

### Device energy use and embodied emissions

See [Consumer Devices](./consumer_devices)

```
default_device_watts:
  scope3:
    phone:          0.77
    pc:            53.2
    tablet:         3.0
    tv:            87.4
    smart-speaker:  2.5
  sri:
    phone:          2.856
    pc:            29.4
    tablet:        29.4
    tv:            81.6
default_device_embodied_emissions_per_second:
  scope3:
    phone:          0.0058
    pc:             0.007
    tablet:         0.0029
    tv:             0.0096
    smart-speaker:  0.0061
  sri:
    phone:          0.00946
    pc:             0.0132
    tablet:         0.0128
    tv:             0.00889
```

### Time in view for non-video ads

Observations from various channels

```
default_time_in_view_seconds: 6
```

### Ad platform defaults

Observations from various channels

```
default_client_side_device_request_size_bytes:
  web:             1500
  app:             1000
  ctv-bvod:        0
  dooh:            0
  audio:           1000
  social:          1000
  streaming-video: 0

default_server_side_request_size_bytes: 1500

default_emissions_per_creative_request_gco2_per_imp: 0.0003
default_emissions_per_bid_request_gco2_per_imp:      0.11442
default_emissions_per_rtdp_request_gco2_per_imp:     0.01
default_emissions_generic_ad_server_gco2_per_imp: 0.000016

generic_creative_ad_server:
  emissions_per_creative_request_per_geo_gco2_per_imp:
    NAMER: 0.0001
    EMEA: 0.0001
    JAPAC: 0.0003
    LATAM: 0.0001
generic_measurement_platform:
  emissions_per_creative_request_per_geo_gco2_per_imp:
    NAMER: 0.0001
    EMEA: 0.0001
    JAPAC: 0.0003
    LATAM: 0.0001
```

### Channel and device type mappings

```
default_channel_by_device:
  phone:
    - social
    - ctv-bvod
    - audio
    - app
    - web
  tablet:
    - social
    - ctv-bvod
    - audio
    - app
    - web
  pc:
    - ctv-bvod
    - social
    - audio
    - web
  tv:
    - ctv-bvod
    - app
  smart-speaker:
    - audio
default_device_by_channel:
  social:   phone
  ctv-bvod: tv
  streaming-video: tv
  audio:    phone
  app:      phone
  web:      pc
default_platform_ad_format_identifier_by_channel:
  dooh:            landscape-dooh
  social:          1080-1920-sponsored-post-social-phone
  ctv-bvod:        15s-video-ctv-bvod-tv
  streaming-video: 15s-video-streaming-video-tv
  audio:           30s-audio-digital-audio-phone
  app:             interstitial-app-phone
  web:             leaderboard-web-pc
default_platform_ad_format_by_channel:
  dooh:     Landscape - 1920x1080 Image
  social:   Sponsored Post - 1080x1920 Image
  ctv-bvod: 15s Video
  streaming-video: 15s Video
  audio:    30s Audio
  app:      Interstitial - 1080x1920 Banner
  web:      Leaderboard - 728x90 Banner
default_property_average_imps_per_session_by_channel:
  social:   24
  ctv-bvod: 8.256
  streaming-video: 8.256
  audio:    4.8
  app:      14
  web:      32
default_property_ad_funded_percentage_by_channel:
  dooh:     100
  social:   100
  ctv-bvod: 100
  streaming-video: 100
  audio:    100
  app:      100
  web:      100
default_average_seconds_per_session_excluding_ads_by_channel:
  social:   240
  ctv-bvod: 2580
  streaming-video: 2580
  audio:    1500
  app:      140
  web:      320
default_average_data_kb_per_session_seconds_excluding_ads_by_channel:
  social:   255.6
  app:      29.5
  web:      1.011
default_property_g_per_imp_by_channel:
  dooh:     0.049
  social:   0.049
  streaming-video: 0.049
  ctv-bvod: 0.049
  audio:    0.049
  app:      0.049
  web:      0.049
```

## Lookups from external sources

### Carbon intensity by country, region, and UTC Date/Time

Providers should clearly and publicly document:

* Which data provider is used for carbon intensity data (for instance, WattTime or ElectricityMaps)
* What carbon intensity metric is used (marginal vs average)

`lookup_carbon_intensity_gco2e_per_kwh(country, region, utc_datetime)` should look up the carbon intensity in gCO2e based on 100-year global warming potential (GWP100) from a database at no less than hourly granularity.

`lookup_carbon_intensity_quality(country, region)` should return the quality of the underlying grid mix data on a scale of 1-5 per [Model Quality](./model_quality)

## Fallbacks

We use all data we have available on every single request but in many situations we may lack some information, for this
we have a series of fallbacks to be able to provide reasonable estimates in most situations.

To determine network when it's not submitted we calculate costs associated to network type
as a weighted average of the fixed and mobile usage in the country (if available) or worldwide.

We can also generally determine the channel from the property or when that is ambiguous but we have device information
we fall back to a default channel by device.

```
  pct_mobile =
      country ?
      default_percent_mobile_by_country[country] / 100 :
      default_percent_mobile / 100

  average_embodied_emissions_gco2e_per_kb =
      default_network_embodied_emissions_gco2e_per_kb['mobile'] x pct_mobile +
      default_network_embodied_emissions_gco2e_per_kb['fixed'] x (1 - pct_mobile)

  embodied_emissions_gco2e_per_kb =
      network_type ?
      default_network_embodied_emissions_gco2e_per_kb[network_type] :
      average_embodied_emissions_gco2e_per_kb

  average_usage_kwh_per_gb =
      default_usage_kwh_per_gb['mobile'] x pct_mobile +
      default_usage_kwh_per_gb['fixed'] x (1 - pct_mobile)

  usage_kwh_per_gb =
      network_type ?
      default_usage_kwh_per_gb['network_type'] :
      average_usage_kwh_per_gb

  average_baseload_watts =
      default_baseload_watts['mobile'] x pct_mobile +
      default_baseload_watts['fixed'] x (1 - pct_mobile)

  average_dynamic_watts_per_mbps =
      default_dynamic_watts_per_mbps['mobile'] x pct_mobile +
      default_dynamic_watts_per_mbps['fixed'] x (1 - pct_mobile)

  baseload_watts =
      network_type ?
      default_baseload_watts[network_type] :
      average_baseload_watts

  dynamic_watts_per_mbps =
      network_type ?
      default_dynamic_watts_per_mbps[network_type] :
      average_dynamic_watts_per_mbps

  lookup_channel:
      if property.channels.length == 1:
            return property.channels[0]
      if channel && channel in property.channels:
            return channel
      is_audio_creative =
            creative_audio_data_transfer_bytes ||
            creative_audio_duration_seconds ||
            ad_format.audio_duration_seconds
      if is_audio_creative && 'audio' in property.channels:
            return 'audio'
      if device_type && default_channel_by_device[device_type] in property.channels:
            return default_channel_by_device[device_type]
      return property.channels[0]

      channel = lookup_channel()
      device_type = device_type ? default_device_by_channel[channel]
```

## Calculating Emissions

### Creative Delivery - Data Transfer

```
creative_data_transfer_emissions_gco2_per_imp =
      creative_data_transfer_usage_emissions_gco2_per_imp +
      creative_data_transfer_embodied_emissions_gco2_per_imp
```

For all channels other than CTV/BVOD, use the conventional model:

```
creative_data_transfer_bytes =
      video_bytes +
      audio_bytes +
      image_bytes +
      ad_format.video_player.size_bytes +
      ad_format.other_asset_bytes

creative_data_transfer_usage_emissions_gco2 =
      creative_data_transfer_bytes / 1000 x
      usage_kwh_per_gb / 1000000 x
      lookup_carbon_intensity_gco2e_per_kwh(country, region, utc_datetime)

creative_data_transfer_embodied_emissions_gco2 =
      creative_data_transfer_bytes / 1000 x
      embodied_emissions_gco2e_per_kb
```

If data transfer is provided in the delivery row, use it:

```
image_bytes = creative_total_image_data_transfer_bytes
video_bytes = creative_total_video_data_transfer_bytes + (creative_video_vast_bytes x loads)
audio_bytes = creative_total_audio_data_transfer_bytes
```

Otherwise, calculate data transfer:

```
image_sizes = creative_image_sizes ? ad_format.image_sizes
image_bytes = SUM(image_sizes[n].width x image_sizes[n].height) x 3 / default_image_compression_ratio x impressions

audio_duration = creative_audio_duration_seconds ?? ad_format.audio_duration_seconds
audio_bytes = audio_duration_seconds x default_audio_bitrate_kbps[device_type] / 8 x 1000 x impressions

is_primary_experience = !ad_format.rendered_width_pixels && !ad_format.rendered_height_pixels
default_bitrate_kbps =
      is_primary_experience ?
      default_video_bitrate_kbps[device_type] :
      default_non_primary_video_bitrate_kbps
video_bitrate_kbps =
      creative_video_bitrate_kbps ??
      creative_video_size_bytes x 8 / 1000 / creative_video_duration  ??
      default_bitrate_kbps
video_duration = creative_video_duration_seconds ?? ad_format.video_duration_seconds
seconds_watched = creative_video_view_time_seconds ??
                  creative_video_view_rate x video_duration_seconds ??
                  video_duration_seconds
buffer = ad_format.video_player.buffering_seconds ?? infinity
seconds_streamed = MIN(seconds_watched + buffer, video_duration_seconds)
loads = switch(ad_format.video_player.download_trigger):
            'view': views
            'play': plays
            'impression': impressions


video_bytes = (video_bitrate_kbps / 8 x 1000 x seconds_streamed + creative_video_vast_bytes) x loads
```

For CTV/BVOD, use the power model:

```
video_bitrate_kbps = creative_video_bitrate_kbps ?? default_video_bitrate_kbps[device_type]

power_watts =
      baseload_watts +
      dynamic_watts_per_mbps x video_bitrate_kbps / 1000

creative_data_transfer_usage_emissions_gco2_per_imp =
      creative_video_duration_seconds / 3600 x
      power_watts / 1000 x
      lookup_carbon_intensity_gco2e_per_kwh(country, region, utc_datetime)

creative_data_transfer_embodied_emissions_gco2_per_imp =
      creative_video_duration_seconds x
      video_bitrate_kbps / 128 x
      embodied_emissions_gco2e_per_kb
```

### Creative Delivery - Platform

```
default_creative_platforms =
      ad_format.is_3p_served ?
      [generic_creative_ad_server, generic_measurement_platform] :
      []
creative_platforms = creative_ad_platforms ?? default_creative_platforms

creative_platform_emissions_gco2_per_imp = 0
for platform in [creative_platforms, ad_format.ad_platforms]:
      creative_platform_emissions_gco2_per_imp += platform.emissions_per_creative_request_per_geo_gco2_per_imp
```

### Creative Delivery - Consumer Device

```
audio_device_coverage =
      device_type == 'smart-speaker' ? 1 : 0
audio_device_coverage_seconds =
      audio_device_coverage x
      audio_duration

device_pixels = default_device_width[device_type] x default_device_height[device_type]
rendered_width = ad_format.rendered_width_pixels ?? default_device_width[device_type]
rendered_height = ad_format.rendered_height_pixels ?? default_device_height[device_type]
visual_device_coverage =
      is_primary_experience ?
      1 :
      MIN(1, rendered_width x rendered_height / device_pixels)
time_in_view =
      video_duration ??
      creative_time_in_view_seconds ??
      default_time_in_view_seconds

device_coverage_seconds =
      audio_duration ?
      audio_device_coverage_seconds :
      visual_device_coverage x time_in_view

creative_consumer_device_usage_emissions_gco2_per_imp =
      device_coverage_seconds / 3600 x
      default_device_watts[device_type] / 1000 x
      lookup_carbon_intensity_gco2e_per_kwh(country, region, utc_datetime)

creative_consumer_device_embodied_emissions_gco2_per_imp =
      device_coverage_seconds x
      default_device_embodied_emissions_per_second[device_type]
```

### Media Delivery - Data Transfer

```
media_data_transfer_emissions_gco2_per_imp =
      media_data_transfer_usage_emissions_gco2_per_imp +
      media_data_transfer_embodied_emissions_gco2_per_imp
```

Determing the session seconds for a single impressions

```
session_seconds_per_imp =
      property.average_seconds_per_session_excluding_ads x
      property.ad_funded_percentage/100 /
      property.average_imps_per_session
```

For all channels other than CTV/BVOD, use the conventional model:

```
media_data_transfer_kb_per_imp =
      property.average_data_kb_per_session_excluding_ads x
      property.ad_funded_percentage/100  /
      property.average_imps_per_session

media_data_transfer_usage_emissions_gco2_per_imp =
      media_data_transfer_kb_per_imp x
      usage_kwh_per_gb / 1000000 x
      lookup_carbon_intensity_gco2e_per_kwh(country, region, utc_datetime)

media_data_transfer_embodied_emissions_gco2_per_imp =
      media_data_transfer_kb_per_imp x
      embodied_emissions_gco2e_per_kb
```

For CTV/BVOD, use the power model:

```
video_bitrate_kbps = default_video_bitrate_kbps[device_type]

power_watts =
      baseload_watts +
      dynamic_watts_per_mbps x video_bitrate_kbps / 1000

media_data_transfer_usage_emissions_gco2_per_imp =
      session_seconds_per_imp / 3600 x
      power_watts / 1000 x
      lookup_carbon_intensity_gco2e_per_kwh(country, region, utc_datetime)

media_data_transfer_embodied_emissions_gco2_per_imp =
      session_seconds_per_imp x
      video_bitrate_kbps / 128 x
      embodied_emissions_gco2e_per_kb
```

### Media Delivery - Consumer Device

```
media_consumer_device_usage_emissions_gco2_per_imp =
      session_seconds_per_imp / 3600 x
      default_device_watts[device_type] / 1000 x
      lookup_carbon_intensity_gco2e_per_kwh(country, region, utc_datetime)

media_consumer_device_embodied_emissions_gco2_per_imp =
      session_seconds_per_imp x
      default_device_embodied_emissions_per_second[device_type]
```

### Media Delivery - Corporate

```
media_corporate_emissions_gco2_per_imp =
      property.allocated_adjusted_corporate_emissions_kg x 1000 /
      property.total_sessions /
      property.average_imps_per_session
```

### Ad Selection - Platform

```
get_platform_emissions(ad_platform):
      direct_emissions = emissions_per_bid_request_per_geo_gco2_per_imp
      rtdp_emissions = 0
      for rtdp in ad_platform.real_time_data_providers:
            rtdp_emissions += emissions_per_rtdp_request_per_geo_gco2_per_imp
      bidder_emissions = 0
      for bidder in ad_platform.bidders:
            bidder_emissions += get_platform_emissions(bidder) x
                  ad_platform.distribution_rate_by_bidder_by_country[country, bidder] ?? 1
      return direct_emissions + rtdp_emissions + bidder_emissions

get_platform_client_side_data_transfer(platform, is_client_side):
    if !is_client_side
        return 0
    bytes_sent = 0   
    for bidder in platform.bidders:
      bidder_bytes =
          bidder.average_bid_request_size ??
          default_consumer_device_request_size_bytes[channel]
      bytes_sent +=
          bidder_bytes x
          platform.distribution_rate_by_bidder_by_country[country, bidder] ?? 1
    return bytes_sent

get_platform_server_side_data_transfer(platform, is_client_side):
    bytes_sent = 0   
    for bidder in platform.bidders:
        bytes_sent += get_platform_server_side_data_transfer(bidder, false)
        if is_client_side:
          continue
        bidder_bytes =
            bidder.average_bid_request_size ??
            default_server_side_request_size_bytes
        bytes_sent +=
            bidder_bytes x
            platform.distribution_rate_by_bidder_by_country[country, bidder] ?? 1
    return bytes_sent

ad_selection_platform_emissions_gco2_per_imp = 0
client_side_data_transfer_bytes = 0
server_side_data_transfer_bytes = 0

for platform in placement.ad_platforms:
  ad_selection_platform_emissions_gco2_per_imp += get_platform_emissions(platform)
  client_side_data_transfer_bytes +=
      platform.average_bid_request_size ??
      default_consumer_device_request_size_bytes[channel]
  client_side_data_transfer_bytes += default_consumer_device_request_size_bytes[channel]
  client_side_data_transfer_bytes +=
      get_platform_client_side_data_transfer(platform, platform.sends_client_side_requests)
  server_side_data_transfer_bytes += 
      get_platform_server_side_data_transfer(platform, platform.sends_client_side_requests)
  
```

### Ad Selection - Data Transfer

```
ad_selection_client_side_data_transfer_usage_emissions_gco2_per_imp =
      client_side_data_transfer_bytes / 1024 x
      usage_kwh_per_gb / 1024 / 1024 x
      lookup_carbon_intensity_gco2e_per_kwh(country, region, utc_datetime)

ad_selection_client_side_data_transfer_embodied_emissions_gco2_per_imp =
      client_side_data_transfer_bytes / 1024 x
      embodied_emissions_gco2e_per_kb

ad_selection_server_side_data_transfer_usage_emissions_gco2_per_imp =
      server_side_data_transfer_bytes / 1024 x
      default_server_to_server_kwh_per_gb / 1024 / 1024 x
      lookup_carbon_intensity_gco2e_by_continent(country, region, utc_datetime)

ad_selection_server_side_data_transfer_embodied_emissions_gco2_per_imp =
      server_side_data_transfer_bytes / 1024 x
      default_server_to_server_embodied_emissions_gco2e_per_kb

ad_selection_data_transfer_emissions_gco2_per_imp =
      ad_selection_server_side_data_transfer_usage_emissions_gco2_per_imp +
      ad_selection_server_side_data_transfer_embodied_emissions_gco2_per_imp +
      ad_selection_client_side_data_transfer_usage_emissions_gco2_per_imp +
      ad_selection_client_side_data_transfer_embodied_emissions_gco2_per_imp
```

### Model Quality

```
grid_mix_model_quality = lookup_carbon_intensity_quality(country, region)
organization_model_quality = property.organization_model_quality
property_model_quality = property.model_quality

total_platforms = 0
modeled_platforms = 0
for platform in placement.ad_platforms:
  total_platforms++
  if platform.model_quality > 1
    modeled_platforms++
  # Model one level of downstream platforms
  for bidder in ad_platform.bidders:
    total_platforms++
    if bidder.model_quality > 1
      modeled_platforms++
ad_platform_modeled_ratio = modeled_platforms / total_platforms
```
