-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery2D.py
executable file
·45 lines (31 loc) · 979 Bytes
/
query2D.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'arnault'
import pymongo
import pyfits
import numpy
from bson import CodecOptions, SON
import glob
import os
import sys
CC = True
if os.name == 'nt':
MONGO_URL = r'mongodb://127.0.0.1:27017'
FILES_ROOT = 'data/'
else:
MONGO_URL = r'mongodb://lsst:lsst2015@172.17.0.190:27017/lsst'
FILES_ROOT = '/sps/lsst/data/CFHT/input/raw/'
MONGO2_URL = r'mongodb://lsst:lsst2015@172.17.0.190:27017/snlsfits'
FILES = FILES_ROOT + '/*/*/*/*/*.fits.fz'
if __name__ == '__main__':
client = pymongo.MongoClient(MONGO_URL)
lsst = client.lsst
print '------------lsst'
c = lsst.fits
print c.count()
c.create_index( [ ('center', '2dsphere') ] )
radius = 1.0
if len(sys.argv) > 1:
radius = float(sys.argv[1])
for o in c.find( { 'center' : { '$geoWithin': { '$centerSphere' : [ [ -145.0, 53.0 ], radius ] } } } , {'_id':0, 'where':1, 'center':1 } ):
print o