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
a0ca5a82
Commit
a0ca5a82
authored
Mar 24, 2021
by
Wei Shoulin
Browse files
datetime bug
parent
5f4964fe
Changes
5
Hide whitespace changes
Inline
Side-by-side
csst_dfs_api_local/ifs/fits.py
View file @
a0ca5a82
...
...
@@ -210,7 +210,7 @@ class FitsApi(object):
new_file_dir
=
create_dir
(
os
.
path
.
join
(
self
.
root_dir
,
"fits"
),
self
.
sub_system
,
"/"
.
join
([
str
(
datetime
.
datetime
.
now
().
year
),
"%02d"
%
(
datetime
.
datetime
.
now
().
month
),
"%02d"
%
(
datetime
.
datetime
.
now
().
day
)]))
"/"
.
join
([
str
(
datetime
.
now
().
year
),
"%02d"
%
(
datetime
.
now
().
month
),
"%02d"
%
(
datetime
.
now
().
day
)]))
file_basename
=
os
.
path
.
basename
(
file_path
)
new_file_path
=
os
.
path
.
join
(
new_file_dir
,
file_basename
)
...
...
csst_dfs_api_local/ifs/reffits.py
View file @
a0ca5a82
...
...
@@ -201,7 +201,7 @@ class RefFitsApi(object):
new_file_dir
=
create_dir
(
os
.
path
.
join
(
self
.
root_dir
,
"refs"
),
self
.
sub_system
,
"/"
.
join
([
str
(
datetime
.
datetime
.
now
().
year
),
"%02d"
%
(
datetime
.
datetime
.
now
().
month
),
"%02d"
%
(
datetime
.
datetime
.
now
().
day
)]))
"/"
.
join
([
str
(
datetime
.
now
().
year
),
"%02d"
%
(
datetime
.
now
().
month
),
"%02d"
%
(
datetime
.
now
().
day
)]))
file_basename
=
os
.
path
.
basename
(
file_path
)
...
...
csst_dfs_api_local/ifs/result0.py
View file @
a0ca5a82
...
...
@@ -107,7 +107,7 @@ class Result0Api(object):
new_file_dir
=
create_dir
(
os
.
path
.
join
(
self
.
root_dir
,
"results0"
),
self
.
sub_system
,
"/"
.
join
([
str
(
datetime
.
datetime
.
now
().
year
),
"%02d"
%
(
datetime
.
datetime
.
now
().
month
),
"%02d"
%
(
datetime
.
datetime
.
now
().
day
)]))
"/"
.
join
([
str
(
datetime
.
now
().
year
),
"%02d"
%
(
datetime
.
now
().
month
),
"%02d"
%
(
datetime
.
now
().
day
)]))
file_basename
=
os
.
path
.
basename
(
file_path
)
...
...
csst_dfs_api_local/ifs/result1.py
View file @
a0ca5a82
...
...
@@ -103,7 +103,7 @@ class Result1Api(object):
new_file_dir
=
create_dir
(
os
.
path
.
join
(
self
.
root_dir
,
"results1"
),
self
.
sub_system
,
"/"
.
join
([
str
(
datetime
.
datetime
.
now
().
year
),
"%02d"
%
(
datetime
.
datetime
.
now
().
month
),
"%02d"
%
(
datetime
.
datetime
.
now
().
day
)]))
"/"
.
join
([
str
(
datetime
.
now
().
year
),
"%02d"
%
(
datetime
.
now
().
month
),
"%02d"
%
(
datetime
.
now
().
day
)]))
file_basename
=
os
.
path
.
basename
(
file_path
)
new_file_path
=
os
.
path
.
join
(
new_file_dir
,
file_basename
)
...
...
tests/test_ifs_result0.py
View file @
a0ca5a82
...
...
@@ -9,25 +9,25 @@ class IFSResult0TestCase(unittest.TestCase):
def
setUp
(
self
):
self
.
api
=
Result0Api
()
def
test_find
(
self
):
recs
=
self
.
api
.
find
(
file_name
=
'CCD2_ObsTime_1200_ObsNum_40.fits'
)
print
(
'find:'
,
recs
)
assert
len
(
recs
)
==
1
recs
=
self
.
api
.
find
()
print
(
'find:'
,
recs
)
assert
len
(
recs
)
>
1
def
test_read
(
self
):
recs
=
self
.
api
.
find
(
file_name
=
'CCD2_ObsTime_1200_ObsNum_40.fits'
)
print
(
"The full path: "
,
os
.
path
.
join
(
self
.
api
.
root_dir
,
recs
[
0
][
'file_path'
]))
file_segments
=
self
.
api
.
read
(
file_path
=
recs
[
0
][
'file_path'
])
file_bytes
=
b
''
.
join
(
file_segments
)
hdul
=
fits
.
HDUList
.
fromstring
(
file_bytes
)
print
(
hdul
.
info
())
hdr
=
hdul
[
0
].
header
print
(
repr
(
hdr
))
#
def test_find(self):
#
recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits')
#
print('find:', recs)
#
assert len(recs) == 1
#
recs = self.api.find()
#
print('find:', recs)
#
assert len(recs) > 1
#
def test_read(self):
#
recs = self.api.find(file_name='CCD2_ObsTime_1200_ObsNum_40.fits')
#
print("The full path: ", os.path.join(self.api.root_dir, recs[0]['file_path']))
#
file_segments = self.api.read(file_path=recs[0]['file_path'])
#
file_bytes = b''.join(file_segments)
#
hdul = fits.HDUList.fromstring(file_bytes)
#
print(hdul.info())
#
hdr = hdul[0].header
#
print(repr(hdr))
def
test_write
(
self
):
self
.
api
.
write
(
raw_id
=
1
,
...
...
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