In [1]:
import folium

In [2]:
from IPython.display import HTML, display

def inline_map(m):
    if isinstance(m, folium.folium.Map):
        m._build_map()
        srcdoc = "data:text/html;base64," + m.HTML.encode('base64')
        embed = HTML('<iframe src="{}" '
                 'style="width: {}px; height: {}px; '
                 'border: none"></iframe>'.format(srcdoc, m.width, m.height))
    else:
        raise ValueError('{!r} is not a folium Map instance.')
    return embed

In [3]:
#to get the wms url for the file calculated by a birdhouse process, go to 
#http://localhost:8080/thredds/catalog/birdhouse/catalog.html and look for your file

#list of CDO operators here: https://code.zmaw.de/projects/cdo/embedded/index.html

In [4]:
# Use url provided by WMS built into birdhouse's thredds server
map = folium.Map(width=600, height=400, zoom_start=2)

#7 land flux models
#Note: ensmean and ensstd files shows the last year in dataset
ensmean = 'http://localhost:8080/thredds/wms/birdhouse/flyingpigeon/ensmean-d1a8a3d6-78a1-11e5-abf5-6c3be5206152.nc?service=WMS&version=1.3.0&request=GetCapabilities'
abs_delta = 'http://localhost:8080/thredds/wms/birdhouse/flyingpigeon/absdelta-d1a8a3d6-78a1-11e5-abf5-6c3be5206152.nc?service=WMS&version=1.3.0&request=GetCapabilities'
ensstd = 'http://localhost:8080/thredds/wms/birdhouse/flyingpigeon/ensstd-d1a8a3d6-78a1-11e5-abf5-6c3be5206152.nc?service=WMS&version=1.3.0&request=GetCapabilities'
binmask = 'http://localhost:8080/thredds/wms/birdhouse/flyingpigeon/binmask-d1a8a3d6-78a1-11e5-abf5-6c3be5206152.nc?service=WMS&version=1.3.0&request=GetCapabilities'

parameters= 'LAYERS=Terrestrial_flux&' + \
    'ELEVATION=0&' + \
    'STYLES=boxfill/redblue&' + \
    'OPACITY=60&' + \
    'COLORSCALERANGE=-100,100&' + \
    'NUMCOLORBANDS=20&'  + \
    'ABOVEMAXCOLOR=extend' + '&' + \
    'BELOWMINCOLOR=extend'
    
parameters_std= 'LAYERS=Terrestrial_flux&' + \
    'ELEVATION=0&' + \
    'TIME=2010-07-01T12:00:00.000Z&' + \
    'STYLES=boxfill/greyscale&' + \
    'OPACITY=100&' + \
    'COLORSCALERANGE=-100,100&' + \
    'NUMCOLORBANDS=100&'   + \
    'ABOVEMAXCOLOR=extend' + '&' + \
    'BELOWMINCOLOR=extend'

parameters_mask= 'LAYERS=Terrestrial_flux&' + \
    'ELEVATION=0&' + \
    'OPACITY=70&' + \
    'COLORSCALERANGE=1,2&' + \
    'STYLES=boxfill/black&' + \
    'NUMCOLORBANDS=2&'  + \
    'ABOVEMAXCOLOR=extend' + '&' + \
    'BELOWMINCOLOR=transparent'
    
map.add_wms_layer(wms_name="Flux ensmean",
    wms_url=ensmean + parameters,
    wms_format="image/png",
    wms_layers='Terrestrial_flux')

map.add_wms_layer(wms_name="Flux abs delta",
    wms_url=abs_delta + parameters_std,
    wms_format="image/png",
    wms_layers='Terrestrial_flux')

map.add_wms_layer(wms_name="ens std",
    wms_url=ensstd + parameters_std,
    wms_format="image/png",
    wms_layers='Terrestrial_flux')

map.add_wms_layer(wms_name="mask",
    wms_url=binmask + parameters_mask,
    wms_format="image/png",
    wms_layers='Terrestrial_flux')

map.add_layers_to_map()
inline_map(map)


Out[4]:

In [5]:
# Bypass birdhouse built-in WMS service (old version) and use ncWMS2 directly from tomcat
map = folium.Map(width=600, height=400, zoom_start=2)

