Skip to content

Commit

Permalink
update example scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
cuill committed Aug 25, 2023
1 parent f43b552 commit aa71859
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/Sflux/gen_sflux_era5.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
if __name__ == '__main__':

startdate=datetime(2018, 1, 1)
rnday=366
rnday=30 #limit rnday less than 180 days (size constrain from cdsapi)

t0=time()
hgrid=Hgrid.open('./hgrid.gr3',crs='EPSG:4326')
Expand Down
4 changes: 2 additions & 2 deletions examples/Sflux/gen_sflux_gfs2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

pscr = '/sciclone/pscr/lcui01/GFS/'
rnday = 5
record = 1
record = 1 # parameter for how many days of time records in each nc file (1 for hindcast, > 1 for forecast)

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

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

Expand Down
9 changes: 5 additions & 4 deletions examples/Sflux/gen_sflux_hrrr3.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

if __name__ == "__main__":
t0 = time()
startdate = datetime(2018, 1, 1)
rnday = 1
record = 1
startdate = nearest_cycle()
hgrid = Hgrid.open('../../static/hgrid.gr3', crs='epsg:4326')
record = 1 #parameter of how many days of time records in each nc file (1-for hindcast, >1 for forecast)
#startdate = nearest_cycle()
hgrid = Hgrid.open('./hgrid.gr3', crs='epsg:4326')

pscr='/sciclone/pscr/lcui01/HRRR/'
pscr='/sciclone/pscr/lcui01/HRRR/' #tmp dir for saving downloaded grib file
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')
12 changes: 6 additions & 6 deletions pyschism/forcing/hycom/hycom2schism.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def get_database(date, Bbox=None):

def get_idxs(date, database, bbox, lonc=None, latc=None):

if date >= datetime.utcnow():
date2 = datetime.utcnow() - timedelta(days=1)
if date >= datetime.now():
date2 = datetime.now() - timedelta(days=1)
baseurl = f'https://tds.hycom.org/thredds/dodsC/{database}/FMRC/runs/GLBy0.08_930_FMRC_RUN_{date2.strftime("%Y-%m-%dT12:00:00Z")}?depth[0:1:-1],lat[0:1:-1],lon[0:1:-1],time[0:1:-1]'
else:
baseurl=f'https://tds.hycom.org/thredds/dodsC/{database}?lat[0:1:-1],lon[0:1:-1],time[0:1:-1],depth[0:1:-1]'
Expand Down Expand Up @@ -406,8 +406,8 @@ def fetch_data(self, outdir: Union[str, os.PathLike], start_date, rnday, ocean_b

time_idx, lon_idx1, lon_idx2, lat_idx1, lat_idx2, x2, y2, _ = get_idxs(date, database, bbox, lonc=blonc, latc=blatc)

if date >= datetime.utcnow():
date2 = datetime.utcnow() - timedelta(days=1)
if date >= datetime.now():
date2 = datetime.now() - timedelta(days=1)
url = f'https://tds.hycom.org/thredds/dodsC/{database}/FMRC/runs/GLBy0.08_930_FMRC_RUN_' + \
f'{date2.strftime("%Y-%m-%dT12:00:00Z")}?depth[0:1:-1],lat[{lat_idx1}:1:{lat_idx2}],' + \
f'lon[{lon_idx1}:1:{lon_idx2}],time[{time_idx}],' + \
Expand Down Expand Up @@ -720,8 +720,8 @@ def fetch_data(self, outdir: Union[str, os.PathLike], vgrid, start_date, rnday,

time_idx, lon_idx1, lon_idx2, lat_idx1, lat_idx2, x2, y2, _ = get_idxs(date, database, bbox, lonc=nlonc, latc=nlatc)

if date >= datetime.utcnow():
date2 = datetime.utcnow() - timedelta(days=1)
if date >= datetime.now():
date2 = datetime.now() - timedelta(days=1)
url = f'https://tds.hycom.org/thredds/dodsC/{database}/FMRC/runs/GLBy0.08_930_FMRC_RUN_' + \
f'{date2.strftime("%Y-%m-%dT12:00:00Z")}?depth[0:1:-1],lat[{lat_idx1}:1:{lat_idx2}],' + \
f'lon[{lon_idx1}:1:{lon_idx2}],time[{time_idx}],' + \
Expand Down

0 comments on commit aa71859

Please sign in to comment.