trigger-msc-v093-rdx-zjlab-v4.py 1.37 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
from csst_dag.constants import MSC_MBI_CHIPID

# set BATCH_ID and DATASET
6
BATCH_ID = "msc-v093-rdx-zjlab-v4"
BO ZHANG's avatar
BO ZHANG committed
7
8
DATASET = "msc-v093"

9
10
OBSID_LIST_PATH = "batch/msc-v093/msc-v093-all.obsid"

BO ZHANG's avatar
BO ZHANG committed
11
# get OBSID
12
with open(OBSID_LIST_PATH, "r") as f:
BO ZHANG's avatar
BO ZHANG committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    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")

# 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

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

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

# dump messages
42
43
44
45
46
47
48
49
50
51
52
dump_message_list(message_list, path=f"batch/msc-v093/msc-v093.{BATCH_ID}")

# re-process?
# read messages
with open(f"batch/msc-v093/C9_W1_Phot.{BATCH_ID}.messages", "r") as f:
    message_list = [_.strip() for _ in f.readlines()]
for msg in message_list[20:30]:
    r.push(msg)

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