예제 #1
0
def visualisation():
    elements = []
    for i in range(0, GRID[0]):
        for j in range(0, GRID[1]):
            p = [round(float(LNG[i][j]), 3), round(float(LAT[i][j]), 3)]
            try:
                point = asShape({'type': 'Point', 'coordinates': p})
                if point.is_valid:
                    elements.append(point)
            except:
                pass

    for z in zone.objects(ztype='zone'):
        print 'PROCESSING: ' + str(z.zid) + ' ' + str(z.name)
        zpolygon = asShape(z.polygon)
        for e in elements:
            if zpolygon.intersects(e):
                print mapping(e)
                point = current.objects(loc__geo_intersects=mapping(e)).first()
                point2 = currentdirection.objects(
                    loc__geo_intersects=mapping(e)).first()

                if point and point2:
                    point = point['values']
                    point2 = point2['values']
                    data = []
                    for i in range(1, 366):
                        if data:
                            current_visualisation.objects.insert(data)
                            data = []
                        if str(i) in point and str(i) in point2:
                            cv = current_visualisation(zid=z.zid)
                            cv.date = datetime(year=2018, month=1,
                                               day=1) + timedelta(days=i - 1)
                            cv.loc = mapping(e)
                            cv.speed = point[str(i)]['0']
                            cv.direction = point2[str(i)]['0']
                            data.append(cv)
                    else:
                        if data:
                            current_visualisation.objects.insert(data)
                            data = []
예제 #2
0
def visualisation():
    elements = []
    for c in current.objects(zid=zid):
        try:
            point = asShape(c.loc)
            if point.is_valid:
                elements.append(point)
        except:
            pass

    for z in zone.objects(ztype='project', zid=zid):
        print 'PROCESSING: ' + str(z.zid) + ' ' + str(z.name)
        zpolygon = asShape(z.polygon)
        for e in elements:
            if zpolygon.intersects(e):
                print mapping(e)
                point = current.objects(
                    zid=zid, loc__geo_intersects=mapping(e)).first()
                point2 = currentdirection.objects(
                    zid=zid, loc__geo_intersects=mapping(e)).first()

                if point and point2:
                    point = point['values']
                    point2 = point2['values']
                    data = []
                    for i in range(1, 366):
                        if data:
                            current_visualisation.objects.insert(data)
                            data = []
                        if str(i) in point and str(i) in point2:
                            cv = current_visualisation(zid=z.zid)
                            cv.date = datetime(year=2018, month=1,
                                               day=1) + timedelta(days=i - 1)
                            cv.loc = mapping(e)
                            cv.speed = point[str(i)]['0']
                            cv.direction = point2[str(i)]['0']
                            data.append(cv)
                    else:
                        if data:
                            current_visualisation.objects.insert(data)
                            data = []
예제 #3
0
파일: quiver.py 프로젝트: frooti/oceandb
    X = []  #np.full(X.shape, np.nan)
    Y = []  #np.full(X.shape, np.nan)
    U = []  #np.full(X.shape, np.nan)
    V = []  #np.full(X.shape, np.nan)

    # fetch data
    current_data = {}
    for c in current.objects(loc__geo_intersects=z.polygon):
        key = ','.join([str(i) for i in c.loc['coordinates']])
        value = c.values['1']['0']
        if key in current_data:
            current_data[key]['s'] = value
        else:
            current_data[key] = {'s': value}

    for cd in currentdirection.objects(loc__geo_intersects=z.polygon):
        key = ','.join([str(i) for i in cd.loc['coordinates']])
        value = cd.values['1']['0']
        if key in current_data:
            current_data[key]['d'] = value
        else:
            current_data[key] = {'d': value}

    for d in current_data:
        x, y = [float(i) for i in d.split(',')]
        speed = current_data[d]['s']
        direction = current_data[d]['d']
        u = speed * math.cos(direction)
        v = speed * math.sin(direction)

        X.append(x)
예제 #4
0
			tide_value = {}
			t = tide.objects(loc__near=centroid).first()
			if t:
				values = t.values
				tide_value = daily_values(values, type='high')

			# current
			current_value = {}
			c = current.objects(loc__near=centroid).first()
			if c:
				values = c.values
				current_value = daily_values(values, type='high')

			# currentdirection
			currentdirection_value = {}
			cd = currentdirection.objects(loc__near=centroid).first()
			if cd:
				values = cd.values
				currentdirection_value = daily_values(values)


			data.append([rt, waveheight_value, wavedirection_value, waveperiod_value, bathy_value, tide_value, current_value, currentdirection_value])
	
	### PRE PROCESS ###

	# delete existing data
	zonedata.objects(zid=z.zid).delete()

	for m in range(1, 13):
		monthly_data = []