def calc_directional_aop(self, report, parameter, parameter_dir):
        """
        Will calcuate the directional AOP (only sub-surface rrs for now) if the direction is defined using @
        e.g. rrs@32.0:45  where <zenith-theta>:<azimuth-phi>

        :param report: The planarrad report dictionary.  should include the quadtables and the directional info
        :param parameter: parameter to calc.  Currently only sub-surface reflectance rrs.
        :return:
        """
        lg.debug('calculating the directional ' + parameter)
        tmp_zenith = []

        param_zenith = parameter_dir.split(':')[0]
        param_azimuth = parameter_dir.split(':')[1]

        # --------------------------------------------------#
        # find the mean directions values
        # --------------------------------------------------#
        for i_iter in range(0, int(report['vn'][1])):
            tmp_zenith.append(report['Quad_solid_angle_mean_point_theta'][i_iter][:].split(',')[0]) #that was a pain!

        tmp_azimuth = report['Quad_solid_angle_mean_point_phi'][1]
        zenith = scipy.asarray(tmp_zenith, dtype=float)
        azimuth = scipy.fromstring(tmp_azimuth, dtype=float, sep=',')

        # --------------------------------------------------#
        # now grab the min and max index of the closest match
        # --------------------------------------------------#
        #min_zenith_idx = (scipy.abs(zenith - param_zenith)).argmin()

        from scipy import interpolate


        lw = scipy.zeros(int(report['band_count'][1]))

        for j_iter in range(0, int(report['band_count'][1])):

            if parameter == 'rrs':
                lg.info('Calculating directional rrs')
                tmp_lw = report['L_w_band_' + str(j_iter + 1)]
            elif parameter == 'Rrs':
                lg.info('Calculating directional Rrs')
                print(report.keys())
                tmp_lw = report['L_it_band_' + str(j_iter + 1)]

            lw_scal = scipy.zeros((int(report['vn'][1]), int(report['hn'][1])))

            # for the fist and last line we have to replicate the top and bottom circle
            for i_iter in range(0, int(report['hn'][1])):
                lw_scal[0, i_iter] = tmp_lw[0].split(',')[0]
                lw_scal[int(report['vn'][1]) - 1, i_iter] = tmp_lw[-1].split(',')[0]

            for i_iter in range(1, int(report['vn'][1]) - 1):
                lw_scal[i_iter, :] = scipy.asarray(tmp_lw[i_iter].split(','), dtype=float)

            # to do, make an array of zeros and loop over each list an apply to eah line.  bruteforce

            f1 = interpolate.interp2d(zenith, azimuth, lw_scal)
            lw[j_iter] = f1(float(param_zenith), float(param_azimuth))

        # ----
        # Now we finally have L_w we calculate the rrs
        # ----

        if parameter == 'rrs':
            tmp_rrs = lw / scipy.asarray(report['Ed_w'], dtype=float)[1:]  # ignore the first val as that is depth of val
        elif parameter == 'Rrs':
            tmp_rrs = lw / scipy.asarray(report['Ed_a'], dtype=float)[1:]  # ignore the first val as that is depth of val

        # make rrs a string so it can be written to file.

        rrs = ",".join(map(str, tmp_rrs))

        return " ," + rrs
def calc_directional_aop(self, report, parameter, parameter_dir):
        """
        Will calcuate the directional AOP (only sub-surface rrs for now) if the direction is defined using @
        e.g. rrs@32.0:45  where <zenith-theta>:<azimuth-phi>

        :param report: The planarrad report dictionary.  should include the quadtables and the directional info
        :param parameter: parameter to calc.  Currently only sub-surface reflectance rrs.
        :return:
        """
        lg.debug('calculating the directional ' + parameter)
        tmp_zenith = []

        param_zenith = parameter_dir.split(':')[0]
        param_azimuth = parameter_dir.split(':')[1]

        # --------------------------------------------------#
        # find the mean directions values
        # --------------------------------------------------#
        for i_iter in range(0, int(report['vn'][1])):
            tmp_zenith.append(report['Quad_solid_angle_mean_point_theta'][i_iter][:].split(',')[0]) #that was a pain!

        tmp_azimuth = report['Quad_solid_angle_mean_point_phi'][1]
        zenith = scipy.asarray(tmp_zenith, dtype=float)
        azimuth = scipy.fromstring(tmp_azimuth, dtype=float, sep=',')

        # --------------------------------------------------#
        # now grab the min and max index of the closest match
        # --------------------------------------------------#
        #min_zenith_idx = (scipy.abs(zenith - param_zenith)).argmin()

        from scipy import interpolate


        lw = scipy.zeros(int(report['band_count'][1]))

        for j_iter in range(0, int(report['band_count'][1])):

            if parameter == 'rrs':
                lg.info('Calculating directional rrs')
                tmp_lw = report['L_w_band_' + str(j_iter + 1)]
            elif parameter == 'Rrs':
                lg.info('Calculating directional Rrs')
                print(report.keys())
                tmp_lw = report['L_it_band_' + str(j_iter + 1)]

            lw_scal = scipy.zeros((int(report['vn'][1]), int(report['hn'][1])))

            # for the fist and last line we have to replicate the top and bottom circle
            for i_iter in range(0, int(report['hn'][1])):
                lw_scal[0, i_iter] = tmp_lw[0].split(',')[0]
                lw_scal[int(report['vn'][1]) - 1, i_iter] = tmp_lw[-1].split(',')[0]

            for i_iter in range(1, int(report['vn'][1]) - 1):
                lw_scal[i_iter, :] = scipy.asarray(tmp_lw[i_iter].split(','), dtype=float)

            # to do, make an array of zeros and loop over each list an apply to eah line.  bruteforce

            f1 = interpolate.interp2d(zenith, azimuth, lw_scal)
            lw[j_iter] = f1(float(param_zenith), float(param_azimuth))

        # ----
        # Now we finally have L_w we calculate the rrs
        # ----

        if parameter == 'rrs':
            tmp_rrs = lw / scipy.asarray(report['Ed_w'], dtype=float)[1:]  # ignore the first val as that is depth of val
        elif parameter == 'Rrs':
            tmp_rrs = lw / scipy.asarray(report['Ed_a'], dtype=float)[1:]  # ignore the first val as that is depth of val

        # make rrs a string so it can be written to file.

        rrs = ",".join(map(str, tmp_rrs))

        return " ," + rrs
