#!/usr/bin/python
# lock processing
import os
from sadcat.tools import lockproc
lockFileName = lockproc('proc_sentinel1.lock',
                        wrn='WARNING!! RS2ICE PROCESSING STOPPED!',
                        from_='sat@johansen.nersc.no',
                        to_='anton.korosov@nersc.no')

# headless matplotlib (for johansen)
import matplotlib
matplotlib.use('Agg')

from nansat import Nansat

from sadcat import *

# L2 processing of Radarsat2 with Ice/water classification
# image-by-image calculation of ice mask using GLCM_NN
# Update database of all images
cic = CommonImagesCatalog()
cic.fill_database('sentinel1', '/Data/sat/downloads/sentinel1/', 'S1A_EW_GRDM_*zip', Sentinel1Image)
cic = None

# perform L2-processing of ice/water classification
rs2ice = L2Catalog('sentinel1')
rs2ice.process(Sentinel1Image)
rs2ice = None

# unlock processing
os.remove(lockFileName)
