import os.path

from nansat import Nansat
from openwind import SARWind
from asar_image import AsarImage
import numpy as np

class AsarWindImage(SARWind, AsarImage, object):

    def __init__(self, fileName, logLevel=20):

        # init AsarImage object
        AsarImage.__init__(self, fileName)
        # get ncep file name corresponding to self (asar)
        ncepFileName = self.get_ncep(fileName)
        ncep = Nansat(ncepFileName)
        # init SARWind object (open GDAL dataset, compute wind, etc)
        SARWind.__init__(self, fileName, wind_direction=ncepFileName,
                         pixelsize=500, eResampleAlg=1)

        if not (self.has_band('U') and self.has_band('V')):
            raise ValueError('There is no U and V data')

        # add landmask
        self.add_mask(self)

        # get only wind data
        self.get_wind_only(self)

    def reproject(self, domain, **kwargs):
        # go to Nansat.reproject()
        super(SARWind, self).reproject(dstDomain=domain, **kwargs)





