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-pipeline
csst_common
Commits
442fb3c7
Commit
442fb3c7
authored
Nov 23, 2022
by
BO ZHANG
🏀
Browse files
update dm.dfs_is_available()
parent
51c6e403
Changes
2
Hide whitespace changes
Inline
Side-by-side
csst_common/data_manager.py
View file @
442fb3c7
...
@@ -26,8 +26,8 @@ from csst_dfs_api.msc.level0 import Level0DataApi
...
@@ -26,8 +26,8 @@ from csst_dfs_api.msc.level0 import Level0DataApi
from
csst_dfs_api.msc.level0prc
import
Level0PrcApi
from
csst_dfs_api.msc.level0prc
import
Level0PrcApi
from
csst_dfs_api.msc.level1
import
Level1DataApi
from
csst_dfs_api.msc.level1
import
Level1DataApi
from
csst_dfs_api.msc.level2
import
Level2DataApi
from
csst_dfs_api.msc.level2
import
Level2DataApi
from
csst_dfs_api.common.catalog
import
CatalogApi
from
.dfs
import
gaia_query_from_dfs
from
.logger
import
get_logger
from
.logger
import
get_logger
from
.params
import
CSST_PARAMS
as
CP
from
.params
import
CSST_PARAMS
as
CP
from
.params
import
DFS_CONF
from
.params
import
DFS_CONF
...
@@ -248,6 +248,10 @@ class CsstMsDataManager:
...
@@ -248,6 +248,10 @@ class CsstMsDataManager:
def
dfs_CalApi
(
self
):
def
dfs_CalApi
(
self
):
return
CalMergeApi
()
return
CalMergeApi
()
@
property
def
dfs_CatApi
(
self
):
return
CatalogApi
()
def
set_env
(
self
):
def
set_env
(
self
):
""" set environment variables """
""" set environment variables """
if
os
.
uname
()[
1
]
==
"dandelion"
:
if
os
.
uname
()[
1
]
==
"dandelion"
:
...
@@ -567,17 +571,21 @@ class CsstMsDataManager:
...
@@ -567,17 +571,21 @@ class CsstMsDataManager:
def
dfs_is_available
():
def
dfs_is_available
():
""" Test if DFS works. """
""" Test if DFS works. """
try
:
try
:
tbl
=
gaia_query_from_dfs
(
radius
=
0.001
)
tbl
=
CatalogApi
().
catalog_query
(
assert
len
(
tbl
)
==
0
catalog_name
=
"gaia3"
,
ra
=
180
,
dec
=
0
,
radius
=
.
1
,
min_mag
=
0
,
max_mag
=
30
,
obstime
=-
1
,
limit
=-
1
return
True
)
return
len
(
tbl
)
>
0
except
:
except
:
return
False
return
False
def
dfs_rc_query
(
self
,
ra
=
180
,
dec
=
0
,
radius
=
2
,
min_mag
=
0
,
max_mag
=
30
,
obstime
=-
1
,
limit
=-
1
):
def
dfs_rc_query
(
self
,
ra
=
180
,
dec
=
0
,
radius
=
2
,
min_mag
=
0
,
max_mag
=
30
,
obstime
=-
1
,
limit
=-
1
):
""" Query Reference Catalog (RC) from DFS. """
""" Query Reference Catalog (RC) from DFS. """
try
:
try
:
tbl
=
gaia_query_from_dfs
(
cat
=
self
.
dfs_CatApi
.
catalog_query
(
ra
=
ra
,
dec
=
dec
,
radius
=
radius
,
min_mag
=
min_mag
,
max_mag
=
max_mag
,
obstime
=
obstime
,
limit
=
limit
)
catalog_name
=
"gaia3"
,
ra
=
ra
,
dec
=
dec
,
radius
=
radius
,
min_mag
=
min_mag
,
max_mag
=
max_mag
,
obstime
=
obstime
,
limit
=
limit
)
tbl
=
self
.
dfs_CatApi
.
to_table
(
cat
)
return
tbl
return
tbl
except
:
except
:
print
(
"Error occurred during the query!"
)
print
(
"Error occurred during the query!"
)
...
@@ -686,14 +694,3 @@ class CsstMsDataManager:
...
@@ -686,14 +694,3 @@ class CsstMsDataManager:
# temporarily compatible with old interface
# temporarily compatible with old interface
CsstMbiDataManager
=
CsstMsDataManager
CsstMbiDataManager
=
CsstMsDataManager
def
test_dm
():
import
joblib
from
csst_common.data_manager
import
CsstMsDataManager
dm
=
CsstMsDataManager
(
dfs_node
=
"pml"
)
def
f
(
dm
,
a
=
1
):
print
(
a
)
joblib
.
Parallel
(
n_jobs
=
10
,
)(
joblib
.
delayed
(
f
)(
dm
)
for
i
in
range
(
10
))
csst_common/dfs.py
deleted
100644 → 0
View file @
51c6e403
import
os
from
csst_dfs_api.common.catalog
import
CatalogApi
from
csst_dfs_api.msc.level1
import
Level1DataApi
# DFS query
def
gaia_query_from_dfs
(
ra
=
180
,
dec
=
0
,
radius
=
2
,
min_mag
=
0
,
max_mag
=
30
,
obstime
=-
1
,
limit
=-
1
):
""" query gaia edr3 catalog from dfs """
api
=
CatalogApi
()
cat
=
api
.
catalog_query
(
catalog_name
=
"gaia3"
,
ra
=
ra
,
dec
=
dec
,
radius
=
radius
,
min_mag
=
min_mag
,
max_mag
=
max_mag
,
obstime
=
obstime
,
limit
=
limit
)
tbl
=
api
.
to_table
(
cat
)
return
tbl
def
get_l1api
(
node
=
"pm"
):
""" get DFS L1 API
Parameters
----------
node: str
in present, node has to be "pm"
Returns
-------
DFS L1 API
Examples
--------
>>>
>>> rec = l1api.write(
>>> level0_id='10000000020',
>>> data_type = "sci",
>>> cor_sci_id = 1,
>>> prc_status = 3,
>>> prc_time = '2022-01-05 15:18:13',
>>> filename = "MSC_MS_210525120000_100000000_20_img.fits",
>>> file_path = "/nfs/data/test20211012/output/L1/150s/MSC_MS_210525120000_100000000_20_img.fits",
>>> pipeline_id = "P1_test",
>>> refs = {})
>>> print('write:', rec)
"""
l1api
=
Level1DataApi
()
return
l1api
if
__name__
==
"__main__"
:
tbl
=
gaia_query_from_dfs
()
print
(
tbl
)
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