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
90a3e69f
Commit
90a3e69f
authored
Jun 16, 2022
by
Wei Shoulin
Browse files
object name
parent
ad97ab01
Changes
3
Hide whitespace changes
Inline
Side-by-side
csst_dfs_api_local/common/db.sql
View file @
90a3e69f
...
...
@@ -300,6 +300,7 @@ create table ifs_level0_data
level0_id
varchar
(
20
)
not
null
,
obs_id
varchar
(
10
)
not
null
,
detector_no
varchar
(
10
)
not
null
,
object_name
varchar
(
64
)
not
null
,
obs_type
varchar
(
16
),
obs_time
datetime
,
exp_time
float
,
...
...
csst_dfs_api_local/ifs/ingest.py
View file @
90a3e69f
...
...
@@ -51,6 +51,7 @@ def ingest_one(file_path, db, copyfiles):
module_id
=
header
[
"INSTRUME"
]
obs_type
=
header
[
"OBSTYPE"
]
object_name
=
header
[
"OBJECT"
]
qc0_status
=
-
1
prc_status
=
-
1
time_now
=
datetime
.
datetime
.
now
()
...
...
@@ -92,9 +93,9 @@ def ingest_one(file_path, db, copyfiles):
level0_id
=
f
"
{
obs_id
}{
detector
}
"
c
=
db
.
execute
(
"insert into ifs_level0_data
\
(level0_id, obs_id, detector_no, obs_type, obs_time, exp_time,detector_status_id, filename, file_path,qc0_status, prc_status,create_time)
\
values (?,?,?,?,?,?,?,?,?,?,?,?)"
,
(
level0_id
,
obs_id
,
detector
,
obs_type
,
exp_start_time
,
exp_time
,
detector_status_id
,
filename
,
file_full_path
,
qc0_status
,
prc_status
,
create_time
))
(level0_id, obs_id, detector_no,
object_name,
obs_type, obs_time, exp_time,detector_status_id, filename, file_path,qc0_status, prc_status,create_time)
\
values (?,?,?,?,?,?,?,?,?,?,?,?
,?
)"
,
(
level0_id
,
obs_id
,
detector
,
object_name
,
obs_type
,
exp_start_time
,
exp_time
,
detector_status_id
,
filename
,
file_full_path
,
qc0_status
,
prc_status
,
create_time
))
db
.
end
()
level0_id_id
=
db
.
last_row_id
()
#level0-header
...
...
csst_dfs_api_local/ifs/level0.py
View file @
90a3e69f
...
...
@@ -21,13 +21,14 @@ class Level0DataApi(object):
''' retrieve level0 records from database
parameter kwargs:
obs_id: [str]
detector_no: [str]
obs_type: [str]
obs_id: [str],
detector_no: [str],
obs_type: [str],
object_name: [str],
obs_time : (start, end),
qc0_status : [int],
prc_status : [int],
file_name: [str]
file_name: [str]
,
limit: limits returns the number of records,default 0:no-limit
return: csst_dfs_common.models.Result
...
...
@@ -36,6 +37,7 @@ class Level0DataApi(object):
obs_id
=
get_parameter
(
kwargs
,
"obs_id"
)
detector_no
=
get_parameter
(
kwargs
,
"detector_no"
)
obs_type
=
get_parameter
(
kwargs
,
"obs_type"
)
object_name
=
get_parameter
(
kwargs
,
"object_name"
)
exp_time_start
=
get_parameter
(
kwargs
,
"obs_time"
,
[
None
,
None
])[
0
]
exp_time_end
=
get_parameter
(
kwargs
,
"obs_time"
,
[
None
,
None
])[
1
]
qc0_status
=
get_parameter
(
kwargs
,
"qc0_status"
)
...
...
@@ -53,6 +55,8 @@ class Level0DataApi(object):
sql_condition
=
f
"
{
sql_condition
}
and detector_no='
{
detector_no
}
'"
if
obs_type
:
sql_condition
=
f
"
{
sql_condition
}
and obs_type='
{
obs_type
}
'"
if
object_name
:
sql_condition
=
f
"
{
sql_condition
}
and object_name='
{
object_name
}
'"
if
exp_time_start
:
sql_condition
=
f
"
{
sql_condition
}
and obs_time >='
{
exp_time_start
}
'"
if
exp_time_end
:
...
...
@@ -200,6 +204,7 @@ class Level0DataApi(object):
obs_id
=
get_parameter
(
kwargs
,
"obs_id"
),
detector_no
=
get_parameter
(
kwargs
,
"detector_no"
),
obs_type
=
get_parameter
(
kwargs
,
"obs_type"
),
object_name
=
get_parameter
(
kwargs
,
"object_name"
),
obs_time
=
get_parameter
(
kwargs
,
"obs_time"
),
exp_time
=
get_parameter
(
kwargs
,
"exp_time"
),
detector_status_id
=
get_parameter
(
kwargs
,
"detector_status_id"
),
...
...
@@ -217,9 +222,9 @@ class Level0DataApi(object):
return
Result
.
error
(
message
=
'%s existed'
%
(
rec
.
filename
,
))
self
.
db
.
execute
(
'INSERT INTO ifs_level0_data (level0_id, obs_id, detector_no, obs_type, obs_time, exp_time,detector_status_id, filename, file_path,qc0_status, prc_status,create_time)
\
VALUES(?,?,?,?,?,?,?,?,?,?,?,?)'
,
(
rec
.
level0_id
,
rec
.
obs_id
,
rec
.
detector_no
,
rec
.
obs_type
,
rec
.
obs_time
,
rec
.
exp_time
,
rec
.
detector_status_id
,
rec
.
filename
,
rec
.
file_path
,
-
1
,
-
1
,
format_time_ms
(
time
.
time
()))
'INSERT INTO ifs_level0_data (level0_id, obs_id, detector_no,
object_name,
obs_type, obs_time, exp_time,detector_status_id, filename, file_path,qc0_status, prc_status,create_time)
\
VALUES(?,?,?,?,?,?,?,?,?,?,?,?
,?
)'
,
(
rec
.
level0_id
,
rec
.
obs_id
,
rec
.
detector_no
,
rec
.
object_name
,
rec
.
obs_type
,
rec
.
obs_time
,
rec
.
exp_time
,
rec
.
detector_status_id
,
rec
.
filename
,
rec
.
file_path
,
-
1
,
-
1
,
format_time_ms
(
time
.
time
()))
)
self
.
db
.
end
()
rec
.
id
=
self
.
db
.
last_row_id
()
...
...
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