Commit 197e0914 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

fix deps and version

parent 0cee9195
......@@ -2,7 +2,7 @@
## Introduction
This package provides basic common library for CSST.
This package provides common library for DFS of CSST.
## Installation
......
......@@ -18,3 +18,6 @@ def format_time_ms(float_time):
data_head = time.strftime("%Y-%m-%d %H:%M:%S", local_time)
data_secs = (float_time - int(float_time)) * 1000
return "%s.%03d" % (data_head, data_secs)
def str_to_datetime(str_time):
return datetime.strptime(str_time.split('.')[0], '%Y-%m-%d %H:%M:%S')
\ No newline at end of file
......@@ -2,6 +2,20 @@ import dataclasses
from typing import List,Dict
from .common import BaseModel, default_field
@dataclasses.dataclass
class UserRecord(BaseModel):
id: int = 0
user_name: str=""
true_name: str=""
email: str=""
passwd: str=""
organization: str=""
create_time: str=""
status: int = 0
last_login_ip: str=""
last_login_time: str=""
role: str=""
@dataclasses.dataclass
class Observation(BaseModel):
id: int = 0
......
import dataclasses
from .common import BaseModel
@dataclasses.dataclass
class Level2Record(BaseModel):
id: int = 0
level0_id: str = ''
level1_id: int = 0
brick_id: int = 0
module_id: str = ''
object_name : str=""
data_type: str=""
filename : str=""
file_path: str=""
qc2_status: int = 0
qc2_time: str=""
prc_status: int = 0
prc_time: str=""
create_time: str=""
update_time: str=""
pipeline_id: str=""
import_status: int = 0
@dataclasses.dataclass
class Level2TypeRecord(BaseModel):
data_type: str=""
module_id: str = ''
key_column : str=""
hdu_index: int=0
demo_filename : str=""
demo_file_path: str=""
ra_column: str=""
dec_column: str=""
update_time: str=""
create_time: str=""
import_status: int = 0
def filter_table_name(data_type):
return '_'.join(data_type.split('-'))
......@@ -6,6 +6,7 @@ from astropy.io import fits
from astropy import wcs
import numpy as np
import healpy as hp
from csst_dfs_commons.models.constants import PI, DEFAULT_NSIDE
def get_header_value(key: str, headers, default_value = None):
try:
......@@ -74,3 +75,34 @@ def hdul_of_healpix_ids(hdulist, nside=256):
healpixids = hp.query_polygon(nside, xyzpoly.T)
return healpixids
def heapix_sql_condition(ra, dec, radius, ra_col = 'ra', dec_col = 'dec', nside = DEFAULT_NSIDE):
arcDec = (PI / 180) * dec
whereSql = f"abs((180./{PI}) * ACOS(SIN({PI} * {dec_col}/180) * SIN({arcDec}) + COS({PI} * {dec_col}/180) * COS({arcDec}) * COS(({PI}/180) * ({ra_col} - {ra})))) < {radius}"
heapix_ids = get_healpix_ids(ra, dec, radius, nside)
nside_column = "NS%dHIdx" % (nside,)
whereZoneSql = "%s in (%s)" % \
(nside_column, ','.join([str(i) for i in heapix_ids]))
return whereZoneSql, whereSql
def level2_heapix_sql_condition(ra, dec, radius, ra_col = 'ra', dec_col = 'dec', nside = DEFAULT_NSIDE):
x2 = f"cos({dec_col})*cos({ra_col})"
y2 = f"cos({dec_col})*sin({ra_col})"
z2 = f"sin({dec_col})"
x1 = f"cos({dec})*cos({ra})"
y1 = f"cos({dec})*sin({ra})"
z1 = f"sin({dec})"
distance = f"pow(({x2}-{x1}),2)+pow(({y2}-{y1}),2)+pow(({z2}-{z1}),2)"
heapix_ids = get_healpix_ids(ra, dec, radius, nside)
nside_column = "brick_id"
whereZoneSql = "%s in (%s)" % \
(nside_column, ','.join([str(i) for i in heapix_ids]))
whereSql = f"{distance} <= 4*pow({radius}/2, 2) and {whereZoneSql}"
return whereSql
\ No newline at end of file
__version__ = "1.0.0"
\ No newline at end of file
astropy
astropy_healpix
healpy
\ No newline at end of file
# base
astropy==5.3.4
pandas==2.0.3
numpy==1.26.1
healpy==1.16.6
# specific
astropy_healpix==1.0.1
\ No newline at end of file
......@@ -7,16 +7,18 @@ description = CSST Commons Module.
long_description = file: README.md
long_description_content_type = text/markdown
keywords = astronomy, astrophysics, cosmology, space, CSST
url = https://github.com/astronomical-data-processing/csst-dfs-commons
project_urls =
Bug Tracker = https://github.com/astronomical-data-processing/csst-dfs-commons/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
Operating System :: OS Independent
url = https://csst-tb.bao.ac.cn/code/csst-dfs/csst-dfs-commons
[options]
packages = find:
python_requires = >=3.7
zip_safe = False
setup_requires = setuptools_scm
\ No newline at end of file
[bumpver]
current_version = "1.0.0"
version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"
commit_message = "Release {new_version}"
commit = True
tag = True
push = True
[bumpver:file_patterns]
setup.cfg =
current_version = "{version}"
csst_dfs_commons/version.py =
__version__ = "{version}"
\ No newline at end of file
# coding: utf-8
import os
from setuptools import setup
setup_pars = {
"packages" : [
'csst_dfs_commons',
'csst_dfs_commons.convert',
'csst_dfs_commons.logging',
'csst_dfs_commons.models',
'csst_dfs_commons.utils',
],
"package_dir" : {
'csst_dfs_commons' : 'csst_dfs_commons',
'csst_dfs_commons.convert' : 'csst_dfs_commons/convert',
'csst_dfs_commons.logging' : 'csst_dfs_commons/logging',
'csst_dfs_commons.models' : 'csst_dfs_commons/models',
'csst_dfs_commons.utils' : 'csst_dfs_commons/utils',
},
}
def requirements():
with open("requirements.txt", "r") as f:
return [
req.strip()
for req in f.readlines()
if not req.startswith("#") and req.__contains__("==")
]
def version():
__version = {}
version_path = os.path.join(os.path.dirname(__file__), "csst_dfs_commons", "version.py")
with open(version_path, "r") as file:
exec(file.read(), __version)
return __version["__version__"]
setup(
name="csst_dfs_commons",
version=version(),
description="common library for CSST Data Flow System (DFS)",
long_description=open('README.md').read(),
license="MIT",
python_requires=">=3.7",
install_requires=requirements(),
zip_safe=False,
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Scientific/Engineering :: Astronomy",
],
include_package_data=False,
project_urls={
'Source': 'https://csst-tb.bao.ac.cn/code/csst-dfs/csst-dfs-api-local',
},
**setup_pars
)
setup(use_scm_version={'write_to': os.path.join('csst_dfs_commons', '_version.py')})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment