-
Notifications
You must be signed in to change notification settings - Fork 16
/
CMRE_Demo.py
71 lines (46 loc) · 1.53 KB
/
CMRE_Demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <headingcell level=1>
# CMRE search, access and visualize demo
# <headingcell level=2>
# Search for data using OGC Catalog Service for the Web (CSW)
# <codecell>
from owslib.csw import CatalogueServiceWeb
from owslib import fes
import netCDF4
import numpy as np
# <codecell>
endpoint='http://scsrv26v:8000/pycsw'
#endpoint='http://www.ngdc.noaa.gov/geoportal/csw'
csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.version
# <codecell>
box=[38., 6., 41., 9.] # lon_min lat_min lon_max lat_max
start_date='2014-03-12 18:00'
stop_date='2014-09-18 18:00'
val = 'sea_water_potential_temperature'
# <codecell>
# convert User Input into FES filters
start,stop = dateRange(start_date,stop_date)
bbox = fes.BBox(box)
any_text = fes.PropertyIsLike(propertyname='apiso:AnyText',literal=('*%s*' % val),
escapeChar='\\',wildCard='*',singleChar='?')
# <codecell>
# combine filters into a list
filter_list = [fes.And([ start, stop, bbox,any_text]) ]
# <codecell>
csw.getrecords2(constraints=filter_list,maxrecords=100,esn='full')
len(csw.records.keys())
# <codecell>
#scheme='urn:x-esri:specification:ServiceType:odp:url'
scheme='OPeNDAP:OPeNDAP'
urls = service_urls(csw.records,service_string=scheme)
print "\n".join(urls)
# <headingcell level=2>
# Use Iris to access CF data
# <codecell>
cube = iris.load_cube(urls[7],'sea_water_potential_temperature')
# <codecell>
# color filled contour plot
h = iplt.contourf(cube[1,0,:,:],64)
plt.title(cube.attributes['title']);