Esempio n. 1
0
def profile(profiler):
    imagePath = getResourcePath('ISS030-E-102170_dc.jpg')
    wcsPath = getResourcePath('ISS030-E-102170_dc.wcs')
    m = getMapping(imagePath, wcsPath, fastCenterCalculation=True)
    profiler(_profileLatsLons)(m)
    profiler(_profileBoundingBox)(m)
    profiler(_profileMeanResampling)(m)
Esempio n. 2
0
def profile(profiler):
    imagePath = getResourcePath('ISS030-E-102170_dc.jpg')
    wcsPath = getResourcePath('ISS030-E-102170_dc.wcs')
    m = getMapping(imagePath, wcsPath, fastCenterCalculation=True)
    profiler(_profileLatsLons)(m)
    profiler(_profileBoundingBox)(m)
    profiler(_profileMeanResampling)(m)
Esempio n. 3
0
 def testRawNetCDFExport(self):
     imagePath = getResourcePath('ISS030-E-102170_dc.jpg')
     wcsPath = getResourcePath('ISS030-E-102170_dc.wcs')
     mapping = getMapping(imagePath, wcsPath, fastCenterCalculation=True)
     mapping.checkGuarantees()
     path = tempfile.mktemp(suffix='.nc')
     try:            
         auromat.export.netcdf.write(path, mapping)
         
         with Dataset(path, 'r') as root:
             var = root.variables
             assert set(var.keys()) == set(['time', 'lat', 'lon', 'altitude', 
                                     'lat_bounds', 'lon_bounds', 'mlat', 
                                     'mlt', 'mlat_bounds', 'mlt_bounds', 
                                     'mcrs', 'img_red', 'img_green', 
                                     'img_blue', 'zenith_angle', 
                                     'camera_pos', 'crs'])
         
         cdfmapping = NetCDFMapping(path)
         cdfmapping.checkGuarantees()
         check_equal(cdfmapping, mapping)
             
     finally:
         if os.path.exists(path):
             os.remove(path)
Esempio n. 4
0
 def seq():
     for frame in range(102170,102172):
         wcsPath = getResourcePath('seq3/ISS030-E-%i.wcs' % frame)
         mapping = getMapping(imagePath, wcsPath, fastCenterCalculation=True)
         mapping = mapping.maskedByElevation(10)
         print('SENDING MAPPING', frame, 'TO COROUTINES')
         yield mapping
Esempio n. 5
0
def _getISSMapping():
    imagePath = getResourcePath('ISS029-E-8492.jpg')
    wcsPath = getResourcePath('ISS029-E-8492.wcs')
    mapping = spacecraft.getMapping(imagePath,
                                    wcsPath,
                                    fastCenterCalculation=True)
    return mapping
Esempio n. 6
0
    def testRawNetCDFExport(self):
        imagePath = getResourcePath('ISS030-E-102170_dc.jpg')
        wcsPath = getResourcePath('ISS030-E-102170_dc.wcs')
        mapping = getMapping(imagePath, wcsPath, fastCenterCalculation=True)
        mapping.checkGuarantees()
        path = tempfile.mktemp(suffix='.nc')
        try:
            auromat.export.netcdf.write(path, mapping)

            with Dataset(path, 'r') as root:
                var = root.variables
                assert set(var.keys()) == set([
                    'time', 'lat', 'lon', 'altitude', 'lat_bounds',
                    'lon_bounds', 'mlat', 'mlt', 'mlat_bounds', 'mlt_bounds',
                    'mcrs', 'img_red', 'img_green', 'img_blue', 'zenith_angle',
                    'camera_pos', 'crs'
                ])

            cdfmapping = NetCDFMapping(path)
            cdfmapping.checkGuarantees()
            check_equal(cdfmapping, mapping)

        finally:
            if os.path.exists(path):
                os.remove(path)
Esempio n. 7
0
 def testParallelsMeridiansPlot(self):
     imagePath = getResourcePath('ISS030-E-102170_dc.jpg')
     wcsPath = getResourcePath('ISS030-E-102170_dc.wcs')
     m = getMapping(imagePath, wcsPath, altitude=0, fastCenterCalculation=True)
     figax = loadFigImage(imagePath)
     drawParallelsAndMeridians(m, figax=figax)
     drawConstellations(figax, wcsPath, clipPoly=outline(~m.intersectsEarth))
     saveFig('test_parallelsmeridians.jpg', figax)
Esempio n. 8
0
 def _testConstellationPlot(self):
     imagePath = getResourcePath('ISS030-E-102170_dc.jpg')
     wcsPath = getResourcePath('ISS030-E-102170_dc.wcs')
     
     m = getMapping(imagePath, wcsPath)
     figax = loadFigImage(imagePath)
     drawConstellations(figax, wcsPath, clipPoly=outline(~m.intersectsEarth))
     saveFig('test_constellations.jpg', figax)
Esempio n. 9
0
 def _getmapping(frame):
     gc.collect()
     if frame > 8494:
         # at this place we only have exactly 1 resampled mapping floating around
         assert_equal(len(list(filter(lambda o: isinstance(o, BaseMapping), gc.get_objects()))), 1)                
         
     print('Process memory:', proc.get_memory_info()[0]/1024/1024, 'MB')
     wcsPath = getResourcePath('seq/ISS029-E-%i.wcs' % frame)
     mapping = getMapping(imagePath, wcsPath, fastCenterCalculation=True, identifier=str(frame))
     mapping = mapping.maskedByElevation(10)
     # save some memory by removing additional data
     mapping = GenericMapping.fromMapping(mapping)
     print('SENDING MAPPING', frame, 'TO COROUTINES')            
     return mapping
Esempio n. 10
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)
Esempio n. 11
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)
Esempio n. 12
0
 def get(self, date):
     idx, offset = self._getIdxWithOffset(date)
     if offset > self.maxTimeOffset:
         raise ValueError('No image found')
     
     key = list(self.apiImages.keys())[idx]
     
     self._downloadFiles(key)
     wcsPath = self.wcsPaths[key]
     imagePathOrArray = self._processedImage(key)
     
     metadata = dict(list(self.metadata['sequence_metadata'].items()) +
                     list(self.metadata['image_metadata'][key].items()))
     
     mapping = getMapping(imagePathOrArray, wcsPath, altitude=self.altitude, 
                          fastCenterCalculation=self.fastCenterCalculation,
                          metadata=metadata, identifier=key)
     return mapping
Esempio n. 13
0
 def _testParallelsMeridiansPlotOptimized(self):
     imagePath = getResourcePath('ISS030-E-102170_dc.jpg')
     wcsPath = getResourcePath('ISS030-E-102170_dc.wcs')
     # As we precalculated the bounding box and the lat/lon label position
     # we only need to access the 'latCenter', 'lonCenter' and 'intersectsEarth'
     # attributes of the spacecraft mapping. This means that we don't need
     # any sanitization applied on the corner coordinate arrays ('lats','lons').
     # For this reason, and because we don't use masking, we set nosanitize=True
     # and can cut the required time in half. 
     m = getMapping(imagePath, wcsPath, altitude=0, fastCenterCalculation=False, nosanitize=True)
     
     # the following values must be precalculated to use the optimization
     # the bounding box at altitude=0 without any masking
     bb = BoundingBox(latSouth=49.3401757697, lonWest=-116.368770925, latNorth=64.288454984, lonEast=-91.8890098192)
     # center of bounding box at altitude=0 when masked below 10deg elevation
     labelLat, labelLon = 53.133, -98.684
     
     figax = loadFigImage(imagePath)
     drawParallelsAndMeridians(figax, m, boundingBox=bb, labelLat=labelLat, labelLon=labelLon)
     drawConstellations(figax, wcsPath, clipPoly=outline(~m.intersectsEarth))
     saveFig('test_parallelsmeridians_optimized.jpg', figax)
Esempio n. 14
0
    def get(self, date):
        idx, offset = self._getIdxWithOffset(date)
        if offset > self.maxTimeOffset:
            raise ValueError('No image found')

        key = list(self.apiImages.keys())[idx]

        self._downloadFiles(key)
        wcsPath = self.wcsPaths[key]
        imagePathOrArray = self._processedImage(key)

        metadata = dict(
            list(self.metadata['sequence_metadata'].items()) +
            list(self.metadata['image_metadata'][key].items()))

        mapping = getMapping(imagePathOrArray,
                             wcsPath,
                             altitude=self.altitude,
                             fastCenterCalculation=self.fastCenterCalculation,
                             metadata=metadata,
                             identifier=key)
        return mapping
Esempio n. 15
0
def _getMappingSouth():
    imagePath = getResourcePath('ISS029-E-8492.jpg')
    wcsPath = getResourcePath('ISS029-E-8492.wcs')
    mapping = getMapping(imagePath, wcsPath, fastCenterCalculation=True)
    return mapping
Esempio n. 16
0
def _getMapping():
    imagePath = getResourcePath('ISS030-E-102170_dc.jpg')
    wcsPath = getResourcePath('ISS030-E-102170_dc.wcs')
    mapping = getMapping(imagePath, wcsPath, fastCenterCalculation=True)
    return mapping
Esempio n. 17
0
    assert bounds.shape == (arr.shape[0]-1, 2)
    return bounds

def _bounds2d(arr):
    assert arr.ndim == 2
    arr = arr[:,:,None]
    bounds = np.concatenate((
                arr[0:-1, 0:-1],
                arr[0:-1, 1:  ],
                arr[1:  , 1:  ],
                arr[1:  , 0:-1],
                ), axis=2)
    assert bounds.shape == (arr.shape[0]-1, arr.shape[1]-1, 4)
    return bounds

def _unix(dt):
    return (dt - datetime(1970, 1, 1)).total_seconds()

if __name__ == '__main__':
    import os
    from auromat.mapping.spacecraft import getMapping
    
    m = getMapping('/home/mriecher/data/arrrgh/img/ISS030-E/102100/ISS030-E-102170.jpg',
                   '/home/mriecher/data/arrrgh/wcs/ISS030-E/102100/ISS030-E-102170_1727.wcs')

    path = '/user_data/mriecher/test.nc'
    if os.path.exists(path):
        os.remove(path)

    write(path, m, includeBounds=True, includeMagCoords=True, zlib=True)
    
Esempio n. 18
0
def _getMappingNorth():
    imagePath = getResourcePath('ISS030-E-102170_dc.jpg')
    wcsPath = getResourcePath('ISS030-E-102170_dc.wcs')
    mapping = getMapping(imagePath, wcsPath, fastCenterCalculation=True)
    return mapping