예제 #1
0
파일: sensor.py 프로젝트: yanggis/espa-api
    def __init__(self, product_id):
        product_id = product_id.strip()
        super(Sentinel2, self).__init__(product_id)

        id_len = self.check_id(product_id)

        if id_len is 'short':
            _idlist = product_id.split('_')
            self.year = _idlist[3][:4]
            self.doy = julian_from_date(self.year, _idlist[3][4:6],
                                        _idlist[3][6:8])
            self.julian = self.year + self.doy
            self.tile = _idlist[1]

        elif id_len is 'long':
            self.year = product_id[25:29]
            self.doy = julian_from_date(self.year, product_id[29:31],
                                        product_id[31:33])
            self.julian = self.year + self.doy
            self.tile = product_id[66:71]

        else:
            msg = 'the Sentinel-2 product_id {} does not match any expected pattern'.format(
                product_id)
            logger.exception(msg)
            raise ProductNotImplemented(product_id)
예제 #2
0
def instance(product_id):
    """
    Supported MODIS products
    MOD09A1 MOD09GA MOD09GQ MOD09Q1 MYD09A1 MYD09GA MYD09GQ MYD09Q1
    MOD13A1 MOD13A2 MOD13A3 MOD13Q1 MYD13A1 MYD13A2 MYD13A3 MYD13Q1

    MODIS FORMAT:   MOD09GQ.A2000072.h02v09.005.2008237032813

    Supported VIIRS products
    VNP09GA

    VIIRS FORMAT:   VNP09GA.A2019059.h18v06.001.2019061005706

    Supported LANDSAT products
    LT04 LT05 LE07 LC08 LO08

    LANDSAT FORMAT: LE07_L1TP_026027_20170912_20171008_01_T1
    """

    # remove known file extensions before comparison
    # do not alter the case of the actual product_id!
    _id = product_id.lower().strip()
    __modis_ext = Modis.input_filename_extension
    __viirs_ext = Viirs.input_filename_extension
    __landsat_ext = Landsat.input_filename_extension

    if _id.endswith(__modis_ext):
        index = _id.index(__modis_ext)
        # leave original case intact
        product_id = product_id[0:index]
        _id = _id[0:index]

    elif _id.endswith(__landsat_ext):
        index = _id.index(__landsat_ext)
        # leave original case intact
        product_id = product_id[0:index]
        _id = _id[0:index]

    elif _id.endswith(__viirs_ext):
        index = _id.index(__viirs_ext)
        product_id = product_id[0:index]
        _id = _id[0:index]

    instances = SensorCONST.instances

    for key in instances.iterkeys():
        if re.match(instances[key][0], _id):
            inst = instances[key][1](product_id.strip())
            inst.shortname = key
            return inst

    msg = u"[{0:s}] is not a supported sensor product".format(product_id)
    raise ProductNotImplemented(msg)
예제 #3
0
def instance(product_id):
    """
    Supported MODIS products
    MOD09A1 MOD09GA MOD09GQ MOD09Q1 MYD09A1 MYD09GA MYD09GQ MYD09Q1
    MOD13A1 MOD13A2 MOD13A3 MOD13Q1 MYD13A1 MYD13A2 MYD13A3 MYD13Q1

    MODIS FORMAT:   MOD09GQ.A2000072.h02v09.005.2008237032813

    Supported LANDSAT products
    LT4 LT5 LE7 LC8 LO8

    LANDSAT FORMAT: LE72181092013069PFS00
    """

    # remove known file extensions before comparison
    # do not alter the case of the actual product_id!
    _id = product_id.lower().strip()
    __modis_ext = Modis.input_filename_extension
    __landsat_ext = Landsat.input_filename_extension

    if _id.endswith(__modis_ext):
        index = _id.index(__modis_ext)
        # leave original case intact
        product_id = product_id[0:index]
        _id = _id[0:index]

    elif _id.endswith(__landsat_ext):
        index = _id.index(__landsat_ext)
        # leave original case intact
        product_id = product_id[0:index]
        _id = _id[0:index]

    instances = SensorCONST.instances

    for key in instances.iterkeys():
        if re.match(instances[key][0], _id):
            inst = instances[key][1](product_id.strip())
            inst.shortname = key
            return inst

    msg = u"[{0:s}] is not a supported sensor product".format(product_id)
    raise ProductNotImplemented(msg)