armanddemasson commited on
Commit
19905de
·
1 Parent(s): 01a4939

feat: added queries on huge countries in talk to ipcc

Browse files
climateqa/engine/talk_to_data/ipcc/config.py CHANGED
@@ -51,7 +51,9 @@ MACRO_COUNTRIES = ['JP',
51
  'ZA',
52
  'NZ',
53
  'TF',
54
- 'CL',
 
 
55
  'CA',
56
  'AU',
57
  'US',
 
51
  'ZA',
52
  'NZ',
53
  'TF',
54
+ ]
55
+
56
+ HUGE_MACRO_COUNTRIES = ['CL',
57
  'CA',
58
  'AU',
59
  'US',
climateqa/engine/talk_to_data/ipcc/plots.py CHANGED
@@ -154,7 +154,7 @@ def plot_choropleth_map_of_country_indicator_for_specific_year(
154
 
155
  fig.update_layout(
156
  mapbox_style="open-street-map",
157
- mapbox_zoom=3,
158
  height=800,
159
  mapbox_center={
160
  "lat": latitudes[len(latitudes)//2] if latitudes else 0,
 
154
 
155
  fig.update_layout(
156
  mapbox_style="open-street-map",
157
+ mapbox_zoom=2,
158
  height=800,
159
  mapbox_center={
160
  "lat": latitudes[len(latitudes)//2] if latitudes else 0,
climateqa/engine/talk_to_data/ipcc/queries.py CHANGED
@@ -1,6 +1,6 @@
1
  from typing import TypedDict, Optional
2
 
3
- from climateqa.engine.talk_to_data.ipcc.config import IPCC_DATASET_URL, MACRO_COUNTRIES
4
 
5
  class IndicatorPerYearAtLocationQueryParams(TypedDict, total=False):
6
  """
@@ -50,6 +50,14 @@ def indicator_per_year_at_location_query(
50
  GROUP BY scenario, year
51
  ORDER BY year, scenario
52
  """
 
 
 
 
 
 
 
 
53
  else:
54
  table_path = f"'{IPCC_DATASET_URL}/{table.lower()}/{country_code}.parquet'"
55
  sql_query = f"""
@@ -109,6 +117,14 @@ def indicator_for_given_year_query(
109
  GROUP BY latitude, longitude, scenario
110
  ORDER BY latitude, longitude, scenario
111
  """
 
 
 
 
 
 
 
 
112
  else:
113
  table_path = f"'{IPCC_DATASET_URL}/{table.lower()}/{country_code}.parquet'"
114
  sql_query = f"""
 
1
  from typing import TypedDict, Optional
2
 
3
+ from climateqa.engine.talk_to_data.ipcc.config import HUGE_MACRO_COUNTRIES, IPCC_DATASET_URL, MACRO_COUNTRIES
4
 
5
  class IndicatorPerYearAtLocationQueryParams(TypedDict, total=False):
6
  """
 
50
  GROUP BY scenario, year
51
  ORDER BY year, scenario
52
  """
53
+ elif country_code in HUGE_MACRO_COUNTRIES:
54
+ table_path = f"'{IPCC_DATASET_URL}/{table.lower()}/{country_code}_macro.parquet'"
55
+ sql_query = f"""
56
+ SELECT year, scenario, {indicator_column},
57
+ FROM {table_path}
58
+ WHERE latitude = {latitude} AND longitude = {longitude} AND year >= 1950
59
+ ORDER year, scenario
60
+ """
61
  else:
62
  table_path = f"'{IPCC_DATASET_URL}/{table.lower()}/{country_code}.parquet'"
63
  sql_query = f"""
 
117
  GROUP BY latitude, longitude, scenario
118
  ORDER BY latitude, longitude, scenario
119
  """
120
+ elif country_code in HUGE_MACRO_COUNTRIES:
121
+ table_path = f"'{IPCC_DATASET_URL}/{table.lower()}/{country_code}_macro.parquet'"
122
+ sql_query = f"""
123
+ SELECT latitude, longitude, scenario, {indicator_column},
124
+ FROM {table_path}
125
+ WHERE year = {year}
126
+ ORDER BY latitude, longitude, scenario
127
+ """
128
  else:
129
  table_path = f"'{IPCC_DATASET_URL}/{table.lower()}/{country_code}.parquet'"
130
  sql_query = f"""