0% found this document useful (0 votes)
36 views

End Datetime - Utcnow : # Find All Runs From The Last Day

The document discusses using a TDS catalog to filter GOES-16 satellite data for Hurricane Irma by time range, retrieving netcdf files for a specific date and location. Code examples are provided to connect to a catalog, filter datasets by time, and print results.

Uploaded by

Jeremy Fl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

End Datetime - Utcnow : # Find All Runs From The Last Day

The document discusses using a TDS catalog to filter GOES-16 satellite data for Hurricane Irma by time range, retrieving netcdf files for a specific date and location. Code examples are provided to connect to a catalog, filter datasets by time, and print results.

Uploaded by

Jeremy Fl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 6

from datetime import datetime

from siphon.catalog import TDSCatalog


from datetime import timedelta
from siphon.catalog import TDSCatalog

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)
ds

RESULT:

Out[26]: GFS_Global_0p25deg_20180129_1800.grib2

from datetime import datetime


from siphon.catalog import TDSCatalog

cat = TDSCatalog('http://thredds.ucar.edu/thredds/catalog/grib/'
'NCEP/GFS/Global_0p25deg/catalog.xml')
# Find all runs from the last day
end = datetime.utcnow()
start = end - timedelta(days=1)
datasets = cat.catalog_refs.filter_time_range(start, end)

RESULT:

Out[29]:
[GFS_Global_0p25deg_20180129_0600.grib2,
GFS_Global_0p25deg_20180129_1200.grib2,
GFS_Global_0p25deg_20180129_1800.grib2]
siphon.ncss

This module contains code to support making data requests to the NetCDF subset service (NCSS)
on a THREDDS Data Server (TDS). This includes forming proper queries as well as parsing the
returned data.

# Copyright (c) 2013-2015 University Corporation


for Atmospheric Research/Unidata.
# Distributed under the terms of the MIT License.
# SPDX-License-Identifier: MIT
"""Support making data requests to the NetCDF subset
service (NCSS) on a TDS.
This includes forming proper queries as well as parsing
the returned data.
"""

Example 1:

from siphon.ncss import NCSS


cat = TDSCatalog('http://thredds.ucar.edu/thredds/catalog/grib/'
'NCEP/GFS/Global_0p25deg/catalog.xml')
ds = list(cat.datasets.values())[0]
ncss = NCSS(ds.access_urls['NetcdfSubset'])

RESULT:

ds
Out[51]: Full Collection (Reference / Forecast Time) Dataset

ncss
Out[52]: <siphon.ncss.NCSS at 0x7fac36ecd438>
Example:

url = ('http://thredds.ucar.edu/thredds/catalog/grib/NCEP/NAM/'
'CONUS_20km/noaaport/catalog.xml')
cat = TDSCatalog(url)
in_range = cat.catalog_refs.filter_time_range(datetime(2018, 1, 24, 6),
datetime(2018, 1, 30, 0))
titles = [item.title for item in in_range]

RESULT:

titles
Out[34]:
['NAM_CONUS_20km_noaaport_20180124_0600.grib1',
'NAM_CONUS_20km_noaaport_20180124_1200.grib1',
'NAM_CONUS_20km_noaaport_20180124_1800.grib1',
'NAM_CONUS_20km_noaaport_20180125_0000.grib1',
'NAM_CONUS_20km_noaaport_20180125_0600.grib1',
'NAM_CONUS_20km_noaaport_20180125_1200.grib1',
'NAM_CONUS_20km_noaaport_20180125_1800.grib1',
'NAM_CONUS_20km_noaaport_20180126_0000.grib1',
'NAM_CONUS_20km_noaaport_20180126_0600.grib1',
'NAM_CONUS_20km_noaaport_20180126_1200.grib1',
'NAM_CONUS_20km_noaaport_20180126_1800.grib1',
'NAM_CONUS_20km_noaaport_20180127_0000.grib1',
'NAM_CONUS_20km_noaaport_20180127_0600.grib1',
'NAM_CONUS_20km_noaaport_20180127_1200.grib1',
'NAM_CONUS_20km_noaaport_20180127_1800.grib1',
'NAM_CONUS_20km_noaaport_20180128_0000.grib1',
'NAM_CONUS_20km_noaaport_20180128_0600.grib1',
'NAM_CONUS_20km_noaaport_20180128_1200.grib1',
'NAM_CONUS_20km_noaaport_20180128_1800.grib1',
'NAM_CONUS_20km_noaaport_20180129_0000.grib1',
'NAM_CONUS_20km_noaaport_20180129_0600.grib1',
'NAM_CONUS_20km_noaaport_20180129_1200.grib1',
'NAM_CONUS_20km_noaaport_20180129_1800.grib1']
from datetime import datetime
from siphon.catalog import TDSCatalog
from datetime import timedelta

cat = TDSCatalog('http://thredds-test.unidata.ucar.edu/thredds/catalog/'
'casestudies/irma/goes16/catalog.xml')
meso = cat.catalog_refs['Mesoscale-1'].follow()
channel = meso.catalog_refs['Channel02'].follow()
date_cat = channel.catalog_refs['20170906'].follow()

date = datetime(2017, 9, 6, 21)


datasets = date_cat.datasets.filter_time_range(date - timedelta(hours=1),
date + timedelta(hours=1))
print(datasets)

RESULT:

[GOES16_Mesoscale-1_20170906_200024_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200054_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200124_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200154_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200224_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200254_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200324_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200354_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200424_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200454_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200524_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200554_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200624_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200654_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200724_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200754_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200824_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200854_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200924_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_200954_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201024_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201054_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201124_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201154_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201224_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201254_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201324_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201354_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201424_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201454_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201524_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201554_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201624_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201654_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201724_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201754_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201824_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201854_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201924_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_201954_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202024_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202054_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202124_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202154_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202224_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202254_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202324_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202354_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202424_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202454_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202524_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202554_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202624_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202654_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202724_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202754_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202824_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202854_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202924_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_202954_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203024_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203054_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203124_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203154_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203224_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203254_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203324_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203354_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203424_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203454_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203524_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203554_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203624_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203654_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203724_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203754_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203824_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203854_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203924_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_203954_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204024_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204054_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204124_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204154_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204224_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204254_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204324_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204354_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204424_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204454_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204524_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204554_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204624_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204654_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204724_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204754_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204824_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204854_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204924_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_204954_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205024_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205054_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205124_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205154_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205224_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205254_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205324_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205354_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205424_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205454_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205524_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205554_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205624_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205654_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205724_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205754_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205824_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205854_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-
1_20170906_205924_0.64_500m_19.0N_64.3W.nc4, GOES16_Mesoscale-

Bibliografía:

https://github.com/Unidata/siphon/blob/master/siphon/ncss.py
https://www.unidata.ucar.edu/blogs/news/entry/siphon-0-5
https://github.com/Unidata/siphon/blob/master/siphon/ncss.py

You might also like