def getLast25hours(ref): dsi = ref.getData().getIterator() esi = ElementFilterIterator(dsi, Constants.DEFAULT_FLAG_FILTER) while not esi.atEnd(): esi.advance() esi.retreat() el = esi.getElement() endTime = TimeFactory.getInstance().createTime(el.getXString()) tidalDay = TimeFactory.getInstance().createTimeInterval('25hours') startTime = endTime.create(endTime) startTime.incrementBy(tidalDay,-1) tw = TimeFactory.getInstance().createTimeWindow(startTime,endTime) return DataReference.create(ref,tw)
def getLast25hours(ref): dsi = ref.getData().getIterator() esi = ElementFilterIterator(dsi, Constants.DEFAULT_FLAG_FILTER) while not esi.atEnd(): esi.advance() esi.retreat() el = esi.getElement() endTime = TimeFactory.getInstance().createTime(el.getXString()) tidalDay = TimeFactory.getInstance().createTimeInterval('25hours') startTime = endTime.create(endTime) startTime.incrementBy(tidalDay, -1) tw = TimeFactory.getInstance().createTimeWindow(startTime, endTime) return DataReference.create(ref, tw)
# get the iterator on that data set, these iterates # through all the values in the data set. Till now there is no # difference between stepping thro the data set or the # iterator dsi = ds.getIterator() # lets filter out the missing values... missing_filter = Constants.DEFAULT_FILTER # lets create an iterator that skips over values for which # missing_filter.isAcceptable returns false # this iterator takes another iterator and the filter missing_iterator = ElementFilterIterator(dsi,missing_filter) # the x value: element.getX() # the y value: element.getY() # the flag (if available else = 0): element.getFlag() element = missing_iterator.getElement() print element.getX(), element.getY(), element.getFlag() # get the 30th good value missing_iterator.positionAtIndex(29) element = missing_iterator.getElement() print element.getX(), element.getY(), element.getFlag() # a loop to loop over all the values till it # reaches the end # we get the element and advance, then check if are at end # if not we continue doing so till we hit the end while not missing_iterator.atEnd(): element = missing_iterator.getElement(); missing_iterator.advance() # # lets step through back, always retreat then get element then check #
# get the iterator on that data set, these iterates # through all the values in the data set. Till now there is no # difference between stepping thro the data set or the # iterator dsi = ds.getIterator() # lets filter out the missing values... missing_filter = Constants.DEFAULT_FILTER # lets create an iterator that skips over values for which # missing_filter.isAcceptable returns false # this iterator takes another iterator and the filter missing_iterator = ElementFilterIterator(dsi, missing_filter) # the x value: element.getX() # the y value: element.getY() # the flag (if available else = 0): element.getFlag() element = missing_iterator.getElement() print element.getX(), element.getY(), element.getFlag() # get the 30th good value missing_iterator.positionAtIndex(29) element = missing_iterator.getElement() print element.getX(), element.getY(), element.getFlag() # a loop to loop over all the values till it # reaches the end # we get the element and advance, then check if are at end # if not we continue doing so till we hit the end while not missing_iterator.atEnd(): element = missing_iterator.getElement() missing_iterator.advance() # # lets step through back, always retreat then get element then check #