Skip to content

Commit

Permalink
update example scripts for gfs and hrrr
Browse files Browse the repository at this point in the history
  • Loading branch information
cuill committed Nov 10, 2023
1 parent d9abee9 commit 8107b86
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
24 changes: 15 additions & 9 deletions examples/Sflux/gen_sflux_gfs2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
from time import time
import multiprocessing as mp
import logging
import pathlib

import numpy as np
import pandas as pd
from matplotlib.transforms import Bbox

from pyschism.mesh.hgrid import Hgrid
from pyschism.forcing.nws.nws2.gfs2 import GFS
from pyschism.dates import nearest_cycle


logging.basicConfig(
format="[%(asctime)s] %(name)s %(levelname)s: %(message)s",
force=True,
Expand All @@ -20,16 +23,19 @@
logging.getLogger('pyschism').setLevel(log_level)

if __name__ == "__main__":

t0 = time()
startdate = datetime(2021, 10, 13)

pscr = '/sciclone/pscr/lcui01/GFS/'
rnday = 5
record = 1
#now = datetime.now()
#last_cycle = np.datetime64(pd.DatetimeIndex([now-timedelta(hours=2)]).floor('6H').values[0], 'h').tolist()
#start = (last_cycle - timedelta(days=1)).replace(hour=0)
start = datetime(2023, 10, 1)
rnday = 10
#record = 5
#outdir = path = pathlib.Path('./GFS_2023')

hgrid = Hgrid.open('../../static/hgrid.gr3', crs='epsg:4326')

gfs = GFS(start_date=startdate, rnday=rnday, pscr=pscr, record=record, bbox=hgrid.bbox)

print(f'It took {(time()-t0)/60} mins to process {rnday} days, {record*24} records/day')
pscr = '/sciclone/pscr/lcui01/GFS/'
gfs = GFS(level=1, pscr=pscr, bbox=hgrid.bbox)
gfs.write(start_date=start, rnday=rnday, air=True, prc=True, rad=True)

print(f'It took {(time()-t0)/60} mins to process {rnday} days')
30 changes: 24 additions & 6 deletions examples/Sflux/gen_sflux_hrrr3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from datetime import datetime, timedelta
from time import time
import logging
import pathlib

import numpy as np
import pandas as pd
from matplotlib.transforms import Bbox

from pyschism.mesh.hgrid import Hgrid
from pyschism.forcing.nws.nws2.hrrr3 import HRRR
Expand All @@ -17,11 +22,24 @@

if __name__ == "__main__":
t0 = time()
rnday = 1
record = 1
startdate = nearest_cycle()
hgrid = Hgrid.open('../../static/hgrid.gr3', crs='epsg:4326')

#now = datetime.now()
#last_cycle = np.datetime64(pd.DatetimeIndex([now-timedelta(hours=2)]).floor('6H').values[0], 'h').tolist()
#print(last_cycle)

#start = (last_cycle - timedelta(days=1)).replace(hour=0)
#end = last_cycle + timedelta(days=2)

#rndelta = end -start
#rnday = rndelta.total_seconds() / 86400.
start = datetime(2023, 10, 26)
rnday = 2
hgrid = Hgrid.open('./hgrid.gr3', crs='epsg:4326')
#outdir = path = pathlib.Path('./HRRR_2017_2')
#bbox = Bbox.from_extents(-162, 60.79, -143, 69.1)


pscr='/sciclone/pscr/lcui01/HRRR/'
hrrr = HRRR(start_date=startdate, rnday=rnday, pscr=pscr, record=record, bbox=hgrid.bbox)
print(f'It took {(time()-t0)/60} mins to process {rnday} days, {record*24} files/day')
hrrr = HRRR(level=2, region='alaska', pscr=pscr, bbox=bbox)
hrrr.write(start_date=start, rnday=rnday, air=True, prc=True, rad=True)
print(f'It took {(time()-t0)/60} mins to process {rnday} days!')

0 comments on commit 8107b86

Please sign in to comment.