This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Greetings!
Due to the way the grib collections are structured by the THREDDS Data Server,
you need to use `.catalog_refs` rather than `.datasets`. So that code would
work as:
cat = TDSCatalog('http://thredds.ucar.edu/thredds/catalog/grib/'
'NCEP/GFS/Global_0p25deg/catalog.xml')
# Find the run closest to 6 hours ago
time = datetime.utcnow() - timedelta(hours=6)
ds = cat.catalog_refs.filter_time_nearest(time)
# Find all runs from the last day
end = datetime.utcnow()
start = end - timedelta(days=1)
cat.catalog_refs.filter_time_range(start, end)
Also, if you're accessing model data, you just might be better off using the
'Full Collection (Reference / Forecast Time) Dataset', 'Best GFS Quarter Degree
Forecast Time Series', or 'Latest Collection for GFS Quarter Degree Forecast'
datasets that *are* available within the `.datasets` attribute. You can also
see them listed at the top of the catalog here:
https://thredds.ucar.edu/thredds/catalog/grib/NCEP/GFS/Global_0p25deg/catalog.html
Hope this helps,
Ryan
> Ryan !
>
> I'm trying to get filter_time_nearest to work. I tried the code in
> https://www.unidata.ucar.edu/blogs/news/entry/siphon-0-5 (and changed
> "cat.filter_time_nearest(time)" to "cat.datasets.filter_time_nearest(time)"
> ), but I get "No datasets with times found".
>
> Suggestions ?
Ticket Details
===================
Ticket ID: VOC-640241
Department: Support Python
Priority: Low
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata
inquiry tracking system and then made publicly available through the web. If
you do not want to have your interactions made available in this way, you must
let us know in each email you send to us.