当前位置: 首页>>代码示例>>Python>>正文


Python nansat.Nansat类代码示例

本文整理汇总了Python中nansat.Nansat的典型用法代码示例。如果您正苦于以下问题:Python Nansat类的具体用法?Python Nansat怎么用?Python Nansat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Nansat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_export_gcps_complex_to_netcdf

    def test_export_gcps_complex_to_netcdf(self):
        """ Should export file with GCPs and write correct complex bands"""
        n0 = Nansat(self.test_file_gcps, log_level=40, mapper=self.default_mapper)
        b0 = n0['L_469']

        n1 = Nansat.from_domain(n0)
        n1.add_band(b0.astype('complex64'), parameters={'name': 'L_469'})

        tmpfilename = os.path.join(self.tmp_data_path, 'nansat_export_gcps_complex.nc')
        n1.export(tmpfilename)

        ncf = Dataset(tmpfilename)
        self.assertTrue(os.path.exists(tmpfilename))
        self.assertTrue('GCPX' in ncf.variables)
        self.assertTrue('GCPY' in ncf.variables)
        self.assertTrue('GCPPixel' in ncf.variables)
        self.assertTrue('GCPLine' in ncf.variables)

        n2 = Nansat(tmpfilename, mapper=self.default_mapper)
        b2 = n2['L_469']

        lon0, lat0 = n0.get_geolocation_grids()
        lon2, lat2 = n1.get_geolocation_grids()
        np.testing.assert_allclose(lon0, lon2)
        np.testing.assert_allclose(lat0, lat2)
开发者ID:nansencenter,项目名称:nansat,代码行数:25,代码来源:test_exporter.py

示例2: test_get_auto_ticks_vector

    def test_get_auto_ticks_vector(self):
        n = Nansat(self.test_file_gcps)
        lon, lat = n.get_geolocation_grids()
        f = Figure(lon)
        lonTicks = f._get_auto_ticks([28, 29, 30, 100], lon)

        self.assertEqual(len(lonTicks), 3)
开发者ID:scollis,项目名称:nansat,代码行数:7,代码来源:test_figure.py

示例3: make_reproject

def make_reproject(path, final_path, file_name, show='off'):
    """
    Функция для перепроецирования снимков согласно параметрам указываемым в dom.
    После перепроецирования к файлу снимку генерируется и добавляется маска
    :param path: Путь до папки в которой лежит файл
    :param final_path: Путь до папки в которую нужно положить перепроецированный файл
    :param file_name: Имя файла (исходного)
    :param show: Флаг для отрисовки [2] канала. По умолчанию 'off', чтобы включить show='on'
    :return: Перепроецированный файл с иходным file_name
    """
    print path + file_name
    nansat_obj = Nansat(path + file_name)
    #  Для маленького конечного куска
    #dom = Domain('+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs', '-lle -86.20 45.10 -86.10 45.20 -ts 300 300')
    #   Для всего района
    dom = Domain('+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs', '-lle -86.3 44.6 -85.2 45.3 -ts 300 200')
    nansat_obj.reproject(dom)
    nansat_obj = create_mask(nansat_obj)

    if show == 'on':
        plt.imshow(nansat_obj[2])
        plt.colorbar()
        plt.show()

    nansat_obj.export(final_path + file_name + '.reproject.nc')
开发者ID:korvinos,项目名称:work,代码行数:25,代码来源:custrepr.py

示例4: test_write_geotiffimage

    def test_write_geotiffimage(self):
        n1 = Nansat(self.test_file_stere, logLevel=40)
        tmpfilename = os.path.join(ntd.tmp_data_path,
                                   'nansat_write_geotiffimage.tif')
        n1.write_geotiffimage(tmpfilename)

        self.assertTrue(os.path.exists(tmpfilename))
开发者ID:WYC19910220,项目名称:nansat,代码行数:7,代码来源:test_nansat.py

示例5: test_get_GDALRasterBand

    def test_get_GDALRasterBand(self):
        n = Nansat(self.test_file_gcps, logLevel=40)
        b = n.get_GDALRasterBand(1)
        arr = b.ReadAsArray()

        self.assertEqual(type(b), gdal.Band)
        self.assertEqual(type(arr), np.ndarray)
开发者ID:WYC19910220,项目名称:nansat,代码行数:7,代码来源:test_nansat.py

示例6: test_crop_lonlat

    def test_crop_lonlat(self):
        n1 = Nansat(self.test_file_gcps, logLevel=40)
        ext = n1.crop_lonlat([28, 29], [70.5, 71])

        self.assertEqual(n1.shape(), (111, 110))
        self.assertEqual(ext, (31, 89, 110, 111))
        self.assertEqual(type(n1[1]), np.ndarray)
开发者ID:,项目名称:,代码行数:7,代码来源:

示例7: test_write_figure_clim

    def test_write_figure_clim(self):
        n1 = Nansat(self.test_file_stere, logLevel=40)
        tmpfilename = os.path.join(ntd.tmp_data_path,
                                   'nansat_write_figure_legend.png')
        n1.write_figure(tmpfilename, 3, clim='hist', legend=True)

        self.assertTrue(os.path.exists(tmpfilename))
开发者ID:WYC19910220,项目名称:nansat,代码行数:7,代码来源:test_nansat.py

示例8: test_export_netcdf_arctic_hardcopy

 def test_export_netcdf_arctic_hardcopy(self):
     n = Nansat(self.test_file_arctic, mapper=self.default_mapper)
     n.export(self.tmp_filename, hardcopy=True)
     exported = Nansat(self.tmp_filename, mapper=self.default_mapper)
     self.assertTrue((n[1] == exported[1]).any())
     self.assertTrue((n[2] == exported[2]).any())
     self.assertTrue((n[3] == exported[3]).any())
开发者ID:nansencenter,项目名称:nansat,代码行数:7,代码来源:test_exporter.py

示例9: test_crop_no_gcps_arctic

    def test_crop_no_gcps_arctic(self):
        n1 = Nansat(self.test_file_arctic, logLevel=40)
        ext = n1.crop(10, 20, 50, 60)

        self.assertEqual(n1.shape(), (60, 50))
        self.assertEqual(ext, (10, 20, 50, 60))
        self.assertEqual(type(n1[1]), np.ndarray)
开发者ID:,项目名称:,代码行数:7,代码来源:

示例10: test_write_figure_band

    def test_write_figure_band(self):
        n1 = Nansat(self.test_file_stere, logLevel=40)
        tmpfilename = os.path.join(ntd.tmp_data_path,
                                   'nansat_write_figure_band.png')
        n1.write_figure(tmpfilename, 2)

        self.assertTrue(os.path.exists(tmpfilename))
开发者ID:WYC19910220,项目名称:nansat,代码行数:7,代码来源:test_nansat.py

示例11: test_get_no_transect_interactive

    def test_get_no_transect_interactive(self):
        import matplotlib.pyplot as plt
        plt.ion()
        n1 = Nansat(self.test_file_gcps, logLevel=40)
        noneResult = n1.get_transect()

        self.assertEqual(noneResult, None)
        plt.ioff()
开发者ID:WYC19910220,项目名称:nansat,代码行数:8,代码来源:test_nansat.py

示例12: test_dont_export2thredds_gcps

 def test_dont_export2thredds_gcps(self):
     n = Nansat(self.test_file_gcps, logLevel=40)
     n2 = Nansat(domain=n)
     n.add_band(np.ones(n2.shape(), np.float32))
     tmpfilename = os.path.join(ntd.tmp_data_path,
                                'nansat_export2thredds.nc')
     self.assertRaises(OptionError, n2.export2thredds, tmpfilename,
                       ['L_645'])
开发者ID:,项目名称:,代码行数:8,代码来源:

示例13: test_digitize_points

    def test_digitize_points(self):
        ''' shall return empty array in non interactive mode '''
        plt.ion()
        n1 = Nansat(self.test_file_gcps, logLevel=40)
        points = n1.digitize_points(1)

        self.assertEqual(len(points), 0)
        plt.ioff()
开发者ID:,项目名称:,代码行数:8,代码来源:

示例14: test_bands

    def test_bands(self):
        n = Nansat(self.test_file_gcps, logLevel=40)
        bands = n.bands()

        self.assertEqual(type(bands), dict)
        self.assertTrue(1 in bands)
        self.assertTrue('name' in bands[1])
        self.assertEqual(bands[1]['name'], 'L_645')
开发者ID:WYC19910220,项目名称:nansat,代码行数:8,代码来源:test_nansat.py

示例15: test_get_item_inf_expressions

 def test_get_item_inf_expressions(self):
     ''' inf should be replaced with nan '''
     d = Domain(4326, "-te 25 70 35 72 -ts 500 500")
     n = Nansat(domain=d, logLevel=40)
     arr = np.empty((500, 500))
     n.add_band(arr, {'expression': 'np.array([0,1,2,3,np.inf,5,6,7])'})
     self.assertIsInstance(n[1], np.ndarray)
     self.assertTrue(np.isnan(n[1][4]))
开发者ID:,项目名称:,代码行数:8,代码来源:


注:本文中的nansat.Nansat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。