def test_good_level3_query(self): """Test that a valid level 3 query succeeds.""" dt = datetime(2015, 6, 15, 12, 0, 0) client = RadarServer(self.server + '/nexrad/level3/IDD/') q = client.query().stations('FTG').time(dt).variables('N0Q') cat = client.get_catalog(q) assert len(cat.datasets) == 1
def test_bad_query_raises(self): """Test that a bad query raises an error.""" dt = datetime(2015, 6, 15, 12, 0, 0) client = RadarServer(self.server + '/nexrad/level3/IDD') q = client.query().stations('FTG').time(dt) with pytest.raises(BadQueryError): client.get_catalog(q)
import warnings warnings.filterwarnings("ignore", category=matplotlib.cbook.MatplotlibDeprecationWarning) get_ipython().magic(u'matplotlib inline') # First we'll create an instance of RadarServer to point to the appropriate radar server access URL. # In[2]: # The S3 URL did not work for me, despite .edu domain #url = 'http://thredds-aws.unidata.ucar.edu/thredds/radarServer/nexrad/level2/S3/' #Trying motherlode URL url = 'http://thredds.ucar.edu/thredds/radarServer/nexrad/level2/IDD/' from siphon.radarserver import RadarServer rs = RadarServer(url) # Next, we'll create a new query object to help request the data. Using the chaining methods, let's ask for the latest data at the radar KLVX (Louisville, KY). We see that when the query is represented as a string, it shows the encoded URL. # In[3]: from datetime import datetime, timedelta query = rs.query() query.stations('KLVX').time(datetime.utcnow()) # We can use the RadarServer instance to check our query, to make sure we have required parameters and that we have chosen valid station(s) and variable(s) # # In[4]:
def setup(self): self.server = 'http://thredds.ucar.edu/thredds/radarServer/' self.client = RadarServer(self.server + 'nexrad/level2/IDD')
def test_rs_constructor_throws(): with pytest.raises(HTTPError): RadarServer('http://thredds-aws.unidata.ucar.edu/thredds/' 'radarServer/nexrad/level2/S3/')
def test_catalog_access(self): ds = get_radarserver_datasets('http://thredds.ucar.edu/thredds/') url = ds['NEXRAD Level III Radar from IDD'].follow().catalog_url assert RadarServer(url)
def test_bad_query_raises(self): dt = datetime(2015, 6, 15, 12, 0, 0) client = RadarServer(self.server + '/nexrad/level3/IDD') q = client.query().stations('FTG').time(dt) client.get_catalog(q)
def test_rs_constructor_throws(self): RadarServer('http://thredds-aws.unidata.ucar.edu/thredds/' 'radarServer/nexrad/level2/S3/')
def test_good_level3_query(self): dt = datetime(2015, 6, 15, 12, 0, 0) client = RadarServer(self.server + '/nexrad/level3/IDD/') q = client.query().stations('FTG').time(dt).variables('N0Q') cat = client.get_catalog(q) eq_(len(cat.datasets), 1)
def setup(self): """Set up server and client for tests.""" self.server = 'http://thredds.ucar.edu/thredds/radarServer/' self.client = RadarServer(self.server + 'nexrad/level2/IDD')
def test_rs_constructor_throws(): """Test that setting up radar server access raises an error for permission denied.""" with pytest.raises(HTTPError): RadarServer('http://thredds-aws.unidata.ucar.edu/thredds/' 'radarServer/nexrad/level2/S3/')
def test_catalog_access(self): """Test that getting datasets returns a proper catalog.""" ds = get_radarserver_datasets('http://thredds.ucar.edu/thredds/') url = ds['NEXRAD Level III Radar from IDD'].follow().catalog_url assert RadarServer(url)
# -*- coding: utf-8 -*- """ Created on Sun Oct 13 20:06:26 2019 @author: Emmanuel """ from datetime import datetime, timedelta from siphon.catalog import TDSCatalog from siphon.radarserver import RadarServer import cartopy import matplotlib.pyplot as plt import numpy as np from siphon.cdmr import Dataset cat = TDSCatalog('http://thredds.ucar.edu/thredds/radarServer/catalog.xml') rs = RadarServer(cat.catalog_refs['NEXRAD Level III Radar from IDD'].href) query = rs.query() now = datetime.utcnow() query.stations('FTG').time_range(now - timedelta(hours=1), now).variables('N0Q') query_cat = rs.get_catalog(query) list(cat.catalog_refs) #pour utiliser n'importe quelle partie du catalogue d'UCAR cat.catalog_refs['NEXRAD Level III Radar from IDD'].href rs = RadarServer(cat.catalog_refs['NEXRAD Level III Radar from IDD'].href) data = query_cat.datasets[0].remote_access()
auth_client = APIKeyAuthClient(args.CARTO_BASE_URL, args.CARTO_API_KEY) sql_client = SQLClient(auth_client) copy_client = CopySQLClient(auth_client) # Create a table suitable to receive the data logger.info('Creating table nexrad_copy_example...') sql_client.send("""CREATE TABLE IF NOT EXISTS nexrad_copy_example ( the_geom geometry(Geometry,4326), reflectivity numeric )""") sql_client.send( "SELECT CDB_CartodbfyTable(current_schema, 'nexrad_copy_example')") logger.info('Done') logger.info('Trying to connect to the THREDDS radar query service') rs = RadarServer( 'http://thredds.ucar.edu/thredds/radarServer/nexrad/level2/IDD/') logger.info('Quering data from the station') query = rs.query() query.stations('KLVX').time(datetime.utcnow()) assert rs.validate_query(query) catalog = rs.get_catalog(query) logger.info('Avaliable datasets: %s' % catalog.datasets) logger.info('Using the first one') ds = list(catalog.datasets.values())[0] data = Dataset(ds.access_urls['CdmRemote']) logger.info('Got the following data: %s' % data.Title) logger.info(data.Summary)
import matplotlib import warnings from datetime import datetime, timedelta from siphon.radarserver import RadarServer from siphon.cdmr import Dataset import numpy as np from metpy.plots import ctables # For NWS colortable import matplotlib.pyplot as plt import cartopy rs = RadarServer( 'http://thredds-aws.unidata.ucar.edu/thredds/radarServer/nexrad/level2/S3/' ) warnings.filterwarnings("ignore", category=matplotlib.cbook.MatplotlibDeprecationWarning) query = rs.query() query.stations('KLVX').time(datetime.utcnow()) rs.validate_query(query) catalog = rs.get_catalog(query) # We can pull that dataset out of the dictionary and look at the available access URLs. We see URLs for OPeNDAP, CDMRemote, and HTTPServer (direct download). ds = list(catalog.datasets.values())[0] # ds.access_urls will be something like #