def calc_directional_aop ( self , report , parameter , parameter_dir ) : lg . debug ( 'calculating the directional ' + parameter ) tmp_zenith = [ ] param_zenith = parameter_dir . split ( ':' ) [ 0 ] param_azimuth = parameter_dir . split ( ':' ) [ 1 ] # --------------------------------------------------# # find the mean directions values # --------------------------------------------------# for i_iter in range ( 0 , int ( report [ 'vn' ] [ 1 ] ) ) : tmp_zenith . append ( report [ 'Quad_solid_angle_mean_point_theta' ] [ i_iter ] [ : ] . split ( ',' ) [ 0 ] ) #that was a pain! tmp_azimuth = report [ 'Quad_solid_angle_mean_point_phi' ] [ 1 ] zenith = scipy . asarray ( tmp_zenith , dtype = float ) azimuth = scipy . fromstring ( tmp_azimuth , dtype = float , sep = ',' ) # --------------------------------------------------# # now grab the min and max index of the closest match # --------------------------------------------------# #min_zenith_idx = (scipy.abs(zenith - param_zenith)).argmin() from scipy import interpolate lw = scipy . zeros ( int ( report [ 'band_count' ] [ 1 ] ) ) for j_iter in range ( 0 , int ( report [ 'band_count' ] [ 1 ] ) ) : if parameter == 'rrs' : lg . info ( 'Calculating directional rrs' ) tmp_lw = report [ 'L_w_band_' + str ( j_iter + 1 ) ] elif parameter == 'Rrs' : lg . info ( 'Calculating directional Rrs' ) print ( report . keys ( ) ) tmp_lw = report [ 'L_it_band_' + str ( j_iter + 1 ) ] lw_scal = scipy . zeros ( ( int ( report [ 'vn' ] [ 1 ] ) , int ( report [ 'hn' ] [ 1 ] ) ) ) # for the fist and last line we have to replicate the top and bottom circle for i_iter in range ( 0 , int ( report [ 'hn' ] [ 1 ] ) ) : lw_scal [ 0 , i_iter ] = tmp_lw [ 0 ] . split ( ',' ) [ 0 ] lw_scal [ int ( report [ 'vn' ] [ 1 ] ) - 1 , i_iter ] = tmp_lw [ - 1 ] . split ( ',' ) [ 0 ] for i_iter in range ( 1 , int ( report [ 'vn' ] [ 1 ] ) - 1 ) : lw_scal [ i_iter , : ] = scipy . asarray ( tmp_lw [ i_iter ] . split ( ',' ) , dtype = float ) # to do, make an array of zeros and loop over each list an apply to eah line.  bruteforce f1 = interpolate . interp2d ( zenith , azimuth , lw_scal ) lw [ j_iter ] = f1 ( float ( param_zenith ) , float ( param_azimuth ) ) # ---- # Now we finally have L_w we calculate the rrs # ---- if parameter == 'rrs' : tmp_rrs = lw / scipy . asarray ( report [ 'Ed_w' ] , dtype = float ) [ 1 : ] # ignore the first val as that is depth of val elif parameter == 'Rrs' : tmp_rrs = lw / scipy . asarray ( report [ 'Ed_a' ] , dtype = float ) [ 1 : ] # ignore the first val as that is depth of val # make rrs a string so it can be written to file. rrs = "," . join ( map ( str , tmp_rrs ) ) return " ," + rrs
Will calcuate the directional AOP (only sub-surface rrs for now) if the direction is defined using @
        e.g. rrs@32.0:45  where <zenith-theta>:<azimuth-phi>

        :param report: The planarrad report dictionary.  should include the quadtables and the directional info
        :param parameter: parameter to calc.  Currently only sub-surface reflectance rrs.
        :return:
Will calcuate the directional AOP ( only sub - surface rrs for now ) if the direction is defined using @ e . g . rrs@32 . 0 : 45 where <zenith - theta > : <azimuth - phi >