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)
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)
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)
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)
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)
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)
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'])
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)
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)
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)
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)