Legacy Data Interface
The climakitae.core.data_interface module is the main compatibility layer for the original climakitae API. It exposes the legacy parameter object, the data retrieval entry points, and the discovery helpers that powered the old GUI.
Warning
This page documents the legacy climakitae.core.data_interface module. It is kept for backward compatibility. New code should use climakitae.new_core.user_interface.ClimateData.
On this page
- What this module does
- Core concepts
- Query flow
- Legacy field names
- Examples
- Public API
- Notes on behavior
What this module does
The legacy data interface is responsible for:
- mapping human-readable GUI values to catalog values
- validating combinations of resolution, timescale, scenario, and spatial subset
- exposing data and subsetting option lookup helpers
- loading the cached data catalogs, variable metadata, station metadata, and boundary catalogs used by
DataParameters
Core concepts
| Concept | Legacy symbol | Role |
|---|---|---|
| Variable metadata | VariableDescriptions |
Loads variable_descriptions.csv once and keeps it available for option lookups |
| Shared data connections | DataInterface |
Singleton cache for catalogs, stations, boundaries, and warming-level tables |
| Query state | DataParameters |
Param-based configuration object used by the GUI and direct code paths |
| Data discovery | get_data_options() |
Returns the valid query combinations in legacy GUI language |
| Spatial discovery | get_subsetting_options() |
Returns valid boundaries and station geometry options |
| Data retrieval | get_data() / DataParameters.retrieve() |
Executes a legacy query and returns lazily loaded xarray data |
Query flow
DataParametersloads the singletonDataInterfaceand populates the available options.- Option observers keep fields like
resolution,timescale,scenario_ssp, andcached_areain sync. retrieve()orget_data()calls the catalog loader.- The loader returns an
xarray.DataArray,xarray.Dataset, or a list ofDataArrayobjects depending on the request.
Legacy field names
The legacy module uses GUI-style names instead of catalog-native names. Common examples:
| Legacy field | Meaning | Modern equivalent |
|---|---|---|
downscaling_method |
Dynamical, Statistical, or both | activity_id |
resolution |
3 km, 9 km, or 45 km | grid_label |
timescale |
hourly, daily, monthly | table_id |
scenario_ssp / scenario_historical |
Scenario selection buckets | experiment_id |
area_subset / cached_area |
Named boundary selection | clip processor |
time_slice |
Year range tuple | time_slice processor |
See Core Concepts for the full mapping.
Examples
Direct query with DataParameters
from climakitae.core.data_interface import DataParameters
params = DataParameters()
params.variable = "Air Temperature at 2m"
params.downscaling_method = "Dynamical"
params.resolution = "9 km"
params.timescale = "hourly"
params.scenario_historical = ["Historical Climate"]
params.scenario_ssp = ["SSP 3-7.0"]
params.area_subset = "CA counties"
params.cached_area = ["Los Angeles County"]
data = params.retrieve()
Direct query with get_data
from climakitae.core.data_interface import get_data
data = get_data(
variable="Air Temperature at 2m",
resolution="9 km",
timescale="hourly",
downscaling_method="Dynamical",
scenario=["Historical Climate", "SSP 3-7.0"],
area_subset="CA counties",
cached_area=["Los Angeles County"],
)
Public API
VariableDescriptions
Load Variable Desciptions CSV only once
This is a singleton class that needs to be called separately from DataInterface because variable descriptions are used without DataInterface in ck.view. Also ck.view is loaded on package load so this avoids loading boundary data when not needed.
Attributes:
| Name | Type | Description |
|---|---|---|
variable_descriptions |
DataFrame
|
pandas dataframe that stores available data variables usable with the package |
Source code in climakitae/core/data_interface.py
load()
Read the variable descriptions csv into class variable.
DataInterface
Load data connections into memory once
This is a singleton class called by the various Param classes to connect to the local data and to the intake data catalog and parquet boundary catalog. The class attributes are read only so that the data does not get changed accidentially.
Attributes:
| Name | Type | Description |
|---|---|---|
variable_descriptions |
DataFrame
|
variable descriptions pandas data frame |
stations |
DataFrame
|
station locations pandas data frame |
stations_gdf |
GeoDataFrame
|
station locations geopandas data frame |
data_catalog |
ESMDataSource
|
intake ESM data catalog |
boundary_catalog |
Catalog
|
parquet boundary catalog |
geographies |
Boundaries
|
boundary dictionaries class |
warming_level_times |
DataFrame
|
table of when each simulation/scenario reaches each warming level |
Source code in climakitae/core/data_interface.py
variable_descriptions
property
Get the variable descriptions dataframe
stations
property
Get the stations dataframe
stations_gdf
property
Get the stations geopandas dataframe
data_catalog
property
Get the data catalog
warming_level_times
property
Get the warming level times dataframe
boundary_catalog
property
Get the boundary catalog
geographies
property
Get the geographies object
DataParameters
Bases: Parameterized
Python param object to hold data parameters for use in panel GUI.
Call DataParameters when you want to select and retrieve data from the climakitae data catalog without using the ckg.Select GUI. ckg.Select uses this class to store selections and retrieve data.
DataParameters calls DataInterface, a singleton class that makes the connection to the intake-esm data store in S3 bucket.
Attributes:
| Name | Type | Description |
|---|---|---|
unit_options_dict |
dict
|
options dictionary for converting unit to other units |
area_subset |
str
|
dataset to use from Boundaries for sub area selection |
cached_area |
list of strs
|
one or more features from area_subset datasets to use for selection |
latitude |
tuple
|
latitude range of selection box |
longitude |
tuple
|
longitude range of selection box |
variable_type |
str
|
toggle raw or derived variable selection |
default_variable |
str
|
initial variable to have selected in widget |
time_slice |
tuple
|
year range to select |
resolution |
str
|
resolution of data to select ("3 km", "9 km", "45 km") |
timescale |
str
|
frequency of dataset ("hourly", "daily", "monthly") |
scenario_historical |
list of strs
|
historical scenario selections |
area_average |
str
|
whether to comput area average ("Yes", "No") |
downscaling_method |
str
|
whether to choose WRF or LOCA2 data or both ("Dynamical", "Statistical", "Dynamical+Statistical") |
data_type |
str
|
whether to choose gridded or station based data ("Gridded", "Stations") |
stations |
list or strs
|
list of stations that can be filtered by cached_area |
_station_data_info |
str
|
informational statement when station data selected with data_type |
scenario_ssp |
list of strs
|
list of future climate scenarios selected (availability depends on other params) |
simulation |
list of strs
|
list of simulations (models) selected (availability depends on other params) |
variable |
str
|
variable long display name |
units |
str
|
unit abbreviation currently of the data (native or converted) |
enable_hidden_vars |
boolean
|
enable selection of variables that are hidden from the GUI? |
extended_description |
str
|
extended description of the data variable |
variable_id |
list of strs
|
list of variable ids that match the variable (WRF and LOCA2 can have different codes for same type of variable) |
historical_climate_range_wrf |
tuple
|
time range of historical WRF data |
historical_climate_range_loca |
tuple
|
time range of historical LOCA2 data |
historical_climate_range_wrf_and_loca |
tuple
|
time range of historical WRF and LOCA2 data combined |
historical_reconstruction_range |
tuple
|
time range of historical reanalysis data |
ssp_range |
tuple
|
time range of future scenario SSP data |
_info_about_station_data |
str
|
warning message about station data |
_data_warning |
str
|
warning about selecting unavailable data combination |
data_interface |
DataInterface
|
data connection singleton class that provides data |
_data_catalog |
ESMDataSource
|
shorthand alias to DataInterface.data_catalog |
_variable_descriptions |
DataFrame
|
shorthand alias to DataInterface.variable_descriptions |
_stations_gdf |
GeoDataFrame
|
shorthand alias to DataInterface.stations_gdf |
_geographies |
Boundaries
|
shorthand alias to DataInterface.geographies |
_geography_choose |
dict
|
shorthand alias to Boundaries.boundary_dict() |
_warming_level_times |
DataFrame
|
shorthand alias to DataInterface.warming_level_times |
colormap |
str
|
default colormap to render the currently selected data |
scenario_options |
list of strs
|
list of available scenarios (historical and ssp) for selection |
variable_options_df |
DataFrame
|
filtered variable descriptions for the downscaling_method and timescale |
warming_level |
array
|
global warming level(s) |
warming_level_window |
integer
|
years around Global Warming Level (+/-) (e.g. 15 means a 30yr window) |
approach |
(str, 'Warming Level' or Time)
|
how do you want the data to be retrieved? |
warming_level_months |
array
|
months of year to use for computing warming levels default to entire calendar year: 1,2,3,4,5,6,7,8,9,10,11,12 |
all_touched |
boolean
|
spatial subset option for within or touching selection |
Source code in climakitae/core/data_interface.py
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 | |
retrieve(config=None, merge=True)
Retrieve data from catalog
By default, DataParameters determines the data retrieved. Grabs the data from the AWS S3 bucket, returns lazily loaded dask array. User-facing function that provides a wrapper for read_catalog_from_select.
Returns:
| Name | Type | Description |
|---|---|---|
data_return |
DataArray | Dataset | List[DataArray]
|
DataArray or Dataset object |
Source code in climakitae/core/data_interface.py
1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 | |
get_data_options
Get data options, in the same format as the Select GUI, given a set of possible inputs. Allows the user to access the data using the same language as the GUI, bypassing the sometimes unintuitive naming in the catalog. If no function inputs are provided, the function returns the entire AE catalog that is available via the Select GUI
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
Default to None |
None
|
downscaling_method
|
str
|
Default to None |
None
|
resolution
|
str
|
Default to None |
None
|
timescale
|
str
|
Default to None |
None
|
scenario
|
str or list
|
Default to None |
None
|
tidy
|
boolean
|
Format the pandas dataframe? This creates a DataFrame with a MultiIndex that makes it easier to parse the options. Default to True |
True
|
enable_hidden_vars
|
boolean
|
Return all variables, including the ones in which "show" is set to False? Default to False |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
cat_subset |
DataFrame
|
Catalog options for user-provided inputs |
Source code in climakitae/core/data_interface.py
1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 | |
get_subsetting_options
Get all geometry options for spatial subsetting. Options match those in selections GUI
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area_subset
|
str
|
One of "all", "states", "CA counties", "CA Electricity Demand Forecast Zones", "CA watersheds", "CA Electric Balancing Authority Areas", "CA Electric Load Serving Entities (IOU & POU)", "Stations" Defaults to "all", which shows all the geometry options with area_subset as a multiindex |
'all'
|
Returns:
| Name | Type | Description |
|---|---|---|
geom_df |
DataFrame
|
Geometry options Shows only options for one area_subset if input is provided that is not "all" i.e. if area_subset = "states", only the options for states will be returned |
Source code in climakitae/core/data_interface.py
1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 | |
get_data
Retrieve formatted data from the Analytics Engine data catalog.
Contrasts with DataParameters().retrieve(), which retrieves data from the user inputs in climakitaegui's selections GUI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
String name of climate variable |
required |
resolution
|
str, one of ["3 km", "9 km", "45 km"]
|
Resolution of data in kilometers |
required |
timescale
|
str, one of ["hourly", "daily", "monthly"]
|
Temporal frequency of dataset |
required |
downscaling_method
|
str, one of ["Dynamical", "Statistical", "Dynamical+Statistical"]
|
Downscaling method of the data: WRF ("Dynamical"), LOCA2 ("Statistical"), or both "Dynamical+Statistical" Default to "Dynamical" |
'Dynamical'
|
data_type
|
str, one of ["Gridded", "Stations"]
|
Whether to choose gridded data or weather station data Default to "Gridded" |
'Gridded'
|
approach
|
one of ["Time", "Warming Level"]
|
Default to "Time" |
'Time'
|
scenario
|
str or list of str
|
SSP scenario ["SSP 3-7.0", "SSP 2-4.5","SSP 5-8.5"] and/or historical data selection ["Historical Climate", "Historical Reconstruction"] If approach = "Time", you need to set a valid option If approach = "Warming Level", scenario is ignored |
None
|
units
|
str
|
Variable units. Defaults to native units of data |
None
|
area_subset
|
str
|
Area category: i.e "CA counties" Defaults to entire domain ("none") |
'none'
|
cached_area
|
list
|
Area: i.e "Alameda county" Defaults to entire domain (["entire domain"]) |
None
|
area_average
|
one of ["Yes","No"]
|
Take an average over spatial domain? Default to "No". |
None
|
latitude
|
None or tuple of float
|
Tuple of valid latitude bounds Default to entire domain |
None
|
longitude
|
None or tuple of float
|
Tuple of valid longitude bounds Default to entire domain |
None
|
time_slice
|
tuple
|
Time range for retrieved data Only valid for approach = "Time" |
None
|
stations
|
list of str
|
Which weather stations to retrieve data for Only valid for data_type = "Stations" Default to all stations |
None
|
warming_level
|
list of float
|
Must be one of the warming levels available in |
None
|
warming_level_window
|
int in range(5, 25)
|
Years around Global Warming Level (+/-) (e.g. 15 means a 30yr window) |
None
|
warming_level_months
|
list of int
|
Months of year for which to perform warming level computation Default to all months in a year: [1,2,3,4,5,6,7,8,9,10,11,12] For example, you may want to set warming_level_months=[12,1,2] to perform the analysis for the winter season. Only valid for approach = "Warming Level" and data_type = "Stations" |
None
|
all_touched
|
boolean
|
spatial subset option for within or touching selection |
False
|
enable_hidden_vars
|
boolean
|
Return all variables, including the ones in which "show" is set to False? Default to False |
False
|
kwargs
|
dict
|
Additional keyword arguments to pass to DataParameters() |
{}
|
Returns:
| Type | Description |
|---|---|
DataArray
|
The requested climate data, or None if an error occurred. |
Notes
Errors aren't raised by the function. Rather, an appropriate informative message is printed, and the function returns None. This is due to the fact that the AE Jupyter Hub raises a strange Pieces Mismatch Error for some bad inputs; instead, that error is ignored and a more informative error message is printed instead.
Source code in climakitae/core/data_interface.py
1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 | |
Notes on behavior
DataParameters.retrieve()is the closest analogue to the old GUI workflow.get_data_options()andget_subsetting_options()are useful when you need to discover valid values programmatically.- The module does not raise on every bad input. In several cases it prints a diagnostic message and returns
Noneto match the original notebook behavior. get_data()is the lower-level direct entry point and accepts the same legacy naming conventions as the GUI.