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
Commits
be47b5da
Commit
be47b5da
authored
Jan 05, 2023
by
Wei Shoulin
Browse files
to_table
parent
b72c7669
Changes
2
Show whitespace changes
Inline
Side-by-side
csst_dfs_api/common/utils.py
View file @
be47b5da
...
...
@@ -82,14 +82,14 @@ def fields_dtypes(rec):
def
tuple_fields_dtypes
(
rec
:
tuple
):
dtypes
=
[]
for
_
,
f
in
rec
:
if
f
.
type
==
int
:
for
f
in
rec
:
if
type
(
f
)
==
int
:
dtypes
.
append
(
'i8'
)
elif
f
.
type
==
float
:
elif
type
(
f
)
==
float
:
dtypes
.
append
(
'f8'
)
elif
f
.
type
==
str
:
elif
type
(
f
)
==
str
:
dtypes
.
append
(
'S2'
)
elif
f
.
type
==
list
:
elif
type
(
f
)
==
list
:
dtypes
.
append
(
'(12,)f8'
)
else
:
dtypes
.
append
(
'S2'
)
...
...
@@ -101,12 +101,10 @@ def to_table(query_result):
return
Table
()
fields
=
query_result
[
'columns'
]
dtypes
=
tuple_fields_dtypes
(
query_result
.
data
[
0
])
t
=
Table
(
names
=
fields
,
dtype
=
dtypes
)
t
.
meta
[
'co
mment
s'
]
=
[
str
(
query_result
.
data
[
0
].
__class__
)]
t
=
Table
(
names
=
fields
,
dtype
=
dtypes
,
rows
=
query_result
.
data
)
t
.
meta
[
'co
lumn
s'
]
=
fields
t
.
meta
[
'total'
]
=
query_result
[
'totalCount'
]
for
rec
in
query_result
.
data
:
t
.
add_row
(
rec
)
return
t
def
object_list_to_table
(
query_result
):
...
...
tests/common/test_common_catalog.py
View file @
be47b5da
...
...
@@ -16,6 +16,7 @@ class CommonCatalogTestCase(unittest.TestCase):
ra
=
90
,
dec
=
24.5
,
radius
=
1
,
columns
=
(
'ref_epoch'
,
'ra'
,
'ra_error'
,
'dec'
,
'dec_error'
,
'parallax'
,
'parallax_error'
,
'pmra'
,
'pmra_error'
,
'pmdec'
,
'pmdec_error'
,
'phot_g_mean_mag'
,
'source_id'
),
catalog_name
=
'gaia3'
,
min_mag
=-
1
,
max_mag
=-
1
,
...
...
@@ -23,7 +24,8 @@ class CommonCatalogTestCase(unittest.TestCase):
limit
=
0
)
# print(result)
# dt = self.api.to_table(result)
dt
=
self
.
api
.
to_table
(
result
)
dt
.
pprint
()
# df = dt.to_pandas()
# print(df.head())
print
(
'used:'
,
time
.
time
()
-
t
)
...
...
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