How to use the nansat.nansat.Nansat 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 / nansat / nansat_integration_tests / test_netcdf_cf_mappers.py View on Github external
def test_reproject_arome_to_SAR(self):
        sar = Nansat(self.s1bIW)
        wind = Nansat(self.test_file_arome_metcoop, netcdf_dim={'time':
            np.datetime64(sar.time_coverage_start)},
            bands=['y_wind','x_wind'])
        self.assertTrue(wind['x_wind_10m'].any())
        self.assertTrue(wind['y_wind_10m'].any())
        wind.reproject(sar, addmask=False)
        self.assertTrue(wind['x_wind_10m'].any())
        self.assertTrue(wind['y_wind_10m'].any())
github nansencenter / nansat / nansat_integration_tests / test_netcdf_cf_mappers.py View on Github external
def test_reproject_arome_to_SAR(self):
        sar = Nansat(self.s1bIW)
        wind = Nansat(self.test_file_arome_metcoop, netcdf_dim={'time':
            np.datetime64(sar.time_coverage_start)},
            bands=['y_wind','x_wind'])
        self.assertTrue(wind['x_wind_10m'].any())
        self.assertTrue(wind['y_wind_10m'].any())
        wind.reproject(sar, addmask=False)
        self.assertTrue(wind['x_wind_10m'].any())
        self.assertTrue(wind['y_wind_10m'].any())
github nansencenter / nansat / nansat_integration_tests / test_netcdf_cf_mappers.py View on Github external
def test_arome_mapper_is_used(self):
        n = Nansat(self.test_file_arome_arctic)
        self.assertEqual(n.mapper, 'arome')
        n = Nansat(self.test_file_arome_metcoop)
        self.assertEqual(n.mapper, 'arome')
        self.assertTrue(n['x_wind_10m'].any())
        self.assertTrue(n['y_wind_10m'].any())
github nansencenter / nansat / nansat / mappers / mapper_ncep_wind_online.py View on Github external
command = (get_inv + ' ' + url + baseName +
                               '.inv | egrep "(:UGRD:10 m |:VGRD:10 m )" | ' +
                               get_grib + ' ' + url + fileName +
                               ' ' + outFileName)
                    os.system(command)
                    if os.path.isfile(outFileName):
                        print 'Downloaded ' + fileName + ' to ' + outFolder
                else:
                    print 'Already downloaded %s' % outFileName
                if not os.path.isfile(outFileName):
                    sys.exit('No NCEP wind files found for requested time')

        ######################################################
        # Open downloaded grib file with a(ny) Nansat mapper
        ######################################################
        w = Nansat(outFileName)
        VRT.__init__(self, vrtDataset=w.vrt.dataset)

        return
github nansencenter / nansat / nansat / nansat.py View on Github external
self.vrt : super-VRT is created with modified SrcRect and DstRect

        Returns
        -------
        extent : (x_offset, y_offset, x_size, y_size)
            x_offset  - X offset in the original dataset
            y_offset  - Y offset in the original dataset
            x_size - width of the new dataset
            y_size - height of the new dataset

        Examples
        --------
            >>> extent = n.crop(10, 20, 100, 200)

        """
        x_offset, x_size = Nansat._fix_crop_offset_size(x_offset, x_size,
                                                        self.shape()[1], allow_larger)
        y_offset, y_size = Nansat._fix_crop_offset_size(y_offset, y_size,
                                                        self.shape()[0], allow_larger)

        extent = (int(x_offset), int(y_offset), int(x_size), int(y_size))
        self.logger.debug('x_offset: %d, y_offset: %d, x_size: %d, y_size: %d' % extent)

        # test if crop is larger or equal to image size
        if x_offset == y_offset == 0 and (y_size, x_size) == self.shape():
            self.logger.error(('WARNING! Cropping region is larger or equal to image!'))
            return extent

        # create super VRT and change it
        self.vrt = self.vrt.get_super_vrt()
        self.vrt.set_offset_size('x', x_offset, x_size)
        self.vrt.set_offset_size('y', y_offset, y_size)
github nansencenter / django-geo-spaas / geospaas / processing_sar_doppler / utils.py View on Github external
#    bands=['eastward_geostrophic_current_velocity'])
        #n.export(expFn)
        n = Nansat(expFn, mapperName='generic')
        n.reproject(domain, addmask=False)
        u = n['eastward_geostrophic_current_velocity']
        # OK:
        #plt.imshow(u)
        #plt.colorbar()
        #plt.show()
        if np.sum(np.isnan(u))==u.size:
            continue
        else:
            U = np.append(U, np.expand_dims(u, axis=2), axis=2)
        dt = dt + timezone.timedelta(days=1)
    meanU = np.nanmean(U, axis=2)
    nu = Nansat(array=meanU, domain=domain)
    nmap=Nansatmap(nu, resolution='h')
    nmap.pcolormesh(nu[1], vmin=-1.5, vmax=1.5, cmap='jet') #bwr
    nmap.add_colorbar()
    nmap.draw_continents()
    nmap.fig.savefig('/vagrant/shared/u_gc.png', bbox_inches='tight')
    #stdU = np.nanstd(U, axis=2)
github nansencenter / nansat / nansat / nansat.py View on Github external
"""
        resized = False
        if self.shape()[1] > maxwidth:
            factor = self.resize(width=1000)
            resized = True
        else:
            factor = 1
        # use interactive PointBrowser for selecting extent
        try:
           points = self.digitize_points(band=band,**kwargs)[0]
        except:
           if resized:
              self.undo()
           return

        x_offset, x_size = Nansat._get_crop_offset_size(0, points, factor)
        y_offset, y_size = Nansat._get_crop_offset_size(1, points, factor)

        if resized:
            self.undo()

        return self.crop(x_offset, y_offset, x_size, y_size)
github nansencenter / nansat / nansat / nansat.py View on Github external
if mod44path is None:
            mod44path = os.getenv('MOD44WPATH')
        if mod44path is None:
            mod44DataExist = False
        # check if VRT file exist
        elif not os.path.exists(mod44path + '/MOD44W.vrt'):
            mod44DataExist = False
        self.logger.debug('MODPATH: %s' % mod44path)

        if not mod44DataExist:
            raise IOError('250 meters resolution watermask from MODIS ' \
                    '44W Product does not exist - see Nansat ' \
                    'documentation to get it (the path is %s)' %mod44path)

        # MOD44W data does exist: open the VRT file in Nansat
        watermask = Nansat(mod44path + '/MOD44W.vrt', mapperName='MOD44W',
                            logLevel=self.logger.level)
        # reproject on self or given Domain
        if dstDomain is None:
            watermask.reproject(self, **kwargs)
        else:
            watermask.reproject(dstDomain, **kwargs)

        return watermask
github nansencenter / django-geo-spaas / geospaas / processing_sar_nrcs / managers.py View on Github external
# ingest file to db
        ds, created = super(DatasetManager, self).get_or_create(uri, *args,
                **kwargs)

        # set Dataset entry_title
        ds.entry_title = 'SAR NRCS'
        ds.save()

        # Unless reprocess==True, we may not need to do the following... (see
        # managers.py in sar doppler processor)
        #visExists = ... # check if visualization(s) already created
        #if visExists and not reprocess:
        #    warnings.warn('NO VISUALISATIONS CREATED - update managers.py')
        #    return ds, created

        n = Nansat(nansat_filename(uri))
        n.resize(pixelsize=500)
        lon, lat = n.get_corners()
        d = Domain(NSR(3857),
                   '-lle %f %f %f %f -tr 1000 1000' % (
                        lon.min(), lat.min(), lon.max(), lat.max()))
        n.reproject(d, eResampleAlg=1, tps=True)

        # Get all NRCS bands
        s0bands = []
        pp = []
        for key, value in n.bands().iteritems():
            try:
                if value['standard_name']==standard_name:
                    s0bands.append(key)
                    pp.append(value['polarization'])
            except KeyError: