def do_day2(yyyymmdd='20200101', n=35, m=1): '''daemon like routine''' from glob import glob p_in = '/run/user/4986/' from xu import safe_run @safe_run def ncea(fin='/p/t*.nc', fout='/p/te.nc'): run(f'/cpc/home/li.xu/anaconda3/bin/ncea {fin} -O {fout}') for _ in range(10): print('cycle:', _) for i in range(n): date = ndates(i * 24, yyyymmdd, fmt='%Y-%m-%d') fin = f'{p_in}/*{date}*.nc' files = glob(fin) if len(files) == 0: continue count = 0 while len(files) < 22: print(date) print('wait: ', m, 'sec, for times:', count) time.sleep(m) count += 1 files = glob(fin) if count > 60: print('deleting...', files) run(f'rm -f {fin}') break else: time.sleep(1) print('all 24 files in:') fout = f'{p_out}/ufs_land_output.{date}.nc' print('fout:', fout) ncea(fin, fout) print('deleting...') run(f'rm -f {fin}')
def ncea(fin='/p/t*.nc', fout='/p/te.nc'): run(f'/cpc/home/li.xu/anaconda3/bin/ncea {fin} -O {fout}')