Example #1
0
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
Example #2
0
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
Example #3
0
File: _xrit.py Project: 3Geo/mipp
 def __init__(self, fp):
     self.rec_len = read_uint2(fp.read(2))
     self.text = fp.read(self.rec_len-3).strip()
     a = [x.strip('_') for x in self.text.split('-')]
     self.xrit_channel_id = a[0]
     self.dissemination_id = int(a[1])
     self.dissemination_sc = a[2]
     self.platform = a[3]
     self.product_name = a[4]
     self.segment_name = a[5]
     self.time_stamp = mipp.strptime(a[6], "%Y%m%d%H%M")
     self.flags = a[7]
     self.segment_id = a[3] + '_' + a[4] + '_' + a[5] + '_' + self.time_stamp.strftime("%Y%m%d_%H%M")
     self.product_id = a[3] + '_' + a[4] + '_' + self.time_stamp.strftime("%Y%m%d_%H%M")
Example #4
0
 def __init__(self, fp):
     self.rec_len = rbin.read_uint2(fp.read(2))
     self.text = fp.read(self.rec_len-3).strip()
     a = [x.strip('_') for x in self.text.split('-')]
     self.xrit_channel_id = a[0]
     self.dissemination_id = int(a[1])
     self.dissemination_sc = a[2]
     self.platform = a[3]
     self.product_name = a[4]
     self.segment_name = a[5]
     self.time_stamp = mipp.strptime(a[6], "%Y%m%d%H%M")
     self.flags = a[7]
     self.segment_id = a[3] + '_' + a[4] + '_' + a[5] + '_' + self.time_stamp.strftime("%Y%m%d_%H%M")
     self.product_id = a[3] + '_' + a[4] + '_' + self.time_stamp.strftime("%Y%m%d_%H%M")