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
b771e96c
Commit
b771e96c
authored
Jun 23, 2025
by
BO ZHANG
🏀
Browse files
adapt for input pmapname
parent
4a969a95
Pipeline
#8873
passed with stage
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
csst_common/ccds/ccds.py
View file @
b771e96c
...
...
@@ -16,16 +16,21 @@ from .slsconf import convert_slsconf
class
CCDS
:
def
__init__
(
self
,
ccds_root
=
"/ccds_root"
,
ccds_cache
=
"/pipeline/ccds_cache"
):
print
(
"Setting CCDS root path ... "
,
end
=
""
)
def
__init__
(
self
,
ccds_root
=
"/ccds_root"
,
ccds_cache
=
"/pipeline/ccds_cache"
,
pmapname
=
None
,
):
print
(
"[CCDS] Setting CCDS root path ... "
,
end
=
""
)
self
.
ccds_root
=
ccds_root
print
(
self
.
ccds_root
)
print
(
"Setting CCDS cache path ... "
,
end
=
""
)
print
(
"
[CCDS]
Setting CCDS cache path ... "
,
end
=
""
)
self
.
ccds_cache
=
ccds_cache
print
(
self
.
ccds_cache
)
print
(
"Setting CCDS environment variables ... "
,
end
=
""
)
print
(
"
[CCDS]
Setting CCDS environment variables ... "
,
end
=
""
)
os
.
environ
[
"CCDS_MODE"
]
=
"remote"
os
.
environ
[
"CCDS_PATH"
]
=
ccds_cache
os
.
environ
[
"CCDS_OBSERVATORY"
]
=
"csst"
...
...
@@ -36,24 +41,26 @@ class CCDS:
print
(
self
.
observatory
)
assert
(
self
.
observatory
==
"csst"
),
f
"observatory [
{
self
.
observatory
}
] is not csst!"
),
f
"observatory [
{
self
.
observatory
}
] is not
`
csst
`
!"
print
(
"Query for operational_context ... "
,
end
=
""
)
self
.
operational_context
=
client
.
get_default_context
(
self
.
observatory
)
print
(
f
"[CCDS] Query for operational_context =
{
self
.
operational_context
}
... "
)
self
.
pmapname
=
pmapname
if
pmapname
is
not
None
else
self
.
operational_context
print
(
f
"[CCDS] Setting pmapname =
{
self
.
pmapname
}
... "
)
try
:
self
.
operational_context
=
client
.
get_default_context
(
self
.
observatory
)
# dump mappings
client
.
dump_mappings
(
self
.
operational_context
)
client
.
dump_mappings
(
self
.
pmapname
)
self
.
is_available
=
True
except
BaseException
as
e
:
print
(
"CCDS access failed! "
,
e
.
args
)
self
.
operational_context
=
""
print
(
f
"[CCDS] Failed to get pmapname=
{
self
.
pmapname
}
:"
,
e
.
args
)
self
.
is_available
=
False
print
(
self
.
operational_context
)
# assert self.operational_context != "", f"operational_context [{self.operational_context}] is empty!"
print
(
f
"[CCDS] operational_context =
{
self
.
operational_context
}
"
)
print
(
f
"[CCDS] pmapname =
{
self
.
pmapname
}
"
)
def
__repr__
(
self
):
return
(
f
"
<
CCDS url='
{
os
.
getenv
(
'CCDS_SERVER_URL'
,
default
=
''
)
}
' >
\n
"
f
"
[
CCDS
]
url='
{
os
.
getenv
(
'CCDS_SERVER_URL'
,
default
=
''
)
}
' >
\n
"
f
" - is_available=
{
self
.
is_available
}
\n
"
f
" - observatory='
{
self
.
observatory
}
'
\n
"
f
" - operational_context='
{
self
.
operational_context
}
'
\n
"
...
...
@@ -67,7 +74,7 @@ class CCDS:
):
# print("get min header")
hdrs
=
client
.
api
.
get_minimum_header
(
self
.
operational_context
,
file_path
,
ignore_cache
=
False
self
.
pmapname
,
file_path
,
ignore_cache
=
False
)
# {'CAMERA': 'MS',
# 'CHIPID': '10',
...
...
@@ -76,7 +83,7 @@ class CCDS:
# 'INSTRUME': 'MSC',
# 'REFTYPE': 'UNDEFINED'}
# print("get best ref")
refs
=
client
.
api
.
get_best_references
(
self
.
operational_context
,
hdrs
)
refs
=
client
.
api
.
get_best_references
(
self
.
pmapname
,
hdrs
)
# {'bias': 'csst_msc_ms_bias_10_000001.fits',
# 'dark': 'csst_msc_ms_dark_10_000001.fits',
# 'ledflat': 'csst_msc_ms_ledflat_10_000001.fits',
...
...
@@ -86,7 +93,7 @@ class CCDS:
# print("get file info")
refs_fp
=
dict
()
for
ref_type
in
refs
.
keys
():
d
=
client
.
api
.
get_file_info
(
self
.
operational_context
,
refs
[
ref_type
])
d
=
client
.
api
.
get_file_info
(
self
.
pmapname
,
refs
[
ref_type
])
if
d
:
fp
=
os
.
path
.
join
(
self
.
ccds_root
,
d
[
"file_path"
])
assert
os
.
path
.
exists
(
fp
),
f
"File path [
{
fp
}
] does not exist!"
...
...
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