casa
$Rev:20696$
|
00001 # 00002 # This file was generated using xslt from its XML file 00003 # 00004 # Copyright 2009, Associated Universities Inc., Washington DC 00005 # 00006 import sys 00007 import os 00008 from casac import * 00009 import string 00010 from taskinit import casalog 00011 #from taskmanager import tm 00012 import task_simobserve 00013 def simobserve(project='sim', skymodel='', inbright='', indirection='', incell='', incenter='', inwidth='', complist='', compwidth='"8GHz"', setpointings=True, ptgfile='$project.ptg.txt', integration='10s', direction=[''], mapsize=['', ''], maptype='hexagonal', pointingspacing='', caldirection='', calflux='1Jy', obsmode='int', refdate='2014/01/01', hourangle='transit', totaltime='7200s', antennalist='', sdantlist='', sdant=0, thermalnoise='', user_pwv=1., t_ground=270., t_sky=260., tau0=0.1, seed=11111, leakage=0.0, graphics='both', verbose=False, overwrite=True): 00014 00015 """mosaic simulation task 00016 mosaic simulation task: 00017 00018 This task simulates interferometric observations (currently 00019 only ALMA can be done easily). New functionality is actively 00020 being added, so if you have changed versions of CASA, check 00021 the inputs carefully. 00022 More information and examples are availible at 00023 http://casaguides.nrao.edu/index.php?title=Simulating_Observations_in_CASA 00024 Please contact CASA experts with any questions, especially 00025 about features noted below as *experimental* 00026 ------------------------------- 00027 project -- root filename for all output files. 00028 ------------------------------- 00029 skymodel -- image model of the sky in FITS or CASA image, 00030 with optional parameters that can be overridden 00031 inbright -- peak brightness in Jy/pixel, or "" for unchanged 00032 * NOTE: "unchanged" will take the numerical values in your image 00033 and assume they are in Jy/pixel, even if it says some other unit 00034 in the header. 00035 indirection -- central direction, or "" for unchanged 00036 incell -- spatial pixel size, or "" for unchanged 00037 incenter -- frequency of center channel e.g. "89GHz", or "" for unchanged 00038 inwidth -- width of channels, or "" for unchanged - this should be a 00039 string representing a quantity with units e.g. "10MHz" 00040 * NOTE: only works reliably with frequencies, not velocities 00041 * NOTE: it is not possible to change the number of spectral planes 00042 of the sky model, only to relabel them with different frequencies 00043 That kind of regridding can be accomplished with the CASA toolkit. 00044 ------------------------------- 00045 complist -- component list model of the sky, added to or instead of skymodel 00046 compwidth -- bandwidth of components; if simulating from components only, 00047 this defines the bandwidth of the MS and output images 00048 ------------------------------- 00049 setpointings -- calculate a map of pointings, or if false, provide ptgfile 00050 * if graphics are on, display the pointings shown on the model image 00051 ptgfile -- a text file specifying directions in the following 00052 format, with optional integration times, e.g. 00053 #Epoch RA DEC TIME(optional) 00054 J2000 23h59m28.10 -019d52m12.35 10.0 00055 * if the time column is not present in the file, it will use 00056 "integration" for all pointings. 00057 * NOTE: at this time the file should contain only science pointings: 00058 simobserve will observe these, then optionally the calibrator, 00059 then the list of science pointings again, etc, until totaltime 00060 is used up. 00061 integration --- Time interval for each integration e.g '10s' 00062 * NOTE: to simulate a "scan" longer than one integration, use 00063 setpointings to generate a pointing file, and then edit the 00064 file to increase the time at each point to be larger than 00065 the parameter integration time. 00066 direction -- mosaic center direction e.g 'J2000 19h00m00 -40d00m00' 00067 * can optionally be a list of pointings 00068 * otherwise simobserve will pack mapsize according to maptype 00069 mapsize -- angular size of map 00070 * set to "" to span the model image 00071 maptype -- hexagonal, square (rectangular raster), 00072 "ALMA" for the same hex algorithm as the ALMA OT 00073 or "ALMA2012" for the algorithm used in the Cycle 0 OT 00074 pointingspacing -- spacing in between beams e.g '1arcsec' 00075 or "0.25PB" to use 1/4 of the primary beam FWHM, or 00076 "" will use Nyquist spacing, lambda/d/sqrt(3). 00077 ------------------------------- 00078 obsmode -- observation mode to calculate visibilities from skymodel (which 00079 may have been modified above, (optionally) complist, and $ptgfile (which 00080 may have been generated above) 00081 * this parameter takes two possible values: 00082 - interferometer (or i) 00083 - singledish (or s) 00084 * if graphics are on, display the array (like plotants), the uv 00085 coverage, the synthesized (dirty) beam, and ephemeris information 00086 * if simulating from component list, you should specify 00087 compwidth, the desired bandwidth - 00088 there is not currently a way to specify the spectrum of a component, 00089 so simulations from a componentlist only will be continuum (1 chan) 00090 refdate -- date of simulated observation eg: '2014/05/21' 00091 hourangle -- hour angle of observation e.g. '-3h' 00092 totaltime --- total time of observation e.g '7200s' or if a number without 00093 units, interpreted as the number of times to repeat the map 00094 antennalist -- ascii file containing antenna positions. 00095 each row has x y z coordinates and antenna diameter; 00096 header lines are required to specify the observatory name 00097 and coordinate system e.g. 00098 # observatory=ALMA 00099 # coordsys=UTM 00100 # datum=WGS84 00101 # zone=19 00102 * standard arrays are found in your CASA data repository, 00103 os.getenv("CASAPATH").split()[0]+"/data/alma/simmos/" 00104 * if "", will not not produce an interferometric MS 00105 * a string of the form "alma;0.5arcsec" will be parsed into a full 12m ALMA 00106 configuration. This only works for full ALMA and may fail to find the 00107 standard configuration files on some systems - see casaguides.nrao.edu 00108 caldirection -- *NEW* an unresolved calibrator can be observed 00109 interleaved with the science pointings. This feature is 00110 experimental, so please contact us with any questions. 00111 * The calibrator is implemented as a point source clean component 00112 with this direction and flux=calflux 00113 sdant -- the index of the antenna in the list to use for total 00114 power. defaults to the first antenna on the list. 00115 ------------------------------- 00116 thermalnoise -- add thermal noise 00117 * this parameter takes two possible values: 00118 - tsys-atm: J. Pardo's ATM library will be used to construct an 00119 atmospheric profile for the ALMA site: 00120 altitude 5000m, ground pressure 650mbar, relhum=20%, 00121 a water layer of user_pwv at altitude of 2km, 00122 the sky brightness temperature returned by ATM, 00123 and internally tabulated receiver temperatures 00124 - tsys-manual: instead of using the ATM model, specify the zenith 00125 sky brightness and opacity manually. Noise is added and then 00126 the visibility flux scale is referenced above the atmosphere. 00127 * In either mode, noise is calculated using an antenna spillover 00128 efficiency of 0.96, taper of 0.86, 00129 surface accuracy of 25 and 300 microns for ALMA and EVLA 00130 respectively (using the Ruze formula for surface efficiency), 00131 correlator efficiencies of 0.95 and 0.91 for ALMA and EVLA, 00132 receiver temperatures for ALMA of 00133 17, 30, 37, 51, 65, 83,147,196,175,230 K interpolated between 00134 35, 75,110,145,185,230,345,409,675,867 GHz, 00135 for EVLA of 00136 500, 70, 60, 55, 100, 130, 350 K interpolated between 00137 0.33,1.47,4.89,8.44,22.5,33.5,43.3 GHz, 00138 for SMA of 00139 67, 116, 134, 500 K interpolated between 00140 212.,310.,383.,660. GHz 00141 * These are only approximate numbers and do not take into account 00142 performance at edges of receiver bands, neither are they guaranteed 00143 to reflect the most recent measurements. Caveat emptor and use the 00144 sm tool to add noise if you want more precise control. 00145 t_ground -- ground/spillover temperature in K 00146 user_pwv -- precipitable water vapor if constructing an atmospheric model 00147 t_sky -- atmospheric temperature in K [for tsys-manual] 00148 tau0 -- zenith opacity at observing frequency [for tsys-manual] 00149 * see casaguides.nrao.edu for more information on noise, 00150 in particular how to add a phase screen using the toolkit 00151 seed -- random number seed for noise generation 00152 ------------------------------- 00153 leakage -- add cross polarization corruption of this fractional magnitude 00154 00155 graphics -- view plots on the screen, saved to file, both, or neither 00156 verbose -- print extra information to the logger and terminal 00157 overwrite -- overwrite existing files in the project subdirectory 00158 00159 00160 00161 ------------------------------- 00162 How to specify a model image: 00163 ------------------------------- 00164 * simobserve requires a CASA or fits image. If you merely have a grid of 00165 numbers, you will need to write them out as fits or write a CASA script to 00166 read them in and use the ia tool to create an image and insert the data. 00167 00168 * simobserve does NOT require a coordinate system in the header. If the 00169 coordinate information is incomplete, missing, or you would like to 00170 override it, set the appropriate "in" paremeters. 00171 In the absence of other information, simobserve will assume that the axes of 00172 your input correspond to RA, Dec, and (optionally) frequency and 00173 (optionally) Stokes parameter. 00174 00175 * If you have a proper Coordinate System, simobserve will do its best to 00176 generate visibilities from that, and then create a synthesis image 00177 according to the specified user parameters. Regridding the 00178 spectral dimension may not have complete flexibility yet. 00179 00180 * You can manipulate an image header with the "imhead" task, or you can 00181 delve deeper with the ia and cs tools. If you use the tools, you should 00182 be aware that a CoordinateSystem in CASA can exist independently of an 00183 Image. Once the CoordinateSystem is detached from the image, it is the 00184 user's responsibility to do any manipulation e.g. axis reordering on 00185 both. Example: 00186 ia.open("myimage_filename") 00187 ia.summary() # see header as attached to the image 00188 csys=ia.coordsys() # detach the CoordinateSystem 00189 csys.summary() # examine it 00190 csys.setreferencepixel([100,100]) 00191 arr=ia.getchunk() # get the data from the Image 00192 ia.done() 00193 csys.reorder([0,2,1]) # reorder the CoordinateSystem 00194 arr=arr.reorder([0,2,1]) # reorder the data 00195 ia.fromshape(outfile="mynewimage_file",shape=[32,32,256],csys=csys.torecord(),overwrite=True) 00196 # make a new image, with the right shape and CoordinateSystem 00197 ia.putchunk(arr) # put the data into the new image. 00198 csys.done() 00199 ia.done() 00200 00201 ------------------------------- 00202 Output produced: (not all will always exist, depending on input parameters) 00203 To support different runs with different arrays, the names have the 00204 configuration name from antennalist appended. 00205 ------------------------------- 00206 00207 project.[cfg].skymodel = 4d input sky model image (optionally) scaled 00208 project.[cfg].skymodel.flat.regrid.conv = input sky regridded to match the 00209 output image, and convolved with the output clean beam 00210 project.[cfg].skymodel.png = diagnostic figure of sky model with pointings 00211 00212 project.[cfg].ptg.txt = list of mosaic pointings 00213 project.[cfg].quick.psf = psf calculated from uv coverage 00214 project.[cfg].ms = noise-free measurement set 00215 project.[cfg].noisy.ms = corrupted measurement set 00216 project.[cfg].observe.png = diagnostic figure of uv coverage and 00217 visibilities 00218 00219 project.[cfg].simobserve.last = saved input parameters for simobserve task 00220 00221 00222 """ 00223 if type(direction)==str: direction=[direction] 00224 if type(mapsize)==str: mapsize=[mapsize] 00225 00226 # 00227 # The following is work around to avoid a bug with current python translation 00228 # 00229 mytmp = {} 00230 00231 mytmp['project'] = project 00232 mytmp['skymodel'] = skymodel 00233 mytmp['inbright'] = inbright 00234 mytmp['indirection'] = indirection 00235 mytmp['incell'] = incell 00236 mytmp['incenter'] = incenter 00237 mytmp['inwidth'] = inwidth 00238 mytmp['complist'] = complist 00239 mytmp['compwidth'] = compwidth 00240 mytmp['setpointings'] = setpointings 00241 mytmp['ptgfile'] = ptgfile 00242 mytmp['integration'] = integration 00243 mytmp['direction'] = direction 00244 mytmp['mapsize'] = mapsize 00245 mytmp['maptype'] = maptype 00246 mytmp['pointingspacing'] = pointingspacing 00247 mytmp['caldirection'] = caldirection 00248 mytmp['calflux'] = calflux 00249 mytmp['obsmode'] = obsmode 00250 mytmp['refdate'] = refdate 00251 mytmp['hourangle'] = hourangle 00252 mytmp['totaltime'] = totaltime 00253 mytmp['antennalist'] = antennalist 00254 mytmp['sdantlist'] = sdantlist 00255 mytmp['sdant'] = sdant 00256 mytmp['thermalnoise'] = thermalnoise 00257 mytmp['user_pwv'] = user_pwv 00258 mytmp['t_ground'] = t_ground 00259 mytmp['t_sky'] = t_sky 00260 mytmp['tau0'] = tau0 00261 mytmp['seed'] = seed 00262 mytmp['leakage'] = leakage 00263 mytmp['graphics'] = graphics 00264 mytmp['verbose'] = verbose 00265 mytmp['overwrite'] = overwrite 00266 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00267 trec = casac.utils().torecord(pathname+'simobserve.xml') 00268 00269 casalog.origin('simobserve') 00270 if trec.has_key('simobserve') and casac.utils().verify(mytmp, trec['simobserve']) : 00271 result = task_simobserve.simobserve(project, skymodel, inbright, indirection, incell, incenter, inwidth, complist, compwidth, setpointings, ptgfile, integration, direction, mapsize, maptype, pointingspacing, caldirection, calflux, obsmode, refdate, hourangle, totaltime, antennalist, sdantlist, sdant, thermalnoise, user_pwv, t_ground, t_sky, tau0, seed, leakage, graphics, verbose, overwrite) 00272 00273 else : 00274 result = False 00275 return result