示例#1
0
文件: sat.py 项目: jferencik/mipp
    def load(self, time_stamp, channel, **kwarg):
        if channel not in self._config_reader.channel_names:
            raise mipp.ReaderError("unknown channel name '%s'" % channel)
        opt = self._config_reader('level1')
        val = {}
        val["channel"] = channel + '*'

        # Prologue

        val["segment"] = "PRO".ljust(9, '_')

        filename_pro = opt.get('filename_pro', opt['filename'])
        prologue = glob.glob(opt['dir'] + '/' + \
                             (time_stamp.strftime(filename_pro)%val))
        if not prologue:
            raise mipp.NoFiles("missing prologue file: '%s'" %
                               (time_stamp.strftime(filename_pro) % val))
        prologue = prologue[0]

        # Regular channels

        val["segment"] = "0????????"
        image_files = glob.glob(opt['dir'] + '/' + \
                                time_stamp.strftime(opt['filename'])%val)

        if not image_files:
            raise mipp.NoFiles("no data files: '%s'" %
                               (time_stamp.strftime(opt['filename']) % val))
        image_files.sort()

        # Check if the files are xrit-compressed, and decompress them
        # accordingly:
        decomp_files = decompress(image_files)

        logger.info("Read %s" % prologue)
        prologue = _xrit.read_prologue(prologue)

        # Epilogue

        val["segment"] = "EPI".ljust(9, '_')

        filename_epi = opt.get('filename_epi', opt['filename'])
        epilogue = glob.glob(opt['dir'] + '/' + \
                             (time_stamp.strftime(filename_epi)%val))

        if not epilogue:
            logger.info("No epilogue file to read.")
        else:
            epilogue = epilogue[0]
            logger.info("Read %s" % epilogue)
            epilogue = _xrit.read_epilogue(epilogue)
            return self.load_files(prologue,
                                   decomp_files,
                                   epilogue=epilogue,
                                   **kwarg)

        return self.load_files(prologue, decomp_files, **kwarg)
示例#2
0
文件: sat.py 项目: jferencik/mipp
def load_files(prologue, image_files, epilogue=None, **kwarg):
    if type(prologue) == type('string'):
        logger.info("Read %s" % prologue)
        prologue = _xrit.read_prologue(prologue)
    if epilogue and type(epilogue) == type('string'):
        logger.info("Read %s" % epilogue)
        epilogue = _xrit.read_epilogue(epilogue)
    satname = prologue.platform.lower()
    return SatelliteLoader(mipp.cfg.read_config(satname)).load_files(
        prologue, image_files, epilogue=epilogue, **kwarg)
示例#3
0
文件: sat.py 项目: 3Geo/mipp
def load_files(prologue, image_files, epilogue=None, **kwarg):
    if type(prologue) == type('string'):
        logger.info("Read %s"%prologue)
        prologue = _xrit.read_prologue(prologue)
    if epilogue and type(epilogue) == type('string'):
        logger.info("Read %s"%epilogue)
        epilogue = _xrit.read_epilogue(epilogue)
    satname = prologue.platform.lower()
    return SatelliteLoader(mipp.cfg.read_config(satname)).load_files(prologue, 
                                                                     image_files, 
                                                                     epilogue=epilogue, 
                                                                     **kwarg)
示例#4
0
    def load(self, time_stamp, channel, **kwarg):
        if channel not in self._config_reader.channel_names:
            raise mipp.ReaderError("unknown channel name '%s'"%channel)
        opt = self._config_reader('level1')
        val = {}
        val["channel"] = channel + '*'

        # Prologue
        
        val["segment"] = "PRO".ljust(9, '_')

        filename_pro = opt.get('filename_pro', opt['filename'])
        prologue = glob.glob(opt['dir'] + '/' + \
                             (time_stamp.strftime(filename_pro)%val))
        if not prologue:
            raise mipp.NoFiles("missing prologue file: '%s'"%(time_stamp.strftime(filename_pro)%val))
        prologue = prologue[0]

        # Regular channels
           
        val["segment"] = "0????????"
        image_files = glob.glob(opt['dir'] + '/' + \
                                time_stamp.strftime(opt['filename'])%val)
        
        if not image_files:
            raise mipp.NoFiles("no data files: '%s'"%(time_stamp.strftime(opt['filename'])%val))
        image_files.sort()

        # Check if the files are xrit-compressed, and decompress them
        # accordingly:
        decomp_files = decompress(image_files)
                
        logger.info("Read %s" % prologue)
        prologue = _xrit.read_prologue(prologue)

        # Epilogue

        val["segment"] = "EPI".ljust(9, '_')

        filename_epi = opt.get('filename_epi', opt['filename'])
        epilogue = glob.glob(opt['dir'] + '/' + \
                             (time_stamp.strftime(filename_epi)%val))

        if not epilogue:
            logger.info("No epilogue file to read.")
        else:
            epilogue = epilogue[0]
            logger.info("Read %s" % epilogue)
            epilogue = _xrit.read_epilogue(epilogue)
            return self.load_files(prologue, decomp_files,
                                   epilogue=epilogue, **kwarg)
        
        return self.load_files(prologue, decomp_files, **kwarg)
示例#5
0
def load_files(prologue, image_files, epilogue=None, **kwarg):
    if isinstance(prologue, (str, six.text_type)):
        logger.info("Read %s", prologue)
        prologue = _xrit.read_prologue(prologue)
    if epilogue and isinstance(epilogue, (str, six.text_type)):
        logger.info("Read %s", epilogue)
        epilogue = _xrit.read_epilogue(epilogue)

    satname = kwarg.pop('platform_name', None)
    if satname is None:
        satname = prologue.platform
    return SatelliteLoader(mipp.cfg.read_config(satname)).load_files(
        prologue, image_files, epilogue=epilogue, **kwarg)
示例#6
0
文件: sat.py 项目: pytroll/mipp
def load_files(prologue, image_files, epilogue=None, **kwarg):
    if isinstance(prologue, (str, six.text_type)):
        logger.info("Read %s", prologue)
        prologue = _xrit.read_prologue(prologue)
    if epilogue and isinstance(epilogue, (str, six.text_type)):
        logger.info("Read %s", epilogue)
        epilogue = _xrit.read_epilogue(epilogue)

    satname = kwarg.pop('platform_name', None)
    if satname is None:
        satname = prologue.platform
    return SatelliteLoader(mipp.cfg.read_config(satname)).load_files(prologue,
                                                                     image_files,
                                                                     epilogue=epilogue,
                                                                     **kwarg)
示例#7
0
文件: MSG.py 项目: EBarbera/mipp
def read_obstimes(epilogue):
    """Get the start and end full disk scan times from the Epilogue file."""
    epi = _xrit.read_epilogue(epilogue)
    fpt = StringIO(epi.data)
    ftr = read_epiheader(fpt)
    return (ftr['ForwardScanStart'], ftr['ForwardScanEnd'])
示例#8
0
文件: MSG.py 项目: EBarbera/mipp
    return md

def read_obstimes(epilogue):
    """Get the start and end full disk scan times from the Epilogue file."""
    epi = _xrit.read_epilogue(epilogue)
    fpt = StringIO(epi.data)
    ftr = read_epiheader(fpt)
    return (ftr['ForwardScanStart'], ftr['ForwardScanEnd'])

def read_scanline_quality(segment_filename):
    """Get the line quality data from the segment file. This is from the
    ImageSegmentLineQuality class of the _xrit module, which maps the Header
    Type 129 - Image Segment Line Quality as decribed in the 'MSG Ground
    Segment LRIT/HRIT Mission Specific Implementation, EUM/MSG/SPE/057'
    document, see reference below.
    
    This record contains the scan line mean acquisition times
    
    http://www.eumetsat.int/website/wcm/idc/idcplg?IdcService=GET_FILE&dDocName=PDF_TEN_05057_SPE_MSG_LRIT_HRI&RevisionSelectionMethod=LatestReleased&Rendition=Web

    """
    imgdata = _xrit.read_imagedata(segment_filename)
    return imgdata.image_quality.line_quality
    

if __name__ == '__main__':
    p = _xrit.read_prologue(sys.argv[1])
    e = _xrit.read_epilogue(sys.argv[-1])
    print read_metadata(p, sys.argv[2:-1], e)
示例#9
0
文件: MSG.py 项目: lorehov/mipp
def read_obstimes(epilogue):
    """Get the start and end full disk scan times from the Epilogue file."""
    epi = _xrit.read_epilogue(epilogue)
    fpt = StringIO(epi.data)
    ftr = read_epiheader(fpt)
    return (ftr['ForwardScanStart'], ftr['ForwardScanEnd'])
示例#10
0
文件: MSG.py 项目: lorehov/mipp

def read_obstimes(epilogue):
    """Get the start and end full disk scan times from the Epilogue file."""
    epi = _xrit.read_epilogue(epilogue)
    fpt = StringIO(epi.data)
    ftr = read_epiheader(fpt)
    return (ftr['ForwardScanStart'], ftr['ForwardScanEnd'])


def read_scanline_quality(segment_filename):
    """Get the line quality data from the segment file. This is from the
    ImageSegmentLineQuality class of the _xrit module, which maps the Header
    Type 129 - Image Segment Line Quality as decribed in the 'MSG Ground
    Segment LRIT/HRIT Mission Specific Implementation, EUM/MSG/SPE/057'
    document, see reference below.

    This record contains the scan line mean acquisition times

    http://www.eumetsat.int/website/wcm/idc/idcplg?IdcService=GET_FILE&dDocName=PDF_TEN_05057_SPE_MSG_LRIT_HRI&RevisionSelectionMethod=LatestReleased&Rendition=Web

    """
    imgdata = _xrit.read_imagedata(segment_filename)
    return imgdata.image_quality.line_quality


