Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.mrao.cam.ac.uk/~bn204/alma/memo-turb/imagingsim.py
Дата изменения: Fri Aug 10 20:17:35 2012
Дата индексирования: Tue Oct 2 10:42:16 2012
Кодировка:

Поисковые слова: система координат галактическая
# Bojan Nikolic ,
#
# Initial version October 2007
# Updates 2008
#
# Simulations of imaging with turbulent screens

import os
import pyfits

import uvblow
import uvfits
import uvfits_cal
import imagingsim_utils

import iofits4

def SnapshotMovie():

"Illustrate effect of a screen blowin across"

fnamein="../casasim/base/pointsrc.ms.fits"
screenname="temp/t4.fits"

for t in range(0, 2000, 180.0) :
uvblow.BlowSimple(fnamein,
screenname,
6,
6,
"../casasim/windmovie/pint-t%g.ms.fits" % t,
phasescale=4.0,
toffset=t)


def LongInteg():

"A 50 min obs with 10s integrations"

fnamein="../casasim/base/longobs.ms.fits"
screenname="temp/t4.fits"

for s in [0, 2, 4, 6]:
uvblow.BlowSimple(fnamein,
screenname,
6,
6,
"../casasim/longint/p-s%g.ms.fits" % s,
phasescale=s,
toffset=0)

if 0:
# whoops, don't wont to put the low dec source in same
# directory, will confuse the reduce-all-in-directory approach
fnamein="../casasim/base/lowlongobs.ms.fits"
screenname="temp/t4.fits"

for s in [0, 4]:
uvblow.BlowSimple(fnamein,
screenname,
6,
6,
"../casasim/longint/p-l-s%g.ms.fits" % s,
phasescale=s,
toffset=0)

def LongIntObliq():

fnamein="../casasim/base/longobs.ms.fits"
screenname="temp/y-long-screen.fits"

for s in [0, 4]:
uvblow.BlowSimple(fnamein,
screenname,
6,
6,
"../casasim/longint/p-y-s%g.ms.fits" % s,
phasescale=s,
toffset=0,
dc="y")

def Switched():

for conf,s in [ ("short", 4) , ("mid", 1.5) ] :

fnamein="../casasim/base/%sswitch.ms.fits" % conf
fnw="../casasim/switch/%sswitch.ms.fits" % conf

screenname="temp/t5.fits"

# This is no-op with the screen scaled to zero
uvblow.BlowSimple(fnamein,
screenname,
6,
0.1, # wind speed doesn't matter here
fnw,
phasescale=0,
toffset=0)

for ws in [ 0.1 , 0.5, 1.0, 5, 10]:

fw="../casasim/switch/%sswitch-w%g.ms.fits" % ( conf , ws)
fwc="../casasim/switch/%sswitch-w%g-cal.ms.fits" % ( conf, ws)

# For this to make sense on a compact array, the wind needs to be
# ridiculously slow... w*300s < 70 , pick 0.1
uvblow.BlowSimple(fnamein,
screenname,
6,
ws,
fw,
phasescale=s,
toffset=0)

uvfits.AntennaPhaseCalibrate( fw,
fwc,
[1,3])

def ThicknessSwitch():

"Different thicknesses of turbulent layer on switched obs"

uvfnamein="../casasim/base/midswitch.ms.fits"
ws=12
s=2.0

for t in [ 1, 9, 33, 129, 513 ] :
screenname="temp/ts_%g.fits" % t

fw="../casasim/tsw/mid-%g-%g-%gw.ms.fits" % (t, s* 10, ws)
fwc="../casasim/tsw/mid-%g-%g-%gw-cal.ms.fits" % (t, s*10, ws)

sf=pyfits.open(screenname)

uvblow.BlowSimple(uvfnamein,
screenname,
6,
ws,
fw,
phasescale=s/float(sf[0].header["dz"]),
toffset=0)

uvfits.AntennaPhaseCalibrate( fw,
fwc,
[1,3])


def FluctMagnitude():

"""
Do the first obvioius systematic test: crank up the fluctuations
and see what happens
"""

uvfnamein="../casasim/base/MidLong.ms.fits"
ws=12.0
pixelscale=24.0

for t in [ 1, 9, 33, 129 ] :

screenname="temp/ts_%g.fits" % t
sf=pyfits.open(screenname)

for s in [0.1, 0.5, 1.0, 2.0 , 5.0, 10 ] :

fw="../casasim/mids/mid-%g-%g-%gw.ms.fits" % (t, s* 10, ws)
uvblow.BlowSimple(uvfnamein,
screenname,
pixelscale,
ws,
fw,
phasescale=s/float(sf[0].header["dz"]),
toffset=0)

iofits4.AddKeyword( fw,
"RMS300",
uvblow.BaselineRMS(uvfnamein,
screenname,
pixelscale,
ws,
300,
phasescale=s/float(sf[0].header["dz"])))

def SmallFluctMagnitude():


uvfnamein="../casasim/base/SmallLong.ms.fits"
ws=12.0
pixelscale=24.0

tsarray = [ [ 1, [ 0.3, 1.0, 5.0 , 10.0 , 20.0 ] ],
[ 9, [ 0.3, 1.0, 5.0 , 10.0 , 20.0 ] ],
[ 33,[ 1.0, 5.0 , 10.0 , 20.0 , 50.0 ]],
[129, [5.0 , 10.0 , 20.0 , 50.0, 100.0] ]]

for t,sl in tsarray:

