Commit 5cff1b93 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

add model

parent 6cd92ae6
......@@ -6,13 +6,14 @@ class Result(dict):
self["message"] = ""
self["data"] = None
@property
def success(self):
return self["code"] >= 0
@property
def data(self):
return self["data"]
@property
def message(self):
return self["message"]
......@@ -25,7 +26,7 @@ class Result(dict):
return r
@staticmethod
def ok_data(data):
def ok_data(data=None):
r = Result()
r["data"] = data
return r
......
import dataclasses
def from_proto_model_list(clazz, records):
return [clazz().from_proto_model(r) for r in records]
@dataclasses.dataclass
class BaseModel:
def from_dict(self, data = {}):
for k in self.__dataclass_fields__.keys():
self.__setattr__(k, data.get(k, None))
return self
def from_proto_model(self, record):
return self.from_dict({r.name:v for r,v in record.ListFields()})
@dataclasses.dataclass
class Gaia3Record(BaseModel):
SourceId: int = -1
RandomIndex: int = -1
RefEpoch: float = -1
Ra: float = -1
RaError: float = -1
Dec : float = -1
DecError: float = -1
Parallax: float = -1
ParallaxError: float = -1
ParallaxOverError: float = -1
Pm: float = -1
Pmra: float = -1
PmraError: float = -1
Pmdec: float = -1
PmdecError: float = -1
RaDecCorr : float = -1
RaParallaxCorr: float = -1
RaPmraCorr: float = -1
RaPmdecCorr: float = -1
DecParallaxCorr: float = -1
DecPmraCorr: float = -1
DecPmdecCorr: float = -1
ParallaxPmraCorr: float = -1
ParallaxPmdecCorr: float = -1
PmraPmdecCorr: float = -1
AstrometricNObsAl: int = -1
AstrometricNObsAc: int = -1
AstrometricNGoodObsAl: int = -1
AstrometricNBadObsAl: int = -1
AstrometricGofAl: float = -1
AstrometricChi2Al: float = -1
AstrometricExcessNoise: float = -1
AstrometricExcessNoiseSi: float = -1
AstrometricParamsSolved: int = -1
AstrometricPrimaryFlag: int = -1
NuEffUsedInAstrometry: float = -1
Pseudocolour: float = -1
PseudocolourError: float = -1
RaPseudocolourCorr: float = -1
DecPseudocolourCorr: float = -1
ParallaxPseudocolourCorr: float = -1
PmraPseudocolourCorr : float = -1
PmdecPseudocolourCorr: float = -1
AstrometricMatchedTransits: int = -1
VisibilityPeriodsUsed: int = -1
AstrometricSigma5dMax : float = -1
MatchedTransits: int = -1
NewMatchedTransits: int = -1
MatchedTransitsRemoved: int = -1
IpdGofHarmonicAmplitude: float = -1
IpdGofHarmonicPhase: float = -1
IpdFracMultiPeak: int = -1
IpdFracOddWin: int = -1
Ruwe: float = -1
ScanDirectionStrengthK1: float = -1
ScanDirectionStrengthK2: float = -1
ScanDirectionStrengthK3: float = -1
ScanDirectionStrengthK4: float = -1
ScanDirectionMeanK1: float = -1
ScanDirectionMeanK2: float = -1
ScanDirectionMeanK3: float = -1
ScanDirectionMeanK4: float = -1
DuplicatedSource: int = -1
PhotGNObs: int = -1
PhotGMeanFlux: float = -1
PhotGMeanFluxError: float = -1
PhotGMeanFluxOverError: float = -1
PhotGMeanMag: float = -1
PhotBpNObs: int = -1
PhotBpMeanFlux: float = -1
PhotBpMeanFluxError: float = -1
PhotBpMeanFluxOverError: float = -1
PhotBpMeanMag: float = -1
PhotRpNObs: int = -1
PhotRpMeanFlux: float = -1
PhotRpMeanFluxError: float = -1
PhotRpMeanFluxOverError: float = -1
PhotRpMeanMag: float = -1
PhotBpNContaminatedTransits: float = -1
PhotBpNBlendedTransits: float = -1
PhotRpNContaminatedTransits: float = -1
PhotRpNBlendedTransits: float = -1
PhotProcMode : float = -1
PhotBpRpExcessFactor: float = -1
BpRp: float = -1
BpG : float = -1
GRp : float = -1
Dr2RadialVelocity: float = -1
Dr2RadialVelocityError: float = -1
Dr2RvNbTransits: int = -1
Dr2RvTemplateTeff: float = -1
Dr2RvTemplateLogg: float = -1
Dr2RvTemplateFeH : float = -1
L: float = -1
B: float = -1
EclLon: float = -1
EclLat: float = -1
NS8HIdx: int = -1
NS16HIdx: int = -1
NS32HIdx: int = -1
NS64HIdx: int = -1
def __init__(self):
self.AstrometricNObsAc = 0
import dataclasses
from typing import List
from .common import BaseModel
@dataclasses.dataclass
class Observation(BaseModel):
id: int = 0
obs_time: str = ""
exp_time : float = 0
module_id: str=""
obs_type: str=""
facility_status_id: int = 0
module_status_id: int = 0
qc0_status: int = 0
qc0_time: str=""
prc_status: int = 0
prc_time: str=""
create_time: str=""
import_status: int = 0
@dataclasses.dataclass
class Level0PrcRecord(BaseModel):
id: int = 0
level0_id: int = 0
pipeline_id: str = ""
prc_module: str = ""
params_id: str=""
prc_status: int = 0
prc_time: str=""
file_path: str=""
@dataclasses.dataclass
class Level0Record(BaseModel):
id: int = 0
obs_id: int = 0
detector_no: str = ""
obs_type: str = ""
obs_time: str=""
exp_time: float = 0
detector_status_id: int = 0
filename: str=""
file_path: str=""
qc0_status: int = 0
qc0_time: str=""
prc_status: int = 0
prc_time: str=""
create_time: str=""
@dataclasses.dataclass
class CalMergeRecord(BaseModel):
id: int = 0
detector_no: str = ""
ref_type: str = ""
obs_time: str=""
exp_time: float = 0
filename: str=""
file_path: str=""
qc1_status: int = 0
qc1_time: str=""
prc_status: int = 0
prc_time: str=""
prc_time: str=""
create_time: str=""
level0_ids: list = dataclasses.field(default_factory=list)
@dataclasses.dataclass
class Detector(BaseModel):
no: str = ""
detector_name: str = ""
module_id: str=""
filter_id: float = 0
create_time: str=""
update_time: str=""
@dataclasses.dataclass
class DetectorStatus(BaseModel):
id: int = 0
detector_no: str = ""
status: str=""
create_time: str=""
status_time: str=""
\ No newline at end of file
import dataclasses
from .common import BaseModel
@dataclasses.dataclass
class Level1Record(BaseModel):
id: int = 0
raw_id : int = 0
data_type: str=""
or_sci_id: int = 0
prc_params: str=""
flat_id: int = 0
dark_id: int = 0
bias_id: int = 0
lamp_id: int = 0
arc_id: int = 0
sky_id: int = 0
filename : str=""
file_path: str=""
qc1_status: int = 0
qc1_time: str=""
prc_status: int = 0
prc_time: str=""
create_time: str=""
pipeline_id: str=""
import dataclasses
from .common import BaseModel
@dataclasses.dataclass
class Level1Record(BaseModel):
id: int = 0
raw_id : int = 0
data_type: str=""
or_sci_id: int = 0
prc_params: str=""
flat_id: int = 0
dark_id: int = 0
bias_id: int = 0
filename : str=""
file_path: str=""
qc1_status: int = 0
qc1_time: str=""
prc_status: int = 0
prc_time: str=""
create_time: str=""
pipeline_id: str=""
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