trigger.py 1.05 KB
Newer Older
BO ZHANG's avatar
BO ZHANG committed
1
import numpy as np
BO ZHANG's avatar
BO ZHANG committed
2
from csst_dag import CSST_DAG_LIST, Redis, dump_message_list
BO ZHANG's avatar
BO ZHANG committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from csst_dag.constants import MSC_MBI_CHIPID

# set BATCH_ID and DATASET
BATCH_ID = "msc-v093-rdx-zjlab-v1"
DATASET = "msc-v093"

# get OBSID
with open("batch/msc-v093/C9_W1_Phot.obsid", "r") as f:
    OBSID_LIST = [_.strip() for _ in f.readlines()]
OBSID_LIST_CORRECTED = [_[:3] + "093" + _[6:] for _ in OBSID_LIST]

# get DAG
dag = CSST_DAG_LIST.get("csst-msc-l1-mbi")
# get redis
r = Redis(location="zjlab")

# generate messages
message_list = []
for this_obsid in OBSID_LIST_CORRECTED:
    for this_chipid in MSC_MBI_CHIPID:
        this_message = dag.gen_message(
            batch_id=BATCH_ID,
            dataset=DATASET,
            obsid=this_obsid,
            chipid=this_chipid,
        )
        message_list.append(this_message)

BO ZHANG's avatar
BO ZHANG committed
31

BO ZHANG's avatar
BO ZHANG committed
32
33
34
# push messages to redis
for msg in message_list:
    r.push(msg)
BO ZHANG's avatar
BO ZHANG committed
35
36
37
38
39
40
41

print(f" N_message = {len(message_list)}")
print(f" N_in_redis = {len(r.get_all())}")


# dump messages
dump_message_list(message_list, path=f"batch/msc-v093/C9_W1_Phot.{BATCH_ID}")