Пример #1
0
 def testReal(self):
     m1 = _getMapping()
     m2 = resample(m1, pxPerDeg=15, method='mean')
     m2.checkPlateCarree()
     m3 = resample(m2, arcsecPerPx=100, method='nearest')
     m3.checkPlateCarree()
     
     assert_array_approx_equal(_bbToArray(m2.boundingBox), _bbToArray(m1.boundingBox), 1)
     assert_array_approx_equal(_bbToArray(m3.boundingBox), _bbToArray(m1.boundingBox), 1)
Пример #2
0
    def _testReal(self):
        m1 = _getMapping()
        m2 = resample(m1, pxPerDeg=15, method='mean')
        m2.checkPlateCarree()
        m3 = resample(m2, arcsecPerPx=100, method='nearest')
        m3.checkPlateCarree()

        assert_array_approx_equal(_bbToArray(m2.boundingBox),
                                  _bbToArray(m1.boundingBox), 1)
        assert_array_approx_equal(_bbToArray(m3.boundingBox),
                                  _bbToArray(m1.boundingBox), 1)
Пример #3
0
 def testMiracleMapping(self):
     m = _getMiracleMapping()
     m.checkGuarantees()
     m = m.maskedByElevation(10)
     m.checkGuarantees()
     m = resample(m, arcsecPerPx=100, method='mean')
     m.checkGuarantees()
Пример #4
0
    def test(self):
        lats, lons, latsCenter, lonsCenter = testCoordsDiscontinuity()

        altitude = 110
        rgb = ma.masked_array(
            (np.random.rand(lats.shape[0] - 1, lats.shape[1] - 1, 3) *
             255).astype(np.uint8))
        elevation = np.zeros((rgb.shape[0], rgb.shape[1]))

        date = datetime.datetime.now()
        mapping = GenericMapping(lats,
                                 lons,
                                 latsCenter,
                                 lonsCenter,
                                 elevation,
                                 altitude,
                                 rgb,
                                 cameraPosGCRS=np.array([0, 0, 0]),
                                 photoTime=date,
                                 identifier=None)
        m = resample(mapping, pxPerDeg=1, method='mean')
        m.checkPlateCarree()

        mapping = resampleMLatMLT(mapping, arcsecPerPx=100, method='nearest')
        assert not mapping.isPlateCarree
        mlat, mlt = mapping.mLatMlt
        mlat, mlt = mlat.data, mlt.data
        smlon = mltToSmLon(mlt)
        checkPlateCarree(mlat, smlon)
Пример #5
0
 def testSpacecraftMappingSouth(self):
     m = _getMappingSouth()
     m.checkGuarantees()
     m = m.maskedByElevation(10)
     m.checkGuarantees()
     m = resample(m, arcsecPerPx=100, method='mean')
     m.checkGuarantees()
Пример #6
0
 def _testColors(self):
     m = _getMappingNorth()
     m = resample(m, arcsecPerPx=100, method='mean')
     saveFig('test_white.png', drawStereographic(m, bottomTitle='foo'), bgcolor='white')
     saveFig('test_black.png', drawStereographic(m, bottomTitle='foo'), bgcolor='black')
     saveFig('test_polar_white.png', drawMLatMLTPolar(m), bgcolor='white')
     saveFig('test_polar_black.png', drawMLatMLTPolar(m), bgcolor='black')
Пример #7
0
 def testMiracleMapping(self):
     m = _getMiracleMapping()
     m.checkGuarantees()
     m = m.maskedByElevation(10)
     m.checkGuarantees()
     m = resample(m, arcsecPerPx=100, method='mean')
     m.checkGuarantees()
Пример #8
0
 def testSpacecraftMappingSouth(self):
     m = _getMappingSouth()
     m.checkGuarantees()
     m = m.maskedByElevation(10)
     m.checkGuarantees()
     m = resample(m, arcsecPerPx=100, method='mean')
     m.checkGuarantees()
Пример #9
0
 def _testMLatMLTPolarMapNorthPole(self):
     m = _getMappingNorth()
     m.checkGuarantees()
     #m = m.maskedByElevation(10)
     #m.checkGuarantees()
     m = resample(m, arcsecPerPx=100, method='mean')
     m.checkGuarantees()
     saveFig('test_mlatmlt_polar_north.png', drawMLatMLTPolar(m))
Пример #10
0
 def _testMLatMLTPolarMapBothHemispheres(self):
     m = _getMappingSouth()
     m.checkGuarantees()
     #m = m.maskedByElevation(10)
     #m.checkGuarantees()
     m = resample(m, arcsecPerPx=100, method='mean')
     m.checkGuarantees()
     seqbb = BoundingBox(latSouth=-61.150846231, lonWest=142.622725698, latNorth=6.84984918353, lonEast=-116.820615123)
     saveFig('test_mlatmlt_polar_seqbb.png', drawMLatMLTPolar(m, boundingBox=seqbb))
Пример #11
0
 def _testMiracle(self):
     m = _getMiracleMapping()
     saveFig('heat_intersection.png', drawHeatmap(m.intersectionInflatedCorner[...,0]))
     drawHeatmaps(m)
     m.checkGuarantees()
     m = m.maskedByElevation(10)
     m.checkGuarantees()
     m = resample(m, arcsecPerPx=100, method='mean')
     m.checkGuarantees()
     saveFig('test_stereo.png', drawStereographic(m))
Пример #12
0
 def testSpacecraftMappingNorth(self):
     m = _getMappingNorth()
     m.checkGuarantees()
     m2 = m.maskedByElevation(10)
     m2.checkGuarantees()
     
     assert np.any(~(m.latsCenter.mask == m2.latsCenter.mask))
     assert np.any(~(m.lats.mask == m2.lats.mask))
     
     m3 = resample(m, arcsecPerPx=100, method='mean')
     m3.checkGuarantees()
Пример #13
0
    def testSpacecraftMappingNorth(self):
        m = _getMappingNorth()
        m.checkGuarantees()
        m2 = m.maskedByElevation(10)
        m2.checkGuarantees()

        assert np.any(~(m.latsCenter.mask == m2.latsCenter.mask))
        assert np.any(~(m.lats.mask == m2.lats.mask))

        m3 = resample(m, arcsecPerPx=100, method='mean')
        m3.checkGuarantees()
Пример #14
0
 def _testHoleBug(self):
     """
     Triggers a (now fixed) bug that occured when 'mean' resampling led to
     single-polygon holes where surrounding polygons were well-defined.
     A hole is a polygon such that all corners are defined and just the polygon
     center data was missing (color etc.). The issue was that those holes were
     not filtered and led to subsequent errors. The fix was to filter not by whether
     all corners are defined but whether the color is defined as this also guarantees
     that the corners are defined.        
     """
     m = _getMappingNorth()
     m = resample(m, arcsecPerPx=200, method='mean')
     # saving as svg without rasterization will lead to errors when trying to use
     # polygons with NaN colors; saving as png only leads to black areas!
     saveFig('test_stereo.svg', drawStereographic(m, rasterized=False))
Пример #15
0
    def testPlateCarreeNetCDFExport(self):
        imagePath = getResourcePath('ISS030-E-102170_dc.jpg')
        wcsPath = getResourcePath('ISS030-E-102170_dc.wcs')
        mapping = getMapping(imagePath, wcsPath, fastCenterCalculation=True)
        mapping = resample(mapping, arcsecPerPx=200)
        path = tempfile.mktemp(suffix='.nc')
        try:
            auromat.export.netcdf.write(path, mapping)

            cdfmapping = NetCDFMapping(path)
            cdfmapping.checkGuarantees()
            cdfmapping.checkPlateCarree()

            check_equal(cdfmapping, mapping)
        finally:
            if os.path.exists(path):
                os.remove(path)
Пример #16
0
 def testPlateCarreeNetCDFExport(self):
     imagePath = getResourcePath('ISS030-E-102170_dc.jpg')
     wcsPath = getResourcePath('ISS030-E-102170_dc.wcs')
     mapping = getMapping(imagePath, wcsPath, fastCenterCalculation=True)
     mapping = resample(mapping, arcsecPerPx=200)
     path = tempfile.mktemp(suffix='.nc')
     try:
         auromat.export.netcdf.write(path, mapping)
         
         cdfmapping = NetCDFMapping(path)
         cdfmapping.checkGuarantees()
         cdfmapping.checkPlateCarree()
         
         check_equal(cdfmapping, mapping)
     finally:
         if os.path.exists(path):
             os.remove(path)
