Example #1
0
    def getRatesOfReturn(self, startdate=None, method="Log"):
        if startdate == None:
            startdate = self.startdate
        prices = self.prices
        #        prices = [float(prices[date].adjclosing) for date in u.date_range(startdate) if date in prices.keys()])
        dates = [d for d in u.date_range(startdate) if prices.has_key(d)]

        rates = {}
        for i in range(len(dates)):
            if i != 0:
                d1 = float(prices[dates[i]].adjclosing)
                d2 = float(prices[dates[i - 1]].adjclosing)
                if method == "Log":
                    if d1 != 0.00 and d2 != 0.00:
                        rates[dates[i]] = num.log(d1) - num.log(d2)
                elif method == "Simple":
                    if d2 != 0.00:
                        rates[dates[i]] = (d1 - d2) / d2
        return rates
    def getRatesOfReturn(self, startdate=None, method="Log"):
        if startdate==None:
            startdate = self.startdate
        prices = self.prices
#        prices = [float(prices[date].adjclosing) for date in u.date_range(startdate) if date in prices.keys()])
        dates = [d for d in u.date_range(startdate) if prices.has_key(d)]

        rates = {}
        for i in range(len(dates)):
            if i != 0:    
                d1 = float(prices[dates[i]].adjclosing)
                d2 = float(prices[dates[i-1]].adjclosing)
                if method=="Log":
                    if d1 != 0.00 and d2 != 0.00:
                        rates[dates[i]] = num.log(d1)-num.log(d2)
                elif method=="Simple":
                    if d2 != 0.00:
                        rates[dates[i]] = (d1-d2)/d2
        return rates
Example #3
0
    "names": [
        'currents', 'surface_eastward_sea_water_velocity',
        '*surface_eastward_sea_water_velocity*'
    ],
    "sos_name": ['currents']
}

# <codecell>

endpoint = 'http://www.ngdc.noaa.gov/geoportal/csw'  # NGDC Geoportal
csw = CatalogueServiceWeb(endpoint, timeout=60)

# <codecell>

# convert User Input into FES filters
start, stop = date_range(start_date, stop_date)
bbox = fes.BBox(bounding_box)

#use the search name to create search filter
or_filt = fes.Or([
    fes.PropertyIsLike(propertyname='apiso:AnyText',
                       literal=('*%s*' % val),
                       escapeChar='\\',
                       wildCard='*',
                       singleChar='?')
    for val in data_dict['currents']['names']
])

val = 'Averages'
not_filt = fes.Not([
    fes.PropertyIsLike(propertyname='apiso:AnyText',
data_dict = {}
sos_name = 'Currents'
data_dict['currents'] = {"names":['currents',
                                  'surface_eastward_sea_water_velocity',
                                  '*surface_eastward_sea_water_velocity*'], 
                         "sos_name":['currents']}  

# <codecell>

endpoint = 'http://www.ngdc.noaa.gov/geoportal/csw' # NGDC Geoportal
csw = CatalogueServiceWeb(endpoint,timeout=60)

# <codecell>

# convert User Input into FES filters
start,stop = date_range(start_date,stop_date)
bbox = fes.BBox(bounding_box)

#use the search name to create search filter
or_filt = fes.Or([fes.PropertyIsLike(propertyname='apiso:AnyText',literal=('*%s*' % val),
                    escapeChar='\\',wildCard='*',singleChar='?') for val in data_dict['currents']['names']])

val = 'Averages'
not_filt = fes.Not([fes.PropertyIsLike(propertyname='apiso:AnyText',
                                       literal=('*%s*' % val),
                                       escapeChar='\\',
                                       wildCard='*',
                                       singleChar='?')])
filter_list = [fes.And([ bbox, start, stop, or_filt, not_filt]) ]
# connect to CSW, explore it's properties
# try request using multiple filters "and" syntax: [[filter1,filter2]]
# Search CSW for datasets of interest

# <codecell>

endpoint = 'http://www.ngdc.noaa.gov/geoportal/csw' # NGDC Geoportal
csw = CatalogueServiceWeb(endpoint,timeout=60)

for oper in csw.operations:
    if oper.name == 'GetRecords':
        print '\nISO Queryables:\n',oper.constraints['SupportedISOQueryables']['values']

# <codecell>

# convert User Input into FES filters
start,stop = date_range(start_date,end_date)
box = []
box.append(bounding_box[0][0])
box.append(bounding_box[0][1])
box.append(bounding_box[1][0])
box.append(bounding_box[1][1])
bbox = fes.BBox(box)

#use the search name to create search filter
or_filt = fes.Or([fes.PropertyIsLike(propertyname='apiso:AnyText',literal=('*%s*' % val),
                    escapeChar='\\',wildCard='*',singleChar='?') for val in data_dict["waves"]["names"]])
val = 'Averages'
not_filt = fes.Not([fes.PropertyIsLike(propertyname='apiso:AnyText',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')])
filter_list = [fes.And([ bbox, start, stop, or_filt, not_filt]) ]
# connect to CSW, explore it's properties
Example #6
0
# Search CSW for datasets of interest

# <codecell>

endpoint = 'http://www.ngdc.noaa.gov/geoportal/csw'  # NGDC Geoportal
csw = CatalogueServiceWeb(endpoint, timeout=60)

for oper in csw.operations:
    if oper.name == 'GetRecords':
        print '\nISO Queryables:\n', oper.constraints[
            'SupportedISOQueryables']['values']

# <codecell>

# convert User Input into FES filters
start, stop = date_range(start_date, end_date)
box = []
box.append(bounding_box[0][0])
box.append(bounding_box[0][1])
box.append(bounding_box[1][0])
box.append(bounding_box[1][1])
bbox = fes.BBox(box)

#use the search name to create search filter
or_filt = fes.Or([
    fes.PropertyIsLike(propertyname='apiso:AnyText',
                       literal=('*%s*' % val),
                       escapeChar='\\',
                       wildCard='*',
                       singleChar='?') for val in data_dict["waves"]["names"]
])