<filename>data/gsd.py
from os.path import basename
from re import findall


def get_gsd(name):
    base_name = basename(name)
    # K3A scenes
    if base_name[:3] == 'K3A':
        name = '_'.join(base_name.split('_')[:5])
    # SkySAT scenes
    else:
        splits = base_name.split('_')[:3]
        splits[2] = findall('ssc[0-9]+d', splits[2])[0]
        name = '_'.join(splits)

    try:
        return GSD_LUT[name]
    except:
        return {'width': 0.55, 'height': 0.55}


K3A_LUT = {'K3A_20151028043640_03268_00120118_L1R': {'width': 0.611, 'height': 0.680},
           'K3A_20190129043331_21236_00651970_L1R': {'width': 0.543, 'height': 0.541},
           'K3A_20190129043331_21236_00483847_L1R': {'width': 0.543, 'height': 0.541},
           'K3A_20190129043331_21236_00700034_L1R': {'width': 0.543, 'height': 0.541},
           'K3A_20190129043331_21236_00603951_L1R': {'width': 0.543, 'height': 0.541},
           'K3A_20190129043331_21236_00555909_L1R': {'width': 0.543, 'height': 0.541},
           'K3A_20190129043331_21236_00724030_L1R': {'width': 0.543, 'height': 0.541},
           'K3A_20170128042925_10189_00047422_L1R': {'width': 0.589, 'height': 0.564},
           'K3A_20180925043506_19332_00074292_L1R': {'width': 0.551, 'height': 0.550},
           'K3A_20160618043234_06804_00143914_L1R': {'width': 0.561, 'height': 0.555},
           'K3A_20180707043623_18123_00027139_L1R': {'width': 0.559, 'height': 0.549},
           'K3A_20160618043234_06804_00120499_L1R': {'width': 0.561, 'height': 0.555},
           'K3A_20160328044311_05565_00003608_L1R': {'width': 0.553, 'height': 0.550},
           'K3A_20190129043331_21236_00675990_L1R': {'width': 0.543, 'height': 0.541},
           'K3A_20190129043331_21236_00627950_L1R': {'width': 0.543, 'height': 0.541},
           'K3A_20190120043337_21100_00345008_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20180926042450_19347_00161971_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20151028043641_03268_00153764_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20180707043623_18123_00088471_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20190129043331_21236_00459811_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20151028043640_03268_00120118_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20190129043331_21236_00483847_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20190129043331_21236_00507868_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20190102043431_20828_00329536_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20180926042450_19347_00195222_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20190129043331_21236_00531870_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20180707043623_18123_00050847_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20190102043431_20828_00349927_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20180707043623_18123_00074560_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20151028043641_03268_00099058_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20180926042450_19347_00184622_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20190120043337_21100_00324917_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20190120043337_21100_00365098_L1G': {'width': 0.55, 'height': 0.55},
           'K3A_20151028043641_03268_00137294_L1G': {'width': 0.55, 'height': 0.55},
           }

# TODO(sjhong): Add all SkySAT scenes
SkySAT_LUT = {'20190918_045553_ssc8d': {'width': 0.55, 'height': 0.55},
              '20200201_021514_ssc3d': {'width': 0.55, 'height': 0.55},
              '20200219_020629_ssc3d': {'width': 0.55, 'height': 0.55},
              '20200607_020425_ssc3d': {'width': 0.55, 'height': 0.55},
              '20201011_020357_ssc12d': {'width': 0.55, 'height': 0.55},
              '20201017_045510_ssc6d': {'width': 0.55, 'height': 0.55},
              '20201017_050925_ssc7d': {'width': 0.55, 'height': 0.55}
              }

scenes = [K3A_LUT, SkySAT_LUT]
GSD_LUT = dict()
for scene in scenes:
    for k, v in scene.items():
        GSD_LUT[k] = v