Пример #17
0
    def test(self):
        np.set_printoptions(precision=1)
        lats, lons, latsCenter, lonsCenter = testCoordsDiscontinuity()

        altitude = 110
        rgb = ma.masked_array((np.random.rand(lats.shape[0]-1,lats.shape[1]-1,3) * 255).astype(np.uint8))
        elevation = np.zeros((rgb.shape[0], rgb.shape[1]))
                
        mapping = GenericMapping(lats, lons, latsCenter, lonsCenter, elevation, altitude, rgb, 
                                 cameraPosGCRS=np.array([0,0,0]), photoTime=datetime.datetime.now(), identifier=None)
        m = resample(mapping, pxPerDeg=1, method='mean')
        m.checkPlateCarree()
        
        mapping = resampleMLatMLT(mapping, arcsecPerPx=100, method='nearest')
        assert not mapping.isPlateCarree
        mlat, mlt = mapping.mLatMlt
        smlon = mltToSmLon(mlt)
        checkPlateCarree(mlat, smlon)
Пример #18
0
import numpy as np
import cv2
import base64
import math
import matplotlib.pyplot as plt

for i in range(64757, 64758):

    dcfolder = '/home/lianqiang/data/iss_imgs_dc'
    wcsfolder = '/home/lianqiang/data/iss_wcs'

    print("Calculating...")
    provider = SpacecraftMappingProvider(dcfolder, wcsfolder)
    number = str(i)
    mapping = provider.getById(number)  # id = any unique part of the filename
    resampled = resample(mapping, arcsecPerPx=100)
    masked = resampled.maskedByElevation(10)
    # h = mapping.img.shape[0]
    # w = mapping.img.shape[1]

    # img = list(np.array(masked.img).flatten())
    # lats = list(np.array(masked.lats).flatten())
    # lons = list(np.array(masked.lons).flatten())

    img = masked.img
    lats = masked.lats
    lons = masked.lons

    # plt.scatter(lats, lons, np.array(masked.img).flatten())
    # plt.show()
    # for i in range(0, len(lats)):
Пример #19
0
 def _testPoleBug(self):
     m1 = _getMapping()
     m2 = resample(m1, arcsecPerPx=100, method='mean')
     assert_array_approx_equal(_bbToArray(m2.boundingBox),
                               _bbToArray(m1.boundingBox), 1)
Пример #20
0
def _profileMeanResampling(m):
    print('profiling mean resampling')
    resample(m, method='mean')
Пример #21
0
 def _testStereographicMap(self):
     m = _getMappingSouth()
     m = m.maskedByElevation(10)
     m = resample(m, arcsecPerPx=100, method='mean')
     saveFig('test_stereo.svg', drawStereographic(m), dpi=200)
Пример #22
0
 def _testBBPole2(self):
     bb = BoundingBox(latSouth=35.3446724767, lonWest=-180.0, latNorth=90.0, lonEast=180.0)
     m = _getMappingNorth()
     m = resample(m, arcsecPerPx=100, method='mean')
     saveFig('test_bb.png', drawStereographic(m, boundingBox=bb))
Пример #23
0
import numpy as np
import cv2
import base64
import math
import matplotlib.pyplot as plt

for i in range(64757, 64758):

	dcfolder = '/home/lianqiang/data/iss_imgs_dc'
	wcsfolder = '/home/lianqiang/data/iss_wcs'

	print("Calculating...")
	provider = SpacecraftMappingProvider(dcfolder, wcsfolder)
	number = str(i)
	mapping = provider.getById(number) # id = any unique part of the filename
	resampled = resample(mapping, arcsecPerPx=100)
	masked = resampled.maskedByElevation(10)
	# h = mapping.img.shape[0]
	# w = mapping.img.shape[1]

	# img = list(np.array(masked.img).flatten())
	# lats = list(np.array(masked.lats).flatten())
	# lons = list(np.array(masked.lons).flatten())

	img = masked.img
	lats = masked.lats
	lons = masked.lons

	# plt.scatter(lats, lons, np.array(masked.img).flatten())
	# plt.show()
	# for i in range(0, len(lats)):
Пример #24
0
 def _testSingle(self):
     provider = ISSMappingProvider(url, cacheFolder, altitude=110)
     
     mapping = provider.get(datetime(2012,1,25,9,26,57))
     mapping = resample(mapping, arcsecPerPx=100)
     saveFig('test.png', drawStereographicMLatMLT(mapping))
Пример #25
0
def _profileMeanResampling(m):
    print('profiling mean resampling')
    resample(m, method='mean')
Пример #26
0
 def testPoleBug(self):
     m1 = _getMapping()
     m2 = resample(m1, arcsecPerPx=100, method='mean')
     assert_array_approx_equal(_bbToArray(m2.boundingBox), _bbToArray(m1.boundingBox), 1)