screenname="temp/ts_%g.fits" % t
sf=pyfits.open(screenname)

for s in sl:

fw="../casasim/shorts/long-%g-%g-%gw.ms.fits" % (t, s* 10, ws)
uvblow.BlowSimple(uvfnamein,
screenname,
pixelscale,
ws,
fw,
phasescale=s/float(sf[0].header["dz"]),
toffset=0)

iofits4.AddKeyword( fw,
"RMS300",
uvblow.BaselineRMS(uvfnamein,
screenname,
pixelscale,
ws,
300,
phasescale=s/float(sf[0].header["dz"])))




def BigFluctMagnitude():

uvfnamein="../casasim/base/BigLong.ms.fits"
ws=12.0
pixelscale=48.0

# Defines the simulations to run
simlist = [ [ 1 ,
[0.01, 0.05, 0.1, 0.5 , 1.0, 2.0, 4.0 ] ],
[ 9,
[0.01, 0.05, 0.1, 0.5 , 1.0, 2.0, 4.0 ] ],
[ 33,
[0.01, 0.05, 0.1, 0.5 , 1.0, 2.0, 4.0 ] ],
[ 129,
[0.1, 0.5 , 1.0, 2.0, 4.0, 8.0 ] ]]

for t,slist in simlist:

screenname="temp/ts_%g.fits" % t
sf=pyfits.open(screenname)

for s in slist:

fw="../casasim/longs/long-%g-%g-%gw.ms.fits" % (t, s* 10, ws)
uvblow.BlowSimple(uvfnamein,
screenname,
pixelscale,
ws,
fw,
phasescale=s/float(sf[0].header["dz"]),
toffset=0)

iofits4.AddKeyword( fw,
"RMS300",
uvblow.BaselineRMS(uvfnamein,
screenname,
pixelscale,
ws,
300,
phasescale=s/float(sf[0].header["dz"])))

def LongCalibratedSwitched(conf,
s=1,
pixelscale=24.0,
t = 9 ,
offset=False,
cycle="short"
):

"""Simulate phase corruption for a long switched observation

:param conf: Configuration, see imagingsim_utils for options.
"""

uvfnamein=imagingsim_utils.SWBaseFName( conf=conf,
cycle=cycle)
ws=12.0

screenname="temp/ts_%g_t.fits" % t

fw, cal, fwc = imagingsim_utils.SWCorruptName( conf=conf,
cycle=cycle,
t=t, s=s, ws=ws, offset=offset)
print "Processing ", fw
sf=pyfits.open(screenname)

rms300=uvblow.BaselineRMS(uvfnamein,
screenname,
pixelscale,
ws,
300,
phasescale=s/float(sf[0].header["dz"]))
if not offset:
uvblow.BlowSimple(uvfnamein,
screenname,
float(pixelscale),
ws,
fw,
phasescale=s/float(sf[0].header["dz"]),
toffset=0)
else:
uvblow.BlowMultiSource( uvfnamein,
{ 1 : ("temp/ts_%g_offset_t.fits" % t),
2 : ("temp/ts_%g_t.fits" % t) },
float(pixelscale),
ws,
fw,
phasescale=s/float(sf[0].header["dz"]), )


uvfits_cal.RecordAntennaPhaseSolutions( fw,
cal,
1)
uvfits_cal.CorrectPhaseSimple( fw,
cal,
fwc)

for x in [fw, fwc]:
iofits4.AddKeyword( x,
"RMS300",
rms300)

def GenMidSW(offset=False,
cycle="short"):

tsarray = [ [ 1, [ 0.3, 1.0, 5.0 , 10.0 , 20.0 ] ],
[ 9, [ 0.3, 1.0, 5.0 , 10.0 , 20.0 ] ],
[ 33,[ 1.0, 5.0 , 10.0 , 20.0 , 50.0 ]],
[129, [5.0 , 10.0 , 20.0 , 50.0, 100.0] ]]

for t, sl in tsarray:
for s in sl:
LongCalibratedSwitched("mid", s=s,
pixelscale=24.0,
t=t,
offset=offset,
cycle=cycle)

def GenSmallSW(offset=False):

tsarray = [ [ 1, [ 0.3, 1.0, 5.0 , 10.0 , 20.0 ] ],
[ 9, [ 0.3, 1.0, 5.0 , 10.0 , 20.0 ] ],
[ 33,[ 1.0, 5.0 , 10.0 , 20.0 , 50.0 ]],
[129, [5.0 , 10.0 , 20.0 , 50.0, 100.0] ]]

for t, sl in tsarray:
for s in sl:
LongCalibratedSwitched("comp",
s=s,
pixelscale=24.0,
t=t,
offset=offset)

def GenLongSW(offset=False):

tsarray = [ [ 1, [ 0.3, 1.0, 5.0 , 10.0 , 20.0 ] ],
[ 9, [ 0.3, 1.0, 5.0 , 10.0 , 20.0 ] ],
[ 33,[ 1.0, 5.0 , 10.0 , 20.0 , 50.0 ]],
[129, [1.0, 5.0 , 10.0 , 20.0 , 50.0, 100.0] ]]

for t, sl in tsarray:
for s in sl:
LongCalibratedSwitched("ext",
s=s,
pixelscale=48.0,
t=t,
offset=offset)

# sample session

#ReGenThickness()
#TransposeScreens()
#GenLongSW()
#SwitchedDirDirtyMaps("/import/appcs/bn204/n/almawvr/casasim/longsw/")