dssheaderToJSON.py   dssheaderToJSON.py 
skipping to change at line 24 skipping to change at line 24
removeBoxN=[64*300-2000, 1199] removeBoxN=[64*300-2000, 1199]
removeBoxS=[480, 624] removeBoxS=[480, 624]
def getIntersectPoly(baseFileName, curLevel, i,j): def getIntersectPoly(baseFileName, curLevel, i,j):
"""Return the convex polygons in pixel space defining the valid area of the tile or None if the poly is fully in the invalid area""" """Return the convex polygons in pixel space defining the valid area of the tile or None if the poly is fully in the invalid area"""
scale = 2**(6-curLevel)*300 scale = 2**(6-curLevel)*300
if baseFileName[0]=='N': if baseFileName[0]=='N':
box = removeBoxN box = removeBoxN
x=float(box[0]-i*scale)/scale*300. x=float(box[0]-i*scale)/scale*300.
y=float(box[1]-j*scale)/scale*300. y=float(box[1]-j*scale)/scale*300.
# x,y is the position of the box top left corner in pixel wr t lower left corner of current tile
if x>300. or y<=0.: if x>300. or y<=0.:
# Tile fully valid # Tile fully valid
return [[[0,0], [300, 0], [300, 300], [0, 300]]] return [[[0,0], [300, 0], [300, 300], [0, 300]]]
if x<=0. and y>=300.: if x<=0. and y>=300.:
# Tile fully invalid # Tile fully invalid
return None return None
if x<=0.: if x<=0.:
assert y>0 assert y>0
skipping to change at line 65 skipping to change at line 65
if x<=-300.: if x<=-300.:
assert y>0 assert y>0
assert y<=300. assert y<=300.
return [[[0,y], [300, y], [300, 300], [0, 300]]] return [[[0,y], [300, y], [300, 300], [0, 300]]]
if y>=300.: if y>=300.:
assert x<=0 assert x<=0
assert x>-300. assert x>-300.
return [[[-x,0], [300, 0], [300, 300], [-x, 300]]] return [[[-x,0], [300, 0], [300, 300], [-x, 300]]]
return [[[-x,0], [300, 0], [300, 300], [-x, 300]],[[0,y], [- x, y], [-x, 300], [0, 300]]] return [[[-x,0], [300, 0], [300, 300], [-x, 300]],[[0,y], [- x, y], [-x, 300], [0, 300]]]
def createTile(currentLevel, maxLevel, i, j, outDirectory, plateName): def createTile(currentLevel, maxLevel, i, j, outDirectory, plateName, speci al=False):
# Create the associated tile description # Create the associated tile description
t = skyTile.SkyImageTile() t = skyTile.SkyImageTile()
t.level = currentLevel t.level = currentLevel
t.i = i t.i = i
t.j = j t.j = j
t.imageUrl = "x%.2d/" % (2**currentLevel)+"x%.2d_%.2d_%.2d.jpg" % (2 **currentLevel, i,j) t.imageUrl = "x%.2d/" % (2**currentLevel)+"x%.2d_%.2d_%.2d.jpg" % (2 **currentLevel, i,j)
if currentLevel==0: if currentLevel==0:
t.credits = "Copyright (C) 2008, STScI Digitized Sky Survey" t.credits = "Copyright (C) 2008, STScI Digitized Sky Survey"
t.infoUrl = "http://stdatu.stsci.edu/cgi-bin/dss_form" t.infoUrl = "http://stdatu.stsci.edu/cgi-bin/dss_form"
# t.maxBrightness = 10 # t.maxBrightness = 10
# Create the matching sky polygons, return if there is no relevant p olygons # Create the matching sky polygons, return if there is no relevant p olygons
pl = getIntersectPoly(plateName, currentLevel, i,j) if special==True:
pl = [[[0,0], [300, 0], [300, 300], [0, 300]]]
else:
pl = getIntersectPoly(plateName, currentLevel, i,j)
if pl==None or len(pl)==0: if pl==None or len(pl)==0:
return None return None
# Get the WCS from the input FITS header file for the tile # Get the WCS from the input FITS header file for the tile
wcs=astWCS.WCS(plateName+"/"+levels[currentLevel]+"/"+plateName+"_%. 2d_%.2d_" % (i,j) +levels[currentLevel]+".hhh") wcs=astWCS.WCS(plateName+"/"+levels[currentLevel]+"/"+plateName+"_%. 2d_%.2d_" % (i,j) +levels[currentLevel]+".hhh")
naxis1 = wcs.header.get('NAXIS1') naxis1 = wcs.header.get('NAXIS1')
naxis2 = wcs.header.get('NAXIS2') naxis2 = wcs.header.get('NAXIS2')
t.skyConvexPolygons = [] t.skyConvexPolygons = []
for idx,poly in enumerate(pl): for idx,poly in enumerate(pl):
skipping to change at line 162 skipping to change at line 165
os.system("rm -r "+outDir) os.system("rm -r "+outDir)
os.makedirs(outDir) os.makedirs(outDir)
plateName = prefix + "%.3i" % i plateName = prefix + "%.3i" % i
generateJpgTiles(plateName, outDir) generateJpgTiles(plateName, outDir)
# Create all the JSON files # Create all the JSON files
masterTile = createTile(0, 6, 0, 0, outDir, plateName) masterTile = createTile(0, 6, 0, 0, outDir, plateName)
masterTile.outputJSON(qCompress=True, maxLevelPerFile=2, out Dir=outDir+'/') masterTile.outputJSON(qCompress=True, maxLevelPerFile=2, out Dir=outDir+'/')
command = "scp -r " +outDir+ " vosw@voint1.hq.eso.org:/work/ command = "cd /tmp && mv tmpPlate "+plateName+" && tar -cf "
fabienDSS2/" + plateName; +plateName+ ".tar "+plateName+" && rm -rf "+plateName
print command
os.system(command)
command = "cd /tmp && scp " +plateName+".tar vosw@voint1.hq.
eso.org:/work/fabienDSS2/"+plateName+".tar"
print command
os.system(command)
command = "rm /tmp/" +plateName+ ".tar"
print command print command
os.system(command) os.system(command)
def mainHeader(): def mainHeader():
# Generate the top level file containing pointers on all # Generate the top level file containing pointers on all
outDir = "/tmp/tmpPlate"
f = open('/tmp/allDSS.json', 'w') f = open('/tmp/allDSS.json', 'w')
f.write('{\n') f.write('{\n')
f.write('"minResolution" : 0.1,\n') f.write('"minResolution" : 0.1,\n')
f.write('"maxBrightness" : 13,\n') f.write('"maxBrightness" : 13,\n')
f.write('"subTiles" : \n[\n') f.write('"subTiles" : \n[\n')
for prefix in ['N', 'S']: for prefix in ['N', 'S']:
if prefix=='N': if prefix=='N':
nRange = range(2, 898) nRange = range(2, 898)
if prefix=='S': if prefix=='S':
nRange = range(1, 894) nRange = range(1, 894)
for i in nRange: for i in nRange:
plateName = prefix+"%.3i" % i plateName = prefix+"%.3i" % i
ti = createTile(0, 0, 0, 0, outDir, plateName) ti = createTile(0, 0, 0, 0, outDir, plateName, True)
assert ti != None
f.write('\t{\n') f.write('\t{\n')
f.write('\t\t"minResolution" : %.8f,\n' % ti.minReso lution) f.write('\t\t"minResolution" : %.8f,\n' % ti.minReso lution)
f.write('\t\t"worldCoords" : ') f.write('\t\t"worldCoords" : ')
skyTile.writePolys(ti.skyConvexPolygons, f) skyTile.writePolys(ti.skyConvexPolygons, f)
f.write(',\n') f.write(',\n')
f.write('\t\t"subTiles" : ["'+plateName+"/x01_00_00. json.qZ"+'"]\n') f.write('\t\t"subTiles" : ["'+plateName+"/x01_00_00. json.qZ"+'"]\n')
f.write('\t},\n') f.write('\t},\n')
f.seek(-2, os.SEEK_CUR) f.seek(-2, os.SEEK_CUR)
f.write('\n]}\n') f.write('\n]}\n')
 End of changes. 6 change blocks. 
6 lines changed or deleted 18 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/