def export(self, rsfile): sys.stderr.write('\nexport:'+rsfile+'\n') ncfile = 'test.nc' orig = Nansat(rsfile) sys.stderr.write('\nExporting\n') orig.export(ncfile) sys.stderr.write('\nOpening Copy\n') copy = Nansat(ncfile) inc0 = orig['incidence_angle'] inc1 = copy['incidence_angle'] sys.stderr.write('\nGet orig grids\n') lon0, lat0 = orig.get_geolocation_grids() sys.stderr.write('\nGet copy grids\n') lon1, lat1 = copy.get_geolocation_grids() sys.stderr.write('\nGet orig sigma0_HH\n') sigma0_0 = orig['sigma0_HH'] sys.stderr.write('\nGet copy sigma0_HH\n') sigma0_1 = copy['sigma0_HH'] sys.stderr.write('\nAsserting\n') np.testing.assert_allclose(lon0, lon1) np.testing.assert_allclose(lat0, lat1) # If the next tests fail, it could indicate that the data is flipped # check by pyplot.imshow orig vs copy... np.testing.assert_allclose(inc0, inc1) np.testing.assert_allclose(sigma0_0, sigma0_1) os.unlink(ncfile)
def export(self, rsfile): sys.stderr.write('\nexport:'+rsfile+'\n') ncfile = 'test.nc' orig = Nansat(rsfile) sys.stderr.write('\nExporting\n') orig.export(ncfile) sys.stderr.write('\nOpening Copy\n') copy = Nansat(ncfile) inc0 = orig['incidence_angle'] inc1 = copy['incidence_angle'] sys.stderr.write('\nGet orig grids\n') lon0, lat0 = orig.get_geolocation_grids() sys.stderr.write('\nGet copy grids\n') lon1, lat1 = copy.get_geolocation_grids() sys.stderr.write('\nGet orig sigma0_HH\n') sigma0_0 = orig['sigma0_HH'] sys.stderr.write('\nGet copy sigma0_HH\n') sigma0_1 = copy['sigma0_HH'] sys.stderr.write('\nAsserting\n') np.testing.assert_allclose(lon0, lon1) np.testing.assert_allclose(lat0, lat1) # If the next tests fail, it could indicate that the data is flipped # check by pyplot.imshow orig vs copy... np.testing.assert_allclose(inc0, inc1) np.testing.assert_allclose(sigma0_0, sigma0_1) os.unlink(ncfile)
def export_band(self, rsfile): sys.stderr.write('\nexport_band:'+rsfile+'\n') orig = Nansat(rsfile) ncfile = 'test.nc' orig.export(ncfile, bands=[orig.get_band_number('incidence_angle')]) copy = Nansat(ncfile) inc0 = orig['incidence_angle'] inc1 = copy['incidence_angle'] np.testing.assert_allclose(inc0, inc1) os.unlink(ncfile)
def export_band(self, rsfile): sys.stderr.write("\nexport_band:" + rsfile + "\n") orig = Nansat(rsfile) ncfile = "test.nc" orig.export(ncfile, bands=[orig._get_band_number("incidence_angle")]) copy = Nansat(ncfile) inc0 = orig["incidence_angle"] inc1 = copy["incidence_angle"] np.testing.assert_allclose(inc0, inc1) os.unlink(ncfile)
def export_band(self, rsfile): sys.stderr.write('\nexport_band:'+rsfile+'\n') orig = Nansat(rsfile) ncfile = 'test.nc' orig.export(ncfile, bands=[orig._get_band_number('incidence_angle')]) copy = Nansat(ncfile) inc0 = orig['incidence_angle'] inc1 = copy['incidence_angle'] np.testing.assert_allclose(inc0, inc1) os.unlink(ncfile)
def export(self, rsfile): ncfile = 'test.nc' orig = Nansat(rsfile) orig.export(ncfile) copy = Nansat(ncfile) inc0 = orig['incidence_angle'] inc1 = copy['incidence_angle'] lon0, lat0 = orig.get_geolocation_grids() lon1, lat1 = copy.get_geolocation_grids() sigma0_0 = orig['sigma0_HH'] sigma0_1 = copy['sigma0_HH'] np.testing.assert_allclose(lon0, lon1) np.testing.assert_allclose(lat0, lat1) # If the next tests fail, it could indicate that the data is flipped # check by pyplot.imshow orig vs copy... np.testing.assert_allclose(inc0, inc1) np.testing.assert_allclose(sigma0_0, sigma0_1) os.unlink(ncfile)
n = Nansat(iFileName) # List bands and georeference of the object print n # Write picture with map of the file location n.write_map('map.png') # Write indexed picture with data from the first band n.write_figure('rgb.png', clim='hist') # Reproject input image onto map of Norwegian Coast # 1. Create domain describing the desired map # 2. Transform the original satellite image # 3. Write the transfromed image into RGB picture dLatlong = Domain("+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs", "-te 27 70.2 31 71.5 -ts 2000 2000") n.reproject(dLatlong) n.write_figure('pro.png', bands=[1,2,3], clim=[0, 100]) # Export projected satelite image into NetCDF format n.export('gcps_projected.nc') # Collect values from interactively drawn transect # 1. draw transect interactively # 2. plot the values values, lonlat, pixlinCoord =n.get_transect() plt.plot(lonlat['shape0']['longitude'], values['1:L_645']['shape0'], '.-');plt.show()