def process_year_by_date_mean(year): # print 'Processing year : ' + str(year) cur_day = utils.get_current_day() cur_year = utils.get_current_year() buffer_obj = buffer(constants.db_name_date_mean) dir = str(year) if not os.path.exists(dir): return os.chdir(dir) start_day = constants.gdas_min_day if year == cur_year: end_day = cur_day else: end_day = constants.gdas_max_day # Process the files for a single day for day in range(start_day, end_day + 1): dir = str(day).zfill(3) if not os.path.exists(dir): continue try: os.chdir(dir) files = glob.glob("gdas*z") data = parse_grb_files.parse_files_by_date_mean(files) buffer_obj.insert_to_db(data, label=constants.label_date) os.chdir("../") except: pass os.chdir("../") os.chdir("../") buffer_obj.flush()
def execute_main(year=None): cur_year = utils.get_current_year() if year is None: years = range(constants.gdas_start_year + 1, cur_year + 1) else: years = [year] statistic = constants.stats_db.keys() tables = constants.features process_pool = [] for stat in statistic: for feature in tables: for year in years: p = Process(target=process_year, args=( year, feature, stat, )) process_pool.append(p) for p in process_pool: p.start() for p in process_pool: p.join()
def load_all_years_by_date_mean(): cur_year = utils.get_current_year() os.chdir(constants.data_dir) os.chdir(constants.gdas_data_dir) years = range(constants.gdas_start_year, cur_year + 1) process_pool = [] for year in years: p = Process(target=process_year_by_date_mean, args=(year, )) process_pool.append(p) for p in process_pool: p.start() for p in process_pool: p.join() return
def load_by_date_complete(): print('Current Working directory ', os.getcwd()) cur_year = utils.get_current_year() os.chdir(constants.data_dir) os.chdir(constants.gdas_data_dir) years = range(constants.gdas_start_year, cur_year + 1) process_pool = [] for year in years: p = Process(target=process_year_by_date_complete, args=(year, )) process_pool.append(p) for p in process_pool: p.start() for p in process_pool: p.join() return
def get_current_year_day(): year = utils.get_current_year () day = utils.get_current_day () return year, day