loadPSFSet.py 1.97 KB
Newer Older
1
2
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import unittest

import sys,os,math
from itertools import islice

import numpy as np

import yaml
from ObservationSim.Config import Config
from ObservationSim.Config.Config import config_dir
from ObservationSim.Instrument import Chip

from ObservationSim.PSF.PSFInterp import PSFInterp


def defineCCD(iccd, config_file):
    with open(config_file, "r") as stream:
        try:
            config = yaml.safe_load(stream)
            #for key, value in config.items():
            #    print (key + " : " + str(value))
        except yaml.YAMLError as exc:
            print(exc)
    path_dict = config_dir(config=config, work_dir=config['work_dir'], data_dir=config['data_dir'])
    chip = Chip(chipID=iccd, config=config)
    #chip = Chip(chipID=iccd, ccdEffCurve_dir=path_dict["ccd_dir"], CRdata_dir=path_dict["CRdata_dir"], normalize_dir=path_dict["normalize_dir"], sls_dir=path_dict['sls_dir'], config=config)
    return chip

def loadPSFSet(iccd):
    config_file = "/public/home/weichengliang/CSST_git/newVersion/CSST/config/config_C3.yaml"
    chip = defineCCD(iccd, config_file)
    print(chip.chipID)
    print(chip.cen_pix_x, chip.cen_pix_y)

    ipath = '/data/simudata/CSSOSDataProductsSims/data/csstPSFdata/psfCube'
    psfMat= PSFInterp(chip, npsf=900, PSF_data_file=ipath, PSF_data_prefix="")
    psfSet= psfMat._loadPSF(iccd, ipath, PSF_data_prefix="")

    twave = 0 #[0...3]
    tpsf  = 0 #[0...899]
    field_x= psfSet[twave][tpsf]['field_x']
    field_y= psfSet[twave][tpsf]['field_y']
    image_x= psfSet[twave][tpsf]['image_x']
    image_y= psfSet[twave][tpsf]['image_y']
    centroid_x= psfSet[twave][tpsf]['centroid_x']
    centroid_y= psfSet[twave][tpsf]['centroid_y']
    print("pos_info:", field_x, field_y, image_x, image_y, centroid_x, centroid_y)
    return psfSet



class PSFInterpModule_coverage(unittest.TestCase):
    def test_psfEll_(self):
        iccd = 1  #[1...30]
        psfSet = loadPSFSet(iccd)


if __name__ == '__main__':
    unittest.main()
    print('#####haha#####')