cal-adapt / climakitae

A Python toolkit for retrieving, visualizing, and performing scientific analyses with data from the Cal-Adapt Analytics Engine.
https://climakitae.readthedocs.io
BSD 3-Clause "New" or "Revised" License
21 stars 2 forks source link

Enable non-GUI view and retrieval of derived variables/indices #462

Closed nicolejkeeney closed 1 week ago

nicolejkeeney commented 2 weeks ago

Description of PR

Enable users to view and retrieve derived variables/indices without using the DataInterface GUI. This wasn't previously an option.

Summary of changes and related issue

Relevant motivation and context

When I wrote the two functions get_data_options() and get_data(), I didn't realize they didn't allow you to view/retrieve derived variables; you can only access the catalog variables. Calvin mentioned he needed to get the derived variables using the get_data() function, so I took the opportunity to improve the function.

NOTE: This required a shocking amount of code... the logic in climakitae for accessing the correct subset/combination of options for each variable is really complex.

These are the variable ("display") names of all the derived variables:

How to test

1) Run through the notebook climakitae_direct_data_download.ipynb to ensure that it still works correctly, since I modified the functions used in that notebook 2) Try retrieving some derived variables/indices. For example:

# See all the data combinations (i.e. different resolution, scenario, etc.) for the Fosberg fire weather index
get_data_options(variable = "Fosberg fire weather index")

# Retrieve data for the Fosberg fire weather index 
get_data(
    variable = "Fosberg fire weather index", 
    scenario = "Historical Climate", 
    timescale = "hourly", 
    resolution = "9 km",
    downscaling_method = "Dynamical", 
    time_slice = (1990,1991)
)

# See all the data combinations (i.e. different resolution, scenario, etc.) for Dew point temperature
get_data_options(variable = "Dew point temperature")

# Retrieve data for Dew point temperature 
get_data(
    variable = "Dew point temperature", 
    scenario = ["Historical Climate","SSP 2-4.5 -- Middle of the Road"], 
    timescale = "monthly", 
    resolution = "45 km",
    downscaling_method = "Dynamical",
    time_slice = (1990,2035)
)

Type of change


Definition of Done Checklist

Practical

Conceptual

nicolejkeeney commented 2 weeks ago

Enable derived variables/index retrieval without using GUI