def createTileGrid(self, src, dst, latidx, lonidx, z):

		srcfile = ncOpen(src,"r")
		fname 	= pathLeaf(src,False)
		bbox 	= self.indices_to_bbox(latidx, lonidx)
		inc 	= 1/float(2**z)		
		xsize	= len(srcfile.variables['lon'][:])
		ysize	= len(srcfile.variables['lon'][:])
		xfirst	= bbox["lon_min"]
		yfirst	= bbox["lat_min"]
		xinc   	= inc
		yinc	= inc
		
		gf  = GridFile("latlon", xsize, ysize, xfirst, xinc, yfirst, yinc)

		fgrid = gf.createGrid(dst+fname+".grid")

		return str(dst+fname+".grid")
	kg  = KellyGrinder()
	kc 	= KellyConverter()
	timer = Chrono()

	baselink 	= "http://users.rcc.uchicago.edu/~davidkelly999/agmerra.origgrid.2deg.tile"
	basefilelink 	= baselink + "/0004/clim_0004_0047.tile.nc4"
	sdilesfolder 	= "results/sdiles/"
	
	# basefile setup
	
	print "downloading base file..."
	timer.start()

	basefile 	= kg.downloadFile(basefilelink, "results/base/")
	basenc 		= ncOpen(basefile)
	basefolder 	= "results/"
	
	timer.stop()
	print "basefile downloaded in ", timer.formatted()

	timer.reset('basefile downloaded')

    # ---- loping part starts ---- #

    #inizialization
	dile = Dile(2,0,3)

	bbox = dile.asBoundingBox()		
	lats = linspace(bbox['lat_min'],bbox['lat_max'],dile.YSIZE, endpoint=True)
	lons = linspace(bbox['lon_min'],bbox['lon_max'],dile.XSIZE, endpoint=True)
	
	ng    = NetcdfGeometry()
	df    = DileFactory()
	timer = Chrono()

	path  = "/sdiles/ubuntu/sdiles/sdile_tasmax_2_0_1.nc"
	fname = pathLeaf(path,False)
	

	print "computing md5 for ", fname, "..."
	timer.start()
	md5   = getMD5(path)
	timer.stop()
	print "md5 computed in: ", timer.formatted()
	
	rgrp  = ncOpen(path, mode='r')
	bb 	  = ng.getBoundingBox(rgrp['lat'],rgrp['lon'])
	zoom  = ng.getZoomLevel(rgrp['lat'], rgrp['lon'])

	mim = MetaIngesterMongo(rgrp)

	url   = " http://s3.amazonaws.com/edu-uchicago-rdcep-diles/"
	url   += str(md5)+'/'+str(fname)+'/'

	mim.onConnect('test', 'diles')

	timer.reset()

	print "ingesting metadata..."
	timer.start()
	ndocs = mim.onIngest(path, url, bb, zoom)