Average hours of each month with files located in multiple folders in Python

Viewed 26

Background: I am working with .nc files which I downloaded in mass using a package called goes2go. The way the data is downloaded is that, for example, if I want data for January 2018, then it created a folder called 2018. Within that folder are 31 folders representing the days, and within each day folder are 24 folders representing the hours. When I click on an hour folder, there are 6 files.

Question: I want to average all the hours for the month of January and eventually do it for each month for the years of 2018-2020. I am incredibly stuck and have no clue how to begin especially since the data is all in different folders within each folder, but here is what I have so far:

import os
from glob import glob

import netCDF4 as nc
from netCDF4 import Dataset
import xarray 

#set directory
t= os.chdir("C:/Users/elain/data/noaa-goes16/ABI-L2-ACMC")
print("Current directory", os.getcwd())

data_path = os.path.join("2018")
print(data_path)
stack_bands_path = glob(os.path.join(data_path))
print(stack_bands_path)

Thank you so much.

0 Answers
Related