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 = prologue.product_id md.channel = prologue.product_name[:4] ssp = float(im.product_name[5:-1].replace('_','.')) if im.product_name[-1].lower() == 'w': ssp *= -1 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 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 = 'counts' # Calibration table dd = [] for k in sorted(hdr.keys()): if isinstance(k, int): v = hdr[k] dd.append([float(k), v]) 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)))) 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.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, epilogue): """ Selected items from the Meteosat-9 prolog file. """ segment_size = 464 # number of lines in a segment fp = StringIO(prologue.data) hdr = read_proheader(fp) fp = StringIO(epilogue.data) ftr = read_epiheader(fp) im = _xrit.read_imagedata(image_files[0]) md = Metadata() md.calibrate = _Calibrator(hdr, im.product_name) md.sublon = hdr["SatelliteDefinition"]["NominalLongitude"] md.product_name = im.product_id md.channel = im.product_name if md.channel == "HRV": md.image_size = np.array((hdr["ReferenceGridHRV"]["NumberOfLines"], hdr["ReferenceGridHRV"]["NumberOfColumns"])) else: md.image_size = np.array((hdr["ReferenceGridVIS_IR"]["NumberOfLines"], hdr["ReferenceGridVIS_IR"]["NumberOfColumns"])) md.satname = im.platform.lower() md.product_type = 'full disc' md.region_name = 'full disc' if md.channel == "HRV": md.first_pixel = hdr["ReferenceGridHRV"]["GridOrigin"] ns_, ew_ = md.first_pixel.split() md.boundaries = np.array([[ ftr["LowerSouthLineActual"], ftr["LowerNorthLineActual"], ftr["LowerEastColumnActual"], ftr["LowerWestColumnActual"]], [ftr["UpperSouthLineActual"], ftr["UpperNorthLineActual"], ftr["UpperEastColumnActual"], ftr["UpperWestColumnActual"]]]) im_loff = im.navigation.loff + segment_size * (im.segment.seg_no - 1) md.coff = (ftr["Lower"+ew_.capitalize()+"ColumnActual"] + im.navigation.coff - 1) md.loff = (ftr["Lower"+ns_.capitalize()+"LineActual"] + im_loff - 1) else: md.first_pixel = hdr["ReferenceGridVIS_IR"]["GridOrigin"] ns_, ew_ = md.first_pixel.split() md.boundaries = np.array([[ ftr["SouthernLineActual"], ftr["NorthernLineActual"], ftr["EasternColumnActual"], ftr["WesternColumnActual"]]]) im_loff = im.navigation.loff + segment_size * (im.segment.seg_no - 1) md.coff = (ftr[ew_.capitalize()+"ernColumnActual"] + im.navigation.coff - 1) md.loff = (ftr[ns_.capitalize()+"ernLineActual"] + im_loff - 1) md.data_type = im.structure.nb md.no_data_value = no_data_value md.line_offset = 0 md.time_stamp = im.time_stamp md.production_time = im.production_time md.calibration_unit = 'counts' return md