In [16]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import Image
from nansat import Nansat, Domain, Nansatmap

# SST
#http://data.nodc.noaa.gov/thredds/catalog/ghrsst/L4/GLOB/UKMO/OSTIA/2012/121/catalog.html?dataset=ghrsst/L4/GLOB/UKMO/OSTIA/2012/121/20120430-UKMO-L4HRfnd-GLOB-v01-fv02-OSTIA.nc.bz2
n1 = Nansat('/files/normap/20120430-UKMO-L4HRfnd-GLOB-v01-fv02-OSTIA.nc')

# ice concentration
#http://thredds.met.no/thredds/catalog/osisaf/met.no/ice/conc/2012/04/catalog.html?dataset=osisaf/met.no/ice/conc/2012/04/ice_conc_nh_polstere-100_multi_201204301200.nc
n2 = Nansat('/files/normap/ice_conc_nh_polstere-100_multi_201204301200.nc')

# currents from GLOBCURRENT
#http://www.ifremer.fr/opendap/cerdap1/globcurrent/global_010_deg/total_hs/2012/121/20120430000000-GLOBCURRENT-L4-CUR-ALT-total_hs-v01.0-fv01.0.nc
#n3 = Nansat('/files/normap/20120430000000-GLOBCURRENT-L4-CUR-ALT-total_hs-v01.0-fv01.0.nc')
#n3 = Nansat('http://www.ifremer.fr/opendap/cerdap1/globcurrent/global_010_deg/total_hs/2012/121/20120430000000-GLOBCURRENT-L4-CUR-ALT-total_hs-v01.0-fv01.0.nc')
#print n3
# ice drift
# http://thredds.met.no/thredds/catalog/osisaf/met.no/ice/drift_lr/merged/2012/04/catalog.html?dataset=osisaf/met.no/ice/drift_lr/merged/2012/04/ice_drift_nh_polstere-625_multi-oi_201204281200-201204301200.nc
n4 = Nansat('/files/normap/ice_drift_nh_polstere-625_multi-oi_201204281200-201204301200.nc')

# wind
n5 = Nansat('/files/normap/gfs.t00z.master.grbf00')

minLon = -16
maxLon = 16
minLat = 64
maxLat = 83
d = Domain(4326, '-te %f %f %f %f -tr 0.05 0.05' % (minLon, minLat, maxLon, maxLat))

n1.reproject(d)
n2.reproject(d)
#n3.reproject(d)
n4.reproject(d)
n5.reproject(d)

print 'get arrays with data'
sst = n1['analysed_sst']
ice_conc = n2['ice_conc']
#u = n3['eastward_total_current_velocity_hs000']
#v = n3['northward_total_current_velocity_hs000']
lons, lats = n3.get_geolocation_grids()
uw = n5['U']
vw = n5['V']

dx = n4['dX']
dy = n4['dY']

print 'Mask invalid data'
# mask land
watermask = n1.watermask('/files/MOD44W/')[1]
sst[watermask == 2] = np.nan
#u[watermask == 2] = np.nan
#v[watermask == 2] = np.nan
ice_conc[watermask == 2] = np.nan
dx[watermask == 2] = np.nan
dy[watermask == 2] = np.nan

# mask invalid U and V
#u[u<-10] = np.nan
#v[v<-10] = np.nan

# mask zero ice concentration
ice_conc[ice_conc <= 0] = np.nan

# mask under-ice currents
#u[ice_conc > 0] = np.nan
#v[ice_conc > 0] = np.nan

# mask invalid SST
sst[sst < 0] = np.nan

# mask invalid ice displacement
dx[ice_conc == 0] = np.nan
dy[ice_conc == 0] = np.nan

# mask wind over ice
uw[ice_conc > 0.5] = np.nan
vw[ice_conc > 0.5] = np.nan


02:23:36|40|mapper_generic|__init__|Time format is wrong in input file!
ERROR:Nansat:Time format is wrong in input file!
02:23:36|30|mapper_generic|__init__|Use generic mapper - OK!
WARNING:Nansat:Use generic mapper - OK!
=>OSTIA Sea Surface Temperature and Sea Ice Analysis<=
=>Daily Sea Ice Concentration Analysis from OSI SAF EUMETSAT<=
02:23:36|30|mapper_generic|__init__|Use generic mapper - OK!
WARNING:Nansat:Use generic mapper - OK!
=>Daily Low Resolution Sea Ice Displacement from OSI SAF EUMETSAT<=
02:23:36|30|mapper_generic|__init__|Use generic mapper - OK!
WARNING:Nansat:Use generic mapper - OK!
get arrays with data
Mask invalid data
-c:66: RuntimeWarning: invalid value encountered in less_equal
-c:73: RuntimeWarning: invalid value encountered in less
-c:80: RuntimeWarning: invalid value encountered in greater
-c:81: RuntimeWarning: invalid value encountered in greater

