Skip to content

Instantly share code, notes, and snippets.

@johannah
Created February 4, 2018 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johannah/d4a70fd2fd40d5cf176437fbb380308a to your computer and use it in GitHub Desktop.
Save johannah/d4a70fd2fd40d5cf176437fbb380308a to your computer and use it in GitHub Desktop.
import os, sys
from glob import glob
from IPython import embed
from subprocess import call
# example <a href='catalog.html?dataset=NOAA/CBOFS/MODELS/201710/nos.cbofs.stations.nowcast.20171031.t18z.nc'><tt>nos.cbofs.stations.nowcast.20171031.t18z.nc</tt></a></td>^M
fpaths = glob('/localdata/jhansen/thredds/opendap.co-ops.nos.noaa.gov/thredds/catalog/NOAA/*')
output = '/localdata/jhansen/thredds/ncfiles'
fileServer = 'https://opendap.co-ops.nos.noaa.gov/thredds/fileServer/'
for station in fpaths:
# only get stations which have fairly open oceans
if os.path.split(station)[1] in ['TBOFS','NGOFS', 'GOMOFS', 'DBOFS', 'CREOFS', 'CBOFS']:
print("Getting %s" %station)
station_dates = glob(os.path.join(station, 'MODELS/*'))
print(station_dates)
for d in station_dates:
cat = (os.path.join(d, 'catalog.html'))
if os.path.exists(cat):
ll = open(cat, 'r').readlines()
for l in ll:
if '.nc' in l:
le = l.index('.nc')
ls = l.index('dataset=')
ncpath = l[ls+len('dataset='):le+len('.nc')]
p = fileServer+ncpath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment