Commits
Takeshi Nakazato authored and Ville Suoranta committed 974414231b5 Merge
139 139 | |
140 140 | def gencal(cls, vis=None, caltable=None, caltype=None, infile='None', |
141 141 | endpoint='asdm', timeout=180, retry=3, retry_wait_time=5, |
142 142 | spw=None, antenna=None, pol=None, |
143 143 | parameter=None, uniform=None): |
144 144 | """Generate calibration table.""" |
145 145 | try: |
146 146 | # don't need scr col for this |
147 147 | _cb.open(filename=vis, compress=False, addcorr=False, addmodel=False) |
148 148 | |
149 - | for selection, param in \ |
150 - | JyperkGencal.__gen_specifycal_input(vis=vis, spw=spw, |
151 - | endpoint=endpoint, infile=infile, |
152 - | timeout=timeout, retry=retry, |
153 - | retry_wait_time=retry_wait_time): |
154 - | |
149 + | specifycal_input_list = cls.__gen_specifycal_input( |
150 + | vis=vis, |
151 + | spw=spw, |
152 + | endpoint=endpoint, |
153 + | infile=infile, |
154 + | timeout=timeout, |
155 + | retry=retry, |
156 + | retry_wait_time=retry_wait_time |
157 + | ) |
158 + | for selection, param in specifycal_input_list: |
159 + | pol = cls.__convert_to_pol_selection(polspec=selection['pol']) |
155 160 | _cb.specifycal(caltable=caltable, time='', spw=selection['spw'], |
156 - | caltype='amp', antenna=selection['antenna'], # pol=selection['pol'], |
161 + | caltype='amp', antenna=selection['antenna'], pol=pol, |
157 162 | parameter=param, infile='', uniform=uniform) |
158 163 | |
159 164 | except UserWarning as instance: |
160 165 | casalog.post('*** UserWarning *** %s' % instance, 'WARN') |
161 166 | |
162 167 | finally: |
163 168 | _cb.close() |
164 169 | |
165 170 | |
166 171 | def __gen_specifycal_input(cls, vis=None, spw='*', |
196 201 | yield selection, 1/np.sqrt(float(factor[4])) |
197 202 | |
198 203 | |
199 204 | def __extract_valid_factor(cls, factors, vis_key): |
200 205 | valid_factors = [] |
201 206 | for factor in factors: |
202 207 | if factor[0] == vis_key: |
203 208 | valid_factors.append(factor) |
204 209 | return valid_factors |
205 210 | |
211 + | |
212 + | def __convert_to_pol_selection(cls, polspec: str) -> str: |
213 + | if polspec in ['I', '']: |
214 + | # apply the value to all polarizations |
215 + | pol = '' |
216 + | elif polspec in ['XX', 'YY', 'RR', 'LL']: |
217 + | pol = polspec[0] |
218 + | else: |
219 + | # unexpected value, no pol selection applied |
220 + | pol = '' |
221 + | |
222 + | return pol |
223 + | |
206 224 | |
207 225 | __gencal_factory = { |
208 226 | 'general': GeneralGencal, |
209 227 | 'antpos': AntposGencal, |
210 228 | 'jyperk': JyperkGencal, |
211 229 | } |