def testCoadd () :
	import stomp
	from termcolor import colored

	
	print colored("Defining Coadd",'blue') 
	geom = stomp.LatLonBound(-1.25, 1.25, 3.0, 8.0, stomp.AngularCoordinate.Equatorial)
	#geom = stomp.LatLonBound(-1.25, 1.25, -50, 60.0, stomp.AngularCoordinate.Equatorial)
	coadd = stomp.Map()
	coadd.PixelizeBound(geom, 1.0)
	print colored("starting  map size %d "% coadd.Size(), 'white')


	print colored("\t oh so bad polys ",'red') 
	fourCoord = create4av()
	baVector = stomp.WAngularVector()
	field=stomp.FieldColumnDict({'r2':2,'d2':3,'r3':4,'d3':5,'r4':6,'d4':7})
	stomp.WeightedAngularCoordinate.ToWAngularVector("test.ver",baVector,field)
	#stomp.WeightedAngularCoordinate.ToWAngularVector("badarean.ver",baVector,field)
	i = 0
	for x in baVector:		
		fourCoord = set4av(x, fourCoord) 
		gmap = stomp.Map()
		geom = stomp.PolygonBound(fourCoord)
		gmap.PixelizeBound(geom, 0.0)

		coadd.MultiplyMap(gmap,False)
		print colored("\t{}\t map size {} ".format(i,coadd.Size()) , 'white')
		i += 1

	print colored("\t also bad circle ",'red') 
	field=stomp.FieldColumnDict({'radius':2})
	bcVector = stomp.WAngularVector()
	stomp.WeightedAngularCoordinate.ToWAngularVector("test.cir",bcVector,field)
	#stomp.WeightedAngularCoordinate.ToWAngularVector("badarean.cir",bcVector,field)
	i = 0
	for x in bcVector:		
		geom=stomp.CircleBound(x,x.Field('radius'))
		gmap = stomp.Map()
		gmap.PixelizeBound(geom, 0.0)

		coadd.MultiplyMap(gmap,False)
		print colored("\t{}\t map size {} ".format(i,coadd.Size()) , 'white')
		i += 1

	print colored("ending  map size %d "% coadd.Size(), 'white')
	print colored("write coadd.map",'blue') 
	coadd.Write("coadd.map")
	return coadd


def create4av () :
	import stomp
	fourCoord =stomp.AngularVector()
	stomp.AngularCoordinate.ToAngularVector("define4Coords.dat",fourCoord) ;# this gives me memory to work with
	return fourCoord
def set4av (angCoord, fourCoord = "" ) :
	import stomp
	if (fourCoord == "" ) :
		fourCoord = create4av()

	stomp.AngularCoordinate.SetEquatorialCoordinates(fourCoord[0],angCoord.RA(),angCoord.DEC())
	stomp.AngularCoordinate.SetEquatorialCoordinates(fourCoord[1],angCoord.Field('r2'),angCoord.Field('d2'))
	stomp.AngularCoordinate.SetEquatorialCoordinates(fourCoord[2],angCoord.Field('r3'),angCoord.Field('d3'))
	stomp.AngularCoordinate.SetEquatorialCoordinates(fourCoord[3],angCoord.Field('r4'),angCoord.Field('d4'))
	return fourCoord
	

