def read_metadata(prologue, image_files): """ Selected items from the GOES image data files (not much information in prologue). """ im = _xrit.read_imagedata(image_files[0]) hdr = im.data_function.data_definition md = Metadata() md.calibrate = _Calibrator(hdr) md.satname = im.platform.lower() md.product_type = 'full disc' md.region_name = 'full disc' #md.product_name = im.product_id md.channel = im.product_name #ssp = float(im.product_name[5:-1].replace('_','.')) #if im.product_name[-1].lower() == 'w': # ssp *= -1 ssp = im.navigation.ssp md.sublon = ssp md.first_pixel = 'north west' md.data_type = -im.structure.nb nseg = im.segment.planned_end_seg_no - im.segment.planned_start_seg_no + 1 #nseg = im.segment.total_seg_no md.image_size = (im.structure.nc, im.structure.nl * nseg) # !!! md.line_offset = 0 #md.time_stamp = im.time_stamp md.production_time = im.production_time md.calibration_unit = "" # Calibration table dd = [] for k in sorted(hdr.keys()): if isinstance(k, int): v = hdr[k] dd.append([float(k), v]) try: md.calibration_table = dict( (('name', im.data_function.data_definition['_NAME']), ('unit', im.data_function.data_definition['_UNIT']), ('table', numpy.array(dd, dtype=numpy.float32)))) except KeyError: md.calibration_table = dict( (('unit', im.data_function.data_definition['_UNIT']), ('table', numpy.array(dd, dtype=numpy.float32)))) md.no_data_value = no_data_value segment_size = im.structure.nl #md.loff = im.navigation.loff + segment_size * (im.segment.seg_no - 1) md.loff = im.navigation.loff md.coff = im.navigation.coff return md
def read_metadata(prologue, image_files): """ Selected items from the GOES image data files (not much information in prologue). """ im = _xrit.read_imagedata(image_files[0]) hdr = im.data_function.data_definition md = Metadata() md.calibrate = _Calibrator(hdr) md.satname = im.platform.lower() md.product_type = 'full disc' md.region_name = 'full disc' #md.product_name = im.product_id md.channel = im.product_name #ssp = float(im.product_name[5:-1].replace('_','.')) #if im.product_name[-1].lower() == 'w': # ssp *= -1 ssp = im.navigation.ssp md.sublon = ssp md.first_pixel = 'north west' md.data_type = -im.structure.nb nseg = im.segment.planned_end_seg_no - im.segment.planned_start_seg_no + 1 #nseg = im.segment.total_seg_no md.image_size = (im.structure.nc, im.structure.nl*nseg) # !!! md.line_offset = 0 #md.time_stamp = im.time_stamp md.production_time = im.production_time md.calibration_unit = "" # Calibration table dd = [] for k in sorted(hdr.keys()): if isinstance(k, int): v = hdr[k] dd.append([float(k), v]) try: md.calibration_table = dict((('name', im.data_function.data_definition['_NAME']), ('unit', im.data_function.data_definition['_UNIT']), ('table', numpy.array(dd, dtype=numpy.float32)))) except KeyError: md.calibration_table = dict((('unit', im.data_function.data_definition['_UNIT']), ('table', numpy.array(dd, dtype=numpy.float32)))) md.no_data_value = no_data_value segment_size = im.structure.nl #md.loff = im.navigation.loff + segment_size * (im.segment.seg_no - 1) md.loff = im.navigation.loff md.coff = im.navigation.coff return md
def read_metadata(prologue, image_files): """ Selected items from the Meteosat-7 prolog file. """ im = _xrit.read_imagedata(image_files[0]) fp = StringIO(prologue.data) asc_hdr = _read_ascii_header(fp) bin_hdr = _read_binary_header(fp, asc_hdr['ProductType']) md = Metadata() md.calibrate = _Calibrator(bin_hdr) md.product_name = prologue.product_id pf = asc_hdr['Platform'] if pf == 'M7': pf = 'MET7' md.satname = pf.lower() md.channel = prologue.product_name[:4] md.product_type = asc_hdr['ProductType'] md.region_name = 'full disc' md.sublon = bin_hdr['ssp'] md.first_pixel = asc_hdr['FirstPixelOri'] md.data_type = bin_hdr['dtype']*8 md.no_data_value = 0 md.image_size = (int(asc_hdr['NumberOfPixels']), int(asc_hdr['NumberOfLines'])) md.line_offset = int(asc_hdr['LineOffset']) # handle 24 hour clock d, t = strptime(asc_hdr['Date'], "%y%m%d"), int(asc_hdr['Time']) md.time_stamp = d + timedelta(hours=t//100, minutes=t%100) md.production_time = strptime(asc_hdr['ProdDate'] + asc_hdr['ProdTime'], "%y%m%d%H:%M:%S") md.calibration_unit = 'counts' # Calibration table md.calibration_table = dict((('name', ''), ('unit', ''), ('table', None))) segment_size = im.structure.nl md.loff = im.navigation.loff + segment_size * (im.segment.seg_no - 1) md.coff = im.navigation.coff return md
def read_metadata(prologue, image_files): """ Selected items from the Meteosat-7 prolog file. """ im = _xrit.read_imagedata(image_files[0]) fp = StringIO(prologue.data) asc_hdr = _read_ascii_header(fp) bin_hdr = _read_binary_header(fp, asc_hdr['ProductType']) md = Metadata() md.calibrate = _Calibrator(bin_hdr) md.product_name = prologue.product_id pf = asc_hdr['Platform'] if pf == 'M7': pf = 'MET7' md.satname = pf.lower() md.channel = prologue.product_name[:4] md.product_type = asc_hdr['ProductType'] md.region_name = 'full disc' md.sublon = bin_hdr['ssp'] md.first_pixel = asc_hdr['FirstPixelOri'] md.data_type = bin_hdr['dtype'] * 8 md.no_data_value = 0 md.image_size = (int(asc_hdr['NumberOfPixels']), int(asc_hdr['NumberOfLines'])) md.line_offset = int(asc_hdr['LineOffset']) # handle 24 hour clock d, t = strptime(asc_hdr['Date'], "%y%m%d"), int(asc_hdr['Time']) md.time_stamp = d + timedelta(hours=t // 100, minutes=t % 100) md.production_time = strptime(asc_hdr['ProdDate'] + asc_hdr['ProdTime'], "%y%m%d%H:%M:%S") md.calibration_unit = 'counts' # Calibration table md.calibration_table = dict((('name', ''), ('unit', ''), ('table', None))) segment_size = im.structure.nl md.loff = im.navigation.loff + segment_size * (im.segment.seg_no - 1) md.coff = im.navigation.coff return md