How to use the nansat.NSR function in nansat

To help you get started, we’ve selected a few nansat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nansencenter / sea_ice_drift / sea_ice_drift / tests.py View on Github external
sid = SeaIceDrift(self.testFiles[0], self.testFiles[1])

        lon1b, lat1b = sid.n1.get_border()
        lon1pm, lat1pm = np.meshgrid(np.linspace(lon1b.min(), lon1b.max(), 50),
                             np.linspace(lat1b.min(), lat1b.max(), 50))
        uft, vft, lon1ft, lat1ft, lon2ft, lat2ft = sid.get_drift_FT()
        upm, vpm, apm, rpm, hpm, lon2pm, lat2pm = sid.get_drift_PM(
                                            lon1pm, lat1pm,
                                            lon1ft, lat1ft,
                                            lon2ft, lat2ft)

        lon1, lat1 = sid.n1.get_border()
        lon2, lat2 = sid.n2.get_border()
        ext_str = '-te %s %s %s %s -ts 500 500' % (lon1b.min(), lat1b.min(), lon1b.max(), lat1b.max())
        sid.n1.reproject(Domain(NSR().wkt, ext_str))
        s01 = sid.n1['sigma0_HV']
        sid.n2.reproject(Domain(NSR().wkt, ext_str))
        s02 = sid.n2['sigma0_HV']
        extent=[lon1b.min(), lon1b.max(), lat1b.min(), lat1b.max()]
        plt.imshow(s01, extent=extent, cmap='gray', aspect=10)
        plt.quiver(lon1ft, lat1ft, uft, vft, color='r',
                   angles='xy', scale_units='xy', scale=0.2)
        plt.plot(lon2, lat2, '.-r')
        plt.xlim([lon1b.min(), lon1b.max()])
        plt.ylim([lat1b.min(), lat1b.max()])
        plt.savefig('sea_ice_drift_tests_%s_img1_ft.png' % inspect.currentframe().f_code.co_name,
                    dpi=150, bbox_inches='tight', pad_inches=0)
        plt.close('all')

        plt.imshow(s02, extent=extent, cmap='gray', aspect=10)
        gpi = hpm*rpm > 4
github nansencenter / nansat / tutorial / test_nsr.py View on Github external
#               Dmitry Petrenko, Evgeny Morozov
# Created:      13.02.2014
# Copyright:    (c) NERSC 2011 - 2013
# Licence:
# This file is part of NANSAT.
# NANSAT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
# http://www.gnu.org/licenses/gpl-3.0.html
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

from nansat import osr, NSR

print 'NSR(None)', NSR(None), '\n\n\n'
print 'NSR()', NSR(), '\n\n\n'
print 'NSR(+proj=longlat)', NSR('+proj=longlat'), '\n\n\n'
try:
    n = NSR('crap')
except:
    print 'NSR(crap) raises Error', '\n\n\n'
else:
    print n, '\n\n\n'
print 'NSR(osr.SRS_WKT_WGS84)', NSR(osr.SRS_WKT_WGS84), '\n\n\n'
print 'NSR(4326)', NSR(4326), '\n\n\n'
srs = osr.SpatialReference(NSR(4326).wkt)
print 'NSR(osr.SpatialReference())', NSR(srs), '\n\n\n'
print 'NSR(NSR(4326))', NSR(NSR(4326)), '\n\n\n'
print 'NSR(+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs)', NSR('+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs'), '\n\n\n'

print '\n*** nsr_test completed successfully.\n\n\n'
github nansencenter / nansat / tutorial / test_nsr.py View on Github external
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

from nansat import osr, NSR

print 'NSR(None)', NSR(None), '\n\n\n'
print 'NSR()', NSR(), '\n\n\n'
print 'NSR(+proj=longlat)', NSR('+proj=longlat'), '\n\n\n'
try:
    n = NSR('crap')
except:
    print 'NSR(crap) raises Error', '\n\n\n'
else:
    print n, '\n\n\n'
print 'NSR(osr.SRS_WKT_WGS84)', NSR(osr.SRS_WKT_WGS84), '\n\n\n'
print 'NSR(4326)', NSR(4326), '\n\n\n'
srs = osr.SpatialReference(NSR(4326).wkt)
print 'NSR(osr.SpatialReference())', NSR(srs), '\n\n\n'
print 'NSR(NSR(4326))', NSR(NSR(4326)), '\n\n\n'
print 'NSR(+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs)', NSR('+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs'), '\n\n\n'

print '\n*** nsr_test completed successfully.\n\n\n'
github nansencenter / nansat / tutorial / test_nsr.py View on Github external
# Copyright:    (c) NERSC 2011 - 2013
# Licence:
# This file is part of NANSAT.
# NANSAT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
# http://www.gnu.org/licenses/gpl-3.0.html
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

from nansat import osr, NSR

print 'NSR(None)', NSR(None), '\n\n\n'
print 'NSR()', NSR(), '\n\n\n'
print 'NSR(+proj=longlat)', NSR('+proj=longlat'), '\n\n\n'
try:
    n = NSR('crap')
except:
    print 'NSR(crap) raises Error', '\n\n\n'
else:
    print n, '\n\n\n'
print 'NSR(osr.SRS_WKT_WGS84)', NSR(osr.SRS_WKT_WGS84), '\n\n\n'
print 'NSR(4326)', NSR(4326), '\n\n\n'
srs = osr.SpatialReference(NSR(4326).wkt)
print 'NSR(osr.SpatialReference())', NSR(srs), '\n\n\n'
print 'NSR(NSR(4326))', NSR(NSR(4326)), '\n\n\n'
print 'NSR(+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs)', NSR('+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs'), '\n\n\n'

