Commit edd720e6 authored by Fang Yuedong's avatar Fang Yuedong
Browse files

Merge branch 'develop'

parents 959f0ebc 8df06b27
# z_cssc # z_cssc
# lambda_Angst throughput # lambda_Angst throughput
2000.00 0.00000 2000.00 -0.00000
2010.00 0.00000 2010.00 0.00000
2020.00 0.00000 2020.00 0.00000
2030.00 0.00000 2030.00 -0.00000
2040.00 0.00000 2040.00 0.00000
2050.00 0.00000 2050.00 -0.00000
2060.00 0.00000 2060.00 0.00000
2070.00 0.00000 2070.00 0.00000
2080.00 0.00000 2080.00 0.00000
2090.00 0.00000 2090.00 0.00000
2100.00 0.00000 2100.00 -0.00000
2110.00 0.00000 2110.00 -0.00000
2120.00 0.00000 2120.00 0.00000
2130.00 0.00000 2130.00 -0.00000
2140.00 0.00000 2140.00 0.00000
2150.00 0.00000 2150.00 0.00000
2160.00 0.00000 2160.00 -0.00000
2170.00 0.00000 2170.00 0.00000
2180.00 0.00000 2180.00 0.00000
2190.00 0.00000 2190.00 0.00000
2200.00 0.00000 2200.00 0.00000
2210.00 0.00000 2210.00 0.00000
2220.00 0.00000 2220.00 -0.00000
2230.00 0.00000 2230.00 0.00000
2240.00 0.00000 2240.00 0.00000
2250.00 0.00000 2250.00 0.00000
...@@ -30,49 +30,49 @@ ...@@ -30,49 +30,49 @@
2270.00 0.00000 2270.00 0.00000
2280.00 0.00000 2280.00 0.00000
2290.00 0.00000 2290.00 0.00000
2300.00 0.00000 2300.00 -0.00000
2310.00 0.00000 2310.00 -0.00000
2320.00 0.00000 2320.00 0.00000
2330.00 0.00000 2330.00 -0.00000
2340.00 0.00000 2340.00 0.00000
2350.00 0.00000 2350.00 -0.00000
2360.00 0.00000 2360.00 0.00000
2370.00 0.00000 2370.00 0.00000
2380.00 0.00000 2380.00 0.00000
2390.00 0.00000 2390.00 -0.00000
2400.00 0.00000 2400.00 -0.00000
2410.00 0.00000 2410.00 -0.00000
2420.00 0.00000 2420.00 0.00000
2430.00 0.00000 2430.00 0.00000
2440.00 0.00000 2440.00 0.00000
2450.00 0.00000 2450.00 -0.00000
2460.00 0.00000 2460.00 0.00000
2470.00 0.00000 2470.00 0.00000
2480.00 0.00000 2480.00 -0.00000
2490.00 0.00000 2490.00 0.00000
2500.00 0.00000 2500.00 -0.00000
2510.00 0.00000 2510.00 -0.00000
2520.00 0.00000 2520.00 0.00000
2530.00 0.00000 2530.00 0.00000
2540.00 0.00000 2540.00 0.00000
2550.00 0.00000 2550.00 -0.00000
2560.00 0.00000 2560.00 -0.00000
2570.00 0.00000 2570.00 -0.00000
2580.00 0.00000 2580.00 -0.00000
2590.00 0.00000 2590.00 0.00000
2600.00 0.00000 2600.00 0.00000
2610.00 0.00000 2610.00 -0.00000
2620.00 0.00000 2620.00 0.00000
2630.00 0.00000 2630.00 0.00000
2640.00 0.00000 2640.00 0.00000
2650.00 0.00000 2650.00 0.00000
2660.00 0.00000 2660.00 -0.00000
2670.00 0.00000 2670.00 0.00000
2680.00 0.00000 2680.00 0.00000
2690.00 0.00000 2690.00 -0.00000
2700.00 0.00000 2700.00 0.00000
2710.00 0.00000 2710.00 0.00000
2720.00 0.00000 2720.00 -0.00000
2730.00 0.00000 2730.00 0.00000
2740.00 0.00000 2740.00 0.00000
2750.00 0.00000 2750.00 0.00000
...@@ -82,32 +82,32 @@ ...@@ -82,32 +82,32 @@
2790.00 0.00000 2790.00 0.00000
2800.00 0.00000 2800.00 0.00000
2810.00 0.00000 2810.00 0.00000
2820.00 0.00000 2820.00 -0.00000
2830.00 0.00000 2830.00 0.00000
2840.00 0.00000 2840.00 0.00000
2850.00 0.00000 2850.00 -0.00000
2860.00 0.00000 2860.00 0.00000
2870.00 0.00000 2870.00 -0.00000
2880.00 0.00000 2880.00 -0.00000
2890.00 0.00000 2890.00 0.00000
2900.00 0.00000 2900.00 -0.00000
2910.00 0.00000 2910.00 0.00000
2920.00 0.00000 2920.00 0.00000
2930.00 0.00000 2930.00 0.00000
2940.00 0.00000 2940.00 0.00000
2950.00 0.00000 2950.00 -0.00000
2960.00 0.00000 2960.00 0.00000
2970.00 0.00000 2970.00 0.00000
2980.00 0.00000 2980.00 -0.00000
2990.00 0.00000 2990.00 -0.00000
3000.00 0.00000 3000.00 -0.00000
3010.00 0.00000 3010.00 0.00000
3020.00 0.00000 3020.00 -0.00000
3030.00 0.00000 3030.00 0.00000
3040.00 0.00000 3040.00 -0.00000
3050.00 0.00000 3050.00 0.00000
3060.00 0.00000 3060.00 0.00000
3070.00 0.00000 3070.00 -0.00000
3080.00 0.00000 3080.00 0.00000
3090.00 0.00000 3090.00 0.00000
3100.00 0.00000 3100.00 0.00000
...@@ -115,65 +115,65 @@ ...@@ -115,65 +115,65 @@
3120.00 0.00000 3120.00 0.00000
3130.00 0.00000 3130.00 0.00000
3140.00 0.00000 3140.00 0.00000
3150.00 0.00000 3150.00 -0.00000
3160.00 0.00000 3160.00 -0.00000
3170.00 0.00000 3170.00 0.00000
3180.00 0.00000 3180.00 -0.00000
3190.00 0.00000 3190.00 0.00000
3200.00 0.00000 3200.00 -0.00000
3210.00 0.00000 3210.00 -0.00000
3220.00 0.00000 3220.00 -0.00000
3230.00 0.00000 3230.00 0.00000
3240.00 0.00000 3240.00 0.00000
3250.00 0.00000 3250.00 0.00000
3260.00 0.00000 3260.00 0.00000
3270.00 0.00000 3270.00 0.00000
3280.00 0.00000 3280.00 -0.00000
3290.00 0.00000 3290.00 -0.00000
3300.00 0.00000 3300.00 0.00000
3310.00 0.00000 3310.00 0.00000
3320.00 0.00000 3320.00 0.00000
3330.00 0.00000 3330.00 0.00000
3340.00 0.00000 3340.00 0.00000
3350.00 0.00000 3350.00 -0.00000
3360.00 0.00000 3360.00 -0.00000
3370.00 0.00000 3370.00 0.00000
3380.00 0.00000 3380.00 0.00000
3390.00 0.00000 3390.00 0.00000
3400.00 0.00000 3400.00 -0.00000
3410.00 0.00000 3410.00 -0.00000
3420.00 0.00000 3420.00 -0.00000
3430.00 0.00000 3430.00 -0.00000
3440.00 0.00000 3440.00 -0.00000
3450.00 0.00000 3450.00 -0.00000
3460.00 0.00000 3460.00 0.00000
3470.00 0.00000 3470.00 -0.00000
3480.00 0.00000 3480.00 -0.00000
3490.00 0.00000 3490.00 -0.00000
3500.00 0.00000 3500.00 -0.00000
3510.00 0.00000 3510.00 0.00000
3520.00 0.00000 3520.00 0.00000
3530.00 0.00000 3530.00 0.00000
3540.00 0.00000 3540.00 0.00000
3550.00 0.00000 3550.00 -0.00000
3560.00 0.00000 3560.00 0.00000
3570.00 0.00000 3570.00 0.00000
3580.00 0.00000 3580.00 0.00000
3590.00 0.00000 3590.00 0.00000
3600.00 0.00000 3600.00 0.00000
3610.00 0.00000 3610.00 0.00000
3620.00 0.00000 3620.00 -0.00000
3630.00 0.00000 3630.00 0.00000
3640.00 0.00000 3640.00 -0.00000
3650.00 0.00000 3650.00 0.00000
3660.00 0.00000 3660.00 -0.00000
3670.00 0.00000 3670.00 -0.00000
3680.00 0.00000 3680.00 0.00000
3690.00 0.00000 3690.00 0.00000
3700.00 0.00000 3700.00 0.00000
3710.00 0.00000 3710.00 0.00000
3720.00 0.00000 3720.00 -0.00000
3730.00 0.00000 3730.00 -0.00000
3740.00 0.00000 3740.00 0.00000
3750.00 0.00000 3750.00 0.00000
3760.00 0.00000 3760.00 0.00000
...@@ -182,59 +182,59 @@ ...@@ -182,59 +182,59 @@
3790.00 0.00000 3790.00 0.00000
3800.00 0.00000 3800.00 0.00000
3810.00 0.00000 3810.00 0.00000
3820.00 0.00000 3820.00 -0.00000
3830.00 0.00000 3830.00 -0.00000
3840.00 0.00000 3840.00 0.00000
3850.00 0.00000 3850.00 0.00000
3860.00 0.00000 3860.00 0.00000
3870.00 0.00000 3870.00 0.00000
3880.00 0.00000 3880.00 0.00000
3890.00 0.00000 3890.00 0.00000
3900.00 0.00000 3900.00 -0.00000
3910.00 0.00000 3910.00 0.00000
3920.00 0.00000 3920.00 0.00000
3930.00 0.00000 3930.00 0.00000
3940.00 0.00000 3940.00 0.00000
3950.00 0.00000 3950.00 0.00000
3960.00 0.00000 3960.00 -0.00000
3970.00 0.00000 3970.00 0.00000
3980.00 0.00000 3980.00 -0.00000
3990.00 0.00000 3990.00 -0.00000
4000.00 0.00000 4000.00 -0.00000
4010.00 0.00000 4010.00 -0.00000
4020.00 0.00000 4020.00 -0.00000
4030.00 0.00000 4030.00 0.00000
4040.00 0.00000 4040.00 -0.00000
4050.00 0.00000 4050.00 0.00000
4060.00 0.00000 4060.00 0.00000
4070.00 0.00000 4070.00 -0.00000
4080.00 0.00000 4080.00 0.00000
4090.00 0.00000 4090.00 0.00000
4100.00 0.00000 4100.00 -0.00000
4110.00 0.00000 4110.00 -0.00000
4120.00 0.00000 4120.00 -0.00000
4130.00 0.00000 4130.00 0.00000
4140.00 0.00000 4140.00 0.00000
4150.00 0.00000 4150.00 0.00000
4160.00 0.00000 4160.00 -0.00000
4170.00 0.00000 4170.00 -0.00000
4180.00 0.00000 4180.00 0.00000
4190.00 0.00000 4190.00 -0.00000
4200.00 0.00000 4200.00 0.00000
4210.00 0.00000 4210.00 0.00000
4220.00 0.00000 4220.00 -0.00000
4230.00 0.00000 4230.00 -0.00000
4240.00 0.00000 4240.00 0.00000
4250.00 0.00000 4250.00 0.00000
4260.00 0.00000 4260.00 0.00000
4270.00 0.00000 4270.00 -0.00000
4280.00 0.00000 4280.00 0.00000
4290.00 0.00000 4290.00 -0.00000
4300.00 0.00000 4300.00 -0.00000
4310.00 0.00000 4310.00 -0.00000
4320.00 0.00000 4320.00 0.00000
4330.00 0.00000 4330.00 0.00000
4340.00 0.00000 4340.00 -0.00000
4350.00 0.00000 4350.00 0.00000
4360.00 0.00000 4360.00 0.00000
4370.00 0.00000 4370.00 0.00000
...@@ -243,62 +243,62 @@ ...@@ -243,62 +243,62 @@
4400.00 0.00000 4400.00 0.00000
4410.00 0.00000 4410.00 0.00000
4420.00 0.00000 4420.00 0.00000
4430.00 0.00000 4430.00 -0.00000
4440.00 0.00000 4440.00 -0.00000
4450.00 0.00000 4450.00 0.00000
4460.00 0.00000 4460.00 0.00000
4470.00 0.00000 4470.00 -0.00000
4480.00 0.00000 4480.00 0.00000
4490.00 0.00000 4490.00 0.00000
4500.00 0.00000 4500.00 -0.00000
4510.00 0.00000 4510.00 -0.00000
4520.00 0.00000 4520.00 -0.00000
4530.00 0.00000 4530.00 0.00000
4540.00 0.00000 4540.00 -0.00000
4550.00 0.00000 4550.00 0.00000
4560.00 0.00000 4560.00 0.00000
4570.00 0.00000 4570.00 0.00000
4580.00 0.00000 4580.00 -0.00000
4590.00 0.00000 4590.00 0.00000
4600.00 0.00000 4600.00 0.00000
4610.00 0.00000 4610.00 -0.00000
4620.00 0.00000 4620.00 0.00000
4630.00 0.00000 4630.00 -0.00000
4640.00 0.00000 4640.00 0.00000
4650.00 0.00000 4650.00 0.00000
4660.00 0.00000 4660.00 0.00000
4670.00 0.00000 4670.00 0.00000
4680.00 0.00000 4680.00 0.00000
4690.00 0.00000 4690.00 0.00001
4700.00 0.00000 4700.00 0.00000
4710.00 0.00000 4710.00 0.00000
4720.00 0.00000 4720.00 0.00001
4730.00 0.00000 4730.00 0.00001
4740.00 0.00001 4740.00 0.00001
4750.00 0.00001 4750.00 0.00001
4760.00 0.00001 4760.00 0.00001
4770.00 0.00001 4770.00 0.00001
4780.00 0.00002 4780.00 0.00001
4790.00 0.00003 4790.00 0.00002
4800.00 0.00004 4800.00 0.00003
4810.00 0.00004 4810.00 0.00005
4820.00 0.00005 4820.00 0.00006
4830.00 0.00004 4830.00 0.00005
4840.00 0.00003 4840.00 0.00003
4850.00 0.00002 4850.00 0.00001
4860.00 0.00001 4860.00 0.00000
4870.00 0.00000 4870.00 0.00000
4880.00 0.00000 4880.00 0.00000
4890.00 0.00000 4890.00 -0.00000
4900.00 0.00000 4900.00 0.00000
4910.00 0.00000 4910.00 0.00000
4920.00 0.00000 4920.00 0.00000
4930.00 0.00000 4930.00 -0.00000
4940.00 0.00000 4940.00 -0.00000
4950.00 0.00000 4950.00 0.00000
4960.00 0.00000 4960.00 0.00000
4970.00 0.00000 4970.00 0.00000
4980.00 0.00000 4980.00 -0.00000
4990.00 0.00000 4990.00 0.00000
5000.00 0.00000 5000.00 0.00000
5010.00 0.00000 5010.00 0.00000
...@@ -307,16 +307,16 @@ ...@@ -307,16 +307,16 @@
5040.00 0.00000 5040.00 0.00000
5050.00 0.00000 5050.00 0.00000
5060.00 0.00000 5060.00 0.00000
5070.00 0.00000 5070.00 -0.00000
5080.00 0.00000 5080.00 0.00000
5090.00 0.00000 5090.00 0.00000
5100.00 0.00000 5100.00 -0.00000
5110.00 0.00000 5110.00 0.00000
5120.00 0.00000 5120.00 0.00000
5130.00 0.00000 5130.00 0.00000
5140.00 0.00000 5140.00 -0.00000
5150.00 0.00000 5150.00 0.00000
5160.00 0.00000 5160.00 -0.00000
5170.00 0.00000 5170.00 0.00000
5180.00 0.00000 5180.00 0.00000
5190.00 0.00000 5190.00 0.00000
...@@ -327,22 +327,22 @@ ...@@ -327,22 +327,22 @@
5240.00 0.00000 5240.00 0.00000
5250.00 0.00000 5250.00 0.00000
5260.00 0.00000 5260.00 0.00000
5270.00 0.00000 5270.00 -0.00000
5280.00 0.00000 5280.00 0.00000
5290.00 0.00000 5290.00 -0.00000
5300.00 0.00000 5300.00 -0.00000
5310.00 0.00000 5310.00 0.00000
5320.00 0.00000 5320.00 0.00000
5330.00 0.00000 5330.00 0.00000
5340.00 0.00000 5340.00 -0.00000
5350.00 0.00000 5350.00 0.00000
5360.00 0.00000 5360.00 0.00000
5370.00 0.00000 5370.00 -0.00000
5380.00 0.00000 5380.00 0.00000
5390.00 0.00000 5390.00 -0.00000
5400.00 0.00000 5400.00 0.00000
5410.00 0.00000 5410.00 0.00000
5420.00 0.00000 5420.00 -0.00000
5430.00 0.00000 5430.00 0.00000
5440.00 0.00000 5440.00 0.00000
5450.00 0.00000 5450.00 0.00000
...@@ -352,10 +352,10 @@ ...@@ -352,10 +352,10 @@
5490.00 0.00000 5490.00 0.00000
5500.00 0.00001 5500.00 0.00001
5510.00 0.00001 5510.00 0.00001
5520.00 0.00002 5520.00 0.00001
5530.00 0.00002 5530.00 0.00002
5540.00 0.00002 5540.00 0.00003
5550.00 0.00002 5550.00 0.00003
5560.00 0.00002 5560.00 0.00002
5570.00 0.00001 5570.00 0.00001
5580.00 0.00001 5580.00 0.00001
...@@ -367,7 +367,7 @@ ...@@ -367,7 +367,7 @@
5640.00 0.00000 5640.00 0.00000
5650.00 0.00000 5650.00 0.00000
5660.00 0.00000 5660.00 0.00000
5670.00 0.00000 5670.00 -0.00000
5680.00 0.00000 5680.00 0.00000
5690.00 0.00000 5690.00 0.00000
5700.00 0.00000 5700.00 0.00000
...@@ -379,11 +379,11 @@ ...@@ -379,11 +379,11 @@
5760.00 0.00001 5760.00 0.00001
5770.00 0.00002 5770.00 0.00002
5780.00 0.00002 5780.00 0.00002
5790.00 0.00003 5790.00 0.00002
5800.00 0.00004 5800.00 0.00004
5810.00 0.00004 5810.00 0.00005
5820.00 0.00004 5820.00 0.00005
5830.00 0.00003 5830.00 0.00004
5840.00 0.00002 5840.00 0.00002
5850.00 0.00001 5850.00 0.00001
5860.00 0.00001 5860.00 0.00001
...@@ -392,11 +392,11 @@ ...@@ -392,11 +392,11 @@
5890.00 0.00000 5890.00 0.00000
5900.00 0.00000 5900.00 0.00000
5910.00 0.00000 5910.00 0.00000
5920.00 0.00000 5920.00 -0.00000
5930.00 0.00000 5930.00 -0.00000
5940.00 0.00000 5940.00 0.00000
5950.00 0.00000 5950.00 -0.00000
5960.00 0.00000 5960.00 -0.00000
5970.00 0.00000 5970.00 0.00000
5980.00 0.00000 5980.00 0.00000
5990.00 0.00000 5990.00 0.00000
...@@ -406,498 +406,498 @@ ...@@ -406,498 +406,498 @@
6030.00 0.00000 6030.00 0.00000
6040.00 0.00000 6040.00 0.00000
6050.00 0.00000 6050.00 0.00000
6060.00 0.00000 6060.00 -0.00000
6070.00 0.00000 6070.00 0.00000
6080.00 0.00000 6080.00 0.00000
6090.00 0.00000 6090.00 -0.00001
6100.00 0.00000 6100.00 0.00000
6110.00 0.00000 6110.00 0.00000
6120.00 0.00000 6120.00 0.00000
6130.00 0.00000 6130.00 0.00000
6140.00 0.00000 6140.00 -0.00000
6150.00 0.00000 6150.00 -0.00000
6160.00 0.00000 6160.00 -0.00000
6170.00 0.00000 6170.00 0.00000
6180.00 0.00000 6180.00 0.00000
6190.00 0.00000 6190.00 0.00000
6200.00 0.00000 6200.00 0.00000
6210.00 0.00000 6210.00 0.00000
6220.00 0.00000 6220.00 0.00000
6230.00 0.00000 6230.00 -0.00000
6240.00 0.00000 6240.00 0.00000
6250.00 0.00000 6250.00 0.00000
6260.00 0.00000 6260.00 0.00000
6270.00 0.00000 6270.00 0.00001
6280.00 0.00000 6280.00 0.00000
6290.00 0.00000 6290.00 0.00000
6300.00 0.00000 6300.00 -0.00000
6310.00 0.00000 6310.00 0.00000
6320.00 0.00000 6320.00 0.00000
6330.00 0.00000 6330.00 0.00000
6340.00 0.00000 6340.00 0.00000
6350.00 0.00000 6350.00 -0.00000
6360.00 0.00000 6360.00 0.00000
6370.00 0.00000 6370.00 0.00000
6380.00 0.00000 6380.00 0.00000
6390.00 0.00000 6390.00 0.00000
6400.00 0.00000 6400.00 0.00000
6410.00 0.00000 6410.00 -0.00000
6420.00 0.00000 6420.00 0.00000
6430.00 0.00000 6430.00 0.00000
6440.00 0.00000 6440.00 -0.00000
6450.00 0.00000 6450.00 -0.00000
6460.00 0.00000 6460.00 0.00001
6470.00 0.00000 6470.00 0.00000
6480.00 0.00000 6480.00 0.00000
6490.00 0.00000 6490.00 0.00001
6500.00 0.00000 6500.00 0.00000
6510.00 0.00000 6510.00 0.00000
6520.00 0.00000 6520.00 0.00000
6530.00 0.00000 6530.00 0.00000
6540.00 0.00000 6540.00 0.00000
6550.00 0.00000 6550.00 -0.00000
6560.00 0.00000 6560.00 -0.00000
6570.00 0.00000 6570.00 -0.00000
6580.00 0.00000 6580.00 -0.00000
6590.00 0.00000 6590.00 0.00000
6600.00 0.00000 6600.00 0.00001
6610.00 0.00000 6610.00 0.00000
6620.00 0.00000 6620.00 -0.00000
6630.00 0.00000 6630.00 -0.00000
6640.00 0.00000 6640.00 0.00000
6650.00 0.00000 6650.00 0.00000
6660.00 0.00000 6660.00 -0.00000
6670.00 0.00000 6670.00 -0.00001
6680.00 0.00000 6680.00 -0.00000
6690.00 0.00000 6690.00 0.00000
6700.00 0.00000 6700.00 0.00000
6710.00 0.00000 6710.00 -0.00000
6720.00 0.00000 6720.00 -0.00000
6730.00 0.00000 6730.00 0.00001
6740.00 0.00000 6740.00 -0.00000
6750.00 0.00000 6750.00 -0.00000
6760.00 0.00000 6760.00 -0.00000
6770.00 0.00000 6770.00 -0.00000
6780.00 0.00000 6780.00 -0.00000
6790.00 0.00000 6790.00 -0.00000
6800.00 0.00000 6800.00 0.00000
6810.00 0.00000 6810.00 0.00000
6820.00 0.00000 6820.00 0.00001
6830.00 0.00000 6830.00 0.00000
6840.00 0.00000 6840.00 -0.00001
6850.00 0.00000 6850.00 -0.00001
6860.00 0.00000 6860.00 -0.00001
6870.00 0.00000 6870.00 0.00001
6880.00 0.00000 6880.00 0.00000
6890.00 0.00000 6890.00 0.00001
6900.00 0.00000 6900.00 0.00000
6910.00 0.00000 6910.00 -0.00000
6920.00 0.00000 6920.00 0.00000
6930.00 0.00000 6930.00 0.00001
6940.00 0.00000 6940.00 -0.00000
6950.00 0.00000 6950.00 0.00000
6960.00 0.00000 6960.00 0.00000
6970.00 0.00000 6970.00 0.00000
6980.00 0.00000 6980.00 -0.00000
6990.00 0.00000 6990.00 0.00000
7000.00 0.00000 7000.00 0.00001
7010.00 0.00000 7010.00 -0.00001
7020.00 0.00000 7020.00 0.00000
7030.00 0.00000 7030.00 0.00000
7040.00 0.00000 7040.00 0.00000
7050.00 0.00000 7050.00 0.00000
7060.00 0.00000 7060.00 -0.00001
7070.00 0.00000 7070.00 0.00000
7080.00 0.00000 7080.00 0.00000
7090.00 0.00000 7090.00 0.00000
7100.00 0.00000 7100.00 0.00001
7110.00 0.00000 7110.00 0.00000
7120.00 0.00000 7120.00 0.00001
7130.00 0.00000 7130.00 -0.00001
7140.00 0.00000 7140.00 0.00000
7150.00 0.00000 7150.00 -0.00000
7160.00 0.00000 7160.00 -0.00000
7170.00 0.00000 7170.00 0.00000
7180.00 0.00000 7180.00 0.00000
7190.00 0.00000 7190.00 -0.00000
7200.00 0.00000 7200.00 0.00000
7210.00 0.00000 7210.00 -0.00000
7220.00 0.00000 7220.00 0.00000
7230.00 0.00000 7230.00 0.00000
7240.00 0.00000 7240.00 0.00000
7250.00 0.00000 7250.00 0.00000
7260.00 0.00000 7260.00 -0.00000
7270.00 0.00000 7270.00 0.00000
7280.00 0.00000 7280.00 -0.00001
7290.00 0.00000 7290.00 -0.00000
7300.00 0.00000 7300.00 -0.00000
7310.00 0.00000 7310.00 0.00000
7320.00 0.00000 7320.00 -0.00000
7330.00 0.00000 7330.00 0.00000
7340.00 0.00000 7340.00 0.00001
7350.00 0.00000 7350.00 -0.00000
7360.00 0.00000 7360.00 0.00000
7370.00 0.00000 7370.00 0.00001
7380.00 0.00000 7380.00 0.00000
7390.00 0.00000 7390.00 0.00000
7400.00 0.00000 7400.00 0.00001
7410.00 0.00000 7410.00 0.00000
7420.00 0.00000 7420.00 -0.00001
7430.00 0.00000 7430.00 0.00000
7440.00 0.00000 7440.00 -0.00000
7450.00 0.00000 7450.00 0.00000
7460.00 0.00000 7460.00 -0.00000
7470.00 0.00000 7470.00 0.00000
7480.00 0.00000 7480.00 -0.00001
7490.00 0.00000 7490.00 -0.00000
7500.00 0.00000 7500.00 -0.00000
7510.00 0.00000 7510.00 0.00000
7520.00 0.00000 7520.00 0.00001
7530.00 0.00000 7530.00 0.00000
7540.00 0.00000 7540.00 0.00000
7550.00 0.00000 7550.00 -0.00000
7560.00 0.00000 7560.00 0.00000
7570.00 0.00000 7570.00 0.00000
7580.00 0.00000 7580.00 0.00000
7590.00 0.00000 7590.00 0.00000
7600.00 0.00000 7600.00 -0.00000
7610.00 0.00000 7610.00 -0.00000
7620.00 0.00000 7620.00 -0.00001
7630.00 0.00000 7630.00 -0.00000
7640.00 0.00000 7640.00 0.00000
7650.00 0.00000 7650.00 0.00001
7660.00 0.00000 7660.00 0.00001
7670.00 0.00000 7670.00 0.00000
7680.00 0.00000 7680.00 0.00000
7690.00 0.00000 7690.00 0.00001
7700.00 0.00000 7700.00 0.00001
7710.00 0.00000 7710.00 -0.00000
7720.00 0.00000 7720.00 0.00000
7730.00 0.00000 7730.00 0.00000
7740.00 0.00000 7740.00 -0.00001
7750.00 0.00000 7750.00 -0.00000
7760.00 0.00000 7760.00 0.00000
7770.00 0.00000 7770.00 -0.00000
7780.00 0.00000 7780.00 0.00000
7790.00 0.00000 7790.00 0.00000
7800.00 0.00000 7800.00 -0.00000
7810.00 0.00000 7810.00 0.00000
7820.00 0.00000 7820.00 -0.00000
7830.00 0.00000 7830.00 0.00000
7840.00 0.00000 7840.00 -0.00000
7850.00 0.00000 7850.00 -0.00000
7860.00 0.00000 7860.00 0.00000
7870.00 0.00000 7870.00 -0.00000
7880.00 0.00000 7880.00 0.00000
7890.00 0.00000 7890.00 0.00001
7900.00 0.00000 7900.00 0.00001
7910.00 0.00000 7910.00 0.00001
7920.00 0.00000 7920.00 0.00001
7930.00 0.00000 7930.00 -0.00000
7940.00 0.00000 7940.00 -0.00001
7950.00 0.00000 7950.00 -0.00000
7960.00 0.00000 7960.00 0.00000
7970.00 0.00000 7970.00 0.00000
7980.00 0.00000 7980.00 0.00000
7990.00 0.00000 7990.00 -0.00001
8000.00 0.00002 8000.00 0.00000
8010.00 0.00003 8010.00 0.00000
8020.00 0.00003 8020.00 0.00000
8030.00 0.00003 8030.00 0.00000
8040.00 0.00003 8040.00 0.00000
8050.00 0.00004 8050.00 0.00000
8060.00 0.00004 8060.00 -0.00001
8070.00 0.00005 8070.00 -0.00000
8080.00 0.00007 8080.00 0.00000
8090.00 0.00008 8090.00 0.00000
8100.00 0.00009 8100.00 -0.00000
8110.00 0.00013 8110.00 0.00001
8120.00 0.00018 8120.00 0.00001
8130.00 0.00026 8130.00 0.00000
8140.00 0.00040 8140.00 0.00001
8150.00 0.00065 8150.00 0.00001
8160.00 0.00112 8160.00 0.00002
8170.00 0.00185 8170.00 0.00002
8180.00 0.00305 8180.00 0.00002
8190.00 0.00475 8190.00 0.00003
8200.00 0.00704 8200.00 0.00004
8210.00 0.00994 8210.00 0.00006
8220.00 0.01366 8220.00 0.00008
8230.00 0.01820 8230.00 0.00011
8240.00 0.02345 8240.00 0.00017
8250.00 0.03058 8250.00 0.00025
8260.00 0.03900 8260.00 0.00039
8270.00 0.04796 8270.00 0.00061
8280.00 0.05876 8280.00 0.00099
8290.00 0.07147 8290.00 0.00166
8300.00 0.08580 8300.00 0.00285
8310.00 0.10118 8310.00 0.00503
8320.00 0.11803 8320.00 0.00919
8330.00 0.13528 8330.00 0.01725
8340.00 0.15451 8340.00 0.03236
8350.00 0.17500 8350.00 0.05797
8360.00 0.19415 8360.00 0.09510
8370.00 0.21555 8370.00 0.13780
8380.00 0.23737 8380.00 0.17753
8390.00 0.26134 8390.00 0.21094
8400.00 0.28959 8400.00 0.24084
8410.00 0.31549 8410.00 0.27260
8420.00 0.34437 8420.00 0.31195
8430.00 0.37460 8430.00 0.36404
8440.00 0.40913 8440.00 0.42561
8450.00 0.43985 8450.00 0.48784
8460.00 0.46810 8460.00 0.54363
8470.00 0.50016 8470.00 0.59114
8480.00 0.52985 8480.00 0.61992
8490.00 0.53965 8490.00 0.61842
8500.00 0.54721 8500.00 0.60423
8510.00 0.55913 8510.00 0.59266
8520.00 0.56785 8520.00 0.57987
8530.00 0.57017 8530.00 0.56712
8540.00 0.57030 8540.00 0.55830
8550.00 0.56308 8550.00 0.55096
8560.00 0.56262 8560.00 0.54763
8570.00 0.55976 8570.00 0.54913
8580.00 0.56087 8580.00 0.55235
8590.00 0.56322 8590.00 0.55664
8600.00 0.56420 8600.00 0.56125
8610.00 0.57465 8610.00 0.56833
8620.00 0.58293 8620.00 0.57436
8630.00 0.58455 8630.00 0.57902
8640.00 0.58646 8640.00 0.58299
8650.00 0.58652 8650.00 0.58319
8660.00 0.59005 8660.00 0.58268
8670.00 0.59086 8670.00 0.58363
8680.00 0.59135 8680.00 0.58401
8690.00 0.59191 8690.00 0.58222
8700.00 0.59066 8700.00 0.57987
8710.00 0.58680 8710.00 0.57492
8720.00 0.58734 8720.00 0.56955
8730.00 0.58443 8730.00 0.57340
8740.00 0.58584 8740.00 0.57682
8750.00 0.58551 8750.00 0.57333
8760.00 0.58631 8760.00 0.56984
8770.00 0.57497 8770.00 0.56178
8780.00 0.56742 8780.00 0.55380
8790.00 0.56521 8790.00 0.54976
8800.00 0.56529 8800.00 0.54593
8810.00 0.56261 8810.00 0.54343
8820.00 0.55838 8820.00 0.54117
8830.00 0.55504 8830.00 0.53873
8840.00 0.55008 8840.00 0.53652
8850.00 0.54926 8850.00 0.53661
8860.00 0.55300 8860.00 0.53671
8870.00 0.55054 8870.00 0.53875
8880.00 0.54841 8880.00 0.54060
8890.00 0.54389 8890.00 0.53635
8900.00 0.54021 8900.00 0.53179
8910.00 0.53897 8910.00 0.52536
8920.00 0.53684 8920.00 0.51858
8930.00 0.53275 8930.00 0.51559
8940.00 0.52614 8940.00 0.51230
8950.00 0.52261 8950.00 0.50724
8960.00 0.51701 8960.00 0.50217
8970.00 0.51777 8970.00 0.50011
8980.00 0.51666 8980.00 0.49817
8990.00 0.50958 8990.00 0.49510
9000.00 0.50227 9000.00 0.49228
9010.00 0.49876 9010.00 0.48818
9020.00 0.49809 9020.00 0.48458
9030.00 0.49215 9030.00 0.47889
9040.00 0.48671 9040.00 0.47357
9050.00 0.48609 9050.00 0.47188
9060.00 0.48684 9060.00 0.47040
9070.00 0.48709 9070.00 0.46778
9080.00 0.48235 9080.00 0.46524
9090.00 0.47727 9090.00 0.46254
9100.00 0.47371 9100.00 0.45971
9110.00 0.47099 9110.00 0.45903
9120.00 0.46685 9120.00 0.45812
9130.00 0.46190 9130.00 0.45533
9140.00 0.45953 9140.00 0.45213
9150.00 0.45711 9150.00 0.44653
9160.00 0.45402 9160.00 0.44066
9170.00 0.44954 9170.00 0.43580
9180.00 0.44596 9180.00 0.43076
9190.00 0.43748 9190.00 0.42502
9200.00 0.43258 9200.00 0.41925
9210.00 0.42686 9210.00 0.41491
9220.00 0.42501 9220.00 0.41062
9230.00 0.41694 9230.00 0.40644
9240.00 0.41017 9240.00 0.40239
9250.00 0.40690 9250.00 0.39850
9260.00 0.40273 9260.00 0.39481
9270.00 0.40115 9270.00 0.38929
9280.00 0.39850 9280.00 0.38395
9290.00 0.39300 9290.00 0.37996
9300.00 0.38771 9300.00 0.37613
9310.00 0.38511 9310.00 0.37305
9320.00 0.38115 9320.00 0.37002
9330.00 0.37657 9330.00 0.36793
9340.00 0.37304 9340.00 0.36574
9350.00 0.37035 9350.00 0.36308
9360.00 0.36799 9360.00 0.36032
9370.00 0.36361 9370.00 0.35671
9380.00 0.36175 9380.00 0.35300
9390.00 0.35653 9390.00 0.34747
9400.00 0.35207 9400.00 0.34185
9410.00 0.34870 9410.00 0.33795
9420.00 0.34540 9420.00 0.33396
9430.00 0.34000 9430.00 0.33056
9440.00 0.33454 9440.00 0.32701
9450.00 0.33118 9450.00 0.32285
9460.00 0.32608 9460.00 0.31869
9470.00 0.32235 9470.00 0.31446
9480.00 0.31854 9480.00 0.31021
9490.00 0.31280 9490.00 0.30560
9500.00 0.30897 9500.00 0.30103
9510.00 0.30432 9510.00 0.29661
9520.00 0.30050 9520.00 0.29221
9530.00 0.29516 9530.00 0.28771
9540.00 0.29060 9540.00 0.28323
9550.00 0.28636 9550.00 0.28001
9560.00 0.28360 9560.00 0.27682
9570.00 0.28103 9570.00 0.27341
9580.00 0.27826 9580.00 0.27004
9590.00 0.27258 9590.00 0.26531
9600.00 0.26635 9600.00 0.26066
9610.00 0.26313 9610.00 0.25719
9620.00 0.26024 9620.00 0.25364
9630.00 0.25426 9630.00 0.24921
9640.00 0.25093 9640.00 0.24473
9650.00 0.24715 9650.00 0.24153
9660.00 0.24534 9660.00 0.23823
9670.00 0.24135 9670.00 0.23501
9680.00 0.23866 9680.00 0.23172
9690.00 0.23333 9690.00 0.22735
9700.00 0.22699 9700.00 0.22295
9710.00 0.22368 9710.00 0.21906
9720.00 0.21986 9720.00 0.21517
9730.00 0.21567 9730.00 0.21174
9740.00 0.21298 9740.00 0.20825
9750.00 0.20891 9750.00 0.20478
9760.00 0.20503 9760.00 0.20127
9770.00 0.20208 9770.00 0.19745
9780.00 0.19933 9780.00 0.19364
9790.00 0.19468 9790.00 0.18975
9800.00 0.19016 9800.00 0.18593
9810.00 0.18628 9810.00 0.18298
9820.00 0.18377 9820.00 0.18005
9830.00 0.18008 9830.00 0.17683
9840.00 0.17676 9840.00 0.17366
9850.00 0.17416 9850.00 0.17060
9860.00 0.17185 9860.00 0.16757
9870.00 0.16854 9870.00 0.16472
9880.00 0.16681 9880.00 0.16188
9890.00 0.16231 9890.00 0.15847
9900.00 0.15922 9900.00 0.15509
9910.00 0.15595 9910.00 0.15213
9920.00 0.15261 9920.00 0.14916
9930.00 0.14979 9930.00 0.14617
9940.00 0.14714 9940.00 0.14316
9950.00 0.14405 9950.00 0.14033
9960.00 0.14113 9960.00 0.13746
9970.00 0.13766 9970.00 0.13395
9980.00 0.13428 9980.00 0.13044
9990.00 0.13036 9990.00 0.12698
10000.00 0.12687 10000.00 0.12351
10010.00 0.12353 10010.00 0.12062
10020.00 0.12086 10020.00 0.11773
10030.00 0.11805 10030.00 0.11491
10040.00 0.11487 10040.00 0.11207
10050.00 0.11219 10050.00 0.10941
10060.00 0.10946 10060.00 0.10675
10070.00 0.10670 10070.00 0.10373
10080.00 0.10390 10080.00 0.10071
10090.00 0.10063 10090.00 0.09776
10100.00 0.09769 10100.00 0.09482
10110.00 0.09469 10110.00 0.09198
10120.00 0.09182 10120.00 0.08915
10130.00 0.08876 10130.00 0.08647
10140.00 0.08596 10140.00 0.08379
10150.00 0.08345 10150.00 0.08102
10160.00 0.08038 10160.00 0.07823
10170.00 0.07757 10170.00 0.07544
10180.00 0.07454 10180.00 0.07264
10190.00 0.07143 10190.00 0.06974
10200.00 0.06847 10200.00 0.06683
10210.00 0.06625 10210.00 0.06487
10220.00 0.06415 10220.00 0.06289
10230.00 0.06172 10230.00 0.06064
10240.00 0.05948 10240.00 0.05839
10250.00 0.05752 10250.00 0.05628
10260.00 0.05559 10260.00 0.05417
10270.00 0.05342 10270.00 0.05202
10280.00 0.05111 10280.00 0.04987
10290.00 0.04861 10290.00 0.04760
10300.00 0.04624 10300.00 0.04533
10310.00 0.04473 10310.00 0.04385
10320.00 0.04323 10320.00 0.04236
10330.00 0.04159 10330.00 0.04082
10340.00 0.03990 10340.00 0.03929
10350.00 0.03836 10350.00 0.03776
10360.00 0.03685 10360.00 0.03624
10370.00 0.03495 10370.00 0.03462
10380.00 0.03347 10380.00 0.03301
10390.00 0.03179 10390.00 0.03146
10400.00 0.03022 10400.00 0.02992
10410.00 0.02922 10410.00 0.02882
10420.00 0.02809 10420.00 0.02773
10430.00 0.02687 10430.00 0.02657
10440.00 0.02562 10440.00 0.02542
10450.00 0.02458 10450.00 0.02429
10460.00 0.02340 10460.00 0.02316
10470.00 0.02243 10470.00 0.02207
10480.00 0.02127 10480.00 0.02096
10490.00 0.01998 10490.00 0.01975
10500.00 0.01877 10500.00 0.01855
10510.00 0.01843 10510.00 0.01783
10520.00 0.01806 10520.00 0.01712
10530.00 0.01774 10530.00 0.01643
10540.00 0.01732 10540.00 0.01574
10550.00 0.01701 10550.00 0.01507
10560.00 0.01671 10560.00 0.01441
10570.00 0.01628 10570.00 0.01377
10580.00 0.01597 10580.00 0.01313
10590.00 0.01558 10590.00 0.01251
10600.00 0.01522 10600.00 0.01190
10610.00 0.01479 10610.00 0.01131
10620.00 0.01442 10620.00 0.01072
10630.00 0.01400 10630.00 0.01015
10640.00 0.01363 10640.00 0.00959
10650.00 0.01319 10650.00 0.00904
10660.00 0.01273 10660.00 0.00849
10670.00 0.01234 10670.00 0.00796
10680.00 0.01193 10680.00 0.00743
10690.00 0.01143 10690.00 0.00691
10700.00 0.01087 10700.00 0.00640
10710.00 0.01034 10710.00 0.00589
10720.00 0.00980 10720.00 0.00539
10730.00 0.00922 10730.00 0.00489
10740.00 0.00860 10740.00 0.00441
10750.00 0.00802 10750.00 0.00394
10760.00 0.00742 10760.00 0.00349
10770.00 0.00671 10770.00 0.00305
10780.00 0.00610 10780.00 0.00264
10790.00 0.00546 10790.00 0.00226
10800.00 0.00478 10800.00 0.00191
10810.00 0.00421 10810.00 0.00159
10820.00 0.00366 10820.00 0.00131
10830.00 0.00314 10830.00 0.00107
10840.00 0.00267 10840.00 0.00086
10850.00 0.00226 10850.00 0.00068
10860.00 0.00189 10860.00 0.00053
10870.00 0.00157 10870.00 0.00041
10880.00 0.00130 10880.00 0.00031
10890.00 0.00106 10890.00 0.00023
10900.00 0.00085 10900.00 0.00017
10910.00 0.00068 10910.00 0.00012
10920.00 0.00054 10920.00 0.00009
10930.00 0.00042 10930.00 0.00006
10940.00 0.00032 10940.00 0.00004
10950.00 0.00024 10950.00 0.00002
10960.00 0.00017 10960.00 0.00001
10970.00 0.00011 10970.00 0.00001
10980.00 0.00007 10980.00 0.00000
10990.00 0.00003 10990.00 0.00000
11000.00 0.00000 11000.00 0.00000
...@@ -56,6 +56,8 @@ class CatalogBase(metaclass=ABCMeta): ...@@ -56,6 +56,8 @@ class CatalogBase(metaclass=ABCMeta):
"teff":0., "teff":0.,
"logg":0., "logg":0.,
"feh":0., "feh":0.,
"DM":0.,
"stellarMass":1.,
# C6 galaxies parameters # C6 galaxies parameters
"e1":0., "e1":0.,
"e2":0., "e2":0.,
......
import galsim
import os, sys
import numpy as np
import time
import math
import astropy.constants as cons
from astropy.io import fits
from scipy.interpolate import griddata
from astropy.table import Table
from ObservationSim.MockObject.SpecDisperser import SpecDisperser
from scipy import interpolate
import gc
from ObservationSim.MockObject.MockObject import MockObject
# from ObservationSim.Straylight import calculateSkyMap_split_g
try:
import importlib.resources as pkg_resources
except ImportError:
# Try backported to PY<37 'importlib_resources'
import importlib_resources as pkg_resources
# flatDir = '/Volumes/EAGET/LED_FLAT/'
LED_name = ['LED1', 'LED2', 'LED3', 'LED4', 'LED5', 'LED6', 'LED7', 'LED8', 'LED9', 'LED10', 'LED11', 'LED12', 'LED13',
'LED14']
cwaves_name = {'LED1': '275', 'LED2': '310', 'LED3': '430', 'LED4': '505', 'LED5': '545', 'LED6': '590', 'LED7': '670',
'LED8': '760', 'LED9': '940', 'LED10': '940', 'LED11': '1050', 'LED12': '1050',
'LED13': '340', 'LED14': '365'}
cwaves = {'LED1': 2750, 'LED2': 3100, 'LED3': 4300, 'LED4': 5050, 'LED5': 5250, 'LED6': 5900, 'LED7': 6700,
'LED8': 7600, 'LED9': 8800, 'LED10': 9400, 'LED11': 10500, 'LED12': 15500, 'LED13': 3400, 'LED14': 3650}
cwaves_fwhm = {'LED1': 110, 'LED2': 120, 'LED3': 200, 'LED4': 300, 'LED5': 300, 'LED6': 130, 'LED7': 210,
'LED8': 260, 'LED9': 400, 'LED10': 370, 'LED11': 500, 'LED12': 1400, 'LED13': 90, 'LED14': 100}
# LED_QE = {'LED1': 0.3, 'LED2': 0.4, 'LED13': 0.5, 'LED14': 0.5, 'LED10': 0.4}
# e-/ms
# fluxLED = {'LED1': 0.16478729, 'LED2': 0.084220931, 'LED3': 2.263360617, 'LED4': 2.190623489, 'LED5': 0.703504768,
# 'LED6': 0.446117963, 'LED7': 0.647122098, 'LED8': 0.922313442,
# 'LED9': 0.987278143, 'LED10': 2.043989167, 'LED11': 0.612571429, 'LED12': 1.228915663, 'LED13': 0.17029384,
# 'LED14': 0.27842925}
# e-/ms
fluxLED = {'LED1': 15, 'LED2': 15, 'LED3': 12.5, 'LED4': 9, 'LED5': 9,
'LED6': 9, 'LED7': 9, 'LED8': 9, 'LED9': 9, 'LED10': 12.5, 'LED11': 15, 'LED12':15, 'LED13': 12.5,
'LED14': 12.5}
# fluxLEDL = {'LED1': 10, 'LED2': 10, 'LED3': 10, 'LED4': 10, 'LED5': 10,
# 'LED6': 10, 'LED7': 10, 'LED8': 10, 'LED9': 10, 'LED10': 10, 'LED11': 10, 'LED12':10, 'LED13': 10,
# 'LED14': 10}
mirro_eff = {'GU':0.61, 'GV':0.8, 'GI':0.8}
# mirro_eff = {'GU':1, 'GV':1, 'GI':1}
class FlatLED(object):
def __init__(self, chip,filt, flatDir = None, logger=None):
# self.led_type_list = led_type_list
self.filt = filt
self.chip = chip
self.logger = logger
if flatDir is not None:
self.flatDir = flatDir
else:
try:
with pkg_resources.files('ObservationSim.MockObject.data.led').joinpath("") as ledDir:
self.flatDir = ledDir.as_posix()
except AttributeError:
with pkg_resources.path('ObservationSim.MockObject.data.led', "") as ledDir:
self.flatDir = ledDir.as_posix()
###
### return LED flat, e/s
###
def getLEDImage(self, led_type='LED1'):
# cwave = cwaves[led_type]
flat = fits.open(os.path.join(self.flatDir, 'model_' + cwaves_name[led_type] + 'nm.fits'))
xlen = flat[0].header['NAXIS1']
ylen = 601
x = np.linspace(0, self.chip.npix_x * 6, xlen)
y = np.linspace(0, self.chip.npix_y * 5, ylen)
xx, yy = np.meshgrid(x, y)
a1 = flat[0].data[0:ylen, 0:xlen]
# z = np.sin((xx+yy+xx**2+yy**2))
# fInterp = interp2d(xx, yy, z, kind='linear')
X_ = np.hstack((xx.flatten()[:, None], yy.flatten()[:, None]))
Z_ = a1.flatten()
n_x = np.arange(0, self.chip.npix_x * 6, 1)
n_y = np.arange(0, self.chip.npix_y * 5, 1)
M, N = np.meshgrid(n_x, n_y)
i = self.chip.rowID - 1
j = self.chip.colID - 1
U = griddata(X_, Z_, (
M[self.chip.npix_y * i:self.chip.npix_y * (i + 1), self.chip.npix_x * j:self.chip.npix_x * (j + 1)],
N[self.chip.npix_y * i:self.chip.npix_y * (i + 1), self.chip.npix_x * j:self.chip.npix_x * (j + 1)]),
method='linear')
U = U/np.mean(U)
flatImage = U*fluxLED[led_type]*1000
gc.collect()
return flatImage
###
### return LED flat, e/s
###
def getLEDImage1(self, led_type='LED1'):
# cwave = cwaves[led_type]
flat = fits.open(os.path.join(self.flatDir, 'model_' + cwaves_name[led_type] + 'nm.fits'))
xlen = flat[0].header['NAXIS1']
ylen = 601
i = self.chip.rowID - 1
j = self.chip.colID - 1
x = np.linspace(0, self.chip.npix_x, int(xlen/6.))
y = np.linspace(0, self.chip.npix_y, int(ylen/5.))
xx, yy = np.meshgrid(x, y)
a1 = flat[0].data[int(ylen*i/5.):int(ylen*i/5.)+int(ylen/5.), int(xlen*j/6.):int(xlen*j/6.)+int(xlen/6.)]
# z = np.sin((xx+yy+xx**2+yy**2))
# fInterp = interp2d(xx, yy, z, kind='linear')
X_ = np.hstack((xx.flatten()[:, None], yy.flatten()[:, None]))
Z_ = a1.flatten()
n_x = np.arange(0, self.chip.npix_x , 1)
n_y = np.arange(0, self.chip.npix_y, 1)
M, N = np.meshgrid(n_x, n_y)
U = griddata(X_, Z_, (
M[0:self.chip.npix_y, 0:self.chip.npix_x],
N[0:self.chip.npix_y, 0:self.chip.npix_x ]),
method='linear')
U = U/np.mean(U)
flatImage = U*fluxLED[led_type]*1000
gc.collect()
return flatImage
def drawObj_LEDFlat_img(self, led_type_list=['LED1'], exp_t_list=[0.1]):
if len(led_type_list) > len(exp_t_list):
return np.ones([self.chip.npix_y,self.chip.npix_x])
ledFlat = np.zeros([self.chip.npix_y,self.chip.npix_x])
ledStat = '00000000000000'
ledTimes = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
nledStat = '2'
for i in np.arange(len(led_type_list)):
led_type = led_type_list[i]
exp_t = exp_t_list[i]
# unitFlatImg = self.getLEDImage(led_type=led_type)
unitFlatImg = self.getLEDImage1(led_type=led_type)
# print("---------------TEST mem:",np.mean(unitFlatImg))
led_wave = cwaves[led_type]
led_fwhm = cwaves_fwhm[led_type]
led_spec = self.gaussian1d_profile_led(led_wave, led_fwhm)
speci = interpolate.interp1d(led_spec['WAVELENGTH'], led_spec['FLUX'])
w_list = np.arange(self.filt.blue_limit, self.filt.red_limit, 0.5) #A
f_spec = speci(w_list)
ccd_bp = self.chip._getChipEffCurve(self.chip.filter_type)
ccd_eff = ccd_bp.__call__(w_list / 10.)
filt_bp = self.filt.filter_bandpass
fil_eff = filt_bp.__call__(w_list / 10.)
t_spec = np.trapz(f_spec*ccd_eff*fil_eff, w_list)
# print(i, np.mean(unitFlatImg), t_spec, exp_t)
unitFlatImg = unitFlatImg * t_spec
# print("DEBUG1:---------------",np.mean(unitFlatImg))
ledFlat = ledFlat+unitFlatImg*exp_t
ledStat = ledStat[0:int(led_type[3:])-1]+nledStat+ledStat[int(led_type[3:]):]
ledTimes[int(led_type[3:])-1] = exp_t * 1000
gc.collect()
return ledFlat, ledStat, ledTimes
def drawObj_LEDFlat_slitless(self, led_type_list=['LED1'], exp_t_list=[0.1]):
if len(led_type_list) != len(exp_t_list):
return np.ones([self.chip.npix_y,self.chip.npix_x])
ledFlat = np.zeros([self.chip.npix_y,self.chip.npix_x])
ledStat = '00000000000000'
ledTimes = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
nledStat = '2'
for i in np.arange(len(led_type_list)):
led_type = led_type_list[i]
exp_t = exp_t_list[i]
# unitFlatImg = self.getLEDImage(led_type=led_type)
unitFlatImg = self.getLEDImage1(led_type=led_type)
# print("---------------TEST mem:",np.mean(unitFlatImg))
ledFlat_ = unitFlatImg*exp_t
ledFlat_ = ledFlat_ / mirro_eff[self.filt.filter_type]
ledFlat_.astype(np.float32)
led_wave = cwaves[led_type]
led_fwhm = cwaves_fwhm[led_type]
led_spec = self.gaussian1d_profile_led(led_wave, led_fwhm)
# print("DEBUG1:---------------",np.mean(ledFlat_))
ledspec_map = self.calculateLEDSpec(
skyMap=ledFlat_,
blueLimit=self.filt.blue_limit,
redLimit=self.filt.red_limit,
conf=self.chip.sls_conf,
pixelSize=self.chip.pix_scale,
isAlongY=0,
flat_cube=self.chip.flat_cube, led_spec=led_spec)
ledFlat = ledFlat + ledspec_map
ledStat = ledStat[0:int(led_type[3:])-1]+nledStat+ledStat[int(led_type[3:]):]
ledTimes[int(led_type[3:])-1] = exp_t * 1000
return ledFlat, ledStat, ledTimes
def drawObj_LEDFlat(self, led_type_list=['LED1'], exp_t_list=[0.1]):
if self.chip.survey_type == "photometric":
return self.drawObj_LEDFlat_img(led_type_list=led_type_list, exp_t_list=exp_t_list)
elif self.chip.survey_type == "spectroscopic":
return self.drawObj_LEDFlat_slitless(led_type_list=led_type_list, exp_t_list=exp_t_list)
def gaussian1d_profile_led(self, xc=5050, fwhm=300):
sigma = fwhm/2.355
x_radii = int(5*sigma + 1)
xlist = np.arange(xc-x_radii, xc+x_radii, 0.5)
xlist_ = np.zeros(len(xlist) + 2)
xlist_[1:-1] = xlist
xlist_[0] = 2000
xlist_[-1] = 18000
ids1 = xlist>xc-fwhm
ids2 = xlist[ids1]<xc+fwhm
data = np.exp((-(xlist-xc)*(xlist-xc))/(2*sigma*sigma))/(np.sqrt(2*math.pi)*sigma)
scale = 1/np.trapz(data[ids1][ids2], xlist[ids1][ids2])
data_ = np.zeros(len(xlist) + 2)
data_[1:-1] = data*scale
# print("DEBUG:-------------------------------",np.sum(data_), scale)
return Table(np.array([xlist_.astype(np.float32), data_.astype(np.float32)]).T, names=('WAVELENGTH', 'FLUX'))
def calculateLEDSpec(self, skyMap=None, blueLimit=4200, redLimit=6500,
conf=[''], pixelSize=0.074, isAlongY=0,
split_pos=3685, flat_cube=None, led_spec=None):
conf1 = conf[0]
conf2 = conf[0]
if np.size(conf) == 2:
conf2 = conf[1]
skyImg = galsim.Image(skyMap, xmin=0, ymin=0)
tbstart = blueLimit
tbend = redLimit
fimg = np.zeros_like(skyMap)
fImg = galsim.Image(fimg)
spec = led_spec
if isAlongY == 0:
directParm = 0
if isAlongY == 1:
directParm = 1
if split_pos >= skyImg.array.shape[directParm]:
skyImg1 = galsim.Image(skyImg.array)
origin1 = [0, 0]
# sdp = specDisperser.specDisperser(orig_img=skyImg1, xcenter=skyImg1.center.x, ycenter=skyImg1.center.y,
# full_img=fimg, tar_spec=spec, band_start=tbstart, band_end=tbend,
# origin=origin1,
# conf=conf1)
# sdp.compute_spec_orders()
y_len = skyMap.shape[0]
x_len = skyMap.shape[1]
delt_x = 100
delt_y = 100
sub_y_start_arr = np.arange(0, y_len, delt_y)
sub_y_end_arr = sub_y_start_arr + delt_y
sub_y_end_arr[-1] = min(sub_y_end_arr[-1], y_len)
sub_x_start_arr = np.arange(0, x_len, delt_x)
sub_x_end_arr = sub_x_start_arr + delt_x
sub_x_end_arr[-1] = min(sub_x_end_arr[-1], x_len)
for i, k1 in enumerate(sub_y_start_arr):
sub_y_s = k1
sub_y_e = sub_y_end_arr[i]
sub_y_center = (sub_y_s + sub_y_e) / 2.
for j, k2 in enumerate(sub_x_start_arr):
sub_x_s = k2
sub_x_e = sub_x_end_arr[j]
skyImg_sub = galsim.Image(skyImg.array[sub_y_s:sub_y_e, sub_x_s:sub_x_e])
origin_sub = [sub_y_s, sub_x_s]
sub_x_center = (sub_x_s + sub_x_e) / 2.
sdp = SpecDisperser(orig_img=skyImg_sub, xcenter=sub_x_center, ycenter=sub_y_center,
origin=origin_sub,
tar_spec=spec,
band_start=tbstart, band_end=tbend,
conf=conf2,
flat_cube=flat_cube)
spec_orders = sdp.compute_spec_orders()
for k, v in spec_orders.items():
img_s = v[0]
origin_order_x = v[1]
origin_order_y = v[2]
ssImg = galsim.ImageF(img_s)
ssImg.setOrigin(origin_order_x, origin_order_y)
bounds = ssImg.bounds & fImg.bounds
if bounds.area() == 0:
continue
fImg[bounds] = fImg[bounds] + ssImg[bounds]
else:
# sdp.compute_spec_orders()
y_len = skyMap.shape[0]
x_len = skyMap.shape[1]
delt_x = 500
delt_y = y_len
sub_y_start_arr = np.arange(0, y_len, delt_y)
sub_y_end_arr = sub_y_start_arr + delt_y
sub_y_end_arr[-1] = min(sub_y_end_arr[-1], y_len)
delt_x = split_pos - 0
sub_x_start_arr = np.arange(0, split_pos, delt_x)
sub_x_end_arr = sub_x_start_arr + delt_x
sub_x_end_arr[-1] = min(sub_x_end_arr[-1], split_pos)
for i, k1 in enumerate(sub_y_start_arr):
sub_y_s = k1
sub_y_e = sub_y_end_arr[i]
sub_y_center = (sub_y_s + sub_y_e) / 2.
for j, k2 in enumerate(sub_x_start_arr):
sub_x_s = k2
sub_x_e = sub_x_end_arr[j]
# print(i,j,sub_y_s, sub_y_e,sub_x_s,sub_x_e)
T1 = time.time()
skyImg_sub = galsim.Image(skyImg.array[sub_y_s:sub_y_e, sub_x_s:sub_x_e])
origin_sub = [sub_y_s, sub_x_s]
sub_x_center = (sub_x_s + sub_x_e) / 2.
sdp = SpecDisperser(orig_img=skyImg_sub, xcenter=sub_x_center, ycenter=sub_y_center,
origin=origin_sub,
tar_spec=spec,
band_start=tbstart, band_end=tbend,
conf=conf1,
flat_cube=flat_cube)
spec_orders = sdp.compute_spec_orders()
for k, v in spec_orders.items():
img_s = v[0]
origin_order_x = v[1]
origin_order_y = v[2]
ssImg = galsim.ImageF(img_s)
ssImg.setOrigin(origin_order_x, origin_order_y)
bounds = ssImg.bounds & fImg.bounds
if bounds.area() == 0:
continue
fImg[bounds] = fImg[bounds] + ssImg[bounds]
T2 = time.time()
print('time: %s ms' % ((T2 - T1) * 1000))
delt_x = x_len - split_pos
sub_x_start_arr = np.arange(split_pos, x_len, delt_x)
sub_x_end_arr = sub_x_start_arr + delt_x
sub_x_end_arr[-1] = min(sub_x_end_arr[-1], x_len)
for i, k1 in enumerate(sub_y_start_arr):
sub_y_s = k1
sub_y_e = sub_y_end_arr[i]
sub_y_center = (sub_y_s + sub_y_e) / 2.
for j, k2 in enumerate(sub_x_start_arr):
sub_x_s = k2
sub_x_e = sub_x_end_arr[j]
# print(i,j,sub_y_s, sub_y_e,sub_x_s,sub_x_e)
T1 = time.time()
skyImg_sub = galsim.Image(skyImg.array[sub_y_s:sub_y_e, sub_x_s:sub_x_e])
origin_sub = [sub_y_s, sub_x_s]
sub_x_center = (sub_x_s + sub_x_e) / 2.
sdp = SpecDisperser(orig_img=skyImg_sub, xcenter=sub_x_center, ycenter=sub_y_center,
origin=origin_sub,
tar_spec=spec,
band_start=tbstart, band_end=tbend,
conf=conf2,
flat_cube=flat_cube)
spec_orders = sdp.compute_spec_orders()
for k, v in spec_orders.items():
img_s = v[0]
origin_order_x = v[1]
origin_order_y = v[2]
ssImg = galsim.ImageF(img_s)
ssImg.setOrigin(origin_order_x, origin_order_y)
bounds = ssImg.bounds & fImg.bounds
if bounds.area() == 0:
continue
fImg[bounds] = fImg[bounds] + ssImg[bounds]
T2 = time.time()
print('time: %s ms' % ((T2 - T1) * 1000))
if isAlongY == 1:
fimg, tmx, tmy = rotate90(array_orig=fImg.array, xc=0, yc=0, isClockwise=0)
else:
fimg = fImg.array
# fimg = fimg * pixelSize * pixelSize
return fimg
import numpy as np import numpy as np
import galsim import galsim
import os, sys
import astropy.constants as cons
from astropy.table import Table from astropy.table import Table
from scipy import interpolate
from ObservationSim.MockObject._util import eObs, integrate_sed_bandpass, getNormFactorForSpecWithABMAG, getObservedSED, getABMAG,convolveGaussXorders from ObservationSim.MockObject._util import eObs, integrate_sed_bandpass, getNormFactorForSpecWithABMAG
from ObservationSim.MockObject.SpecDisperser import SpecDisperser from ObservationSim.MockObject.SpecDisperser import SpecDisperser
from ObservationSim.MockObject.MockObject import MockObject from ObservationSim.MockObject.MockObject import MockObject
...@@ -14,18 +11,6 @@ from ObservationSim.MockObject.MockObject import MockObject ...@@ -14,18 +11,6 @@ from ObservationSim.MockObject.MockObject import MockObject
class Galaxy(MockObject): class Galaxy(MockObject):
def __init__(self, param, logger=None): def __init__(self, param, logger=None):
super().__init__(param, logger=logger) super().__init__(param, logger=logger)
# self.thetaR = self.param["theta"]
# self.bfrac = self.param["bfrac"]
# self.hlr_disk = self.param["hlr_disk"]
# self.hlr_bulge = self.param["hlr_bulge"]
# Extract ellipticity components
# self.e_disk = galsim.Shear(g=self.param["ell_disk"], beta=self.thetaR*galsim.degrees)
# self.e_bulge = galsim.Shear(g=self.param["ell_bulge"], beta=self.thetaR*galsim.degrees)
# self.e_total = galsim.Shear(g=self.param["ell_tot"], beta=self.thetaR*galsim.degrees)
# self.e1_disk, self.e2_disk = self.e_disk.g1, self.e_disk.g2
# self.e1_bulge, self.e2_bulge = self.e_bulge.g1, self.e_bulge.g2
# self.e1_total, self.e2_total = self.e_total.g1, self.e_total.g2
if not hasattr(self, "disk_sersic_idx"): if not hasattr(self, "disk_sersic_idx"):
self.disk_sersic_idx = 1. self.disk_sersic_idx = 1.
...@@ -76,7 +61,12 @@ class Galaxy(MockObject): ...@@ -76,7 +61,12 @@ class Galaxy(MockObject):
bulge_shape = galsim.Shear(g1=self.e1_bulge, g2=self.e2_bulge) bulge_shape = galsim.Shear(g1=self.e1_bulge, g2=self.e2_bulge)
bulge = bulge.shear(bulge_shape) bulge = bulge.shear(bulge_shape)
gal = self.bfrac * bulge + (1.0 - self.bfrac) * disk if self.bfrac == 0:
gal = disk
elif self.bfrac == 1:
gal = bulge
else:
gal = self.bfrac * bulge + (1.0 - self.bfrac) * disk
gal = gal.withFlux(nphotons) gal = gal.withFlux(nphotons)
if fd_shear is not None: if fd_shear is not None:
g1 += fd_shear.g1 g1 += fd_shear.g1
...@@ -101,10 +91,6 @@ class Galaxy(MockObject): ...@@ -101,10 +91,6 @@ class Galaxy(MockObject):
if self.logger: if self.logger:
self.logger.error(e) self.logger.error(e)
return 2, None return 2, None
nphotons_sum = 0
photons_list = []
xmax, ymax = 0, 0
# # [C6 TEST] # # [C6 TEST]
# print('hlr_disk = %.4f, hlr_bulge = %.4f'%(self.hlr_disk, self.hlr_bulge)) # print('hlr_disk = %.4f, hlr_bulge = %.4f'%(self.hlr_disk, self.hlr_bulge))
...@@ -114,7 +100,7 @@ class Galaxy(MockObject): ...@@ -114,7 +100,7 @@ class Galaxy(MockObject):
if self.hlr_disk > 3.0 or self.hlr_bulge > 3.0: # Very big galaxy if self.hlr_disk > 3.0 or self.hlr_bulge > 3.0: # Very big galaxy
big_galaxy = True big_galaxy = True
# (TEST) Galsim Parameters # Set Galsim Parameters
if self.getMagFilter(filt) <= 15 and (not big_galaxy): if self.getMagFilter(filt) <= 15 and (not big_galaxy):
folding_threshold = 5.e-4 folding_threshold = 5.e-4
else: else:
...@@ -122,7 +108,7 @@ class Galaxy(MockObject): ...@@ -122,7 +108,7 @@ class Galaxy(MockObject):
gsp = galsim.GSParams(folding_threshold=folding_threshold) gsp = galsim.GSParams(folding_threshold=folding_threshold)
self.real_pos = self.getRealPos(chip.img, global_x=self.posImg.x, global_y=self.posImg.y, self.real_pos = self.getRealPos(chip.img, global_x=self.posImg.x, global_y=self.posImg.y,
img_real_wcs=self.real_wcs) img_real_wcs=self.chip_wcs)
x, y = self.real_pos.x + 0.5, self.real_pos.y + 0.5 x, y = self.real_pos.x + 0.5, self.real_pos.y + 0.5
x_nominal = int(np.floor(x + 0.5)) x_nominal = int(np.floor(x + 0.5))
...@@ -130,9 +116,11 @@ class Galaxy(MockObject): ...@@ -130,9 +116,11 @@ class Galaxy(MockObject):
dx = x - x_nominal dx = x - x_nominal
dy = y - y_nominal dy = y - y_nominal
offset = galsim.PositionD(dx, dy) offset = galsim.PositionD(dx, dy)
# Get real local wcs of object (deal with chip rotation w.r.t its center)
chip_wcs_local = self.chip_wcs.local(self.real_pos)
is_updated = 0
real_wcs_local = self.real_wcs.local(self.real_pos) # Model the galaxy as disk + bulge
disk = galsim.Sersic(n=self.disk_sersic_idx, half_light_radius=self.hlr_disk, flux=1.0, gsparams=gsp) disk = galsim.Sersic(n=self.disk_sersic_idx, half_light_radius=self.hlr_disk, flux=1.0, gsparams=gsp)
disk_shape = galsim.Shear(g1=self.e1_disk, g2=self.e2_disk) disk_shape = galsim.Shear(g1=self.e1_disk, g2=self.e2_disk)
disk = disk.shear(disk_shape) disk = disk.shear(disk_shape)
...@@ -140,38 +128,42 @@ class Galaxy(MockObject): ...@@ -140,38 +128,42 @@ class Galaxy(MockObject):
bulge_shape = galsim.Shear(g1=self.e1_bulge, g2=self.e2_bulge) bulge_shape = galsim.Shear(g1=self.e1_bulge, g2=self.e2_bulge)
bulge = bulge.shear(bulge_shape) bulge = bulge.shear(bulge_shape)
# Get shear and deal with shear induced by field distortion
if fd_shear: if fd_shear:
g1 += fd_shear.g1 g1 += fd_shear.g1
g2 += fd_shear.g2 g2 += fd_shear.g2
gal_shear = galsim.Shear(g1=g1, g2=g2) gal_shear = galsim.Shear(g1=g1, g2=g2)
# Loop over all sub-bandpasses
for i in range(len(bandpass_list)): for i in range(len(bandpass_list)):
bandpass = bandpass_list[i] bandpass = bandpass_list[i]
try: try:
sub = integrate_sed_bandpass(sed=self.sed, bandpass=bandpass) sub = integrate_sed_bandpass(sed=self.sed, bandpass=bandpass)
except Exception as e: except Exception as e:
print(e) print(e)
if self.logger: if self.logger:
self.logger.error(e) self.logger.error(e)
# return False
continue continue
ratio = sub/full ratio = sub/full
if not (ratio == -1 or (ratio != ratio)): if not (ratio == -1 or (ratio != ratio)):
nphotons = ratio * nphotons_tot nphotons = ratio * nphotons_tot
else: else:
continue continue
nphotons_sum += nphotons
# nphotons_sum += nphotons
# # [C6 TEST] # # [C6 TEST]
# print("nphotons_sub-band_%d = %.2f"%(i, nphotons)) # print("nphotons_sub-band_%d = %.2f"%(i, nphotons))
# Get PSF model
psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass, folding_threshold=folding_threshold) psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass, folding_threshold=folding_threshold)
gal_temp = self.bfrac * bulge + (1.0 - self.bfrac) * disk if self.bfrac == 0:
gal_temp = disk
elif self.bfrac == 1:
gal_temp = bulge
else:
gal_temp = self.bfrac * bulge + (1.0 - self.bfrac) * disk
gal_temp = gal_temp.shear(gal_shear) gal_temp = gal_temp.shear(gal_shear)
gal_temp = gal_temp.withFlux(nphotons) gal_temp = gal_temp.withFlux(nphotons)
if not big_galaxy: # Not apply PSF for very big galaxy if not big_galaxy: # Not apply PSF for very big galaxy
gal_temp = galsim.Convolve(psf, gal_temp) gal_temp = galsim.Convolve(psf, gal_temp)
...@@ -186,47 +178,21 @@ class Galaxy(MockObject): ...@@ -186,47 +178,21 @@ class Galaxy(MockObject):
# kfrac = np.random.random()*(1.0 - self.bfrac) # kfrac = np.random.random()*(1.0 - self.bfrac)
# gal = self.bfrac * bulge + (1.0 - self.bfrac - kfrac) * disk + kfrac * knots # gal = self.bfrac * bulge + (1.0 - self.bfrac - kfrac) * disk + kfrac * knots
# # [C6 TEST] # stamp = gal.drawImage(wcs=chip_wcs_local, method='phot', offset=offset, save_photons=True)
# print('xmax = %d, ymax = %d '%(xmax, ymax)) stamp = gal.drawImage(wcs=chip_wcs_local, offset=offset)
# # Output memory usage if np.sum(np.isnan(stamp.array)) > 0:
# snapshot = tracemalloc.take_snapshot() # ERROR happens
# top_stats = snapshot.statistics('lineno') return 2, pos_shear
# for stat in top_stats[:10]:
# print(stat)
stamp = gal.drawImage(wcs=real_wcs_local, method='phot', offset=offset, save_photons=True)
photons = stamp.photons
photons.x += x_nominal
photons.y += y_nominal
photons_list.append(photons)
stamp.wcs = real_wcs_local
stamp.setCenter(x_nominal, y_nominal) stamp.setCenter(x_nominal, y_nominal)
bounds = stamp.bounds & galsim.BoundsI(0, chip.npix_x - 1, 0, chip.npix_y - 1) bounds = stamp.bounds & galsim.BoundsI(0, chip.npix_x - 1, 0, chip.npix_y - 1)
if bounds.area() > 0: if bounds.area() > 0:
chip.img.setOrigin(0, 0) chip.img.setOrigin(0, 0)
stamp[bounds] = chip.img[bounds] chip.img[bounds] += stamp[bounds]
is_updated = 1
if not big_galaxy:
for i in range(len(photons_list)):
if i == 0:
chip.sensor.accumulate(photons_list[i], stamp)
else:
chip.sensor.accumulate(photons_list[i], stamp, resume=True)
else:
sensor = galsim.Sensor()
for i in range(len(photons_list)):
if i == 0:
sensor.accumulate(photons_list[i], stamp)
else:
sensor.accumulate(photons_list[i], stamp, resume=True)
del sensor
chip.img[bounds] = stamp[bounds]
chip.img.setOrigin(chip.bound.xmin, chip.bound.ymin) chip.img.setOrigin(chip.bound.xmin, chip.bound.ymin)
else: del stamp
if is_updated == 0:
# Return code 0: object photons missed this detector # Return code 0: object photons missed this detector
print("obj %s missed"%(self.id)) print("obj %s missed"%(self.id))
if self.logger: if self.logger:
...@@ -235,8 +201,6 @@ class Galaxy(MockObject): ...@@ -235,8 +201,6 @@ class Galaxy(MockObject):
# # [C6 TEST] # # [C6 TEST]
# print("nphotons_sum = ", nphotons_sum) # print("nphotons_sum = ", nphotons_sum)
del photons_list
del stamp
return 1, pos_shear return 1, pos_shear
def drawObj_slitless(self, tel, pos_img, psf_model, bandpass_list, filt, chip, nphotons_tot=None, g1=0, g2=0, def drawObj_slitless(self, tel, pos_img, psf_model, bandpass_list, filt, chip, nphotons_tot=None, g1=0, g2=0,
...@@ -255,7 +219,7 @@ class Galaxy(MockObject): ...@@ -255,7 +219,7 @@ class Galaxy(MockObject):
names=('WAVELENGTH', 'FLUX')) names=('WAVELENGTH', 'FLUX'))
self.real_pos = self.getRealPos(chip.img, global_x=self.posImg.x, global_y=self.posImg.y, self.real_pos = self.getRealPos(chip.img, global_x=self.posImg.x, global_y=self.posImg.y,
img_real_wcs=self.real_wcs) img_real_wcs=self.chip_wcs)
x, y = self.real_pos.x + 0.5, self.real_pos.y + 0.5 x, y = self.real_pos.x + 0.5, self.real_pos.y + 0.5
x_nominal = int(np.floor(x + 0.5)) x_nominal = int(np.floor(x + 0.5))
...@@ -264,7 +228,7 @@ class Galaxy(MockObject): ...@@ -264,7 +228,7 @@ class Galaxy(MockObject):
dy = y - y_nominal dy = y - y_nominal
offset = galsim.PositionD(dx, dy) offset = galsim.PositionD(dx, dy)
real_wcs_local = self.real_wcs.local(self.real_pos) chip_wcs_local = self.chip_wcs.local(self.real_pos)
big_galaxy = False big_galaxy = False
...@@ -282,18 +246,40 @@ class Galaxy(MockObject): ...@@ -282,18 +246,40 @@ class Galaxy(MockObject):
xOrderSigPlus = {'A':1.3909419820029296,'B':1.4760376591236062,'C':4.035447379743442,'D':5.5684364343742825,'E':16.260021029735388} xOrderSigPlus = {'A':1.3909419820029296,'B':1.4760376591236062,'C':4.035447379743442,'D':5.5684364343742825,'E':16.260021029735388}
grating_split_pos_chip = 0 + grating_split_pos grating_split_pos_chip = 0 + grating_split_pos
branges = np.zeros([len(bandpass_list), 2])
# print(hasattr(psf_model, 'bandranges'))
if hasattr(psf_model, 'bandranges'):
if psf_model.bandranges is None:
return 2, None
if len(psf_model.bandranges) != len(bandpass_list):
return 2, None
branges = psf_model.bandranges
else:
for i in range(len(bandpass_list)):
branges[i, 0] = bandpass_list[i].blue_limit * 10
branges[i, 1] = bandpass_list[i].red_limit * 10
for i in range(len(bandpass_list)): for i in range(len(bandpass_list)):
bandpass = bandpass_list[i] # bandpass = bandpass_list[i]
brange = branges[i]
psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass, folding_threshold=folding_threshold) # psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass, folding_threshold=folding_threshold)
disk = galsim.Sersic(n=self.disk_sersic_idx, half_light_radius=self.hlr_disk, flux=1.0, gsparams=gsp) disk = galsim.Sersic(n=self.disk_sersic_idx, half_light_radius=self.hlr_disk, flux=1.0, gsparams=gsp)
disk_shape = galsim.Shear(g1=self.e1_disk, g2=self.e2_disk) disk_shape = galsim.Shear(g1=self.e1_disk, g2=self.e2_disk)
disk = disk.shear(disk_shape) disk = disk.shear(disk_shape)
bulge = galsim.Sersic(n=self.bulge_sersic_idx, half_light_radius=self.hlr_bulge, flux=1.0, gsparams=gsp) bulge = galsim.Sersic(n=self.bulge_sersic_idx, half_light_radius=self.hlr_bulge, flux=1.0, gsparams=gsp)
bulge_shape = galsim.Shear(g1=self.e1_bulge, g2=self.e2_bulge) bulge_shape = galsim.Shear(g1=self.e1_bulge, g2=self.e2_bulge)
bulge = bulge.shear(bulge_shape) bulge = bulge.shear(bulge_shape)
gal = self.bfrac * bulge + (1.0 - self.bfrac) * disk if self.bfrac == 0:
gal = disk
elif self.bfrac == 1:
gal = bulge
else:
gal = self.bfrac * bulge + (1.0 - self.bfrac) * disk
# (TEST) Random knots # (TEST) Random knots
# knots = galsim.RandomKnots(npoints=100, profile=disk) # knots = galsim.RandomKnots(npoints=100, profile=disk)
...@@ -306,14 +292,14 @@ class Galaxy(MockObject): ...@@ -306,14 +292,14 @@ class Galaxy(MockObject):
g2 += fd_shear.g2 g2 += fd_shear.g2
gal_shear = galsim.Shear(g1=g1, g2=g2) gal_shear = galsim.Shear(g1=g1, g2=g2)
gal = gal.shear(gal_shear) gal = gal.shear(gal_shear)
gal = galsim.Convolve(psf, gal) # gal = galsim.Convolve(psf, gal)
if not big_galaxy: # Not apply PSF for very big galaxy # if not big_galaxy: # Not apply PSF for very big galaxy
gal = galsim.Convolve(psf, gal) # gal = galsim.Convolve(psf, gal)
# if fd_shear is not None: # # if fd_shear is not None:
# gal = gal.shear(fd_shear) # # gal = gal.shear(fd_shear)
starImg = gal.drawImage(wcs=real_wcs_local, offset=offset) starImg = gal.drawImage(wcs=chip_wcs_local, offset=offset,method = 'real_space')
origin_star = [y_nominal - (starImg.center.y - starImg.ymin), origin_star = [y_nominal - (starImg.center.y - starImg.ymin),
x_nominal - (starImg.center.x - starImg.xmin)] x_nominal - (starImg.center.x - starImg.xmin)]
...@@ -335,12 +321,16 @@ class Galaxy(MockObject): ...@@ -335,12 +321,16 @@ class Galaxy(MockObject):
sdp_p1 = SpecDisperser(orig_img=star_p1, xcenter=xcenter_p1, sdp_p1 = SpecDisperser(orig_img=star_p1, xcenter=xcenter_p1,
ycenter=ycenter_p1, origin=origin_p1, ycenter=ycenter_p1, origin=origin_p1,
tar_spec=normalSED, tar_spec=normalSED,
band_start=bandpass.blue_limit * 10, band_end=bandpass.red_limit * 10, band_start=brange[0], band_end=brange[1],
conf=chip.sls_conf[0], conf=chip.sls_conf[0],
isAlongY=0, isAlongY=0,
flat_cube=flat_cube) flat_cube=flat_cube)
self.addSLStoChipImage(sdp=sdp_p1, chip=chip, xOrderSigPlus = xOrderSigPlus, local_wcs=real_wcs_local) # self.addSLStoChipImage(sdp=sdp_p1, chip=chip, xOrderSigPlus = xOrderSigPlus, local_wcs=chip_wcs_local)
pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp_p1, chip=chip, pos_img_local=[xcenter_p1, ycenter_p1],
psf_model=psf_model, bandNo=i + 1,
grating_split_pos=grating_split_pos,
local_wcs=chip_wcs_local, pos_img = pos_img)
subImg_p2 = starImg.array[:, subSlitPos+1:starImg.array.shape[1]] subImg_p2 = starImg.array[:, subSlitPos+1:starImg.array.shape[1]]
star_p2 = galsim.Image(subImg_p2) star_p2 = galsim.Image(subImg_p2)
...@@ -352,12 +342,16 @@ class Galaxy(MockObject): ...@@ -352,12 +342,16 @@ class Galaxy(MockObject):
sdp_p2 = SpecDisperser(orig_img=star_p2, xcenter=xcenter_p2, sdp_p2 = SpecDisperser(orig_img=star_p2, xcenter=xcenter_p2,
ycenter=ycenter_p2, origin=origin_p2, ycenter=ycenter_p2, origin=origin_p2,
tar_spec=normalSED, tar_spec=normalSED,
band_start=bandpass.blue_limit * 10, band_end=bandpass.red_limit * 10, band_start=brange[0], band_end=brange[1],
conf=chip.sls_conf[1], conf=chip.sls_conf[1],
isAlongY=0, isAlongY=0,
flat_cube=flat_cube) flat_cube=flat_cube)
self.addSLStoChipImage(sdp=sdp_p2, chip=chip, xOrderSigPlus = xOrderSigPlus, local_wcs=real_wcs_local) # self.addSLStoChipImage(sdp=sdp_p2, chip=chip, xOrderSigPlus = xOrderSigPlus, local_wcs=chip_wcs_local)
pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp_p2, chip=chip, pos_img_local=[xcenter_p2, ycenter_p2],
psf_model=psf_model, bandNo=i + 1,
grating_split_pos=grating_split_pos,
local_wcs=chip_wcs_local, pos_img = pos_img)
del sdp_p1 del sdp_p1
del sdp_p2 del sdp_p2
...@@ -365,25 +359,33 @@ class Galaxy(MockObject): ...@@ -365,25 +359,33 @@ class Galaxy(MockObject):
sdp = SpecDisperser(orig_img=starImg, xcenter=x_nominal - 0, sdp = SpecDisperser(orig_img=starImg, xcenter=x_nominal - 0,
ycenter=y_nominal - 0, origin=origin_star, ycenter=y_nominal - 0, origin=origin_star,
tar_spec=normalSED, tar_spec=normalSED,
band_start=bandpass.blue_limit * 10, band_end=bandpass.red_limit * 10, band_start=brange[0], band_end=brange[1],
conf=chip.sls_conf[1], conf=chip.sls_conf[1],
isAlongY=0, isAlongY=0,
flat_cube=flat_cube) flat_cube=flat_cube)
self.addSLStoChipImage(sdp=sdp, chip=chip, xOrderSigPlus = xOrderSigPlus, local_wcs=real_wcs_local) # self.addSLStoChipImage(sdp=sdp, chip=chip, xOrderSigPlus = xOrderSigPlus, local_wcs=chip_wcs_local)
pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp, chip=chip, pos_img_local=[x_nominal, y_nominal],
psf_model=psf_model, bandNo=i + 1,
grating_split_pos=grating_split_pos,
local_wcs=chip_wcs_local, pos_img = pos_img)
del sdp del sdp
elif grating_split_pos_chip>=gal_end[1]: elif grating_split_pos_chip>=gal_end[1]:
sdp = SpecDisperser(orig_img=starImg, xcenter=x_nominal - 0, sdp = SpecDisperser(orig_img=starImg, xcenter=x_nominal - 0,
ycenter=y_nominal - 0, origin=origin_star, ycenter=y_nominal - 0, origin=origin_star,
tar_spec=normalSED, tar_spec=normalSED,
band_start=bandpass.blue_limit * 10, band_end=bandpass.red_limit * 10, band_start=brange[0], band_end=brange[1],
conf=chip.sls_conf[0], conf=chip.sls_conf[0],
isAlongY=0, isAlongY=0,
flat_cube=flat_cube) flat_cube=flat_cube)
self.addSLStoChipImage(sdp=sdp, chip=chip, xOrderSigPlus = xOrderSigPlus, local_wcs=real_wcs_local) # self.addSLStoChipImage(sdp=sdp, chip=chip, xOrderSigPlus = xOrderSigPlus, local_wcs=chip_wcs_local)
pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp, chip=chip, pos_img_local=[x_nominal, y_nominal],
psf_model=psf_model, bandNo=i + 1,
grating_split_pos=grating_split_pos,
local_wcs=chip_wcs_local, pos_img = pos_img)
del sdp del sdp
# print(self.y_nominal, starImg.center.y, starImg.ymin) # print(self.y_nominal, starImg.center.y, starImg.ymin)
del psf # del psf
return 1, pos_shear return 1, pos_shear
def getGSObj(self, psf, g1=0, g2=0, flux=None, filt=None, tel=None, exptime=150.): def getGSObj(self, psf, g1=0, g2=0, flux=None, filt=None, tel=None, exptime=150.):
...@@ -404,46 +406,6 @@ class Galaxy(MockObject): ...@@ -404,46 +406,6 @@ class Galaxy(MockObject):
final = galsim.Convolve(psf, gal) final = galsim.Convolve(psf, gal)
return final return final
def drawObject(self, img, final, noise_level=0.0, flux=None, filt=None, tel=None, exptime=150.):
""" Override the method in parent class
Need to constrain the size of image stamp for extended objects
"""
isUpdated = True
if flux == None:
flux = self.getElectronFluxFilt(filt, tel, exptime)
stamp = final.drawImage(wcs=self.localWCS, offset=self.offset)
stamp_arr = stamp.array
mask = (stamp_arr >= 0.001*noise_level) # why 0.001?
err = int(np.sqrt(mask.sum()))
if np.mod(err, 2) == 1:
err += 1
# if err == 1:
if err == 0:
subSize = 16 # why 16?
else:
subSize = max([err, 16])
fluxRatio = flux / stamp_arr[mask].sum()
final = final.withScaledFlux(fluxRatio)
imgSub = galsim.ImageF(subSize, subSize)
# Draw with FFT
# stamp = final.drawImage(image=imgSub, wcs=self.localWCS, offset=self.offset)
# Draw with Photon Shoot
stamp = final.drawImage(image=imgSub, wcs=self.localWCS, method='phot', offset=self.offset)
stamp.setCenter(self.x_nominal, self.y_nominal)
if np.sum(np.isnan(stamp.array)) >= 1:
stamp.setZero()
bounds = stamp.bounds & img.bounds
if bounds.area() == 0:
isUpdated = False
else:
img[bounds] += stamp[bounds]
return img, stamp, isUpdated
def getObservedEll(self, g1=0, g2=0): def getObservedEll(self, g1=0, g2=0):
e1_obs, e2_obs, e_obs, theta = eObs(self.e1_total, self.e2_total, g1, g2) e1_obs, e2_obs, e_obs, theta = eObs(self.e1_total, self.e2_total, g1, g2)
return self.e1_total, self.e2_total, g1, g2, e1_obs, e2_obs return self.e1_total, self.e2_total, g1, g2, e1_obs, e2_obs
import os
import galsim import galsim
import numpy as np import numpy as np
import astropy.constants as cons import astropy.constants as cons
from astropy import wcs from astropy import wcs
from astropy.table import Table from astropy.table import Table
import astropy.io.fits as fitsio
from ObservationSim.MockObject._util import magToFlux, VC_A, convolveGaussXorders from ObservationSim.MockObject._util import magToFlux, VC_A, convolveGaussXorders, convolveImg
from ObservationSim.MockObject._util import integrate_sed_bandpass, getNormFactorForSpecWithABMAG, getObservedSED, \ from ObservationSim.MockObject._util import integrate_sed_bandpass, getNormFactorForSpecWithABMAG, getObservedSED, \
getABMAG getABMAG
from ObservationSim.MockObject.SpecDisperser import SpecDisperser from ObservationSim.MockObject.SpecDisperser import SpecDisperser
...@@ -13,7 +15,6 @@ from ObservationSim.MockObject.SpecDisperser import SpecDisperser ...@@ -13,7 +15,6 @@ from ObservationSim.MockObject.SpecDisperser import SpecDisperser
class MockObject(object): class MockObject(object):
def __init__(self, param, logger=None): def __init__(self, param, logger=None):
self.param = param self.param = param
for key in self.param: for key in self.param:
setattr(self, key, self.param[key]) setattr(self, key, self.param[key])
...@@ -27,14 +28,15 @@ class MockObject(object): ...@@ -27,14 +28,15 @@ class MockObject(object):
elif self.param["star"] == 3: elif self.param["star"] == 3:
self.type = "stamp" self.type = "stamp"
###mock_stamp_END ###mock_stamp_END
###for calibration
elif self.param["star"] == 4:
self.type = "calib"
###END
self.sed = None self.sed = None
self.fd_shear = None
# Place holder for outputs # Place holder for outputs
self.additional_output_str = "" self.additional_output_str = ""
self.fd_shear = None
self.logger = logger self.logger = logger
def getMagFilter(self, filt): def getMagFilter(self, filt):
...@@ -65,6 +67,7 @@ class MockObject(object): ...@@ -65,6 +67,7 @@ class MockObject(object):
def getPosImg_Offset_WCS(self, img, fdmodel=None, chip=None, verbose=True, chip_wcs=None, img_header=None): def getPosImg_Offset_WCS(self, img, fdmodel=None, chip=None, verbose=True, chip_wcs=None, img_header=None):
self.posImg = img.wcs.toImage(self.getPosWorld()) self.posImg = img.wcs.toImage(self.getPosWorld())
self.localWCS = img.wcs.local(self.posImg) self.localWCS = img.wcs.local(self.posImg)
# Apply field distortion model
if (fdmodel is not None) and (chip is not None): if (fdmodel is not None) and (chip is not None):
if verbose: if verbose:
print("\n") print("\n")
...@@ -74,6 +77,7 @@ class MockObject(object): ...@@ -74,6 +77,7 @@ class MockObject(object):
if verbose: if verbose:
print("After field distortion:\n") print("After field distortion:\n")
print("x = %.2f, y = %.2f\n" % (self.posImg.x, self.posImg.y), flush=True) print("x = %.2f, y = %.2f\n" % (self.posImg.x, self.posImg.y), flush=True)
x, y = self.posImg.x + 0.5, self.posImg.y + 0.5 x, y = self.posImg.x + 0.5, self.posImg.y + 0.5
self.x_nominal = int(np.floor(x + 0.5)) self.x_nominal = int(np.floor(x + 0.5))
self.y_nominal = int(np.floor(y + 0.5)) self.y_nominal = int(np.floor(y + 0.5))
...@@ -81,50 +85,22 @@ class MockObject(object): ...@@ -81,50 +85,22 @@ class MockObject(object):
dy = y - self.y_nominal dy = y - self.y_nominal
self.offset = galsim.PositionD(dx, dy) self.offset = galsim.PositionD(dx, dy)
# Deal with chip rotation
if chip_wcs is not None: if chip_wcs is not None:
self.real_wcs = chip_wcs self.chip_wcs = chip_wcs
elif img_header is not None: elif img_header is not None:
self.real_wcs = galsim.FitsWCS(header=img_header) self.chip_wcs = galsim.FitsWCS(header=img_header)
else: else:
self.real_wcs = None self.chip_wcs = None
return self.posImg, self.offset, self.localWCS, self.real_wcs, self.fd_shear return self.posImg, self.offset, self.localWCS, self.chip_wcs, self.fd_shear
def getRealPos(self, img, global_x=0., global_y=0., img_real_wcs=None): def getRealPos(self, img, global_x=0., global_y=0., img_real_wcs=None):
img_global_pos = galsim.PositionD(global_x, global_y) img_global_pos = galsim.PositionD(global_x, global_y)
cel_pos = img.wcs.toWorld(img_global_pos) cel_pos = img.wcs.toWorld(img_global_pos)
realPos = img_real_wcs.toImage(cel_pos) realPos = img_real_wcs.toImage(cel_pos)
return realPos return realPos
def drawObject(self, img, final, flux=None, filt=None, tel=None, exptime=150.):
""" Draw (point like) object on img.
Should be overided for extended source, e.g. galaxy...
Paramter:
img: the "canvas"
final: final (after shear, PSF etc.) GSObject
Return:
img: the image with the GSObject added (or discarded)
isUpdated: is the "canvas" been updated? (a flag for updating statistcs)
"""
isUpdated = True
# Draw with FFT
# stamp = final.drawImage(wcs=self.localWCS, offset=self.offset)
# Draw with Photon Shoot
stamp = final.drawImage(wcs=self.localWCS, method='phot', offset=self.offset)
stamp.setCenter(self.x_nominal, self.y_nominal)
if np.sum(np.isnan(stamp.array)) >= 1:
stamp.setZero()
bounds = stamp.bounds & img.bounds
if bounds.area() == 0:
isUpdated = False
else:
img[bounds] += stamp[bounds]
return img, stamp, isUpdated
def drawObj_multiband(self, tel, pos_img, psf_model, bandpass_list, filt, chip, nphotons_tot=None, g1=0, g2=0, def drawObj_multiband(self, tel, pos_img, psf_model, bandpass_list, filt, chip, nphotons_tot=None, g1=0, g2=0,
exptime=150., fd_shear=None): exptime=150., fd_shear=None):
if nphotons_tot == None: if nphotons_tot == None:
...@@ -139,29 +115,27 @@ class MockObject(object): ...@@ -139,29 +115,27 @@ class MockObject(object):
self.logger.error(e) self.logger.error(e)
return 2, None return 2, None
nphotons_sum = 0 # Set Galsim Parameters
photons_list = []
xmax, ymax = 0, 0
# (TEST) Galsim Parameters
if self.getMagFilter(filt) <= 15: if self.getMagFilter(filt) <= 15:
folding_threshold = 5.e-4 folding_threshold = 5.e-4
else: else:
folding_threshold = 5.e-3 folding_threshold = 5.e-3
gsp = galsim.GSParams(folding_threshold=folding_threshold) gsp = galsim.GSParams(folding_threshold=folding_threshold)
# Get real image position of object (deal with chip rotation w.r.t its center)
self.real_pos = self.getRealPos(chip.img, global_x=self.posImg.x, global_y=self.posImg.y, self.real_pos = self.getRealPos(chip.img, global_x=self.posImg.x, global_y=self.posImg.y,
img_real_wcs=self.real_wcs) img_real_wcs=self.chip_wcs)
x, y = self.real_pos.x + 0.5, self.real_pos.y + 0.5 x, y = self.real_pos.x + 0.5, self.real_pos.y + 0.5
x_nominal = int(np.floor(x + 0.5)) x_nominal = int(np.floor(x + 0.5))
y_nominal = int(np.floor(y + 0.5)) y_nominal = int(np.floor(y + 0.5))
dx = x - x_nominal dx = x - x_nominal
dy = y - y_nominal dy = y - y_nominal
offset = galsim.PositionD(dx, dy) offset = galsim.PositionD(dx, dy)
# Get real local wcs of object (deal with chip rotation w.r.t its center)
chip_wcs_local = self.chip_wcs.local(self.real_pos)
is_updated = 0
real_wcs_local = self.real_wcs.local(self.real_pos) # Loop over all sub-bandpasses
for i in range(len(bandpass_list)): for i in range(len(bandpass_list)):
bandpass = bandpass_list[i] bandpass = bandpass_list[i]
try: try:
...@@ -170,61 +144,42 @@ class MockObject(object): ...@@ -170,61 +144,42 @@ class MockObject(object):
print(e) print(e)
if self.logger: if self.logger:
self.logger.error(e) self.logger.error(e)
# return False
continue continue
ratio = sub / full ratio = sub / full
if not (ratio == -1 or (ratio != ratio)): if not (ratio == -1 or (ratio != ratio)):
nphotons = ratio * nphotons_tot nphotons = ratio * nphotons_tot
else: else:
# return False
continue continue
nphotons_sum += nphotons
# nphotons_sum += nphotons
# print("nphotons_sub-band_%d = %.2f"%(i, nphotons)) # print("nphotons_sub-band_%d = %.2f"%(i, nphotons))
# Get PSF model
psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass, psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass,
folding_threshold=folding_threshold) folding_threshold=folding_threshold)
star = galsim.DeltaFunction(gsparams=gsp) # star = galsim.DeltaFunction(gsparams=gsp)
star = star.withFlux(nphotons) # star = star.withFlux(nphotons)
star = galsim.Convolve(psf, star) # star = galsim.Convolve(psf, star)
star = psf.withFlux(nphotons)
stamp = star.drawImage(wcs=real_wcs_local, method='phot', offset=offset, save_photons=True)
xmax = max(xmax, stamp.xmax)
ymax = max(ymax, stamp.ymax)
photons = stamp.photons
photons.x += x_nominal
photons.y += y_nominal
photons_list.append(photons)
stamp = galsim.ImageF(int(xmax * 1.1), int(ymax * 1.1))
stamp.wcs = real_wcs_local
stamp.setCenter(x_nominal, y_nominal)
bounds = stamp.bounds & galsim.BoundsI(0, chip.npix_x - 1, 0, chip.npix_y - 1)
# # (DEBUG)
# print("stamp bounds: ", stamp.bounds)
# print(bounds)
if bounds.area() > 0:
chip.img.setOrigin(0, 0)
stamp[bounds] = chip.img[bounds]
for i in range(len(photons_list)):
if i == 0:
chip.sensor.accumulate(photons_list[i], stamp)
else:
chip.sensor.accumulate(photons_list[i], stamp, resume=True)
chip.img[bounds] = stamp[bounds] stamp = star.drawImage(wcs=chip_wcs_local, offset=offset)
if np.sum(np.isnan(stamp.array)) > 0:
chip.img.setOrigin(chip.bound.xmin, chip.bound.ymin) continue
else: stamp.setCenter(x_nominal, y_nominal)
# Return code 0: object photons missed this detector bounds = stamp.bounds & galsim.BoundsI(0, chip.npix_x - 1, 0, chip.npix_y - 1)
if bounds.area() > 0:
chip.img.setOrigin(0, 0)
chip.img[bounds] += stamp[bounds]
is_updated = 1
chip.img.setOrigin(chip.bound.xmin, chip.bound.ymin)
del stamp
if is_updated == 0:
# Return code 0: object has missed this detector
print("obj %s missed"%(self.id)) print("obj %s missed"%(self.id))
if self.logger: if self.logger:
self.logger.info("obj %s missed"%(self.id)) self.logger.info("obj %s missed"%(self.id))
return 0, pos_shear return 0, pos_shear
del photons_list
del stamp
return 1, pos_shear # Return code 1: draw sucesss return 1, pos_shear # Return code 1: draw sucesss
def addSLStoChipImage(self, sdp=None, chip=None, xOrderSigPlus=None, local_wcs=None): def addSLStoChipImage(self, sdp=None, chip=None, xOrderSigPlus=None, local_wcs=None):
...@@ -275,9 +230,69 @@ class MockObject(object): ...@@ -275,9 +230,69 @@ class MockObject(object):
del stamp del stamp
del spec_orders del spec_orders
def addSLStoChipImageWithPSF(self, sdp=None, chip=None, pos_img_local = [1,1], psf_model=None, bandNo = 1, grating_split_pos=3685, local_wcs=None, pos_img=None):
spec_orders = sdp.compute_spec_orders()
for k, v in spec_orders.items():
img_s = v[0]
# print(bandNo,k)
try:
psf, pos_shear = psf_model.get_PSF(chip, pos_img_local = pos_img_local, bandNo = bandNo, galsimGSObject=True, g_order = k, grating_split_pos=grating_split_pos)
except:
psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img)
psf_img = psf.drawImage(nx=100, ny=100, wcs = local_wcs)
psf_img_m = psf_img.array
#########################################################
# DEBUG
#########################################################
# ids_p = psf_img_m < 0
# psf_img_m[ids_p] = 0
# from astropy.io import fits
# fits.writeto(str(bandNo) + '_' + str(k) + '_psf.fits', psf_img_m)
# print("DEBUG: orig_off is", orig_off)
nan_ids = np.isnan(img_s)
if img_s[nan_ids].shape[0] > 0:
img_s[nan_ids] = 0
print("DEBUG: specImg nan num is", img_s[nan_ids].shape[0])
#########################################################
img_s, orig_off = convolveImg(img_s, psf_img_m)
origin_order_x = v[1] - orig_off[0]
origin_order_y = v[2] - orig_off[1]
specImg = galsim.ImageF(img_s)
# photons = galsim.PhotonArray.makeFromImage(specImg)
# photons.x += origin_order_x
# photons.y += origin_order_y
# xlen_imf = int(specImg.xmax - specImg.xmin + 1)
# ylen_imf = int(specImg.ymax - specImg.ymin + 1)
# stamp = galsim.ImageF(xlen_imf, ylen_imf)
# stamp.wcs = local_wcs
# stamp.setOrigin(origin_order_x, origin_order_y)
specImg.wcs = local_wcs
specImg.setOrigin(origin_order_x, origin_order_y)
bounds = specImg.bounds & galsim.BoundsI(0, chip.npix_x - 1, 0, chip.npix_y - 1)
if bounds.area() == 0:
continue
chip.img.setOrigin(0, 0)
chip.img[bounds] = chip.img[bounds] + specImg[bounds]
# stamp[bounds] = chip.img[bounds]
# # chip.sensor.accumulate(photons, stamp)
# chip.img[bounds] = stamp[bounds]
chip.img.setOrigin(chip.bound.xmin, chip.bound.ymin)
# del stamp
del spec_orders
return pos_shear
def drawObj_slitless(self, tel, pos_img, psf_model, bandpass_list, filt, chip, nphotons_tot=None, g1=0, g2=0, def drawObj_slitless(self, tel, pos_img, psf_model, bandpass_list, filt, chip, nphotons_tot=None, g1=0, g2=0,
exptime=150., normFilter=None, grating_split_pos=3685, fd_shear=None): exptime=150., normFilter=None, grating_split_pos=3685, fd_shear=None):
if normFilter is not None: if normFilter is not None:
norm_thr_rang_ids = normFilter['SENSITIVITY'] > 0.001 norm_thr_rang_ids = normFilter['SENSITIVITY'] > 0.001
sedNormFactor = getNormFactorForSpecWithABMAG(ABMag=self.param['mag_use_normal'], spectrum=self.sed, sedNormFactor = getNormFactorForSpecWithABMAG(ABMag=self.param['mag_use_normal'], spectrum=self.sed,
...@@ -299,7 +314,7 @@ class MockObject(object): ...@@ -299,7 +314,7 @@ class MockObject(object):
names=('WAVELENGTH', 'FLUX')) names=('WAVELENGTH', 'FLUX'))
self.real_pos = self.getRealPos(chip.img, global_x=self.posImg.x, global_y=self.posImg.y, self.real_pos = self.getRealPos(chip.img, global_x=self.posImg.x, global_y=self.posImg.y,
img_real_wcs=self.real_wcs) img_real_wcs=self.chip_wcs)
x, y = self.real_pos.x + 0.5, self.real_pos.y + 0.5 x, y = self.real_pos.x + 0.5, self.real_pos.y + 0.5
x_nominal = int(np.floor(x + 0.5)) x_nominal = int(np.floor(x + 0.5))
...@@ -308,29 +323,45 @@ class MockObject(object): ...@@ -308,29 +323,45 @@ class MockObject(object):
dy = y - y_nominal dy = y - y_nominal
offset = galsim.PositionD(dx, dy) offset = galsim.PositionD(dx, dy)
real_wcs_local = self.real_wcs.local(self.real_pos) chip_wcs_local = self.chip_wcs.local(self.real_pos)
flat_cube = chip.flat_cube flat_cube = chip.flat_cube
xOrderSigPlus = {'A': 1.3909419820029296, 'B': 1.4760376591236062, 'C': 4.035447379743442, xOrderSigPlus = {'A': 1.3909419820029296, 'B': 1.4760376591236062, 'C': 4.035447379743442,
'D': 5.5684364343742825, 'E': 16.260021029735388} 'D': 5.5684364343742825, 'E': 16.260021029735388}
grating_split_pos_chip = 0 + grating_split_pos grating_split_pos_chip = 0 + grating_split_pos
branges = np.zeros([len(bandpass_list),2])
if hasattr(psf_model,'bandranges'):
if psf_model.bandranges is None:
return 2, None
if len(psf_model.bandranges) != len(bandpass_list):
return 2, None
branges = psf_model.bandranges
else:
for i in range(len(bandpass_list)):
branges[i, 0] = bandpass_list[i].blue_limit * 10
branges[i, 1] = bandpass_list[i].red_limit * 10
for i in range(len(bandpass_list)): for i in range(len(bandpass_list)):
bandpass = bandpass_list[i] # bandpass = bandpass_list[i]
psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass, brange = branges[i]
folding_threshold=folding_threshold)
# psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass,
# folding_threshold=folding_threshold)
star = galsim.DeltaFunction(gsparams=gsp) star = galsim.DeltaFunction(gsparams=gsp)
star = star.withFlux(tel.pupil_area * exptime) star = star.withFlux(tel.pupil_area * exptime)
star = galsim.Convolve(psf, star) psf_tmp = galsim.Gaussian(sigma=0.002)
star = galsim.Convolve(psf_tmp, star)
starImg = star.drawImage(nx=100, ny=100, wcs=real_wcs_local, offset=offset) starImg = star.drawImage(nx=60, ny=60, wcs=chip_wcs_local, offset=offset)
origin_star = [y_nominal - (starImg.center.y - starImg.ymin), origin_star = [y_nominal - (starImg.center.y - starImg.ymin),
x_nominal - (starImg.center.x - starImg.xmin)] x_nominal - (starImg.center.x - starImg.xmin)]
starImg.setOrigin(0,0) starImg.setOrigin(0,0)
gal_origin = [origin_star[0], origin_star[1]] gal_origin = [origin_star[0], origin_star[1]]
gal_end = [origin_star[0] + starImg.array.shape[0] - 1, origin_star[1] + starImg.array.shape[1] - 1] gal_end = [origin_star[0] + starImg.array.shape[0] - 1, origin_star[1] + starImg.array.shape[1] - 1]
if gal_origin[1] < grating_split_pos_chip < gal_end[1]: if gal_origin[1] < grating_split_pos_chip < gal_end[1]:
subSlitPos = int(grating_split_pos_chip - gal_origin[1] + 1) subSlitPos = int(grating_split_pos_chip - gal_origin[1] + 1)
## part img disperse ## part img disperse
...@@ -345,12 +376,15 @@ class MockObject(object): ...@@ -345,12 +376,15 @@ class MockObject(object):
sdp_p1 = SpecDisperser(orig_img=star_p1, xcenter=xcenter_p1, sdp_p1 = SpecDisperser(orig_img=star_p1, xcenter=xcenter_p1,
ycenter=ycenter_p1, origin=origin_p1, ycenter=ycenter_p1, origin=origin_p1,
tar_spec=normalSED, tar_spec=normalSED,
band_start=bandpass.blue_limit * 10, band_end=bandpass.red_limit * 10, band_start=brange[0], band_end=brange[1],
conf=chip.sls_conf[0], conf=chip.sls_conf[0],
isAlongY=0, isAlongY=0,
flat_cube=flat_cube) flat_cube=flat_cube)
self.addSLStoChipImage(sdp=sdp_p1, chip=chip, xOrderSigPlus=xOrderSigPlus, local_wcs=real_wcs_local) # self.addSLStoChipImage(sdp=sdp_p1, chip=chip, xOrderSigPlus=xOrderSigPlus, local_wcs=chip_wcs_local)
pos_shear=self.addSLStoChipImageWithPSF(sdp=sdp_p1, chip=chip, pos_img_local = [xcenter_p1,ycenter_p1],
psf_model=psf_model, bandNo = i+1, grating_split_pos=grating_split_pos,
local_wcs=chip_wcs_local, pos_img = pos_img)
subImg_p2 = starImg.array[:, subSlitPos + 1:starImg.array.shape[1]] subImg_p2 = starImg.array[:, subSlitPos + 1:starImg.array.shape[1]]
star_p2 = galsim.Image(subImg_p2) star_p2 = galsim.Image(subImg_p2)
...@@ -362,12 +396,15 @@ class MockObject(object): ...@@ -362,12 +396,15 @@ class MockObject(object):
sdp_p2 = SpecDisperser(orig_img=star_p2, xcenter=xcenter_p2, sdp_p2 = SpecDisperser(orig_img=star_p2, xcenter=xcenter_p2,
ycenter=ycenter_p2, origin=origin_p2, ycenter=ycenter_p2, origin=origin_p2,
tar_spec=normalSED, tar_spec=normalSED,
band_start=bandpass.blue_limit * 10, band_end=bandpass.red_limit * 10, band_start=brange[0], band_end=brange[1],
conf=chip.sls_conf[1], conf=chip.sls_conf[1],
isAlongY=0, isAlongY=0,
flat_cube=flat_cube) flat_cube=flat_cube)
self.addSLStoChipImage(sdp=sdp_p2, chip=chip, xOrderSigPlus=xOrderSigPlus, local_wcs=real_wcs_local) # self.addSLStoChipImage(sdp=sdp_p2, chip=chip, xOrderSigPlus=xOrderSigPlus, local_wcs=chip_wcs_local)
pos_shear=self.addSLStoChipImageWithPSF(sdp=sdp_p2, chip=chip, pos_img_local=[xcenter_p2, ycenter_p2],
psf_model=psf_model, bandNo=i + 1, grating_split_pos=grating_split_pos,
local_wcs=chip_wcs_local, pos_img = pos_img)
del sdp_p1 del sdp_p1
del sdp_p2 del sdp_p2
...@@ -375,23 +412,29 @@ class MockObject(object): ...@@ -375,23 +412,29 @@ class MockObject(object):
sdp = SpecDisperser(orig_img=starImg, xcenter=x_nominal - 0, sdp = SpecDisperser(orig_img=starImg, xcenter=x_nominal - 0,
ycenter=y_nominal - 0, origin=origin_star, ycenter=y_nominal - 0, origin=origin_star,
tar_spec=normalSED, tar_spec=normalSED,
band_start=bandpass.blue_limit * 10, band_end=bandpass.red_limit * 10, band_start=brange[0], band_end=brange[1],
conf=chip.sls_conf[1], conf=chip.sls_conf[1],
isAlongY=0, isAlongY=0,
flat_cube=flat_cube) flat_cube=flat_cube)
self.addSLStoChipImage(sdp=sdp, chip=chip, xOrderSigPlus=xOrderSigPlus, local_wcs=real_wcs_local) # self.addSLStoChipImage(sdp=sdp, chip=chip, xOrderSigPlus=xOrderSigPlus, local_wcs=chip_wcs_local)
pos_shear=self.addSLStoChipImageWithPSF(sdp=sdp, chip=chip, pos_img_local=[x_nominal, y_nominal],
psf_model=psf_model, bandNo=i + 1, grating_split_pos=grating_split_pos,
local_wcs=chip_wcs_local, pos_img = pos_img)
del sdp del sdp
elif grating_split_pos_chip >= gal_end[1]: elif grating_split_pos_chip >= gal_end[1]:
sdp = SpecDisperser(orig_img=starImg, xcenter=x_nominal - 0, sdp = SpecDisperser(orig_img=starImg, xcenter=x_nominal - 0,
ycenter=y_nominal - 0, origin=origin_star, ycenter=y_nominal - 0, origin=origin_star,
tar_spec=normalSED, tar_spec=normalSED,
band_start=bandpass.blue_limit * 10, band_end=bandpass.red_limit * 10, band_start=brange[0], band_end=brange[1],
conf=chip.sls_conf[0], conf=chip.sls_conf[0],
isAlongY=0, isAlongY=0,
flat_cube=flat_cube) flat_cube=flat_cube)
self.addSLStoChipImage(sdp=sdp, chip=chip, xOrderSigPlus=xOrderSigPlus, local_wcs=real_wcs_local) # self.addSLStoChipImage(sdp=sdp, chip=chip, xOrderSigPlus=xOrderSigPlus, local_wcs=chip_wcs_local)
pos_shear=self.addSLStoChipImageWithPSF(sdp=sdp, chip=chip, pos_img_local=[x_nominal, y_nominal],
psf_model=psf_model, bandNo=i + 1, grating_split_pos=grating_split_pos,
local_wcs=chip_wcs_local, pos_img = pos_img)
del sdp del sdp
del psf # del psf
return 1, pos_shear return 1, pos_shear
def SNRestimate(self, img_obj, flux, noise_level=0.0, seed=31415): def SNRestimate(self, img_obj, flux, noise_level=0.0, seed=31415):
...@@ -403,3 +446,88 @@ class MockObject(object): ...@@ -403,3 +446,88 @@ class MockObject(object):
sig_obj = np.std(stamp.array) sig_obj = np.std(stamp.array)
snr_obj = img_flux / sig_obj snr_obj = img_flux / sig_obj
return snr_obj return snr_obj
def drawObj_PSF(self, tel, pos_img, psf_model, bandpass_list, filt, chip, nphotons_tot=None, g1=0, g2=0,
exptime=150., fd_shear=None, chip_output=None):
if nphotons_tot == None:
nphotons_tot = self.getElectronFluxFilt(filt, tel, exptime)
# print("nphotons_tot = ", nphotons_tot)
try:
full = integrate_sed_bandpass(sed=self.sed, bandpass=filt.bandpass_full)
except Exception as e:
print(e)
if self.logger:
self.logger.error(e)
return 2, None
# Set Galsim Parameters
if self.getMagFilter(filt) <= 15:
folding_threshold = 5.e-4
else:
folding_threshold = 5.e-3
gsp = galsim.GSParams(folding_threshold=folding_threshold)
# Get real image position of object (deal with chip rotation w.r.t its center)
self.real_pos = self.getRealPos(chip.img, global_x=self.posImg.x, global_y=self.posImg.y,
img_real_wcs=self.chip_wcs)
x, y = self.real_pos.x + 0.5, self.real_pos.y + 0.5
x_nominal = int(np.floor(x + 0.5))
y_nominal = int(np.floor(y + 0.5))
dx = x - x_nominal
dy = y - y_nominal
offset = galsim.PositionD(dx, dy)
# Get real local wcs of object (deal with chip rotation w.r.t its center)
chip_wcs_local = self.chip_wcs.local(self.real_pos)
is_updated = 0
# Loop over all sub-bandpasses
for i in range(len(bandpass_list)):
bandpass = bandpass_list[i]
try:
sub = integrate_sed_bandpass(sed=self.sed, bandpass=bandpass)
except Exception as e:
print(e)
if self.logger:
self.logger.error(e)
continue
ratio = sub / full
if not (ratio == -1 or (ratio != ratio)):
nphotons = ratio * nphotons_tot
else:
continue
# Get PSF model
psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass,
folding_threshold=folding_threshold)
star_temp = psf.withFlux(nphotons)
if i==0:
star = star_temp
else:
star = star+star_temp
pixelScale = 0.074
stamp = star.drawImage(wcs=chip_wcs_local, offset=offset)
#stamp = star.drawImage(nx=256, ny=256, scale=pixelScale)
if np.sum(np.isnan(stamp.array)) > 0:
return None
fn = chip_output.subdir + "/psfIDW"
os.makedirs(fn, exist_ok=True)
fn = fn + "/ccd_{:}".format(chip.chipID)+"_psf_"+str(self.param['id'])+".fits"
if fn != None:
if os.path.exists(fn):
os.remove(fn)
hdu = fitsio.PrimaryHDU()
hdu.data = stamp.array
hdu.header.set('name', self.type)
hdu.header.set('pixScale', pixelScale)
hdu.header.set('objID', self.param['id'])
hdu.writeto(fn)
del stamp
return None
...@@ -155,7 +155,7 @@ class SpecDisperser(object): ...@@ -155,7 +155,7 @@ class SpecDisperser(object):
sensitivity_beam = ysens sensitivity_beam = ysens
len_spec_x = len(dx) len_spec_x = len(dx)
len_spec_y = int(ceil(ytrace_beam[-1]) - floor(ytrace_beam[0]) + 1) len_spec_y = int(abs(ceil(ytrace_beam[-1]) - floor(ytrace_beam[0])) + 1)
beam_sh = (self.img_sh[0] + len_spec_y, self.img_sh[1] + len_spec_x) beam_sh = (self.img_sh[0] + len_spec_y, self.img_sh[1] + len_spec_x)
modelf = zeros(product(beam_sh), dtype=float) modelf = zeros(product(beam_sh), dtype=float)
...@@ -239,7 +239,7 @@ class SpecDisperser(object): ...@@ -239,7 +239,7 @@ class SpecDisperser(object):
# else: # else:
# beam_flat[k] = self.flat_cube[:, originOut_y + i, originOut_x + j] # beam_flat[k] = self.flat_cube[:, originOut_y + i, originOut_x + j]
status = disperse.disperse_grism_object(self.thumb_img, status = disperse.disperse_grism_object(self.thumb_img.astype(np.float32),
flat_index[nonz], yfrac_beam[nonz], flat_index[nonz], yfrac_beam[nonz],
sensitivity_beam[nonz], sensitivity_beam[nonz],
modelf, x0, modelf, x0,
......
import os, sys import os, sys
import random
import numpy as np import numpy as np
import galsim
import astropy.constants as cons import astropy.constants as cons
from astropy.table import Table from astropy.table import Table
from scipy import interpolate from scipy import interpolate
import astropy.io.fits as fitsio
import galsim
import gc
from ObservationSim.MockObject.MockObject import MockObject from ObservationSim.MockObject.MockObject import MockObject
from ObservationSim.MockObject.SpecDisperser import SpecDisperser
from ObservationSim.MockObject._util import magToFlux,VC_A
from ObservationSim.MockObject._util import eObs, integrate_sed_bandpass, getNormFactorForSpecWithABMAG, getObservedSED, getABMAG,convolveGaussXorders from ObservationSim.MockObject._util import eObs, integrate_sed_bandpass, getNormFactorForSpecWithABMAG, getObservedSED, getABMAG,convolveGaussXorders
class Stamp(MockObject): class Stamp(MockObject):
def __init__(self, param): def __init__(self, param, logger=None):
super().__init__(param) super().__init__(param, logger=logger)
def unload_SED(self): def unload_SED(self):
"""(Test) free up SED memory """(Test) free up SED memory
...@@ -35,9 +30,9 @@ class Stamp(MockObject): ...@@ -35,9 +30,9 @@ class Stamp(MockObject):
self.logger.error(e) self.logger.error(e)
return False return False
nphotons_sum = 0 #nphotons_sum = 0
photons_list = [] #photons_list = []
xmax, ymax = 0, 0 #xmax, ymax = 0, 0
if self.getMagFilter(filt) <= 15: if self.getMagFilter(filt) <= 15:
folding_threshold = 5.e-4 folding_threshold = 5.e-4
...@@ -46,7 +41,7 @@ class Stamp(MockObject): ...@@ -46,7 +41,7 @@ class Stamp(MockObject):
gsp = galsim.GSParams(folding_threshold=folding_threshold) gsp = galsim.GSParams(folding_threshold=folding_threshold)
self.real_pos = self.getRealPos(chip.img, global_x=self.posImg.x, global_y=self.posImg.y, self.real_pos = self.getRealPos(chip.img, global_x=self.posImg.x, global_y=self.posImg.y,
img_real_wcs=self.real_wcs) img_real_wcs=self.chip_wcs)
x, y = self.real_pos.x + 0.5, self.real_pos.y + 0.5 x, y = self.real_pos.x + 0.5, self.real_pos.y + 0.5
x_nominal = int(np.floor(x + 0.5)) x_nominal = int(np.floor(x + 0.5))
...@@ -55,72 +50,237 @@ class Stamp(MockObject): ...@@ -55,72 +50,237 @@ class Stamp(MockObject):
dy = y - y_nominal dy = y - y_nominal
offset = galsim.PositionD(dx, dy) offset = galsim.PositionD(dx, dy)
real_wcs_local = self.real_wcs.local(self.real_pos) chip_wcs_local = self.chip_wcs.local(self.real_pos)
is_updated = 0
if fd_shear:
g1 += fd_shear.g1
g2 += fd_shear.g2
gal_shear = galsim.Shear(g1=g1, g2=g2)
for i in range(len(bandpass_list)): for i in range(len(bandpass_list)):
bandpass = bandpass_list[i] bandpass = bandpass_list[i]
try: try:
sub = integrate_sed_bandpass(sed=self.sed, bandpass=bandpass) sub = integrate_sed_bandpass(sed=self.sed, bandpass=bandpass)
except Exception as e: except Exception as e:
print(e) print(e)
self.logger.error(e) if self.logger:
# return False self.logger.error(e)
continue continue
ratio = sub/full ratio = sub/full
if not (ratio == -1 or (ratio != ratio)): if not (ratio == -1 or (ratio != ratio)):
nphotons = ratio * nphotons_tot nphotons = ratio * nphotons_tot
else: else:
# return False
continue continue
nphotons_sum += nphotons #nphotons_sum += nphotons
psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass, folding_threshold=folding_threshold) psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass, folding_threshold=folding_threshold)
_gal = self.param['image'] _gal = self.param['image']
galIm = galsim.ImageF(_gal, scale=self.param['pixScale']) galImg= galsim.ImageF(_gal, scale=self.param['pixScale'])
gal = galsim.InterpolatedImage(galIm) gal_temp= galsim.InterpolatedImage(galImg)
gal = gal.withFlux(nphotons) gal_temp= gal_temp.shear(gal_shear)
#gal_shear = galsim.Shear(g1=g1, g2=g2) gal_temp= gal_temp.withFlux(nphotons)
#gal = gal.shear(gal_shear)
gal = galsim.Convolve(psf, gal) gal_temp= galsim.Convolve(psf, gal_temp)
if fd_shear is not None:
gal = gal.shear(fd_shear)
stamp = gal.drawImage(wcs=real_wcs_local, method='phot', offset=self.offset, save_photons=True) if i == 0:
gal = gal_temp
xmax = max(xmax, stamp.xmax - stamp.xmin) else:
ymax = max(ymax, stamp.ymax - stamp.ymin) gal = gal + gal_temp
photons = stamp.photons
photons.x += x_nominal
photons.y += y_nominal
photons_list.append(photons)
del gal
# print('xmax = %d, ymax = %d '%(xmax, ymax)) stamp = gal.drawImage(wcs=chip_wcs_local, offset=offset)
if np.sum(np.isnan(stamp.array)) > 0:
# ERROR happens
return 2, pos_shear
stamp = galsim.ImageF(int(xmax*1.1), int(ymax*1.1))
stamp.wcs = real_wcs_local
stamp.setCenter(x_nominal, y_nominal) stamp.setCenter(x_nominal, y_nominal)
bounds = stamp.bounds & galsim.BoundsI(0, chip.npix_x - 1, 0, chip.npix_y - 1) bounds = stamp.bounds & galsim.BoundsI(0, chip.npix_x - 1, 0, chip.npix_y - 1)
if bounds.area() > 0: if bounds.area() > 0:
chip.img.setOrigin(0, 0) chip.img.setOrigin(0, 0)
stamp[bounds] = chip.img[bounds] chip.img[bounds] += stamp[bounds]
for i in range(len(photons_list)): is_updated = 1
if i == 0: chip.img.setOrigin(chip.bound.xmin, chip.bound.ymin)
chip.sensor.accumulate(photons_list[i], stamp) del stamp
else:
chip.sensor.accumulate(photons_list[i], stamp, resume=True)
chip.img[bounds] = stamp[bounds] if is_updated == 0:
print("fits obj %s missed"%(self.id))
if self.logger:
self.logger.info("fits obj %s missed"%(self.id))
return 0, pos_shear
chip.img.setOrigin(chip.bound.xmin, chip.bound.ymin) return 1, pos_shear
def drawObj_slitless(self, tel, pos_img, psf_model, bandpass_list, filt, chip, nphotons_tot=None, g1=0, g2=0,
exptime=150., normFilter=None, grating_split_pos=3685, fd_shear=None):
if normFilter is not None:
norm_thr_rang_ids = normFilter['SENSITIVITY'] > 0.001
sedNormFactor = getNormFactorForSpecWithABMAG(ABMag=self.param['mag_use_normal'], spectrum=self.sed,
norm_thr=normFilter,
sWave=np.floor(normFilter[norm_thr_rang_ids][0][0]),
eWave=np.ceil(normFilter[norm_thr_rang_ids][-1][0]))
if sedNormFactor == 0:
return 2, None
else:
sedNormFactor = 1.
normalSED = Table(np.array([self.sed['WAVELENGTH'], self.sed['FLUX'] * sedNormFactor]).T,
names=('WAVELENGTH', 'FLUX'))
self.real_pos = self.getRealPos(chip.img, global_x=self.posImg.x, global_y=self.posImg.y,
img_real_wcs=self.chip_wcs)
x, y = self.real_pos.x + 0.5, self.real_pos.y + 0.5
x_nominal = int(np.floor(x + 0.5))
y_nominal = int(np.floor(y + 0.5))
dx = x - x_nominal
dy = y - y_nominal
offset = galsim.PositionD(dx, dy)
chip_wcs_local = self.chip_wcs.local(self.real_pos)
if self.getMagFilter(filt) <= 15:
folding_threshold = 5.e-4
else:
folding_threshold = 5.e-3
gsp = galsim.GSParams(folding_threshold=folding_threshold)
# nphotons_sum = 0
flat_cube = chip.flat_cube
xOrderSigPlus = {'A':1.3909419820029296,'B':1.4760376591236062,'C':4.035447379743442,'D':5.5684364343742825,'E':16.260021029735388}
grating_split_pos_chip = 0 + grating_split_pos
branges = np.zeros([len(bandpass_list), 2])
# print(hasattr(psf_model, 'bandranges'))
if hasattr(psf_model, 'bandranges'):
if psf_model.bandranges is None:
return 2, None
if len(psf_model.bandranges) != len(bandpass_list):
return 2, None
branges = psf_model.bandranges
else:
for i in range(len(bandpass_list)):
branges[i, 0] = bandpass_list[i].blue_limit * 10
branges[i, 1] = bandpass_list[i].red_limit * 10
for i in range(len(bandpass_list)):
# bandpass = bandpass_list[i]
brange = branges[i]
# psf, pos_shear = psf_model.get_PSF(chip=chip, pos_img=pos_img, bandpass=bandpass, folding_threshold=folding_threshold)
_gal = self.param['image']
galImg= galsim.ImageF(_gal, scale=self.param['pixScale'])
gal = galsim.InterpolatedImage(galImg)
# (TEST) Random knots
# knots = galsim.RandomKnots(npoints=100, profile=disk)
# kfrac = np.random.random()*(1.0 - self.bfrac)
# gal = self.bfrac * bulge + (1.0 - self.bfrac - kfrac) * disk + kfrac * knots
gal = gal.withFlux(tel.pupil_area * exptime)
if fd_shear:
g1 += fd_shear.g1
g2 += fd_shear.g2
gal_shear = galsim.Shear(g1=g1, g2=g2)
gal = gal.shear(gal_shear)
# gal = galsim.Convolve(psf, gal)
# if not big_galaxy: # Not apply PSF for very big galaxy
# gal = galsim.Convolve(psf, gal)
# # if fd_shear is not None:
# # gal = gal.shear(fd_shear)
starImg = gal.drawImage(wcs=chip_wcs_local, offset=offset,method = 'real_space')
origin_star = [y_nominal - (starImg.center.y - starImg.ymin),
x_nominal - (starImg.center.x - starImg.xmin)]
starImg.setOrigin(0, 0)
gal_origin = [origin_star[0], origin_star[1]]
gal_end = [origin_star[0] + starImg.array.shape[0] - 1, origin_star[1] + starImg.array.shape[1] - 1]
if gal_origin[1] < grating_split_pos_chip < gal_end[1]:
subSlitPos = int(grating_split_pos_chip - gal_origin[1] + 1)
## part img disperse
subImg_p1 = starImg.array[:, 0:subSlitPos]
star_p1 = galsim.Image(subImg_p1)
star_p1.setOrigin(0, 0)
origin_p1 = origin_star
xcenter_p1 = min(x_nominal,grating_split_pos_chip-1) - 0
ycenter_p1 = y_nominal-0
sdp_p1 = SpecDisperser(orig_img=star_p1, xcenter=xcenter_p1,
ycenter=ycenter_p1, origin=origin_p1,
tar_spec=normalSED,
band_start=brange[0], band_end=brange[1],
conf=chip.sls_conf[0],
isAlongY=0,
flat_cube=flat_cube)
# self.addSLStoChipImage(sdp=sdp_p1, chip=chip, xOrderSigPlus = xOrderSigPlus, local_wcs=chip_wcs_local)
pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp_p1, chip=chip, pos_img_local=[xcenter_p1, ycenter_p1],
psf_model=psf_model, bandNo=i + 1,
grating_split_pos=grating_split_pos,
local_wcs=chip_wcs_local, pos_img = pos_img)
subImg_p2 = starImg.array[:, subSlitPos+1:starImg.array.shape[1]]
star_p2 = galsim.Image(subImg_p2)
star_p2.setOrigin(0, 0)
origin_p2 = [origin_star[0], grating_split_pos_chip]
xcenter_p2 = max(x_nominal, grating_split_pos_chip - 1) - 0
ycenter_p2 = y_nominal - 0
sdp_p2 = SpecDisperser(orig_img=star_p2, xcenter=xcenter_p2,
ycenter=ycenter_p2, origin=origin_p2,
tar_spec=normalSED,
band_start=brange[0], band_end=brange[1],
conf=chip.sls_conf[1],
isAlongY=0,
flat_cube=flat_cube)
# self.addSLStoChipImage(sdp=sdp_p2, chip=chip, xOrderSigPlus = xOrderSigPlus, local_wcs=chip_wcs_local)
pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp_p2, chip=chip, pos_img_local=[xcenter_p2, ycenter_p2],
psf_model=psf_model, bandNo=i + 1,
grating_split_pos=grating_split_pos,
local_wcs=chip_wcs_local, pos_img = pos_img)
del sdp_p1
del sdp_p2
elif grating_split_pos_chip<=gal_origin[1]:
sdp = SpecDisperser(orig_img=starImg, xcenter=x_nominal - 0,
ycenter=y_nominal - 0, origin=origin_star,
tar_spec=normalSED,
band_start=brange[0], band_end=brange[1],
conf=chip.sls_conf[1],
isAlongY=0,
flat_cube=flat_cube)
# self.addSLStoChipImage(sdp=sdp, chip=chip, xOrderSigPlus = xOrderSigPlus, local_wcs=chip_wcs_local)
pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp, chip=chip, pos_img_local=[x_nominal, y_nominal],
psf_model=psf_model, bandNo=i + 1,
grating_split_pos=grating_split_pos,
local_wcs=chip_wcs_local, pos_img = pos_img)
del sdp
elif grating_split_pos_chip>=gal_end[1]:
sdp = SpecDisperser(orig_img=starImg, xcenter=x_nominal - 0,
ycenter=y_nominal - 0, origin=origin_star,
tar_spec=normalSED,
band_start=brange[0], band_end=brange[1],
conf=chip.sls_conf[0],
isAlongY=0,
flat_cube=flat_cube)
# self.addSLStoChipImage(sdp=sdp, chip=chip, xOrderSigPlus = xOrderSigPlus, local_wcs=chip_wcs_local)
pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp, chip=chip, pos_img_local=[x_nominal, y_nominal],
psf_model=psf_model, bandNo=i + 1,
grating_split_pos=grating_split_pos,
local_wcs=chip_wcs_local, pos_img = pos_img)
del sdp
del photons_list # print(self.y_nominal, starImg.center.y, starImg.ymin)
del stamp # del psf
gc.collect() return 1, pos_shear
return True, pos_shear
...@@ -4,5 +4,6 @@ from .CatalogBase import CatalogBase ...@@ -4,5 +4,6 @@ from .CatalogBase import CatalogBase
from .Quasar import Quasar from .Quasar import Quasar
from .Star import Star from .Star import Star
from .Stamp import Stamp from .Stamp import Stamp
from .FlatLED import FlatLED
# from .SkybackgroundMap import * # from .SkybackgroundMap import *
# from .CosmicRay import CosmicRay # from .CosmicRay import CosmicRay
...@@ -571,4 +571,14 @@ def convolveGaussXorders(img=None, sigma = 1): ...@@ -571,4 +571,14 @@ def convolveGaussXorders(img=None, sigma = 1):
convImg = signal.fftconvolve(img, psf, mode='full', axes=None) convImg = signal.fftconvolve(img, psf, mode='full', axes=None)
return convImg, offset return convImg, offset
def convolveImg(img=None, psf = None):
from astropy.modeling.models import Gaussian2D
from scipy import signal
convImg = signal.fftconvolve(img, psf, mode='full', axes=None)
offset_x = int(psf.shape[1]/2. + 0.5) - 1
offset_y = int(psf.shape[0]/2. + 0.5) - 1
offset = [offset_x,offset_y]
return convImg, offset
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment