Skip to content

Commit

Permalink
Create inventory_wrf_plot.py
Browse files Browse the repository at this point in the history
  • Loading branch information
parkermac committed Nov 4, 2023
1 parent dcf9d4a commit 6b4c492
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions misc/inventory_wrf_plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
Plot the inventory of WRF files.
"""

from datetime import datetime, timedelta
from lo_tools import Lfun
import pandas as pd
Ldir = Lfun.Lstart()
from pathlib import Path
from time import time

testing = False
if 'mac' in Ldir['lo_env']:
wrf_dir = Ldir['data'] / 'wrf'
testing = True
elif 'apogee' in Ldir['lo_env']:
wrf_dir = Path('/pgdat1/parker/LO_data/wrf')
elif 'perigee' in Ldir['lo_env']:
wrf_dir = Path('/data1/parker/LO_data/wrf')

if testing:
year0 = 2019
year1 = 2019
dti = pd.date_range(start=datetime(year0,7,1), end=datetime(year1,7,7))
else:
year0 = 2012
year1 = datetime.now().year
dti = pd.date_range(start=datetime(year0,1,1), end=datetime(year1,12,31))

tt0 = time()
df = pd.DataFrame(index=dti,columns=['d2','d3','d4'])
for dt in dti:
fdir = wrf_dir / (dt.strftime('%Y%m%d')+'00')
if fdir.is_dir():
for dd in ['d2','d3','d4']:
ddl = list(fdir.glob('*'+dd+'*'))
ddl.sort()
df.loc[dt,dd] = len(ddl)
else:
pass
print('Total time = %0.1f sec' % (time()-tt0))

out_dir = Ldir['LOo'] / 'misc'
Lfun.make_dir(out_dir)
out_fn = out_dir / 'inventory_wrf.p'
print('DataFrame saved to ' + str(out_fn))
df.to_pickle(out_fn)

0 comments on commit 6b4c492

Please sign in to comment.