当前位置: 首页>>代码示例>>Python>>正文


Python ee.Number方法代码示例

本文整理汇总了Python中ee.Number方法的典型用法代码示例。如果您正苦于以下问题:Python ee.Number方法的具体用法?Python ee.Number怎么用?Python ee.Number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ee的用法示例。


在下文中一共展示了ee.Number方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testString

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def testString(self):
    """Verifies basic behavior of ee.String."""
    bare_string = ee.String('foo')
    self.assertEquals('foo', bare_string.encode())

    computed = ee.String('foo').cat('bar')
    self.assertTrue(isinstance(computed, ee.String))
    self.assertEquals(ee.ApiFunction.lookup('String.cat'), computed.func)
    self.assertEquals({'string1': ee.String('foo'),
                       'string2': ee.String('bar')}, computed.args)

    # Casting a non-string ComputedObject.
    obj = ee.Number(1).add(1)
    s = ee.String(obj)
    self.assertTrue(isinstance(s, ee.String))
    self.assertEquals(ee.ApiFunction.lookup('String'), s.func)
    self.assertEquals({'input': obj}, s.args) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:19,代码来源:string_test.py

示例2: pv

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def pv(imList,p,median,j):
    ''' calculate -2log(R_ell,j) and return P-value '''
    imList = ee.List(imList)
    p = ee.Number(p)
    j = ee.Number(j)
    f = p
    one = ee.Number(1.0)
# 1 - (1. + 1./(j*(j-1)))/(6.*p*n)    
    rhoj = one.subtract(one.add(one.divide(j.multiply(j.subtract(one)))).divide(6*ENL))
# -(f/4.)*(1.-1./rhoj)**2'    
    omega2j = one.subtract(one.divide(rhoj)).pow(2.0).multiply(f.divide(-4.0))
    Z = ee.Image(ee.Image(log_det_sum(imList,j.subtract(1)))).multiply(j.subtract(1)) \
                 .add(log_det(imList,j))  \
                 .add(p.multiply(j).multiply(ee.Number(j).log())) \
                 .subtract(p.multiply(j.subtract(1)).multiply(j.subtract(1).log())) \
                 .subtract(ee.Image(log_det_sum(imList,j)).multiply(j)) \
                 .multiply(rhoj) \
                 .multiply(-2*ENL)
# (1.-omega2j)*stats.chi2.cdf(Z,[f])+omega2j*stats.chi2.cdf(Z,[f+4])                 
    P = ee.Image( chi2cdf(Z,f).multiply(one.subtract(omega2j)).add(chi2cdf(Z,f.add(4)).multiply(omega2j))  )
# 3x3 median filter    
    return ee.Algorithms.If(median, P.focal_median(), P) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:24,代码来源:eeWishart.py

示例3: filter_j

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def filter_j(current,prev):
    P = ee.Image(current)
    prev = ee.Dictionary(prev)
    ell = ee.Number(prev.get('ell'))
    cmap = ee.Image(prev.get('cmap'))
    smap = ee.Image(prev.get('smap'))
    fmap = ee.Image(prev.get('fmap'))
    bmap = ee.Image(prev.get('bmap'))
    threshold = ee.Image(prev.get('threshold'))
    j = ee.Number(prev.get('j'))
    cmapj = cmap.multiply(0).add(ell.add(j).subtract(1))
    cmap1 = cmap.multiply(0).add(1)
    tst = P.gt(threshold).And(cmap.eq(ell.subtract(1)))
    cmap = cmap.where(tst,cmapj)
    fmap = fmap.where(tst,fmap.add(1))
    smap = ee.Algorithms.If(ell.eq(1),smap.where(tst,cmapj),smap)
    idx = ell.add(j).subtract(2)
    tmp = bmap.select(idx)
    bname = bmap.bandNames().get(idx)
    tmp = tmp.where(tst,cmap1)
    tmp = tmp.rename([bname])    
    bmap = bmap.addBands(tmp,[bname],True)    
    return ee.Dictionary({'ell':ell,'j':j.add(1),'threshold':threshold,'cmap':cmap,'smap':smap,'fmap':fmap,'bmap':bmap}) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:25,代码来源:eeWishart.py

示例4: covw

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def covw(centeredImage, weights=None, maxPixels=1e9):
    '''Return the (weighted) covariance matrix of a centered image''' 
    if weights==None:
        weights = centeredImage.multiply(0).add(ee.Image.constant(1))           
    B1 = centeredImage.bandNames().get(0)       
    b1 = weights.bandNames().get(0)     
    sumWeights = ee.Number(weights.reduceRegion(ee.Reducer.sum(), maxPixels=maxPixels).get(b1))  
    nPixels = ee.Number(centeredImage.reduceRegion(ee.Reducer.count(), maxPixels=maxPixels).get(B1))   
#    arr = dataArray(centeredImage.multiply(weights.sqrt()))
#    return arr.matrixTranspose().matrixMultiply(arr).divide(sumWeights)
    covW = centeredImage \
        .multiply(weights.sqrt()) \
        .toArray() \
        .reduceRegion(ee.Reducer.centeredCovariance(), maxPixels=1e9) \
        .get('array')
    return ee.Array(covW).multiply(nPixels.divide(sumWeights)) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:18,代码来源:eeMad_old.py

示例5: covarw

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def covarw(image, weights, maxPixels=1e9):
    '''Return the weighted centered image and its weighted covariance matrix'''  
    geometry = image.geometry()
    bandNames = image.bandNames()
    N = bandNames.length()
    scale = image.select(0).projection().nominalScale()
    weightsImage = image.multiply(ee.Image.constant(0)).add(weights)
    means = image.addBands(weightsImage) \
                 .reduceRegion(ee.Reducer.mean().repeat(N).splitWeights(), scale=scale,maxPixels=maxPixels) \
                 .toArray() \
                 .project([1])
    centered = image.toArray().subtract(means) 
    B1 = centered.bandNames().get(0)       
    b1 = weights.bandNames().get(0)     
    nPixels = ee.Number(centered.reduceRegion(ee.Reducer.count(), scale=scale, maxPixels=maxPixels).get(B1)) 
    sumWeights = ee.Number(weights.reduceRegion(ee.Reducer.sum(),geometry=geometry, scale=scale, maxPixels=maxPixels).get(b1))
    covw = centered.multiply(weights.sqrt()) \
                   .toArray() \
                   .reduceRegion(ee.Reducer.centeredCovariance(), geometry=geometry, scale=scale, maxPixels=maxPixels) \
                   .get('array')
    covw = ee.Array(covw).multiply(nPixels).divide(sumWeights)
    return (centered.arrayFlatten([bandNames]), covw) 
开发者ID:mortcanty,项目名称:earthengine,代码行数:24,代码来源:eeMad.py

示例6: round_month

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def round_month(date):
    """
    round date to closest month
    """
    # start of THIS month
    m1 = date.fromYMD(date.get('year'),date.get('month'),ee.Number(1))
    
    # start of NEXT month
    m2 = m1.advance(1,'month')
      
    # difference from date
    d1 = ee.Number(date.difference(m1,'day')).abs()
    d2 = ee.Number(date.difference(m2,'day')).abs()
    
    # return closest start of month
    return ee.Date(ee.Algorithms.If(d2.gt(d1),m1,m2)) 
开发者ID:samsammurphy,项目名称:ee-atmcorr-timeseries,代码行数:18,代码来源:atmospheric.py

示例7: solar_z

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def solar_z(image, mission):
  """
  solar zenith angle (degrees)
  """

  def sentinel2(image):
    return ee.Number(image.get('MEAN_SOLAR_ZENITH_ANGLE'))
  
  def landsat(image):
    return ee.Number(90).subtract(image.get('SUN_ELEVATION'))
  
  switch = {

    'Sentinel2':sentinel2,
    'Landsat8':landsat,
    'Landsat7':landsat,
    'Landsat5':landsat,
    'Landsat4':landsat
  }

  getSolarZenith = switch[mission]

  return getSolarZenith(image) 
开发者ID:samsammurphy,项目名称:ee-atmcorr-timeseries,代码行数:25,代码来源:mission_specifics.py

示例8: map

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def map(self, collection, **kwargs):
        """ Map function to use in BAP

        :param year: the analysing year. Must match the year of the bap
        :type year: int
        """
        range_out = self.range_out
        year = kwargs.get('year')
        date_range = self.season.add_year(year)
        doy = ee.Date(season_module.SeasonDate(self.best_doy).add_year(year))
        doy2 = ee.Date(season_module.SeasonDate(self.best_doy).add_year(year-1))
        condition = date_range.contains(doy)
        best = ee.Number(ee.Algorithms.If(condition, doy, doy2))

        return self.apply(collection, best_doy=best, name=self.name,
                          output_min=range_out[0], output_max=range_out[1],
                          function=self.function, stretch=self.stretch) 
开发者ID:fitoprincipe,项目名称:geebap,代码行数:19,代码来源:scores.py

示例9: add_year

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def add_year(self, year):
        year = ee.Number(year)
        if self.over_end:
            start_year = year.subtract(1)
        else:
            start_year = ee.Number(year)
        end_year = ee.Number(year)

        sday = self.start.day
        eday = self.end.day

        # look for feb 29h in non leap
        if not is_leap(year):
            if self.start.month == 2 and sday == 29:
                sday = 28
            if self.end.month == 2 and eday == 29:
                eday = 28

        start = ee.Date.fromYMD(start_year, self.start.month, sday)
        end = ee.Date.fromYMD(end_year, self.end.month, eday)
        daterange = ee.DateRange(ee.Date(start), ee.Date(end))
        return daterange 
开发者ID:fitoprincipe,项目名称:geebap,代码行数:24,代码来源:season.py

示例10: get

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def get(date, unit="days"):
        """ get the date (ee.Date) of the given value in 'unit'.
        Currentrly ONLY process 'days', so:

        `date.Date.get(365) = '1971-01-01T00:00:00`

        :param date: the value to transform
        :type date: int
        :param unit: date's unit (currently ONLY 'days')
        :return: date corresponding to the given value
        :rtype: ee.Date
        """
        if unit == "days":
            mili = ee.Number(date).multiply(Date.oneday)
            d = ee.Date(mili)
            # dstr = d.format()
        return d 
开发者ID:fitoprincipe,项目名称:geebap,代码行数:19,代码来源:date.py

示例11: date_to_time_0utc

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def date_to_time_0utc(date):
    """Get the 0 UTC time_start for a date

    Parameters
    ----------
    date : ee.Date

    Returns
    -------
    ee.Number

    """
    return ee.Date.fromYMD(date.get('year'), date.get('month'),
                           date.get('day')).millis()
    # Extra operations are needed since update() does not set milliseconds to 0.
    # return date.update(hour=0, minute=0, second=0).millis()\
    #     .divide(1000).floor().multiply(1000) 
开发者ID:Open-ET,项目名称:openet-ssebop-beta,代码行数:19,代码来源:utils.py

示例12: toa_image

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def toa_image(red=0.1, nir=0.9, bt=305):
    """Construct a fake Landsat 8 TOA image with renamed bands"""
    mask_img = ee.Image(f'{COLL_ID}/{SCENE_ID}').select(['B3']).multiply(0)
    return ee.Image([mask_img.add(red), mask_img.add(nir), mask_img.add(bt)]) \
        .rename(['red', 'nir', 'tir'])\
        .set({
            'system:time_start': SCENE_TIME,
            'k1_constant': ee.Number(607.76),
            'k2_constant': ee.Number(1260.56),
        })
    # return ee.Image.constant([red, nir, bt])\
    #     .rename(['red', 'nir', 'lst']) \
    #     .set({
    #         'system:time_start': ee.Date(SCENE_DATE).millis(),
    #         'k1_constant': ee.Number(607.76),
    #         'k2_constant': ee.Number(1260.56),
    #     }) 
开发者ID:Open-ET,项目名称:openet-ssebop-beta,代码行数:19,代码来源:test_c_image.py

示例13: enumerateProperty

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def enumerateProperty(collection, name='enumeration'):
    """

    :param collection:
    :param name:
    :return:
    """
    enumerated = eecollection.enumerate(collection)

    def over_list(l):
        l = ee.List(l)
        index = ee.Number(l.get(0))
        element = l.get(1)
        return ee.Image(element).set(name, index)

    imlist = enumerated.map(over_list)
    return ee.ImageCollection(imlist) 
开发者ID:gee-community,项目名称:gee_tools,代码行数:19,代码来源:imagecollection.py

示例14: minscale

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def minscale(image):
    """ Get the minimal scale of an Image, looking at all Image's bands.
    For example if:
        B1 = 30
        B2 = 60
        B3 = 10
    the function will return 10

    :return: the minimal scale
    :rtype: ee.Number
    """
    bands = image.bandNames()

    first = image.select([ee.String(bands.get(0))])
    ini = ee.Number(first.projection().nominalScale())

    def wrap(name, i):
        i = ee.Number(i)
        scale = ee.Number(image.select([name]).projection().nominalScale())
        condition = scale.lte(i)
        newscale = ee.Algorithms.If(condition, scale, i)
        return newscale

    return ee.Number(bands.slice(1).iterate(wrap, ini)) 
开发者ID:gee-community,项目名称:gee_tools,代码行数:26,代码来源:image.py

示例15: doyToDate

# 需要导入模块: import ee [as 别名]
# 或者: from ee import Number [as 别名]
def doyToDate(image, dateFormat='yyyyMMdd', year=None):
    """ Make a date band from a day of year band """
    if not year:
        year = image.date().get('year')

    doyband = image.select([0])
    leap = date.isLeap(year)
    limit = ee.Number(ee.Algorithms.If(leap, 365, 364))
    alldoys = ee.List.sequence(1, limit)

    def wrap(doy, i):
        i = ee.Image(i)
        doy = ee.Number(doy)
        d = date.fromDOY(doy, year)
        date_band = ee.Image.constant(ee.Number.parse(d.format(dateFormat)))
        condition = i.eq(doy)
        return i.where(condition, date_band)

    datei = ee.Image(alldoys.iterate(wrap, doyband))

    return datei.rename('date') 
开发者ID:gee-community,项目名称:gee_tools,代码行数:23,代码来源:image.py


注:本文中的ee.Number方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。