if __name__ == '__main__':
    p = _xrit.read_prologue(sys.argv[1])
    e = _xrit.read_epilogue(sys.argv[-1])
    print read_metadata(p, sys.argv[2:-1], e)
示例#11
0
文件: sat.py 项目: pytroll/mipp
    def load(self, time_stamp, channel, **kwarg):
        if channel not in self._config_reader.channel_names:
            raise mipp.ReaderError("unknown channel name '%s'" % channel)
        opt = self._config_reader('level1')
        val = {}
        val["channel"] = channel + '*'

        if isinstance(time_stamp, (tuple, list)):
            start_time, end_time = time_stamp
        else:
            start_time = time_stamp
            end_time = time_stamp

        # Prologue

        val["segment"] = "PRO".ljust(9, '_')

        filename_pro = opt.get('filename_pro', opt['filename'])
        prologue = glob.glob(start_time.strftime(
            os.path.join(opt['dir'], filename_pro)) % val)

        if not prologue:
            logger.info("No prologue file to read.")
            prologue = None
        else:
            prologue = prologue[0]
            logger.info("Read %s" % prologue)
            prologue = _xrit.read_prologue(prologue)

        # Regular channels

        val["segment"] = "0??*"
        dt = timedelta(minutes=1)
        image_files = []
        while start_time <= end_time:
            image_files.extend(glob.glob(start_time.strftime(
                os.path.join(opt['dir'], opt['filename'])) % val))
            start_time += dt

        if not image_files:
            raise mipp.NoFiles("no data files: '%s'" %
                               (start_time.strftime(opt['filename']) % val))
        image_files.sort()

        # Check if the files are xrit-compressed, and decompress them
        # accordingly:
        decomp_files = decompress(image_files)

        # Epilogue

        val["segment"] = "EPI".ljust(9, '_')

        filename_epi = opt.get('filename_epi', opt['filename'])
        epilogue = glob.glob(
            end_time.strftime(os.path.join(opt['dir'], filename_epi)) % val)

        if not epilogue:
            logger.info("No epilogue file to read.")
        else:
            epilogue = epilogue[0]
            logger.info("Read %s" % epilogue)
            epilogue = _xrit.read_epilogue(epilogue)
            return self.load_files(prologue, decomp_files,
                                   epilogue=epilogue, **kwarg)

        return self.load_files(prologue, decomp_files, **kwarg)
示例#12
0
    def load(self, time_stamp, channel, **kwarg):
        if channel not in self._config_reader.channel_names:
            raise mipp.ReaderError("unknown channel name '%s'" % channel)
        opt = self._config_reader('level1')
        val = {}
        val["channel"] = channel + '*'

        if isinstance(time_stamp, (tuple, list)):
            start_time, end_time = time_stamp
        else:
            start_time = time_stamp
            end_time = time_stamp

        # Prologue

        val["segment"] = "PRO".ljust(9, '_')

        filename_pro = opt.get('filename_pro', opt['filename'])
        prologue = glob.glob(
            start_time.strftime(os.path.join(opt['dir'], filename_pro)) % val)

        if not prologue:
            logger.info("No prologue file to read.")
            prologue = None
        else:
            prologue = prologue[0]
            logger.info("Read %s" % prologue)
            prologue = _xrit.read_prologue(prologue)

        # Regular channels

        val["segment"] = "0??*"
        dt = timedelta(minutes=1)
        image_files = []
        while start_time <= end_time:
            image_files.extend(
                glob.glob(
                    start_time.strftime(
                        os.path.join(opt['dir'], opt['filename'])) % val))
            start_time += dt

        if not image_files:
            raise mipp.NoFiles("no data files: '%s'" %
                               (start_time.strftime(opt['filename']) % val))
        image_files.sort()

        # Check if the files are xrit-compressed, and decompress them
        # accordingly:
        decomp_files = decompress(image_files)

        # Epilogue

        val["segment"] = "EPI".ljust(9, '_')

        filename_epi = opt.get('filename_epi', opt['filename'])
        epilogue = glob.glob(
            end_time.strftime(os.path.join(opt['dir'], filename_epi)) % val)

        if not epilogue:
            logger.info("No epilogue file to read.")
        else:
            epilogue = epilogue[0]
            logger.info("Read %s" % epilogue)
            epilogue = _xrit.read_epilogue(epilogue)
            return self.load_files(prologue,
                                   decomp_files,
                                   epilogue=epilogue,
                                   **kwarg)

        return self.load_files(prologue, decomp_files, **kwarg)