Commits
26 26 | def _checkinternalephemtab(vis, field): |
27 27 | """ |
28 28 | This function checks if there is an ephemeris table attached in the MS for |
29 29 | the field selected. It will returned table names found under FIELD table. |
30 30 | |
31 31 | """ |
32 32 | import glob |
33 33 | from casatools import table, ms |
34 34 | _tb = table() |
35 35 | _ms = ms() |
36 - | fids = _ms.msseltoindex(vis,field)['field'] |
37 - | _tb.open(msfile+'/FIELD') |
36 + | print(f'vis={vis}, field={field}') |
37 + | fids = _ms.msseltoindex(vis=vis,field=field)['field'] |
38 + | _tb.open(vis+'/FIELD') |
38 39 | ephemnames = [] |
39 - | if 'EPHEMERIS_ID' in tb.colnames(): |
40 + | if 'EPHEMERIS_ID' in _tb.colnames(): |
40 41 | for i in fids: |
41 42 | ephemid = _tb.getcell('EPHEMERIS_ID',i) |
42 43 | ephemnames.append(glob.glob(f'{vis}/FIELD/EPHEM{ephemid}*/')[0]) |
43 44 | _tb.close() |
44 45 | return list(set(ephemnames)) |
45 46 | |
46 47 | def fixplanets(vis, field, fixuvw=False, direction='', refant=0, reftime='first'): |
47 48 | """ |
48 49 | Fix FIELD, SOURCE, and UVW for given fields based on given direction or pointing |
49 50 | table information |
264 265 | thenewdec_rad = thedirmemod['m1']['value'] |
265 266 | _me.done() |
266 267 | shutil.rmtree(fixplanetstemp2, ignore_errors=True) |
267 268 | |
268 269 | else: # direction is not an empty string, use this instead of the pointing table information |
269 270 | if(type(direction)==str): |
270 271 | dirstr = direction.split(' ') |
271 272 | if len(dirstr)==1: # an ephemeris table was given |
272 273 | if(os.path.exists(dirstr[0])): |
273 274 | if os.path.isfile(dirstr[0]): # it is a file, i.e. not a CASA table |
274 - | msg = "*** Error when interpreting parameter \'direction\':\n File is given. Use of the JPL email mime format file is deplicated." |
275 - | |
275 + | msg = "*** Error when interpreting parameter \'direction\':\n A file is given. Use of the JPL-Horizons "+\ |
276 + | "MIME format file is deprecated." |
276 277 | raise RuntimeError(msg) |
277 278 | else: # not a file, assume it is a CASA table |
278 279 | theephemeris = dirstr[0] |
279 280 | # add a check if it is going to replace the existing table in the MS |
280 281 | existingephemtab = _checkinternalephemtab(vis, field) |
281 282 | if existingephemtab != []: |
282 - | casalog.post(f'Will replace existing ephemeris table(s) {existingephemtab} in the MS, which \ |
283 - | is the one used by correlator. This may result in scientifically wrong result.','WARN') |
283 + | casalog.post(f'Will replace existing ephemeris table {existingephemtab} in the MS with {direction}. '+\ |
284 + | 'Ephemeris tables attached in the MS are assumed to be the ones used by the correlator and attaching' +\ |
285 + | ' a different ephemeris table may lead to scientifically wrong results.','WARN') |
286 + | |
284 287 | casalog.post('Will use ephemeris table '+theephemeris+' with offset (0,0)', 'NORMAL') |
285 288 | |
286 289 | thenewra_rad = 0. |
287 290 | thenewdec_rad = 0. |
288 291 | |
289 292 | else: |
290 293 | msg = "*** Error when interpreting parameter \'direction\':\n string is neither a direction nor a table." |
291 294 | raise RuntimeError(msg) |
292 295 | else: |
293 296 | if len(dirstr)==2: # a direction without ref frame was given |
435 438 | newsra_rad = trec['m0']['value'] |
436 439 | newsdec_rad = trec['m1']['value'] |
437 440 | mst.close() |
438 441 | tbt.open(vis+'/SOURCE', nomodify=False) |
439 442 | sdir = tbt.getcol('DIRECTION') |
440 443 | newsdir = sdir |
441 444 | sname = tbt.getcol('NAME') |
442 445 | |
443 446 | for i in range(0,tbt.nrows()): |
444 447 | if(sname[i]==planetname): |
445 - | # casalog.post('i old dir ' + i + " " + sdir[0][i] + sdir[1][i]) |
448 + | #casalog.post('i old dir ' + i + " " + sdir[0][i] + sdir[1][i]) |
446 449 | newsdir[0][i] = newsra_rad |
447 450 | newsdir[1][i] = newsdec_rad |
448 - | # casalog.post(' new dir ' + newsdir[0][i] + newsdir[1][i]) |
451 + | #casalog.post(' new dir ' + newsdir[0][i] + newsdir[1][i]) |
449 452 | tbt.putcol('DIRECTION', newsdir) |
450 453 | tbt.close() |
451 454 | casalog.post("SOURCE table DIRECTION column changed.", 'NORMAL') |
452 455 | |
453 456 | # end for |
454 457 | |
455 458 | if(fixuvw): |
456 459 | casalog.post("Fixing the UVW coordinates ...", 'NORMAL') |
457 460 | |
458 461 | # similar to fixvis |