print '\n*** nsr_test completed successfully.\n\n\n'
github nansencenter / nansat / tutorial / test_nsr.py View on Github external
print 'NSR(None)', NSR(None), '\n\n\n'
print 'NSR()', NSR(), '\n\n\n'
print 'NSR(+proj=longlat)', NSR('+proj=longlat'), '\n\n\n'
try:
    n = NSR('crap')
except:
    print 'NSR(crap) raises Error', '\n\n\n'
else:
    print n, '\n\n\n'
print 'NSR(osr.SRS_WKT_WGS84)', NSR(osr.SRS_WKT_WGS84), '\n\n\n'
print 'NSR(4326)', NSR(4326), '\n\n\n'
srs = osr.SpatialReference(NSR(4326).wkt)
print 'NSR(osr.SpatialReference())', NSR(srs), '\n\n\n'
print 'NSR(NSR(4326))', NSR(NSR(4326)), '\n\n\n'
print 'NSR(+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs)', NSR('+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs'), '\n\n\n'

print '\n*** nsr_test completed successfully.\n\n\n'
github nansencenter / nansat / tutorial / test_nsr.py View on Github external
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

from nansat import osr, NSR

print 'NSR(None)', NSR(None), '\n\n\n'
print 'NSR()', NSR(), '\n\n\n'
print 'NSR(+proj=longlat)', NSR('+proj=longlat'), '\n\n\n'
try:
    n = NSR('crap')
except:
    print 'NSR(crap) raises Error', '\n\n\n'
else:
    print n, '\n\n\n'
print 'NSR(osr.SRS_WKT_WGS84)', NSR(osr.SRS_WKT_WGS84), '\n\n\n'
print 'NSR(4326)', NSR(4326), '\n\n\n'
srs = osr.SpatialReference(NSR(4326).wkt)
print 'NSR(osr.SpatialReference())', NSR(srs), '\n\n\n'
print 'NSR(NSR(4326))', NSR(NSR(4326)), '\n\n\n'
print 'NSR(+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs)', NSR('+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs'), '\n\n\n'

print '\n*** nsr_test completed successfully.\n\n\n'
github nansencenter / nansat / tutorial / test_nsr.py View on Github external
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

from nansat import osr, NSR

print 'NSR(None)', NSR(None), '\n\n\n'
print 'NSR()', NSR(), '\n\n\n'
print 'NSR(+proj=longlat)', NSR('+proj=longlat'), '\n\n\n'
try:
    n = NSR('crap')
except:
    print 'NSR(crap) raises Error', '\n\n\n'
else:
    print n, '\n\n\n'
print 'NSR(osr.SRS_WKT_WGS84)', NSR(osr.SRS_WKT_WGS84), '\n\n\n'
print 'NSR(4326)', NSR(4326), '\n\n\n'
srs = osr.SpatialReference(NSR(4326).wkt)
print 'NSR(osr.SpatialReference())', NSR(srs), '\n\n\n'
print 'NSR(NSR(4326))', NSR(NSR(4326)), '\n\n\n'
print 'NSR(+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs)', NSR('+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs'), '\n\n\n'

print '\n*** nsr_test completed successfully.\n\n\n'
github nansencenter / nansat / tutorial / test_nsr.py View on Github external
from nansat import osr, NSR

print 'NSR(None)', NSR(None), '\n\n\n'
print 'NSR()', NSR(), '\n\n\n'
print 'NSR(+proj=longlat)', NSR('+proj=longlat'), '\n\n\n'
try:
    n = NSR('crap')
except:
    print 'NSR(crap) raises Error', '\n\n\n'
else:
    print n, '\n\n\n'
print 'NSR(osr.SRS_WKT_WGS84)', NSR(osr.SRS_WKT_WGS84), '\n\n\n'
print 'NSR(4326)', NSR(4326), '\n\n\n'
srs = osr.SpatialReference(NSR(4326).wkt)
print 'NSR(osr.SpatialReference())', NSR(srs), '\n\n\n'
print 'NSR(NSR(4326))', NSR(NSR(4326)), '\n\n\n'
print 'NSR(+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs)', NSR('+proj=stere +datum=WGS84 +ellps=WGS84 +lat_0=75 +lon_0=10 +no_defs'), '\n\n\n'

print '\n*** nsr_test completed successfully.\n\n\n'
github nansencenter / sea_ice_drift / examples / simple.py View on Github external
np.linspace(lats, latn, 50))

# apply Pattern Matching and find sea ice drift speed
# for the given grid of points
upm, vpm, apm, rpm, hpm, lon2pm, lat2pm = sid.get_drift_PM(
                                    lon1pm, lat1pm,
                                    lon1ft, lat1ft,
                                    lon2ft, lat2ft)

# ==== PLOTTING ====
# get coordinates of SAR scene borders
lon1, lat1 = sid.n1.get_border()
lon2, lat2 = sid.n2.get_border()

# prepare projected images with sigma0_HV
d = Domain(NSR().wkt, '-te %f %f %f %f -ts 500 500' % (lone, lats, lonw, latn))
sid.n1.reproject(d)
s01 = sid.n1['sigma0_HV']
sid.n2.reproject(d)
s02 = sid.n2['sigma0_HV']

# plot the projected image from the first SAR scene
plt.imshow(s01, extent=[lone, lonw, lats, latn], cmap='gray', aspect=12)
# plot vectors of sea ice drift from Feature Tracking
plt.quiver(lon1ft, lat1ft, uft, vft, color='r',
           angles='xy', scale_units='xy', scale=0.5)
# plot border of the second SAR scene
plt.plot(lon2, lat2, '.-r')
# set X/Y limits of figure
plt.xlim([lone, lonw])
plt.ylim([lats, latn])
plt.savefig('sea_ice_drift_FT_img1.png', dpi=150, bbox_inches='tight', pad_inches=0)