Skip to content

Instantly share code, notes, and snippets.

@joshreini1
Created October 7, 2022 20:18
Show Gist options
  • Save joshreini1/c5a870429e9694cf0502127afcdae9ea to your computer and use it in GitHub Desktop.
Save joshreini1/c5a870429e9694cf0502127afcdae9ea to your computer and use it in GitHub Desktop.
def get_feature_for_year_and_month(data_cache,year, month, suffix) -> pd.DataFrame:
if year not in data_cache:
data_cache[year] = load_data_for_year(year)
data = data_cache[year]
df = pd.DataFrame({
f'burned_fraction_{suffix}': data['burned_area/{:02}/burned_fraction'.format(month)],
f'emissions_DM_{suffix}': data['emissions/{:02}/DM'.format(month)],
f'emissions_C_{suffix}': data['emissions/{:02}/C'.format(month)],
f'emissions_small_fire_fraction_{suffix}': data['emissions/{:02}/small_fire_fraction'.format(month)],
f'biosphere_NPP_{suffix}': data['biosphere/{:02}/NPP'.format(month)],
f'biosphere_Rh_{suffix}': data['biosphere/{:02}/Rh'.format(month)],
f'biosphere_BB_{suffix}': data['biosphere/{:02}/BB'.format(month)],
})
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment