def sample_granule(self): pdict = CoverageCraft.create_parameters() rdt = RecordDictionaryTool(param_dictionary=pdict) rdt['time'] = np.arange(20) rdt['temp'] = np.array([5] * 20) rdt['conductivity'] = np.array([10] * 20) rdt['lat'] = np.array([0] * 20) rdt['lon'] = np.array([0] * 20) rdt['depth'] = np.array([0] * 20) rdt['data'] = np.array([0x01] * 20) return build_granule('sample', param_dictionary=pdict, record_dictionary=rdt)
def _trigger_func(self, stream_id): #@todo - add lots of comments in here while not self.finished.is_set(): length = 10 #Explicitly make these numpy arrays... c = numpy.array([random.uniform(0.0,75.0) for i in xrange(length)]) t = numpy.array([random.uniform(-1.7, 21.0) for i in xrange(length)]) p = numpy.array([random.lognormvariate(1,2) for i in xrange(length)]) lat = numpy.array([random.uniform(-90.0, 90.0) for i in xrange(length)]) lon = numpy.array([random.uniform(0.0, 360.0) for i in xrange(length)]) tvar = numpy.array([self.last_time + i for i in xrange(1,length+1)]) self.last_time = max(tvar) rdt = RecordDictionaryTool(taxonomy=tx) # This is an example of using groups it is not a normative statement about how to use groups rdt['temp'] = t rdt['cond'] = c rdt['pres'] = p #add a value sequence of raw bytes - not sure the type below is correct? with open('/dev/urandom','r') as rand: rdt['raw_fixed'] = numpy.array([rand.read(32) for i in xrange(length)], dtype='a32') #add a value sequence of raw bytes - not sure the type below is correct? with open('/dev/urandom','r') as rand: rdt['raw_blob'] = numpy.array([rand.read(random.randint(1,40)) for i in xrange(length)], dtype=object) rdt['time'] = tvar rdt['lat'] = lat rdt['lon'] = lon g = build_granule(data_producer_id=stream_id, taxonomy=tx, record_dictionary=rdt) log.info('Sending %d values!' % length) if(isinstance(g,Granule)): self.publish(g) gevent.sleep(self.interval)