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
d521aa51
Commit
d521aa51
authored
Apr 01, 2021
by
Wei Shoulin
Browse files
add print
parent
ad1d3c4b
Changes
5
Hide whitespace changes
Inline
Side-by-side
csst_dfs_api_local/common/ephem.py
0 → 100644
View file @
d521aa51
from
urllib
import
request
import
json
class
EphemSearchApi
(
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
):
req
=
request
.
Request
(
url
=
self
.
url
,
method
=
"post"
)
req
.
add_header
(
'Content-Type'
,
'application/json'
)
data
=
{
"ra"
:
ra
,
"dec"
:
dec
,
"radius"
:
radius
,
"mag"
:
mag
,
"limit"
:
limit
}
data
=
json
.
dumps
(
data
)
data
=
data
.
encode
()
res
=
request
.
urlopen
(
req
,
data
=
data
)
content
=
res
.
read
()
print
(
content
)
return
content
\ No newline at end of file
csst_dfs_api_local/ifs/__init__.py
View file @
d521aa51
...
...
@@ -29,7 +29,9 @@ def ingest():
if
file_type
in
[
'obs'
]:
fitsApi
.
import2db
(
file_path
=
file_full_path
.
replace
(
root_dir
,
''
)[
1
:])
print
(
"%s [type:%s] imported"
%
(
file_full_path
,
file_type
))
if
file_type
in
[
'flat'
,
'bias'
,
'arc'
,
'hgar'
,
'sky'
]:
refApi
.
import2db
(
file_path
=
file_full_path
.
replace
(
root_dir
,
''
)[
1
:])
refApi
.
import2db
(
file_path
=
file_full_path
.
replace
(
root_dir
,
''
)[
1
:])
print
(
"%s [type:%s] imported"
%
(
file_full_path
,
file_type
))
return
paths
requirements.txt
View file @
d521aa51
DBUtils
\ No newline at end of file
DBUtils
==1.3
\ No newline at end of file
setup.cfg
View file @
d521aa51
...
...
@@ -22,6 +22,7 @@ zip_safe = False
setup_requires = setuptools_scm
install_requires =
astropy>=4.0
DBUtils==1.3
[options.package_data]
csst_dfs_api_local.common = *.sql
[options.entry_points]
...
...
tests/test_common_ephem.py
0 → 100644
View file @
d521aa51
import
os
import
unittest
from
astropy.io
import
fits
from
csst_dfs_api_local.common.ephem
import
EphemSearchApi
class
CommonEphemTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
api
=
EphemSearchApi
()
def
test_gaia_query
(
self
):
recs
=
self
.
api
.
gaia_query
(
ra
=
260
,
dec
=-
27
,
radius
=
0.01
,
mag
=
0.01
,
limit
=
2
)
print
(
'find:'
,
recs
)
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