Commit 36ba9fbc authored by Wei Shoulin's avatar Wei Shoulin
Browse files

gaia3

parent 1abe728d
from urllib import request from urllib import request
import json import json
class EphemSearchApi(object): class CatalogApi(object):
def __init__(self): def __init__(self):
self.data = [] self.data = []
self.url = 'http://172.31.248.218:30180/search/v2' self.url = 'http://172.31.248.218:30180/search/v2'
def gaia_query(self, ra: float, dec: float, radius: float, mag: float, limit: int): def gaia3_query(self, ra: float, dec: float, radius: float, min_mag: float, max_mag: float, obstime: int, limit: int):
req = request.Request(url = self.url, method="post") req = request.Request(url = self.url, method="post")
req.add_header('Content-Type', 'application/json') req.add_header('Content-Type', 'application/json')
data = { "ra":ra, "dec":dec, "radius":radius, "mag": mag, "limit": limit} data = { "ra":ra, "dec":dec, "radius":radius, "min_mag": min_mag, "max_mag": max_mag, "obstime": obstime, "limit": limit}
data = json.dumps(data) data = json.dumps(data)
data = data.encode() data = data.encode()
res = request.urlopen(req, data=data) res = request.urlopen(req, data=data)
content = res.read() content = res.read()
......
...@@ -2,13 +2,13 @@ import os ...@@ -2,13 +2,13 @@ import os
import unittest import unittest
from astropy.io import fits from astropy.io import fits
from csst_dfs_api_local.common.ephem import EphemSearchApi from csst_dfs_api_local.common.catalog import CatalogApi
class CommonEphemTestCase(unittest.TestCase): class CommonEphemTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.api = EphemSearchApi() self.api = CatalogApi()
def test_gaia_query(self): def test_gaia3_query(self):
recs = self.api.gaia_query(ra=260, dec=-27, radius=0.01, mag=0.01, limit=2) recs = self.api.gaia3_query(ra=260, dec=-27, radius=0.01, min_mag=-1, max_mag=-1, obstime=-1, limit=2)
print('find:', recs) print('find:', recs)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment