test_loadPSFSet.py 1.92 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
import unittest

import sys,os,math
from itertools import islice

import numpy as np

import yaml
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)
    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

Wei Chengliang's avatar
Wei Chengliang committed
25
26
def loadPSFSet(iccd, dataPath):
    config_file = os.path.join(dataPath, 'config_test.yaml')
27
28
29
30
    chip = defineCCD(iccd, config_file)
    print(chip.chipID)
    print(chip.cen_pix_x, chip.cen_pix_y)

Wei Chengliang's avatar
Wei Chengliang committed
31
32
    psfMat= PSFInterp(chip, npsf=900, PSF_data_file=dataPath, PSF_data_prefix="S30x30_")
    psfSet= psfMat._loadPSF(iccd, dataPath, PSF_data_prefix="S30x30_")
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

    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):
Wei Chengliang's avatar
Wei Chengliang committed
48
49
50
51
    def __init__(self, methodName='runTest'):
        super(PSFInterpModule_coverage,self).__init__(methodName)
        self.dataPath = os.path.join(os.getenv('UNIT_TEST_DATA_ROOT'), 'csst_fz_gc1')

52
53
    def test_psfEll_(self):
        iccd = 1  #[1...30]
Wei Chengliang's avatar
Wei Chengliang committed
54
        psfSet = loadPSFSet(iccd, dataPath=self.dataPath)
55
56
57
58
59
60
61
62


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