411
411
- **EXAMPLE 8**: Simultaneous self-calibration and source fitting. We fit a source flux
412
412
density and perform Global Fringe Fitting (i.e., we fit for phases, delays, and delay
413
413
rates) in one shot. Let's fit stokes RR and assume that there are 3 antennas (for
414
simplicity), where "EB" and "FD" are going to be referred to, say, "LA":
416
416
>>> stokes = 'RR'
417
417
>>> model = ['delta']
418
>>> phase_gains = {1:'p[0] + 6.2832*(p[1]*(nu-nu0) + p[2]*t)',
419
>>> 2:'p[3] + 6.2832*(p[4]*(nu-nu0) + p[5]*t)'}
418
>>> phase_gains = {'nuG': {'EB':'p[0] + 6.2832*p[1]*(nu-nu0)',
419
>>> 'FD':'p[3] + 6.2832*p[4]*(nu-nu0)'},
420
>>> 'tG': {'EB':'p[2]*t', 'FD':'p[5]*t'}}
420
422
>>> var = '0,0,p[6]'
422
Good initial estimates for the phase gains can be obtained using the "QuinnFF" method.
424
Notice that "nuG" contains the part of the gains that depends on frequency ("nu"; being "nu0"
425
the lowest frequency in the dataset) and "tG" contains the part of the gains that depends on
426
time. Good initial estimates for the phase gains can be obtained using the "QuinnFF" method.
431
- **EXAMPLE 9**: Fit of a dataset with corrupted phases (and amplitudes) to a simple model
432
source with non-zero closures. If the structure is a double source:
434
>>> model = ['delta','delta']
435
>>> var = ['0,0,1','p[1],p[2],p[3]']
436
>>> phase_closure_Wgt = -1.0
437
>>> amp_closure_Wgt = -1.0
439
In this case, we **only** want to use the closure quantities in the fit (since the antenna
440
gains have been corrupted), so we set "phase_closure_Wgt" and "amp_closure_Wgt" both to a
441
*negative number*. If we would like to use closures **and** visibilities simultaneously, we
442
should set these parameters to positive numbers (which would be the *relative weights between
443
visibilities and closures*). Notice that (since the closures are insenstive to the absolute
444
flux scale and the absolute source position), one of the components has no position offset
445
and a normalized flux density. Hence, the parameters of the second source will be referred
446
to those of the first one.
871
900
UVMultiFit will only use closure information in the fit (i.e., the
872
901
contribution from the visibilities will be turned off).
874
**trispec_refants** : `list'
903
**trispec_refants** : `list`
875
904
List with the indiced of the antennas for which we have a reliable and robust amplitude
876
905
calibration. If the phase closures are being used in the fit, UVMultiFit will add the
877
906
contribution of the amplitudes of the trispectra associated to these antennas. This
4336
4365
if self.doClos and not self.onlyClos:
4337
4366
self.residuals(self.par2[2,:],-1,dof=False,doClos=False,onlyClos=False)
4338
4367
elif self.onlyClos:
4339
self.residuals(self.par2[2,:],-1,dof=False,doClos=True,onlyClos=True)
4368
self.residuals(self.par2[2,:],-1,dof=False,doClos=True,onlyClos=True,doDump=True)
4342
4371
# self.getPar2(mode=1)
4435
4464
# COMPUTE RESIDUALS FOR A MODEL REALIZATION
4438
def residuals(self,p,mode=-1,dof=True,doClos=False,onlyClos=True):
4467
def residuals(self,p,mode=-1,dof=True,doClos=False,onlyClos=True,doDump=False):
4439
4468
""" Compute the residuals, fixed model, and/or covariance matrix and Chi square.
4441
4470
This method has a wide and flexible usage, depending on the value of 'mode'
4456
4485
Whether closure quantities are taken into account to compute the Hessian and Gradient.
4457
4486
onlyClos : `bool`
4458
4487
Whether ONLY closure quantities are used.
4489
If True, writes the observed and (final) model closure quantities (if they are used
4490
in the fit) to a file.
4460
4492
The so-called 'output array' is the data that will be saved into the measurement set(s)
4461
4493
then the "writeModel" method of the parent UVMultiFit instance is called."""
4541
4573
self.varbuffer[0][0,i,:nnu] = tempvar[i]
4542
4574
# print self.varbuffer[0][0,i,:nnu]
4544
self.Ccompmodel(spw,nui,0,0)
4576
self.Ccompmodel(spw,nui,0,0,0,0)
4546
4578
self.imod[0] = modbackup
4671
4703
for i in range(len(tempvar)):
4672
4704
self.varbuffer[j+1][midx,i,0] = tempvar[i]
4674
ChiSq += self.Ccompmodel(spw,nui,mode,doClos,onlyClos)
4706
ChiSq += self.Ccompmodel(spw,nui,mode,doClos,onlyClos,doDump)