wms2='http://localhost:8080/ncWMS2/wms?dataset=http://localhost:8080/thredds/dodsC/birdhouse/flyingpigeon/ \
output-ef8515ca-7337-11e5-b104-308d99192888.nc&service=WMS&version=1.3.0&request=GetCapabilities'


#wms22='http://localhost:8080/ncWMS2/wms?service=WMS&version=1.3.0&request=GetCapabilities&layer=tyty/Terrestrial_flux'
#wms22='http://localhost:8080/ncWMS2/wms?service=WMS&version=1.3.0'

wms22='http://localhost:8080/ncWMS2/wms?REQUEST=GetMap&VERSION=1.3.0&STYLES=contours&CRS=CRS:84&LAYERS=tyty/Terrestrial_flux&BBOX=-180.0,-90.0,180.0,90.0'



wmsorig='http://localhost:8080/ncWMS2/Godiva3.html?permalinking=true&bgmap=NaturalEarth%20WMS&\
dataset=http://localhost:8080/ncWMS2/wms&numColorBands=250&logScale=false&\
bbox=-182.109375,-142.20703125,177.890625,139.04296875&abovemaxcolor=0x000000& \
belowmincolor=0x000000&nodatacolor=transparent&layer=tyty/Terrestrial_flux& \
time=2010-07-01T12%253A00%253A00.000Z&palette=default&style=upstream_dots& \
scaleRange=-385.6,256.8&displayScaleRange=-385.6,256.8&opacity=1'

enstd = 'http://localhost:8080/thredds/wms/birdhouse/hummingbird/output-be3f612e-7313-11e5-9d05-308d99192888.nc?service=WMS&version=1.3.0&request=GetCapabilities'
#enmean = 'http://localhost:8080/thredds/wms/birdhouse/flyingpigeon/output-ef8515ca-7337-11e5-b104-308d99192888.nc?service=WMS&version=1.3.0&request=GetCapabilities'
    
map.add_wms_layer(wms_name="Flux std",
    #wms_url=enstd,
    wms_url=wms22,
    wms_format="image/png",
    wms_layers='Terrestrial_flux')

map.add_layers_to_map()
inline_map(map)


Out[5]:

In [ ]:
#cdo operators: https://code.zmaw.de/projects/cdo/embedded/index.html#x1-1440002.4.1

In [6]:
# Use url provided by WMS built into birdhouse's thredds server
# Read in ensemble avg and mask

map = folium.Map(width=600, height=400, zoom_start=2)

#wms='http://webportals.ipsl.jussieu.fr/thredds/wms/ATLAS/Flux/LandModels/yearlymean/fco2_MEAN_1980-2010_LandModels_yearlymean_XYT.nc?'

#wms = 'http://localhost:8080/thredds/wms/birdhouse/flyingpigeon/output-6ae908ee-740e-11e5-9c83-6c3be5206152.nc?service=WMS&version=1.3.0&request=GetCapabilities'

#mask calculated on ensmean:
wms = 'http://localhost:8080/thredds/wms/birdhouse/flyingpigeon/output-c633ec24-7412-11e5-8ff7-6c3be5206152.nc?service=WMS&version=1.3.0&request=GetCapabilities'


parameters= 'LAYERS=Terrestrial_flux&' + \
    'ELEVATION=0&' + \
    'TIME=2010-07-01T12:00:00.000Z&' + \
    'STYLES=boxfill/rainbow&' + \
    'COLORSCALERANGE=-100,50&' + \
    'NUMCOLORBANDS=20&'
    
#parameters_std= 'LAYERS=Terrestrial_flux&' + \
#    'ELEVATION=0&' + \
#    'TIME=2010-07-01T12:00:00.000Z&' + \
#    'STYLES=boxfill/black&' + \
#    'OPACITY=100&' + \
#    'COLORSCALERANGE=-50,50&' + \
#    'NUMCOLORBANDS=20&'   + \
#    'ABOVEMAXCOLOR=extend' + '&' + \
#    'BELOWMINCOLOR=extend'

map.add_wms_layer(wms_name="Flux",
    wms_url=wms + parameters,
    wms_format="image/png",
    wms_layers='Terrestrial_flux')

#map.add_wms_layer(wms_name="Flux std",
#    wms_url=enstd + parameters_std,
#    wms_format="image/png",
#    wms_layers='Terrestrial_flux')

map.add_layers_to_map()
inline_map(map)


Out[6]:

In [ ]: