Created
October 7, 2022 20:08
-
-
Save joshreini1/dd316119c69470f688a3bf5ce0d50dc5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import h5py | |
def load_data_for_year(year) -> pd.DataFrame: | |
if year > 2016: | |
filename = f'GFED4.1s_{year}_beta.hdf5' | |
else: | |
filename = f'GFED4.1s_{year}.hdf5' | |
filepath = os.path.join(data_dir, filename) | |
data = h5py.File(filepath, 'r') | |
df = pd.DataFrame({ | |
'lat': data['lat'][:].flatten(), | |
'lon': data['lon'][:].flatten(), | |
}) | |
keys = ['burned_area/{:02}/burned_fraction', | |
'emissions/{:02}/DM', | |
'emissions/{:02}/C', | |
'emissions/{:02}/small_fire_fraction', | |
'biosphere/{:02}/NPP', | |
'biosphere/{:02}/Rh', | |
'biosphere/{:02}/BB'] | |
for month in range(1,13): | |
for key in keys: | |
key_str = key.format(month) | |
df[key_str] = data[key_str][:].flatten() | |
df = filter_to_west_us_region(df) | |
return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment