Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Liu Dezi
csst_msc_sim
Commits
edd720e6
Commit
edd720e6
authored
Apr 17, 2024
by
Fang Yuedong
Browse files
Merge branch 'develop'
parents
959f0ebc
8df06b27
Changes
139
Hide whitespace changes
Inline
Side-by-side
ObservationSim/Instrument/data/throughputs/z_throughput.txt
View file @
edd720e6
# z_cssc
# lambda_Angst throughput
2000.00
0.00000
2000.00
-
0.00000
2010.00 0.00000
2020.00 0.00000
2030.00
0.00000
2030.00
-
0.00000
2040.00 0.00000
2050.00
0.00000
2050.00
-
0.00000
2060.00 0.00000
2070.00 0.00000
2080.00 0.00000
2090.00 0.00000
2100.00
0.00000
2110.00
0.00000
2100.00
-
0.00000
2110.00
-
0.00000
2120.00 0.00000
2130.00
0.00000
2130.00
-
0.00000
2140.00 0.00000
2150.00 0.00000
2160.00
0.00000
2160.00
-
0.00000
2170.00 0.00000
2180.00 0.00000
2190.00 0.00000
2200.00 0.00000
2210.00 0.00000
2220.00
0.00000
2220.00
-
0.00000
2230.00 0.00000
2240.00 0.00000
2250.00 0.00000
...
...
@@ -30,49 +30,49 @@
2270.00 0.00000
2280.00 0.00000
2290.00 0.00000
2300.00
0.00000
2310.00
0.00000
2300.00
-
0.00000
2310.00
-
0.00000
2320.00 0.00000
2330.00
0.00000
2330.00
-
0.00000
2340.00 0.00000
2350.00
0.00000
2350.00
-
0.00000
2360.00 0.00000
2370.00 0.00000
2380.00 0.00000
2390.00
0.00000
2400.00
0.00000
2410.00
0.00000
2390.00
-
0.00000
2400.00
-
0.00000
2410.00
-
0.00000
2420.00 0.00000
2430.00 0.00000
2440.00 0.00000
2450.00
0.00000
2450.00
-
0.00000
2460.00 0.00000
2470.00 0.00000
2480.00
0.00000
2480.00
-
0.00000
2490.00 0.00000
2500.00
0.00000
2510.00
0.00000
2500.00
-
0.00000
2510.00
-
0.00000
2520.00 0.00000
2530.00 0.00000
2540.00 0.00000
2550.00
0.00000
2560.00
0.00000
2570.00
0.00000
2580.00
0.00000
2550.00
-
0.00000
2560.00
-
0.00000
2570.00
-
0.00000
2580.00
-
0.00000
2590.00 0.00000
2600.00 0.00000
2610.00
0.00000
2610.00
-
0.00000
2620.00 0.00000
2630.00 0.00000
2640.00 0.00000
2650.00 0.00000
2660.00
0.00000
2660.00
-
0.00000
2670.00 0.00000
2680.00 0.00000
2690.00
0.00000
2690.00
-
0.00000
2700.00 0.00000
2710.00 0.00000
2720.00
0.00000
2720.00
-
0.00000
2730.00 0.00000
2740.00 0.00000
2750.00 0.00000
...
...
@@ -82,32 +82,32 @@
2790.00 0.00000
2800.00 0.00000
2810.00 0.00000
2820.00
0.00000
2820.00
-
0.00000
2830.00 0.00000
2840.00 0.00000
2850.00
0.00000
2850.00
-
0.00000
2860.00 0.00000
2870.00
0.00000
2880.00
0.00000
2870.00
-
0.00000
2880.00
-
0.00000
2890.00 0.00000
2900.00
0.00000
2900.00
-
0.00000
2910.00 0.00000
2920.00 0.00000
2930.00 0.00000
2940.00 0.00000
2950.00
0.00000
2950.00
-
0.00000
2960.00 0.00000
2970.00 0.00000
2980.00
0.00000
2990.00
0.00000
3000.00
0.00000
2980.00
-
0.00000
2990.00
-
0.00000
3000.00
-
0.00000
3010.00 0.00000
3020.00
0.00000
3020.00
-
0.00000
3030.00 0.00000
3040.00
0.00000
3040.00
-
0.00000
3050.00 0.00000
3060.00 0.00000
3070.00
0.00000
3070.00
-
0.00000
3080.00 0.00000
3090.00 0.00000
3100.00 0.00000
...
...
@@ -115,65 +115,65 @@
3120.00 0.00000
3130.00 0.00000
3140.00 0.00000
3150.00
0.00000
3160.00
0.00000
3150.00
-
0.00000
3160.00
-
0.00000
3170.00 0.00000
3180.00
0.00000
3180.00
-
0.00000
3190.00 0.00000
3200.00
0.00000
3210.00
0.00000
3220.00
0.00000
3200.00
-
0.00000
3210.00
-
0.00000
3220.00
-
0.00000
3230.00 0.00000
3240.00 0.00000
3250.00 0.00000
3260.00 0.00000
3270.00 0.00000
3280.00
0.00000
3290.00
0.00000
3280.00
-
0.00000
3290.00
-
0.00000
3300.00 0.00000
3310.00 0.00000
3320.00 0.00000
3330.00 0.00000
3340.00 0.00000
3350.00
0.00000
3360.00
0.00000
3350.00
-
0.00000
3360.00
-
0.00000
3370.00 0.00000
3380.00 0.00000
3390.00 0.00000
3400.00
0.00000
3410.00
0.00000
3420.00
0.00000
3430.00
0.00000
3440.00
0.00000
3450.00
0.00000
3400.00
-
0.00000
3410.00
-
0.00000
3420.00
-
0.00000
3430.00
-
0.00000
3440.00
-
0.00000
3450.00
-
0.00000
3460.00 0.00000
3470.00
0.00000
3480.00
0.00000
3490.00
0.00000
3500.00
0.00000
3470.00
-
0.00000
3480.00
-
0.00000
3490.00
-
0.00000
3500.00
-
0.00000
3510.00 0.00000
3520.00 0.00000
3530.00 0.00000
3540.00 0.00000
3550.00
0.00000
3550.00
-
0.00000
3560.00 0.00000
3570.00 0.00000
3580.00 0.00000
3590.00 0.00000
3600.00 0.00000
3610.00 0.00000
3620.00
0.00000
3620.00
-
0.00000
3630.00 0.00000
3640.00
0.00000
3640.00
-
0.00000
3650.00 0.00000
3660.00
0.00000
3670.00
0.00000
3660.00
-
0.00000
3670.00
-
0.00000
3680.00 0.00000
3690.00 0.00000
3700.00 0.00000
3710.00 0.00000
3720.00
0.00000
3730.00
0.00000
3720.00
-
0.00000
3730.00
-
0.00000
3740.00 0.00000
3750.00 0.00000
3760.00 0.00000
...
...
@@ -182,59 +182,59 @@
3790.00 0.00000
3800.00 0.00000
3810.00 0.00000
3820.00
0.00000
3830.00
0.00000
3820.00
-
0.00000
3830.00
-
0.00000
3840.00 0.00000
3850.00 0.00000
3860.00 0.00000
3870.00 0.00000
3880.00 0.00000
3890.00 0.00000
3900.00
0.00000
3900.00
-
0.00000
3910.00 0.00000
3920.00 0.00000
3930.00 0.00000
3940.00 0.00000
3950.00 0.00000
3960.00
0.00000
3960.00
-
0.00000
3970.00 0.00000
3980.00
0.00000
3990.00
0.00000
4000.00
0.00000
4010.00
0.00000
4020.00
0.00000
3980.00
-
0.00000
3990.00
-
0.00000
4000.00
-
0.00000
4010.00
-
0.00000
4020.00
-
0.00000
4030.00 0.00000
4040.00
0.00000
4040.00
-
0.00000
4050.00 0.00000
4060.00 0.00000
4070.00
0.00000
4070.00
-
0.00000
4080.00 0.00000
4090.00 0.00000
4100.00
0.00000
4110.00
0.00000
4120.00
0.00000
4100.00
-
0.00000
4110.00
-
0.00000
4120.00
-
0.00000
4130.00 0.00000
4140.00 0.00000
4150.00 0.00000
4160.00
0.00000
4170.00
0.00000
4160.00
-
0.00000
4170.00
-
0.00000
4180.00 0.00000
4190.00
0.00000
4190.00
-
0.00000
4200.00 0.00000
4210.00 0.00000
4220.00
0.00000
4230.00
0.00000
4220.00
-
0.00000
4230.00
-
0.00000
4240.00 0.00000
4250.00 0.00000
4260.00 0.00000
4270.00
0.00000
4270.00
-
0.00000
4280.00 0.00000
4290.00
0.00000
4300.00
0.00000
4310.00
0.00000
4290.00
-
0.00000
4300.00
-
0.00000
4310.00
-
0.00000
4320.00 0.00000
4330.00 0.00000
4340.00
0.00000
4340.00
-
0.00000
4350.00 0.00000
4360.00 0.00000
4370.00 0.00000
...
...
@@ -243,62 +243,62 @@
4400.00 0.00000
4410.00 0.00000
4420.00 0.00000
4430.00
0.00000
4440.00
0.00000
4430.00
-
0.00000
4440.00
-
0.00000
4450.00 0.00000
4460.00 0.00000
4470.00
0.00000
4470.00
-
0.00000
4480.00 0.00000
4490.00 0.00000
4500.00
0.00000
4510.00
0.00000
4520.00
0.00000
4500.00
-
0.00000
4510.00
-
0.00000
4520.00
-
0.00000
4530.00 0.00000
4540.00
0.00000
4540.00
-
0.00000
4550.00 0.00000
4560.00 0.00000
4570.00 0.00000
4580.00
0.00000
4580.00
-
0.00000
4590.00 0.00000
4600.00 0.00000
4610.00
0.00000
4610.00
-
0.00000
4620.00 0.00000
4630.00
0.00000
4630.00
-
0.00000
4640.00 0.00000
4650.00 0.00000
4660.00 0.00000
4670.00 0.00000
4680.00 0.00000
4690.00 0.0000
0
4690.00 0.0000
1
4700.00 0.00000
4710.00 0.00000
4720.00 0.0000
0
4730.00 0.0000
0
4720.00 0.0000
1
4730.00 0.0000
1
4740.00 0.00001
4750.00 0.00001
4760.00 0.00001
4770.00 0.00001
4780.00 0.0000
2
4790.00 0.0000
3
4800.00 0.0000
4
4810.00 0.0000
4
4820.00 0.0000
5
4830.00 0.0000
4
4780.00 0.0000
1
4790.00 0.0000
2
4800.00 0.0000
3
4810.00 0.0000
5
4820.00 0.0000
6
4830.00 0.0000
5
4840.00 0.00003
4850.00 0.0000
2
4860.00 0.0000
1
4850.00 0.0000
1
4860.00 0.0000
0
4870.00 0.00000
4880.00 0.00000
4890.00
0.00000
4890.00
-
0.00000
4900.00 0.00000
4910.00 0.00000
4920.00 0.00000
4930.00
0.00000
4940.00
0.00000
4930.00
-
0.00000
4940.00
-
0.00000
4950.00 0.00000
4960.00 0.00000
4970.00 0.00000
4980.00
0.00000
4980.00
-
0.00000
4990.00 0.00000
5000.00 0.00000
5010.00 0.00000
...
...
@@ -307,16 +307,16 @@
5040.00 0.00000
5050.00 0.00000
5060.00 0.00000
5070.00
0.00000
5070.00
-
0.00000
5080.00 0.00000
5090.00 0.00000
5100.00
0.00000
5100.00
-
0.00000
5110.00 0.00000
5120.00 0.00000
5130.00 0.00000
5140.00
0.00000
5140.00
-
0.00000
5150.00 0.00000
5160.00
0.00000
5160.00
-
0.00000
5170.00 0.00000
5180.00 0.00000
5190.00 0.00000
...
...
@@ -327,22 +327,22 @@
5240.00 0.00000
5250.00 0.00000
5260.00 0.00000
5270.00
0.00000
5270.00
-
0.00000
5280.00 0.00000
5290.00
0.00000
5300.00
0.00000
5290.00
-
0.00000
5300.00
-
0.00000
5310.00 0.00000
5320.00 0.00000
5330.00 0.00000
5340.00
0.00000
5340.00
-
0.00000
5350.00 0.00000
5360.00 0.00000
5370.00
0.00000
5370.00
-
0.00000
5380.00 0.00000
5390.00
0.00000
5390.00
-
0.00000
5400.00 0.00000
5410.00 0.00000
5420.00
0.00000
5420.00
-
0.00000
5430.00 0.00000
5440.00 0.00000
5450.00 0.00000
...
...
@@ -352,10 +352,10 @@
5490.00 0.00000
5500.00 0.00001
5510.00 0.00001
5520.00 0.0000
2
5520.00 0.0000
1
5530.00 0.00002
5540.00 0.0000
2
5550.00 0.0000
2
5540.00 0.0000
3
5550.00 0.0000
3
5560.00 0.00002
5570.00 0.00001
5580.00 0.00001
...
...
@@ -367,7 +367,7 @@
5640.00 0.00000
5650.00 0.00000
5660.00 0.00000
5670.00
0.00000
5670.00
-
0.00000
5680.00 0.00000
5690.00 0.00000
5700.00 0.00000
...
...
@@ -379,11 +379,11 @@
5760.00 0.00001
5770.00 0.00002
5780.00 0.00002
5790.00 0.0000
3
5790.00 0.0000
2
5800.00 0.00004
5810.00 0.0000
4
5820.00 0.0000
4
5830.00 0.0000
3
5810.00 0.0000
5
5820.00 0.0000
5
5830.00 0.0000
4
5840.00 0.00002
5850.00 0.00001
5860.00 0.00001
...
...
@@ -392,11 +392,11 @@
5890.00 0.00000
5900.00 0.00000
5910.00 0.00000
5920.00
0.00000
5930.00
0.00000
5920.00
-
0.00000
5930.00
-
0.00000
5940.00 0.00000
5950.00
0.00000
5960.00
0.00000
5950.00
-
0.00000
5960.00
-
0.00000
5970.00 0.00000
5980.00 0.00000
5990.00 0.00000
...
...
@@ -406,498 +406,498 @@
6030.00 0.00000
6040.00 0.00000
6050.00 0.00000
6060.00
0.00000
6060.00
-
0.00000
6070.00 0.00000
6080.00 0.00000
6090.00
0.0000
0
6090.00
-
0.0000
1
6100.00 0.00000
6110.00 0.00000
6120.00 0.00000
6130.00 0.00000
6140.00
0.00000
6150.00
0.00000
6160.00
0.00000
6140.00
-
0.00000
6150.00
-
0.00000
6160.00
-
0.00000
6170.00 0.00000
6180.00 0.00000
6190.00 0.00000
6200.00 0.00000
6210.00 0.00000
6220.00 0.00000
6230.00
0.00000
6230.00
-
0.00000
6240.00 0.00000
6250.00 0.00000
6260.00 0.00000
6270.00 0.0000
0
6270.00 0.0000
1
6280.00 0.00000
6290.00 0.00000
6300.00
0.00000
6300.00
-
0.00000
6310.00 0.00000
6320.00 0.00000
6330.00 0.00000
6340.00 0.00000
6350.00
0.00000
6350.00
-
0.00000
6360.00 0.00000
6370.00 0.00000
6380.00 0.00000
6390.00 0.00000
6400.00 0.00000
6410.00
0.00000
6410.00
-
0.00000
6420.00 0.00000
6430.00 0.00000
6440.00
0.00000
6450.00
0.00000
6460.00 0.0000
0
6440.00
-
0.00000
6450.00
-
0.00000
6460.00 0.0000
1
6470.00 0.00000
6480.00 0.00000
6490.00 0.0000
0
6490.00 0.0000
1
6500.00 0.00000
6510.00 0.00000
6520.00 0.00000
6530.00 0.00000
6540.00 0.00000
6550.00
0.00000
6560.00
0.00000
6570.00
0.00000
6580.00
0.00000
6550.00
-
0.00000
6560.00
-
0.00000
6570.00
-
0.00000
6580.00
-
0.00000
6590.00 0.00000
6600.00 0.0000
0
6600.00 0.0000
1
6610.00 0.00000
6620.00
0.00000
6630.00
0.00000
6620.00
-
0.00000
6630.00
-
0.00000
6640.00 0.00000
6650.00 0.00000
6660.00
0.00000
6670.00
0.0000
0
6680.00
0.00000
6660.00
-
0.00000
6670.00
-
0.0000
1
6680.00
-
0.00000
6690.00 0.00000
6700.00 0.00000
6710.00
0.00000
6720.00
0.00000
6730.00 0.0000
0
6740.00
0.00000
6750.00
0.00000
6760.00
0.00000
6770.00
0.00000
6780.00
0.00000
6790.00
0.00000
6710.00
-
0.00000
6720.00
-
0.00000
6730.00 0.0000
1
6740.00
-
0.00000
6750.00
-
0.00000
6760.00
-
0.00000
6770.00
-
0.00000
6780.00
-
0.00000
6790.00
-
0.00000
6800.00 0.00000
6810.00 0.00000
6820.00 0.0000
0
6820.00 0.0000
1
6830.00 0.00000
6840.00
0.0000
0
6850.00
0.0000
0
6860.00
0.0000
0
6870.00 0.0000
0
6840.00
-
0.0000
1
6850.00
-
0.0000
1
6860.00
-
0.0000
1
6870.00 0.0000
1
6880.00 0.00000
6890.00 0.0000
0
6890.00 0.0000
1
6900.00 0.00000
6910.00
0.00000
6910.00
-
0.00000
6920.00 0.00000
6930.00 0.0000
0
6940.00
0.00000
6930.00 0.0000
1
6940.00
-
0.00000
6950.00 0.00000
6960.00 0.00000
6970.00 0.00000
6980.00
0.00000
6980.00
-
0.00000
6990.00 0.00000
7000.00 0.0000
0
7010.00
0.0000
0
7000.00 0.0000
1
7010.00
-
0.0000
1
7020.00 0.00000
7030.00 0.00000
7040.00 0.00000
7050.00 0.00000
7060.00
0.0000
0
7060.00
-
0.0000
1
7070.00 0.00000
7080.00 0.00000
7090.00 0.00000
7100.00 0.0000
0
7100.00 0.0000
1
7110.00 0.00000
7120.00 0.0000
0
7130.00
0.0000
0
7120.00 0.0000
1
7130.00
-
0.0000
1
7140.00 0.00000
7150.00
0.00000
7160.00
0.00000
7150.00
-
0.00000
7160.00
-
0.00000
7170.00 0.00000
7180.00 0.00000
7190.00
0.00000
7190.00
-
0.00000
7200.00 0.00000
7210.00
0.00000
7210.00
-
0.00000
7220.00 0.00000
7230.00 0.00000
7240.00 0.00000
7250.00 0.00000
7260.00
0.00000
7260.00
-
0.00000
7270.00 0.00000
7280.00
0.0000
0
7290.00
0.00000
7300.00
0.00000
7280.00
-
0.0000
1
7290.00
-
0.00000
7300.00
-
0.00000
7310.00 0.00000
7320.00
0.00000
7320.00
-
0.00000
7330.00 0.00000
7340.00 0.0000
0
7350.00
0.00000
7340.00 0.0000
1
7350.00
-
0.00000
7360.00 0.00000
7370.00 0.0000
0
7370.00 0.0000
1
7380.00 0.00000
7390.00 0.00000
7400.00 0.0000
0
7400.00 0.0000
1
7410.00 0.00000
7420.00
0.0000
0
7420.00
-
0.0000
1
7430.00 0.00000
7440.00
0.00000
7440.00
-
0.00000
7450.00 0.00000
7460.00
0.00000
7460.00
-
0.00000
7470.00 0.00000
7480.00
0.0000
0
7490.00
0.00000
7500.00
0.00000
7480.00
-
0.0000
1
7490.00
-
0.00000
7500.00
-
0.00000
7510.00 0.00000
7520.00 0.0000
0
7520.00 0.0000
1
7530.00 0.00000
7540.00 0.00000
7550.00
0.00000
7550.00
-
0.00000
7560.00 0.00000
7570.00 0.00000
7580.00 0.00000
7590.00 0.00000
7600.00
0.00000
7610.00
0.00000
7620.00
0.0000
0
7630.00
0.00000
7600.00
-
0.00000
7610.00
-
0.00000
7620.00
-
0.0000
1
7630.00
-
0.00000
7640.00 0.00000
7650.00 0.0000
0
7660.00 0.0000
0
7650.00 0.0000
1
7660.00 0.0000
1
7670.00 0.00000
7680.00 0.00000
7690.00 0.0000
0
7700.00 0.0000
0
7710.00
0.00000
7690.00 0.0000
1
7700.00 0.0000
1
7710.00
-
0.00000
7720.00 0.00000
7730.00 0.00000
7740.00
0.0000
0
7750.00
0.00000
7740.00
-
0.0000
1
7750.00
-
0.00000
7760.00 0.00000
7770.00
0.00000
7770.00
-
0.00000
7780.00 0.00000
7790.00 0.00000
7800.00
0.00000
7800.00
-
0.00000
7810.00 0.00000
7820.00
0.00000
7820.00
-
0.00000
7830.00 0.00000
7840.00
0.00000
7850.00
0.00000
7840.00
-
0.00000
7850.00
-
0.00000
7860.00 0.00000
7870.00
0.00000
7870.00
-
0.00000
7880.00 0.00000
7890.00 0.0000
0
7900.00 0.0000
0
7910.00 0.0000
0
7920.00 0.0000
0
7930.00
0.00000
7940.00
0.0000
0
7950.00
0.00000
7890.00 0.0000
1
7900.00 0.0000
1
7910.00 0.0000
1
7920.00 0.0000
1
7930.00
-
0.00000
7940.00
-
0.0000
1
7950.00
-
0.00000
7960.00 0.00000
7970.00 0.00000
7980.00 0.00000
7990.00
0.0000
0
8000.00 0.0000
2
8010.00 0.0000
3
8020.00 0.0000
3
8030.00 0.0000
3
8040.00 0.0000
3
8050.00 0.0000
4
8060.00
0.0000
4
8070.00
0.0000
5
8080.00 0.0000
7
8090.00 0.0000
8
8100.00
0.0000
9
8110.00 0.0001
3
8120.00 0.0001
8
8130.00 0.000
26
8140.00 0.000
4
0
8150.00 0.000
65
8160.00 0.00
11
2
8170.00 0.00
185
8180.00 0.00
305
8190.00 0.00
475
8200.00 0.00
7
04
8210.00 0.00
994
8220.00 0.0
1366
8230.00 0.0
1820
8240.00 0.0
2345
8250.00 0.0
3058
8260.00 0.0
39
00
8270.00 0.0
4796
8280.00 0.0
5876
8290.00 0.0
7147
8300.00 0.085
80
8310.00 0.
10118
8320.00 0.
11803
8330.00 0.
13528
8340.00 0.
15451
8350.00 0.
17500
8360.00 0.
19415
8370.00 0.
21555
8380.00 0.
23737
8390.00 0.2
613
4
8400.00 0.2
8959
8410.00 0.
31549
8420.00 0.3
4437
8430.00 0.3
7460
8440.00 0.4
0913
8450.00 0.4
3985
8460.00 0.
46810
8470.00 0.5
0016
8480.00 0.
52985
8490.00 0.
53965
8500.00 0.
54721
8510.00 0.5
5913
8520.00 0.5
6785
8530.00 0.5
7017
8540.00 0.5
70
30
8550.00 0.5
6308
8560.00 0.5
6262
8570.00 0.5
5976
8580.00 0.5
6087
8590.00 0.5
6322
8600.00 0.56
420
8610.00 0.5
7465
8620.00 0.5
8293
8630.00 0.5
8455
8640.00 0.58
646
8650.00 0.58
652
8660.00 0.5
9005
8670.00 0.5
9086
8680.00 0.5
9135
8690.00 0.5
9191
8700.00 0.5
9066
8710.00 0.5
8680
8720.00 0.5
8734
8730.00 0.5
8443
8740.00 0.5
8584
8750.00 0.5
8551
8760.00 0.5
8631
8770.00 0.5
7497
8780.00 0.5
6742
8790.00 0.5
6521
8800.00 0.5
6529
8810.00 0.5
6261
8820.00 0.5
5838
8830.00 0.5
5504
8840.00 0.5
5008
8850.00 0.5
4926
8860.00 0.5
5300
8870.00 0.5
5054
8880.00 0.54
841
8890.00 0.5
4389
8900.00 0.5
4021
8910.00 0.5
3897
8920.00 0.5
3684
8930.00 0.5
3275
8940.00 0.5
2614
8950.00 0.5
2261
8960.00 0.517
01
8970.00 0.5
1777
8980.00 0.
51666
8990.00 0.
50958
9000.00 0.
50
22
7
9010.00 0.4
9876
9020.00 0.4
9809
9030.00 0.4
9215
9040.00 0.4
8671
9050.00 0.4
8609
9060.00 0.4
8684
9070.00 0.4
8709
9080.00 0.4
8235
9090.00 0.4
7727
9100.00 0.4
73
71
9110.00 0.4
7099
9120.00 0.4
6685
9130.00 0.4
6190
9140.00 0.45
95
3
9150.00 0.4
5711
9160.00 0.4
5
40
2
9170.00 0.4
4954
9180.00 0.4
459
6
9190.00 0.4
3748
9200.00 0.4
3
25
8
9210.00 0.4
2686
9220.00 0.4
2501
9230.00 0.4
169
4
9240.00 0.4
1017
9250.00 0.
4069
0
9260.00 0.
40273
9270.00 0.
40115
9280.00 0.3
9850
9290.00 0.3
9300
9300.00 0.3
8771
9310.00 0.3
8511
9320.00 0.3
8115
9330.00 0.3
7657
9340.00 0.3
730
4
9350.00 0.3
7035
9360.00 0.36
799
9370.00 0.3
636
1
9380.00 0.3
6175
9390.00 0.3
5653
9400.00 0.3
5207
9410.00 0.3
4870
9420.00 0.3
4540
9430.00 0.3
4000
9440.00 0.3
3454
9450.00 0.3
3118
9460.00 0.3
2608
9470.00 0.3
2235
9480.00 0.31
854
9490.00 0.3
128
0
9500.00 0.30
897
9510.00 0.
30432
9520.00 0.
30050
9530.00 0.2
9516
9540.00 0.2
9060
9550.00 0.28
636
9560.00 0.2
8360
9570.00 0.2
8103
9580.00 0.27
826
9590.00 0.2
7258
9600.00 0.26
635
9610.00 0.2
6313
9620.00 0.2
602
4
9630.00 0.2
5426
9640.00 0.2
509
3
9650.00 0.24
7
15
9660.00 0.2
4534
9670.00 0.2
41
35
9680.00 0.23
866
9690.00 0.2
3333
9700.00 0.22
699
9710.00 0.2
2368
9720.00 0.21
986
9730.00 0.21
567
9740.00 0.2
1298
9750.00 0.20
891
9760.00 0.20
503
9770.00 0.
20208
9780.00 0.19
933
9790.00 0.1
9468
9800.00 0.1
9016
9810.00 0.18
6
28
9820.00 0.18
377
9830.00 0.1
8008
9840.00 0.176
7
6
9850.00 0.17
416
9860.00 0.1
7185
9870.00 0.16
854
9880.00 0.16
681
9890.00 0.1
6231
9900.00 0.15
922
9910.00 0.15
595
9920.00 0.1
5261
9930.00 0.14
979
9940.00 0.14
714
9950.00 0.14
405
9960.00 0.1
4113
9970.00 0.13
766
9980.00 0.13
428
9990.00 0.1
3036
10000.00 0.12
687
10010.00 0.12
353
10020.00 0.1
2086
10030.00 0.11
805
10040.00 0.11
48
7
10050.00 0.1
1219
10060.00 0.10
946
10070.00 0.10
670
10080.00 0.10
390
10090.00 0.
10063
10100.00 0.09
769
10110.00 0.09
469
10120.00 0.091
82
10130.00 0.08
876
10140.00 0.08
596
10150.00 0.08
345
10160.00 0.0
8038
10170.00 0.07
757
10180.00 0.07
45
4
10190.00 0.0
7143
10200.00 0.06
847
10210.00 0.06
625
10220.00 0.06
415
10230.00 0.06
172
10240.00 0.05
948
10250.00 0.05
752
10260.00 0.05
559
10270.00 0.05
34
2
10280.00 0.0
5111
10290.00 0.04
861
10300.00 0.04
624
10310.00 0.04
473
10320.00 0.04
3
23
10330.00 0.04
159
10340.00 0.0399
0
10350.00 0.03
83
6
10360.00 0.036
85
10370.00 0.034
95
10380.00 0.033
47
10390.00 0.031
79
10400.00 0.0
302
2
10410.00 0.02
92
2
10420.00 0.02
809
10430.00 0.026
8
7
10440.00 0.025
6
2
10450.00 0.024
58
10460.00 0.023
40
10470.00 0.022
43
10480.00 0.02
127
10490.00 0.019
98
10500.00 0.018
77
10510.00 0.018
4
3
10520.00 0.01
806
10530.00 0.01
774
10540.00 0.01
732
10550.00 0.01
701
10560.00 0.01
67
1
10570.00 0.01
628
10580.00 0.01
597
10590.00 0.01
558
10600.00 0.01
522
10610.00 0.01
479
10620.00 0.01
44
2
10630.00 0.01
400
10640.00 0.0
1363
10650.00 0.0
1319
10660.00 0.0
1273
10670.00 0.0
1234
10680.00 0.0
119
3
10690.00 0.0
1143
10700.00 0.0
1087
10710.00 0.0
1034
10720.00 0.00
980
10730.00 0.00
922
10740.00 0.00
860
10750.00 0.00
802
10760.00 0.00
742
10770.00 0.00
671
10780.00 0.00
610
10790.00 0.00
54
6
10800.00 0.00
478
10810.00 0.00
421
10820.00 0.00
366
10830.00 0.00
314
10840.00 0.00
267
10850.00 0.00
226
10860.00 0.00
189
10870.00 0.00
157
10880.00 0.00
130
10890.00 0.00
106
10900.00 0.000
85
10910.00 0.000
68
10920.00 0.000
54
10930.00 0.000
42
10940.00 0.000
32
10950.00 0.0002
4
10960.00 0.0001
7
10970.00 0.000
1
1
10980.00 0.0000
7
10990.00 0.0000
3
7990.00
-
0.0000
1
8000.00 0.0000
0
8010.00 0.0000
0
8020.00 0.0000
0
8030.00 0.0000
0
8040.00 0.0000
0
8050.00 0.0000
0
8060.00
-
0.0000
1
8070.00
-
0.0000
0
8080.00 0.0000
0
8090.00 0.0000
0
8100.00
-
0.0000
0
8110.00 0.000
0
1
8120.00 0.000
0
1
8130.00 0.000
00
8140.00 0.0000
1
8150.00 0.000
01
8160.00 0.00
00
2
8170.00 0.00
002
8180.00 0.00
002
8190.00 0.00
003
8200.00 0.00
0
04
8210.00 0.00
006
8220.00 0.0
0008
8230.00 0.0
0011
8240.00 0.0
0017
8250.00 0.0
0025
8260.00 0.000
39
8270.00 0.0
0061
8280.00 0.0
0099
8290.00 0.0
0166
8300.00 0.0
02
85
8310.00 0.
00503
8320.00 0.
00919
8330.00 0.
01725
8340.00 0.
03236
8350.00 0.
05797
8360.00 0.
09510
8370.00 0.
13780
8380.00 0.
17753
8390.00 0.2
109
4
8400.00 0.2
4084
8410.00 0.
27260
8420.00 0.3
1195
8430.00 0.3
6404
8440.00 0.4
2561
8450.00 0.4
8784
8460.00 0.
54363
8470.00 0.5
9114
8480.00 0.
61992
8490.00 0.
61842
8500.00 0.
60423
8510.00 0.5
9266
8520.00 0.5
7987
8530.00 0.5
6712
8540.00 0.5
58
30
8550.00 0.5
5096
8560.00 0.5
4763
8570.00 0.5
4913
8580.00 0.5
5235
8590.00 0.5
5664
8600.00 0.56
125
8610.00 0.5
6833
8620.00 0.5
7436
8630.00 0.5
7902
8640.00 0.58
299
8650.00 0.58
319
8660.00 0.5
8268
8670.00 0.5
8363
8680.00 0.5
8401
8690.00 0.5
8222
8700.00 0.5
7987
8710.00 0.5
7492
8720.00 0.5
6955
8730.00 0.5
7340
8740.00 0.5
7682
8750.00 0.5
7333
8760.00 0.5
6984
8770.00 0.5
6178
8780.00 0.5
5380
8790.00 0.5
4976
8800.00 0.5
4593
8810.00 0.5
4343
8820.00 0.5
4117
8830.00 0.5
3873
8840.00 0.5
3652
8850.00 0.5
3661
8860.00 0.5
3671
8870.00 0.5
3875
8880.00 0.54
060
8890.00 0.5
3635
8900.00 0.5
3179
8910.00 0.5
2536
8920.00 0.5
1858
8930.00 0.5
1559
8940.00 0.5
1230
8950.00 0.5
0724
8960.00 0.5
02
17
8970.00 0.5
0011
8980.00 0.
49817
8990.00 0.
49510
9000.00 0.
49
22
8
9010.00 0.4
8818
9020.00 0.4
8458
9030.00 0.4
7889
9040.00 0.4
7357
9050.00 0.4
7188
9060.00 0.4
7040
9070.00 0.4
6778
9080.00 0.4
6524
9090.00 0.4
6254
9100.00 0.4
59
71
9110.00 0.4
5903
9120.00 0.4
5812
9130.00 0.4
5533
9140.00 0.45
21
3
9150.00 0.4
4653
9160.00 0.440
66
9170.00 0.4
3580
9180.00 0.4
307
6
9190.00 0.4
2502
9200.00 0.4
19
25
9210.00 0.4
1491
9220.00 0.4
1062
9230.00 0.4
064
4
9240.00 0.4
0239
9250.00 0.
3985
0
9260.00 0.
39481
9270.00 0.
38929
9280.00 0.3
8395
9290.00 0.3
7996
9300.00 0.3
7613
9310.00 0.3
7305
9320.00 0.3
7002
9330.00 0.3
6793
9340.00 0.3
657
4
9350.00 0.3
6308
9360.00 0.36
032
9370.00 0.3
567
1
9380.00 0.3
5300
9390.00 0.3
4747
9400.00 0.3
4185
9410.00 0.3
3795
9420.00 0.3
3396
9430.00 0.3
3056
9440.00 0.3
2701
9450.00 0.3
2285
9460.00 0.3
1869
9470.00 0.3
1446
9480.00 0.31
021
9490.00 0.3
056
0
9500.00 0.30
103
9510.00 0.
29661
9520.00 0.
29221
9530.00 0.2
8771
9540.00 0.2
8323
9550.00 0.28
001
9560.00 0.2
7682
9570.00 0.2
7341
9580.00 0.27
004
9590.00 0.2
6531
9600.00 0.26
066
9610.00 0.2
5719
9620.00 0.2
536
4
9630.00 0.2
4921
9640.00 0.2
447
3
9650.00 0.2415
3
9660.00 0.2
3823
9670.00 0.235
01
9680.00 0.23
172
9690.00 0.2
2735
9700.00 0.22
295
9710.00 0.2
1906
9720.00 0.21
517
9730.00 0.21
174
9740.00 0.2
0825
9750.00 0.20
478
9760.00 0.20
127
9770.00 0.
19745
9780.00 0.19
364
9790.00 0.1
8975
9800.00 0.1
8593
9810.00 0.182
9
8
9820.00 0.18
005
9830.00 0.1
7683
9840.00 0.17
3
66
9850.00 0.17
060
9860.00 0.1
6757
9870.00 0.16
472
9880.00 0.16
188
9890.00 0.1
5847
9900.00 0.15
509
9910.00 0.15
213
9920.00 0.1
4916
9930.00 0.14
617
9940.00 0.14
316
9950.00 0.14
033
9960.00 0.1
3746
9970.00 0.13
395
9980.00 0.13
044
9990.00 0.1
2698
10000.00 0.12
351
10010.00 0.12
062
10020.00 0.1
1773
10030.00 0.11
491
10040.00 0.11
20
7
10050.00 0.1
0941
10060.00 0.10
675
10070.00 0.10
373
10080.00 0.10
071
10090.00 0.
09776
10100.00 0.09
482
10110.00 0.09
198
10120.00 0.0
8
91
5
10130.00 0.08
647
10140.00 0.08
379
10150.00 0.08
102
10160.00 0.0
7823
10170.00 0.07
544
10180.00 0.07
26
4
10190.00 0.0
6974
10200.00 0.06
683
10210.00 0.06
487
10220.00 0.06
289
10230.00 0.06
064
10240.00 0.05
839
10250.00 0.05
628
10260.00 0.05
417
10270.00 0.05
20
2
10280.00 0.0
4987
10290.00 0.04
760
10300.00 0.04
533
10310.00 0.04
385
10320.00 0.0423
6
10330.00 0.04
082
10340.00 0.039
2
9
10350.00 0.03
77
6
10360.00 0.036
24
10370.00 0.034
62
10380.00 0.033
01
10390.00 0.031
46
10400.00 0.0
299
2
10410.00 0.02
88
2
10420.00 0.02
773
10430.00 0.026
5
7
10440.00 0.025
4
2
10450.00 0.024
29
10460.00 0.023
16
10470.00 0.022
07
10480.00 0.02
096
10490.00 0.019
75
10500.00 0.018
55
10510.00 0.01
7
83
10520.00 0.01
712
10530.00 0.01
643
10540.00 0.01
574
10550.00 0.01
507
10560.00 0.01
44
1
10570.00 0.01
377
10580.00 0.01
313
10590.00 0.01
251
10600.00 0.01
190
10610.00 0.01
131
10620.00 0.01
07
2
10630.00 0.01
015
10640.00 0.0
0959
10650.00 0.0
0904
10660.00 0.0
0849
10670.00 0.0
0796
10680.00 0.0
074
3
10690.00 0.0
0691
10700.00 0.0
0640
10710.00 0.0
0589
10720.00 0.00
539
10730.00 0.00
489
10740.00 0.00
441
10750.00 0.00
394
10760.00 0.00
349
10770.00 0.00
305
10780.00 0.00
264
10790.00 0.00
22
6
10800.00 0.00
191
10810.00 0.00
159
10820.00 0.00
131
10830.00 0.00
107
10840.00 0.00
086
10850.00 0.00
068
10860.00 0.00
053
10870.00 0.00
041
10880.00 0.00
031
10890.00 0.00
023
10900.00 0.000
17
10910.00 0.000
12
10920.00 0.000
09
10930.00 0.000
06
10940.00 0.000
04
10950.00 0.000
0
2
10960.00 0.000
0
1
10970.00 0.000
0
1
10980.00 0.0000
0
10990.00 0.0000
0
11000.00 0.00000
ObservationSim/MockObject/CatalogBase.py
View file @
edd720e6
...
...
@@ -56,6 +56,8 @@ class CatalogBase(metaclass=ABCMeta):
"teff"
:
0.
,
"logg"
:
0.
,
"feh"
:
0.
,
"DM"
:
0.
,
"stellarMass"
:
1.
,
# C6 galaxies parameters
"e1"
:
0.
,
"e2"
:
0.
,
...
...
ObservationSim/MockObject/FlatLED.py
0 → 100755
View file @
edd720e6
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
ObservationSim/MockObject/Galaxy.py
View file @
edd720e6
import
numpy
as
np
import
galsim
import
os
,
sys
import
astropy.constants
as
cons
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.MockObject
import
MockObject
...
...
@@ -14,18 +11,6 @@ from ObservationSim.MockObject.MockObject import MockObject
class
Galaxy
(
MockObject
):
def
__init__
(
self
,
param
,
logger
=
None
):
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"
):
self
.
disk_sersic_idx
=
1.
...
...
@@ -76,7 +61,12 @@ class Galaxy(MockObject):
bulge_shape
=
galsim
.
Shear
(
g1
=
self
.
e1_bulge
,
g2
=
self
.
e2_bulge
)
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
)
if
fd_shear
is
not
None
:
g1
+=
fd_shear
.
g1
...
...
@@ -101,10 +91,6 @@ class Galaxy(MockObject):
if
self
.
logger
:
self
.
logger
.
error
(
e
)
return
2
,
None
nphotons_sum
=
0
photons_list
=
[]
xmax
,
ymax
=
0
,
0
# # [C6 TEST]
# print('hlr_disk = %.4f, hlr_bulge = %.4f'%(self.hlr_disk, self.hlr_bulge))
...
...
@@ -114,7 +100,7 @@ class Galaxy(MockObject):
if
self
.
hlr_disk
>
3.0
or
self
.
hlr_bulge
>
3.0
:
# Very big galaxy
big_galaxy
=
True
#
(TEST)
Galsim Parameters
#
Set
Galsim Parameters
if
self
.
getMagFilter
(
filt
)
<=
15
and
(
not
big_galaxy
):
folding_threshold
=
5.e-4
else
:
...
...
@@ -122,7 +108,7 @@ class Galaxy(MockObject):
gsp
=
galsim
.
GSParams
(
folding_threshold
=
folding_threshold
)
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_nominal
=
int
(
np
.
floor
(
x
+
0.5
))
...
...
@@ -130,9 +116,11 @@ class Galaxy(MockObject):
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
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_shape
=
galsim
.
Shear
(
g1
=
self
.
e1_disk
,
g2
=
self
.
e2_disk
)
disk
=
disk
.
shear
(
disk_shape
)
...
...
@@ -140,38 +128,42 @@ class Galaxy(MockObject):
bulge_shape
=
galsim
.
Shear
(
g1
=
self
.
e1_bulge
,
g2
=
self
.
e2_bulge
)
bulge
=
bulge
.
shear
(
bulge_shape
)
# Get shear and deal with shear induced by field distortion
if
fd_shear
:
g1
+=
fd_shear
.
g1
g2
+=
fd_shear
.
g2
gal_shear
=
galsim
.
Shear
(
g1
=
g1
,
g2
=
g2
)
# 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
)
# return False
continue
ratio
=
sub
/
full
if
not
(
ratio
==
-
1
or
(
ratio
!=
ratio
)):
nphotons
=
ratio
*
nphotons_tot
else
:
continue
nphotons_sum
+=
nphotons
# nphotons_sum += nphotons
# # [C6 TEST]
# 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
)
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
.
withFlux
(
nphotons
)
if
not
big_galaxy
:
# Not apply PSF for very big galaxy
gal_temp
=
galsim
.
Convolve
(
psf
,
gal_temp
)
...
...
@@ -186,47 +178,21 @@ class Galaxy(MockObject):
# kfrac = np.random.random()*(1.0 - self.bfrac)
# gal = self.bfrac * bulge + (1.0 - self.bfrac - kfrac) * disk + kfrac * knots
# # [C6 TEST]
# print('xmax = %d, ymax = %d '%(xmax, ymax))
# # Output memory usage
# snapshot = tracemalloc.take_snapshot()
# top_stats = snapshot.statistics('lineno')
# 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 = gal.drawImage(wcs=chip_wcs_local, method='phot', offset=offset, save_photons=True)
stamp
=
gal
.
drawImage
(
wcs
=
chip_wcs_local
,
offset
=
offset
)
if
np
.
sum
(
np
.
isnan
(
stamp
.
array
))
>
0
:
# ERROR happens
return
2
,
pos_shear
stamp
.
setCenter
(
x_nominal
,
y_nominal
)
bounds
=
stamp
.
bounds
&
galsim
.
BoundsI
(
0
,
chip
.
npix_x
-
1
,
0
,
chip
.
npix_y
-
1
)
if
bounds
.
area
()
>
0
:
chip
.
img
.
setOrigin
(
0
,
0
)
stamp
[
bounds
]
=
chip
.
img
[
bounds
]
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
[
bounds
]
+=
stamp
[
bounds
]
is_updated
=
1
chip
.
img
.
setOrigin
(
chip
.
bound
.
xmin
,
chip
.
bound
.
ymin
)
else
:
del
stamp
if
is_updated
==
0
:
# Return code 0: object photons missed this detector
print
(
"obj %s missed"
%
(
self
.
id
))
if
self
.
logger
:
...
...
@@ -235,8 +201,6 @@ class Galaxy(MockObject):
# # [C6 TEST]
# print("nphotons_sum = ", nphotons_sum)
del
photons_list
del
stamp
return
1
,
pos_shear
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):
names
=
(
'WAVELENGTH'
,
'FLUX'
))
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_nominal
=
int
(
np
.
floor
(
x
+
0.5
))
...
...
@@ -264,7 +228,7 @@ class Galaxy(MockObject):
dy
=
y
-
y_nominal
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
...
...
@@ -282,18 +246,40 @@ class Galaxy(MockObject):
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
]
# 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_shape
=
galsim
.
Shear
(
g1
=
self
.
e1_disk
,
g2
=
self
.
e2_disk
)
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_shape
=
galsim
.
Shear
(
g1
=
self
.
e1_bulge
,
g2
=
self
.
e2_bulge
)
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
# knots = galsim.RandomKnots(npoints=100, profile=disk)
...
...
@@ -306,14 +292,14 @@ class Galaxy(MockObject):
g2
+=
fd_shear
.
g2
gal_shear
=
galsim
.
Shear
(
g1
=
g1
,
g2
=
g2
)
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
gal
=
galsim
.
Convolve
(
psf
,
gal
)
# if fd_shear is not None:
# gal = gal.shear(fd_shear)
#
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
=
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
),
x_nominal
-
(
starImg
.
center
.
x
-
starImg
.
xmin
)]
...
...
@@ -335,12 +321,16 @@ class Galaxy(MockObject):
sdp_p1
=
SpecDisperser
(
orig_img
=
star_p1
,
xcenter
=
xcenter_p1
,
ycenter
=
ycenter_p1
,
origin
=
origin_p1
,
tar_spec
=
normalSED
,
band_start
=
ban
dpass
.
blue_limit
*
10
,
band_end
=
ban
dpass
.
red_limit
*
10
,
band_start
=
b
r
an
ge
[
0
]
,
band_end
=
b
r
an
ge
[
1
]
,
conf
=
chip
.
sls_conf
[
0
],
isAlongY
=
0
,
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
]]
star_p2
=
galsim
.
Image
(
subImg_p2
)
...
...
@@ -352,12 +342,16 @@ class Galaxy(MockObject):
sdp_p2
=
SpecDisperser
(
orig_img
=
star_p2
,
xcenter
=
xcenter_p2
,
ycenter
=
ycenter_p2
,
origin
=
origin_p2
,
tar_spec
=
normalSED
,
band_start
=
ban
dpass
.
blue_limit
*
10
,
band_end
=
ban
dpass
.
red_limit
*
10
,
band_start
=
b
r
an
ge
[
0
]
,
band_end
=
b
r
an
ge
[
1
]
,
conf
=
chip
.
sls_conf
[
1
],
isAlongY
=
0
,
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_p2
...
...
@@ -365,25 +359,33 @@ class Galaxy(MockObject):
sdp
=
SpecDisperser
(
orig_img
=
starImg
,
xcenter
=
x_nominal
-
0
,
ycenter
=
y_nominal
-
0
,
origin
=
origin_star
,
tar_spec
=
normalSED
,
band_start
=
ban
dpass
.
blue_limit
*
10
,
band_end
=
ban
dpass
.
red_limit
*
10
,
band_start
=
b
r
an
ge
[
0
]
,
band_end
=
b
r
an
ge
[
1
]
,
conf
=
chip
.
sls_conf
[
1
],
isAlongY
=
0
,
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
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
=
ban
dpass
.
blue_limit
*
10
,
band_end
=
ban
dpass
.
red_limit
*
10
,
band_start
=
b
r
an
ge
[
0
]
,
band_end
=
b
r
an
ge
[
1
]
,
conf
=
chip
.
sls_conf
[
0
],
isAlongY
=
0
,
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
# print(self.y_nominal, starImg.center.y, starImg.ymin)
del
psf
#
del psf
return
1
,
pos_shear
def
getGSObj
(
self
,
psf
,
g1
=
0
,
g2
=
0
,
flux
=
None
,
filt
=
None
,
tel
=
None
,
exptime
=
150.
):
...
...
@@ -404,46 +406,6 @@ class Galaxy(MockObject):
final
=
galsim
.
Convolve
(
psf
,
gal
)
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
):
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
ObservationSim/MockObject/MockObject.py
View file @
edd720e6
import
os
import
galsim
import
numpy
as
np
import
astropy.constants
as
cons
from
astropy
import
wcs
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
,
\
getABMAG
from
ObservationSim.MockObject.SpecDisperser
import
SpecDisperser
...
...
@@ -13,7 +15,6 @@ from ObservationSim.MockObject.SpecDisperser import SpecDisperser
class
MockObject
(
object
):
def
__init__
(
self
,
param
,
logger
=
None
):
self
.
param
=
param
for
key
in
self
.
param
:
setattr
(
self
,
key
,
self
.
param
[
key
])
...
...
@@ -27,14 +28,15 @@ class MockObject(object):
elif
self
.
param
[
"star"
]
==
3
:
self
.
type
=
"stamp"
###mock_stamp_END
###for calibration
elif
self
.
param
[
"star"
]
==
4
:
self
.
type
=
"calib"
###END
self
.
sed
=
None
self
.
fd_shear
=
None
# Place holder for outputs
self
.
additional_output_str
=
""
self
.
fd_shear
=
None
self
.
logger
=
logger
def
getMagFilter
(
self
,
filt
):
...
...
@@ -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
):
self
.
posImg
=
img
.
wcs
.
toImage
(
self
.
getPosWorld
())
self
.
localWCS
=
img
.
wcs
.
local
(
self
.
posImg
)
# Apply field distortion model
if
(
fdmodel
is
not
None
)
and
(
chip
is
not
None
):
if
verbose
:
print
(
"
\n
"
)
...
...
@@ -74,6 +77,7 @@ class MockObject(object):
if
verbose
:
print
(
"After field distortion:
\n
"
)
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
self
.
x_nominal
=
int
(
np
.
floor
(
x
+
0.5
))
self
.
y_nominal
=
int
(
np
.
floor
(
y
+
0.5
))
...
...
@@ -81,50 +85,22 @@ class MockObject(object):
dy
=
y
-
self
.
y_nominal
self
.
offset
=
galsim
.
PositionD
(
dx
,
dy
)
# Deal with chip rotation
if
chip_wcs
is
not
None
:
self
.
real
_wcs
=
chip_wcs
self
.
chip
_wcs
=
chip_wcs
elif
img_header
is
not
None
:
self
.
real
_wcs
=
galsim
.
FitsWCS
(
header
=
img_header
)
self
.
chip
_wcs
=
galsim
.
FitsWCS
(
header
=
img_header
)
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
):
img_global_pos
=
galsim
.
PositionD
(
global_x
,
global_y
)
cel_pos
=
img
.
wcs
.
toWorld
(
img_global_pos
)
realPos
=
img_real_wcs
.
toImage
(
cel_pos
)
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
,
exptime
=
150.
,
fd_shear
=
None
):
if
nphotons_tot
==
None
:
...
...
@@ -139,29 +115,27 @@ class MockObject(object):
self
.
logger
.
error
(
e
)
return
2
,
None
nphotons_sum
=
0
photons_list
=
[]
xmax
,
ymax
=
0
,
0
# (TEST) Galsim Parameters
# 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
.
real_wcs
)
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
real_wcs_local
=
self
.
real_wcs
.
local
(
self
.
real_pos
)
# Loop over all sub-bandpasses
for
i
in
range
(
len
(
bandpass_list
)):
bandpass
=
bandpass_list
[
i
]
try
:
...
...
@@ -170,61 +144,42 @@ class MockObject(object):
print
(
e
)
if
self
.
logger
:
self
.
logger
.
error
(
e
)
# return False
continue
ratio
=
sub
/
full
if
not
(
ratio
==
-
1
or
(
ratio
!=
ratio
)):
nphotons
=
ratio
*
nphotons_tot
else
:
# return False
continue
nphotons_sum
+=
nphotons
# nphotons_sum += 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
)
star
=
galsim
.
DeltaFunction
(
gsparams
=
gsp
)
star
=
star
.
withFlux
(
nphotons
)
star
=
galsim
.
Convolve
(
psf
,
star
)
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
)
# star = galsim.DeltaFunction(gsparams=gsp)
# star = star.withFlux(nphotons)
# star = galsim.Convolve(psf, star)
star
=
psf
.
withFlux
(
nphotons
)
chip
.
img
[
bounds
]
=
stamp
[
bounds
]
chip
.
img
.
setOrigin
(
chip
.
bound
.
xmin
,
chip
.
bound
.
ymin
)
else
:
# Return code 0: object photons missed this detector
stamp
=
star
.
drawImage
(
wcs
=
chip_wcs_local
,
offset
=
offset
)
if
np
.
sum
(
np
.
isnan
(
stamp
.
array
))
>
0
:
continue
stamp
.
setCenter
(
x_nominal
,
y_nominal
)
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
))
if
self
.
logger
:
self
.
logger
.
info
(
"obj %s missed"
%
(
self
.
id
))
return
0
,
pos_shear
del
photons_list
del
stamp
return
1
,
pos_shear
# Return code 1: draw sucesss
def
addSLStoChipImage
(
self
,
sdp
=
None
,
chip
=
None
,
xOrderSigPlus
=
None
,
local_wcs
=
None
):
...
...
@@ -275,9 +230,69 @@ class MockObject(object):
del
stamp
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
,
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
,
...
...
@@ -299,7 +314,7 @@ class MockObject(object):
names
=
(
'WAVELENGTH'
,
'FLUX'
))
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_nominal
=
int
(
np
.
floor
(
x
+
0.5
))
...
...
@@ -308,29 +323,45 @@ class MockObject(object):
dy
=
y
-
y_nominal
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
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
])
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
]
psf
,
pos_shear
=
psf_model
.
get_PSF
(
chip
=
chip
,
pos_img
=
pos_img
,
bandpass
=
bandpass
,
folding_threshold
=
folding_threshold
)
# 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)
star
=
galsim
.
DeltaFunction
(
gsparams
=
gsp
)
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
=
10
0
,
ny
=
10
0
,
wcs
=
real
_wcs_local
,
offset
=
offset
)
starImg
=
star
.
drawImage
(
nx
=
6
0
,
ny
=
6
0
,
wcs
=
chip
_wcs_local
,
offset
=
offset
)
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
...
...
@@ -345,12 +376,15 @@ class MockObject(object):
sdp_p1
=
SpecDisperser
(
orig_img
=
star_p1
,
xcenter
=
xcenter_p1
,
ycenter
=
ycenter_p1
,
origin
=
origin_p1
,
tar_spec
=
normalSED
,
band_start
=
ban
dpass
.
blue_limit
*
10
,
band_end
=
ban
dpass
.
red_limit
*
10
,
band_start
=
b
r
an
ge
[
0
]
,
band_end
=
b
r
an
ge
[
1
]
,
conf
=
chip
.
sls_conf
[
0
],
isAlongY
=
0
,
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
]]
star_p2
=
galsim
.
Image
(
subImg_p2
)
...
...
@@ -362,12 +396,15 @@ class MockObject(object):
sdp_p2
=
SpecDisperser
(
orig_img
=
star_p2
,
xcenter
=
xcenter_p2
,
ycenter
=
ycenter_p2
,
origin
=
origin_p2
,
tar_spec
=
normalSED
,
band_start
=
ban
dpass
.
blue_limit
*
10
,
band_end
=
ban
dpass
.
red_limit
*
10
,
band_start
=
b
r
an
ge
[
0
]
,
band_end
=
b
r
an
ge
[
1
]
,
conf
=
chip
.
sls_conf
[
1
],
isAlongY
=
0
,
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_p2
...
...
@@ -375,23 +412,29 @@ class MockObject(object):
sdp
=
SpecDisperser
(
orig_img
=
starImg
,
xcenter
=
x_nominal
-
0
,
ycenter
=
y_nominal
-
0
,
origin
=
origin_star
,
tar_spec
=
normalSED
,
band_start
=
ban
dpass
.
blue_limit
*
10
,
band_end
=
ban
dpass
.
red_limit
*
10
,
band_start
=
b
r
an
ge
[
0
]
,
band_end
=
b
r
an
ge
[
1
]
,
conf
=
chip
.
sls_conf
[
1
],
isAlongY
=
0
,
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
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
=
ban
dpass
.
blue_limit
*
10
,
band_end
=
ban
dpass
.
red_limit
*
10
,
band_start
=
b
r
an
ge
[
0
]
,
band_end
=
b
r
an
ge
[
1
]
,
conf
=
chip
.
sls_conf
[
0
],
isAlongY
=
0
,
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
psf
#
del psf
return
1
,
pos_shear
def
SNRestimate
(
self
,
img_obj
,
flux
,
noise_level
=
0.0
,
seed
=
31415
):
...
...
@@ -403,3 +446,88 @@ class MockObject(object):
sig_obj
=
np
.
std
(
stamp
.
array
)
snr_obj
=
img_flux
/
sig_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
ObservationSim/MockObject/SpecDisperser/SpecDisperser.py
View file @
edd720e6
...
...
@@ -155,7 +155,7 @@ class SpecDisperser(object):
sensitivity_beam
=
ysens
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
)
modelf
=
zeros
(
product
(
beam_sh
),
dtype
=
float
)
...
...
@@ -239,7 +239,7 @@ class SpecDisperser(object):
# else:
# 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
],
sensitivity_beam
[
nonz
],
modelf
,
x0
,
...
...
ObservationSim/MockObject/Stamp.py
View file @
edd720e6
import
os
,
sys
import
random
import
numpy
as
np
import
galsim
import
astropy.constants
as
cons
from
astropy.table
import
Table
from
scipy
import
interpolate
import
astropy.io.fits
as
fitsio
import
galsim
import
gc
from
ObservationSim.MockObject.MockObject
import
MockObject
from
ObservationSim.MockObject._util
import
magToFlux
,
VC_A
from
ObservationSim.MockObject.SpecDisperser
import
SpecDisperser
from
ObservationSim.MockObject._util
import
eObs
,
integrate_sed_bandpass
,
getNormFactorForSpecWithABMAG
,
getObservedSED
,
getABMAG
,
convolveGaussXorders
class
Stamp
(
MockObject
):
def
__init__
(
self
,
param
):
super
().
__init__
(
param
)
def
__init__
(
self
,
param
,
logger
=
None
):
super
().
__init__
(
param
,
logger
=
logger
)
def
unload_SED
(
self
):
"""(Test) free up SED memory
...
...
@@ -35,9 +30,9 @@ class Stamp(MockObject):
self
.
logger
.
error
(
e
)
return
False
nphotons_sum
=
0
photons_list
=
[]
xmax
,
ymax
=
0
,
0
#
nphotons_sum = 0
#
photons_list = []
#
xmax, ymax = 0, 0
if
self
.
getMagFilter
(
filt
)
<=
15
:
folding_threshold
=
5.e-4
...
...
@@ -46,7 +41,7 @@ class Stamp(MockObject):
gsp
=
galsim
.
GSParams
(
folding_threshold
=
folding_threshold
)
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_nominal
=
int
(
np
.
floor
(
x
+
0.5
))
...
...
@@ -55,72 +50,237 @@ class Stamp(MockObject):
dy
=
y
-
y_nominal
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
)):
bandpass
=
bandpass_list
[
i
]
try
:
sub
=
integrate_sed_bandpass
(
sed
=
self
.
sed
,
bandpass
=
bandpass
)
except
Exception
as
e
:
print
(
e
)
self
.
logger
.
error
(
e
)
# return False
if
self
.
logger
:
self
.
logger
.
error
(
e
)
continue
ratio
=
sub
/
full
if
not
(
ratio
==
-
1
or
(
ratio
!=
ratio
)):
nphotons
=
ratio
*
nphotons_tot
else
:
# return False
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
)
_gal
=
self
.
param
[
'image'
]
galIm
=
galsim
.
ImageF
(
_gal
,
scale
=
self
.
param
[
'pixScale'
])
gal
=
galsim
.
InterpolatedImage
(
galIm
)
gal
=
gal
.
withFlux
(
nphotons
)
#gal_shear = galsim.Shear(g1=g1, g2=g2)
#gal = gal.shear(gal_shear)
galImg
=
galsim
.
ImageF
(
_gal
,
scale
=
self
.
param
[
'pixScale'
])
gal_temp
=
galsim
.
InterpolatedImage
(
galImg
)
gal_temp
=
gal_temp
.
shear
(
gal_shear
)
gal_temp
=
gal_temp
.
withFlux
(
nphotons
)
gal
=
galsim
.
Convolve
(
psf
,
gal
)
if
fd_shear
is
not
None
:
gal
=
gal
.
shear
(
fd_shear
)
gal_temp
=
galsim
.
Convolve
(
psf
,
gal_temp
)
stamp
=
gal
.
drawImage
(
wcs
=
real_wcs_local
,
method
=
'phot'
,
offset
=
self
.
offset
,
save_photons
=
True
)
xmax
=
max
(
xmax
,
stamp
.
xmax
-
stamp
.
xmin
)
ymax
=
max
(
ymax
,
stamp
.
ymax
-
stamp
.
ymin
)
photons
=
stamp
.
photons
photons
.
x
+=
x_nominal
photons
.
y
+=
y_nominal
photons_list
.
append
(
photons
)
del
gal
if
i
==
0
:
gal
=
gal_temp
else
:
gal
=
gal
+
gal_temp
# 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
)
bounds
=
stamp
.
bounds
&
galsim
.
BoundsI
(
0
,
chip
.
npix_x
-
1
,
0
,
chip
.
npix_y
-
1
)
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
]
is_updated
=
1
chip
.
img
.
setOrigin
(
chip
.
bound
.
xmin
,
chip
.
bound
.
ymin
)
del
stamp
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
del
stamp
gc
.
collect
()
return
True
,
pos_shear
# print(self.y_nominal, starImg.center.y, starImg.ymin)
# del psf
return
1
,
pos_shear
ObservationSim/MockObject/__init__.py
View file @
edd720e6
...
...
@@ -4,5 +4,6 @@ from .CatalogBase import CatalogBase
from
.Quasar
import
Quasar
from
.Star
import
Star
from
.Stamp
import
Stamp
from
.FlatLED
import
FlatLED
# from .SkybackgroundMap import *
# from .CosmicRay import CosmicRay
ObservationSim/MockObject/_util.py
View file @
edd720e6
...
...
@@ -571,4 +571,14 @@ def convolveGaussXorders(img=None, sigma = 1):
convImg
=
signal
.
fftconvolve
(
img
,
psf
,
mode
=
'full'
,
axes
=
None
)
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
ObservationSim/MockObject/data/led/__init__.py
0 → 100644
View file @
edd720e6
ObservationSim/MockObject/data/led/__pycache__/__init__.cpython-38.pyc
0 → 100644
View file @
edd720e6
File added
ObservationSim/MockObject/data/led/model_1050nm.fits
0 → 100644
View file @
edd720e6
File added
ObservationSim/MockObject/data/led/model_275nm.fits
0 → 100644
View file @
edd720e6
File added
ObservationSim/MockObject/data/led/model_310nm.fits
0 → 100644
View file @
edd720e6
File added
ObservationSim/MockObject/data/led/model_340nm.fits
0 → 100644
View file @
edd720e6
File added
ObservationSim/MockObject/data/led/model_365nm.fits
0 → 100644
View file @
edd720e6
File added
ObservationSim/MockObject/data/led/model_430nm.fits
0 → 100644
View file @
edd720e6
File added
ObservationSim/MockObject/data/led/model_505nm.fits
0 → 100644
View file @
edd720e6
File added
ObservationSim/MockObject/data/led/model_545nm.fits
0 → 100644
View file @
edd720e6
File added
ObservationSim/MockObject/data/led/model_590nm.fits
0 → 100644
View file @
edd720e6
File added
Prev
1
2
3
4
5
6
7
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment