3 from shesha.util.writers
import common
5 def write_json_sys_param(sup, *, wfss_indices=None, ts=False, dms_indices=None, file_name="./sys-params.json"):
6 """Return a json representation of the AO system
9 sup : (CompassSupervisor) : supervisor to get the json representation from
12 wfss_indices : (list(int)) : list of wfs indices added into the json
14 dms_indices : (list(int)) : list of dm indices added into the json
16 file_name : (str) : output file name
19 if(wfss_indices
is None):
20 wfss_indices = list(range(len(sup.config.p_wfss)))
21 elif(isinstance(wfss_indices,int)):
22 wfss_indices = list(range(wfss_indices))
24 if(dms_indices
is None):
25 dms_indices = list(range(len(sup.config.p_dms)))
26 elif(isinstance(dms_indices,int)):
27 dms_indices = list(range(dms_indices))
32 "comment":
" meter : telescope diameter",
33 "value" : sup.config.p_tel.get_diam()
36 "comment":
" percent : central obscuration",
37 "value" : sup.config.p_tel.get_cobs()
40 "comment":
" second : frame rate",
41 "value": sup.config.p_loop.ittime
44 "comment":
"Minimal illumination fraction for valid subap",
45 "value": sup.config.p_wfss[0].get_fracsub()
48 "comment":
"percent : atmosphere transmission",
52 "comment":
"arcsec^2 : telescope tracking error parameters (x^2, y^2 and xy)",
61 diam = sup.config.p_tel.get_diam()
62 geom = sup.config.p_geom
68 for i
in wfss_indices:
69 w = sup.config.p_wfss[i]
70 if w
in sup.config.p_wfs_lgs:
71 lgs_json.append(common.wfs_to_json(w,geom,
"lgs"))
72 elif w
in sup.config.p_wfs_ngs:
73 if( i == (len(sup.config.p_wfss) - 1) ):
74 target_json = common.wfs_to_json(w,geom,
"target",
75 x_pos = [t.xpos
for t
in sup.config.p_targets],
76 y_pos = [t.ypos
for t
in sup.config.p_targets] )
78 ngs_json.append(common.wfs_to_json(w,geom,
"ngs"))
80 w = sup.config.p_wfs_ts
82 argmax = np.array([sup.config.p_wfss[i].nxsub
for i
in wfss_indices]).argmax()
83 w[0].set_nxsub(sup.config.p_wfss[argmax].nxsub)
84 w[0].set_pdiam(sup.config.p_wfss[argmax]._pdiam)
85 ts_json = common.wfs_to_json(w,geom,
"ts")
88 "notice_lgs" : common.wfs_json_notice(
"lgs"),
89 "notice_ngs" : common.wfs_json_notice(
"ngs"),
95 sys_json[
"wfs"] = wfs_json
100 d = sup.config.p_dms[i]
101 dm_json.append(common.dm_to_json(d, geom))
102 sys_json[
"dm"] = dm_json
104 f = open(file_name,
"w")
105 f.write(json.dumps({
"instrument":sys_json},indent=4))
def write_json_sys_param(sup, *wfss_indices=None, ts=False, dms_indices=None, file_name="./sys-params.json")
Return a json representation of the AO system.