In [20]:
print np.nanmin(sst)-273.15
print np.nanmax(sst)-273.15

print np.nanmin(dx)
print np.nanmax(dy)

print np.nanmin(uw)
print np.nanmax(vw)


-1.91998901367
7.74999389648
-1.46697
31.3112
-17.9799995422
20.8899993896

In [18]:
nmap = Nansatmap(n1, resolution='l')
nmap.pcolormesh(sst-273.15, vmin=-5, vmax=13)
nmap.pcolormesh(ice_conc, cmap='bone')

nmap.quiver(-dx, -dy, step=15, width=0.0015, scale=1000)
nmap.streamplot(lons, lats, u, v, density=5, linewidth=np.hypot(u,v)*10, color='k')

stp = 50
nmap.barbs(lons[::stp, ::stp], lats[::stp, ::stp], uw[::stp, ::stp], vw[::stp, ::stp],
    pivot='middle', barbcolor='w', linewidth=3)

nmap.draw_continents()
nmap.drawmeridians(np.arange(minLon, maxLon, 5), labels=[False,False,True,False])
nmap.drawparallels(np.arange(minLat, maxLat, 3), labels=[True, False, False, False])

# set size of the figure (inches)
nmap.fig.set_figheight(20)
nmap.fig.set_figwidth(15)

# save figure to a PNG file
nmap.save('h2020_scube4ocean.png')



In [2]:
uw.min()


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-cdcc2535b135> in <module>()
----> 1 uw.min()

NameError: name 'uw' is not defined

In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import Image
from nansat import Nansat, Domain, Nansatmap

# SST
#http://data.nodc.noaa.gov/thredds/catalog/ghrsst/L4/GLOB/UKMO/OSTIA/2012/121/catalog.html?dataset=ghrsst/L4/GLOB/UKMO/OSTIA/2012/121/20120430-UKMO-L4HRfnd-GLOB-v01-fv02-OSTIA.nc.bz2
n1 = Nansat('/files/normap/20120430-UKMO-L4HRfnd-GLOB-v01-fv02-OSTIA.nc')

# ice concentration
#http://thredds.met.no/thredds/catalog/osisaf/met.no/ice/conc/2012/04/catalog.html?dataset=osisaf/met.no/ice/conc/2012/04/ice_conc_nh_polstere-100_multi_201204301200.nc
n2 = Nansat('/files/normap/ice_conc_nh_polstere-100_multi_201204301200.nc')

minLon = -40
maxLon = 80
minLat = 60
maxLat = 85
d = Domain(4326, '-te %f %f %f %f -tr 0.05 0.05' % (minLon, minLat, maxLon, maxLat))

n1.reproject(d)
n2.reproject(d)

print 'get arrays with data'
sst = n1['analysed_sst']
ice_conc = n2['ice_conc']

print 'Mask invalid data'
# mask land
watermask = n1.watermask('/files/MOD44W/')[1]
sst[watermask == 2] = np.nan
ice_conc[watermask == 2] = np.nan

# mask zero ice concentration
ice_conc[ice_conc <= 0] = np.nan

# mask invalid SST
sst[sst < 0] = np.nan

# make map canvas
nmap = Nansatmap(n1, resolution='l')
nmap.pcolormesh(sst-273.15, vmin=-5, vmax=13)
nmap.pcolormesh(ice_conc, cmap='bone')

nmap.draw_continents()

# set size of the figure (inches)
nmap.fig.set_figheight(20)
nmap.fig.set_figwidth(30)

# save figure to a PNG file
nmap.save('h2020_scube4ocean_map.png')


01:49:00|40|mapper_generic|__init__|Time format is wrong in input file!
ERROR:Nansat:Time format is wrong in input file!
01:49:00|30|mapper_generic|__init__|Use generic mapper - OK!
WARNING:Nansat:Use generic mapper - OK!
=>OSTIA Sea Surface Temperature and Sea Ice Analysis<=
=>Daily Sea Ice Concentration Analysis from OSI SAF EUMETSAT<=
01:49:00|30|mapper_generic|__init__|Use generic mapper - OK!
WARNING:Nansat:Use generic mapper - OK!
get arrays with data
Mask invalid data
-c:35: RuntimeWarning: invalid value encountered in less_equal
-c:38: RuntimeWarning: invalid value encountered in less