Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-dfs
csst-dfs-api-local
Commits
36ba9fbc
Commit
36ba9fbc
authored
Apr 07, 2021
by
Wei Shoulin
Browse files
gaia3
parent
1abe728d
Changes
2
Hide whitespace changes
Inline
Side-by-side
csst_dfs_api_local/common/
ephem
.py
→
csst_dfs_api_local/common/
catalog
.py
View file @
36ba9fbc
from
urllib
import
request
import
json
class
EphemSearch
Api
(
object
):
class
Catalog
Api
(
object
):
def
__init__
(
self
):
self
.
data
=
[]
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
gaia
3
_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
.
add_header
(
'Content-Type'
,
'application/json'
)
data
=
{
"ra"
:
ra
,
"dec"
:
dec
,
"radius"
:
radius
,
"mag"
:
m
ag
,
"limit"
:
limit
}
data
=
{
"ra"
:
ra
,
"dec"
:
dec
,
"radius"
:
radius
,
"
min_
mag"
:
m
in_mag
,
"max_mag"
:
max_mag
,
"obstime"
:
obstime
,
"limit"
:
limit
}
data
=
json
.
dumps
(
data
)
data
=
data
.
encode
()
res
=
request
.
urlopen
(
req
,
data
=
data
)
content
=
res
.
read
()
...
...
tests/test_common_
ephem
.py
→
tests/test_common_
catalog
.py
View file @
36ba9fbc
...
...
@@ -2,13 +2,13 @@ import os
import
unittest
from
astropy.io
import
fits
from
csst_dfs_api_local.common.
ephem
import
EphemSearch
Api
from
csst_dfs_api_local.common.
catalog
import
Catalog
Api
class
CommonEphemTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
api
=
EphemSearch
Api
()
self
.
api
=
Catalog
Api
()
def
test_gaia_query
(
self
):
recs
=
self
.
api
.
gaia_query
(
ra
=
260
,
dec
=-
27
,
radius
=
0.01
,
m
ag
=
0.0
1
,
limit
=
2
)
print
(
'find:'
,
recs
)
def
test_gaia
3
_query
(
self
):
recs
=
self
.
api
.
gaia
3
_query
(
ra
=
260
,
dec
=-
27
,
radius
=
0.01
,
m
in_mag
=-
1
,
max_mag
=-
1
,
obstime
=-
1
,
limit
=
2
)
print
(
'find:'
,
recs
)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment