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_simalma 00013 def simalma(project='sim', skymodel='', inbright='', indirection='', incell='', incenter='', inwidth='', complist='', compwidth='"8GHz"', setpointings=True, ptgfile='$project.ptg.txt', integration='10s', direction=[''], mapsize=['', ''], antennalist='alma_cycle1_1.cfg', hourangle='transit', totaltime='7200s', acaratio=0.0, acaconfig='', pwv=0.0, image=True, imsize=[128, 128], imdirection='', cell='', niter=500, threshold='0.1mJy', graphics='both', verbose=False, overwrite=False): 00014 00015 """(Experimental) simple simulation task for ALMA 00016 ALMA simulation task: 00017 00018 ##### WARNING: This task is EXPERIMENTAL ##### 00019 This task simulates ALMA observation including 12-m, ACA 7-m and total 00020 power arrays, and images and analyzes simulated data. 00021 New functionality is actively being added, so if you have changed 00022 versions of CASA, check the inputs carefully. 00023 More information and examples are availible at 00024 http://casaguides.nrao.edu/index.php?title=Simulating_Observations_in_CASA 00025 Please contact CASA experts with any questions, especially 00026 about features noted below as *experimental* 00027 ------------------------------- 00028 project -- root filename for all output files. 00029 ------------------------------- 00030 skymodel -- image model of the sky in FITS or CASA image, 00031 with optional parameters that can be overridden 00032 inbright -- peak brightness in Jy/pixel, or "" for unchanged 00033 * NOTE: "unchanged" will take the numerical values in your image 00034 and assume they are in Jy/pixel, even if it says some other unit 00035 in the header. 00036 indirection -- central direction, or "" for unchanged 00037 incell -- spatial pixel size, or "" for unchanged 00038 incenter -- frequency of center channel e.g. "89GHz", or "" for unchanged 00039 inwidth -- width of channels, or "" for unchanged - this should be a 00040 string representing a quantity with units e.g. "10MHz" 00041 * NOTE: only works reliably with frequencies, not velocities 00042 * NOTE: it is not possible to change the number of spectral planes 00043 of the sky model, only to relabel them with different frequencies 00044 That kind of regridding can be accomplished with the CASA toolkit. 00045 ------------------------------- 00046 complist -- component list model of the sky, added to or instead of skymodel 00047 compwidth -- bandwidth of components; if simulating from components only, 00048 this defines the bandwidth of the MS and output images 00049 ------------------------------- 00050 setpointings -- calculate a map of pointings, or if false, provide ptgfile 00051 * if graphics are on, display the pointings shown on the model image 00052 ptgfile -- a text file specifying directions in the same 00053 format as the example, and optional integration times, e.g. 00054 #Epoch RA DEC TIME(optional) 00055 J2000 23h59m28.10 -019d52m12.35 10.0 00056 * if the time column is not present in the file, it will use 00057 "integration" for all pointings. 00058 * NOTE: at this time the file should contain only science pointings: 00059 simalma will observe these until totaltime is used up. 00060 integration --- Time interval for each integration e.g '10s' 00061 * NOTE: to simulate a "scan" longer than one integration, use 00062 setpointings to generate a pointing file, and then edit the 00063 file to increase the time at each point to be larger than 00064 the parameter integration time. 00065 direction -- mosaic center direction e.g 'J2000 19h00m00 -40d00m00' 00066 * can optionally be a list of pointings 00067 * otherwise simalma will pack mapsize with grids proper for the 00068 array (see below). 00069 mapsize -- angular size of map 00070 * set to "" to span the model image 00071 ------------------------------- 00072 antennalist -- ascii file containing antenna positions. 00073 * NOTE: In this task, it should be an ALMA configuration. 00074 * standard arrays are found in your CASA data repository, 00075 os.getenv("CASAPATH").split()[0]+"/data/alma/simmos/" 00076 * a string of the form "alma;0.5arcsec" will be parsed into a full 12m ALMA 00077 configuration. This only works for full ALMA and may fail to find the 00078 standard configuration files on some systems - see casaguides.nrao.edu 00079 hourangle -- hour angle of observation e.g. '-3h' 00080 totaltime --- total time of observation e.g '7200s' or if a number without 00081 units, interpreted as the number of times to repeat the map 00082 acaratio --- ratio of the total observation time of ACA relative to 00083 that of 12m array. Set 0 for no ACA observation. 00084 For Cycle-1, set acaratio = 0 or 3. 00085 acaconfig --- ACA configuration. Available configurations are: 00086 * "" (default) : automatically defines based on antennalist. 00087 If antennalist is Cycle-1 configuration, acaconfig='cycle1'. 00088 Otherwise, acaconfig='i' 00089 * 'cycle1' : Cycle-1 ACA-7m configuration. Uses 'aca_cycle1.cfg'. 00090 * "i" : Normal ACA configuration in full operation. Uses 'aca.i.cfg'. 00091 * "ns": North-South extended configuration in full operation. 00092 Uses 'aca.ns.cfg'. 00093 ------------------------------- 00094 pwv -- precipitable water vapor if constructing an atmospheric model. 00095 Set 0 for noise-free simulation. When pwv > 0, thermal noise is 00096 applied to the simulated data. 00097 * J. Pardo's ATM library will be used to construct anatmospheric 00098 profile for the ALMA site: 00099 altitude 5000m, ground pressure 650mbar, relhum=20%, 00100 a water layer of user_pwv at altitude of 2km, 00101 the sky brightness temperature returned by ATM, and internally 00102 tabulated receiver temperatures. 00103 See the documents of simobserve for more details. 00104 ------------------------------- 00105 image -- invert and deconvolve the simulated measurement set(s) 00106 * NOTE: interactive clean or more parameters than the subset visible 00107 here are available by simply running the clean task directly. 00108 * NOTE: the channelization of the output image cube will be the 00109 same as that in the simulated Measurement Set. 00110 * if graphics turned on, display the clean image and residual image 00111 * uses Cotton-Schwab clean for single fields and Mosaic gridding 00112 for multiple fields (with Clark PSF calculation in minor cycles). 00113 imsize -- image size in spatial pixels (x,y) 00114 0 or -1 will use the model image size; example: imsize=[500,500] 00115 imdirection -- phase center for synthesized image. default is to 00116 center on the sky model. 00117 cell -- cell size e.g '10arcsec'. "" defaults to the skymodel cell 00118 niter -- number of clean/deconvolution iterations, 0 for no cleaning 00119 threshold -- flux level to stop cleaning 00120 ------------------------------- 00121 graphics -- view plots on the screen, saved to file, both, or neither 00122 verbose -- print extra information to the logger and terminal 00123 overwrite -- overwrite existing files in the project subdirectory 00124 00125 ------------------------------- 00126 What does this task do: 00127 ------------------------------- 00128 simalma is a task to simulate ALMA observation with simple interface. 00129 It simulates ALMA 12m observation and optionally ACA 7m and Total power 00130 observations when acaratio > 0. 00131 When image=True, simulated data are imaged and analyzed. CLEAN is used 00132 to generate image(s) from simulated data. ALMA 12m and ACA data are 00133 combined (if both geneareted) by taking ACA image as an initial model 00134 in CLEAN of ALMA 12m data. 00135 NOTE this task is very experimental and may not exactly reproduce 00136 actual ALMA products. 00137 00138 The following assumptions are made to make the interface simple: 00139 * This task is intended to be run only once with a set of parameters. 00140 Therefore, it always sets up input model and pointings, and invokes simulation. 00141 You can stop before imaging step and reduce data manually with the other tasks, 00142 e.g, simanalyze, clean, and feather. 00143 * acaratio controls whether or not ACA observation is simulated. if acaratio > 0, 00144 ACA observation is simulated with total observation time = acaratio * totaltime 00145 for both ACA 7m and Total power array. 00146 * pwv controls whether or not thermal noise is applied to simulated data. 00147 When pwv > 0, the thermal noise is applied to simulated data. J. Pardo's ATM 00148 library is used to construct an atmospheric profile of the ALMA site. 00149 * if a list of directions is not specified, ALMA 12m and ACA 7m arrays will 00150 pack mapsize with the same hex algorithm as the ALMA OT in Nyquist sampling 00151 * Total power array maps slightly (+1 PB) larger area compared to 12m array for 00152 later combined imaging. It samples the region with lattice grids of spacing, 00153 0.36 lamba/d. 00154 00155 ------------------------------- 00156 How to specify a model image: 00157 ------------------------------- 00158 * simalma requires a CASA or fits image. If you merely have a grid of 00159 numbers, you will need to write them out as fits or write a CASA script to 00160 read them in and use the ia tool to create an image and insert the data. 00161 00162 * simalma does NOT require a coordinate system in the header. If the 00163 coordinate information is incomplete, missing, or you would like to 00164 override it, set the appropriate "in" paremeters. 00165 In the absence of other information, simalma will assume that the axes of 00166 your input correspond to RA, Dec, and (optionally) frequency and 00167 (optionally) Stokes parameter. 00168 00169 * If you have a proper Coordinate System, simalma will do its best to 00170 generate visibilities from that, and then create a synthesis image 00171 according to the specified user parameters. Regridding the 00172 spectral dimension may not have complete flexibility yet. 00173 00174 * You can manipulate an image header with the "imhead" task. 00175 00176 00177 Please see the documents of simobserve and simanalyze for 00178 the list of outputs produced. 00179 00180 00181 """ 00182 if type(direction)==str: direction=[direction] 00183 if type(mapsize)==str: mapsize=[mapsize] 00184 if type(imsize)==int: imsize=[imsize] 00185 00186 # 00187 # The following is work around to avoid a bug with current python translation 00188 # 00189 mytmp = {} 00190 00191 mytmp['project'] = project 00192 mytmp['skymodel'] = skymodel 00193 mytmp['inbright'] = inbright 00194 mytmp['indirection'] = indirection 00195 mytmp['incell'] = incell 00196 mytmp['incenter'] = incenter 00197 mytmp['inwidth'] = inwidth 00198 mytmp['complist'] = complist 00199 mytmp['compwidth'] = compwidth 00200 mytmp['setpointings'] = setpointings 00201 mytmp['ptgfile'] = ptgfile 00202 mytmp['integration'] = integration 00203 mytmp['direction'] = direction 00204 mytmp['mapsize'] = mapsize 00205 mytmp['antennalist'] = antennalist 00206 mytmp['hourangle'] = hourangle 00207 mytmp['totaltime'] = totaltime 00208 mytmp['acaratio'] = acaratio 00209 mytmp['acaconfig'] = acaconfig 00210 mytmp['pwv'] = pwv 00211 mytmp['image'] = image 00212 mytmp['imsize'] = imsize 00213 mytmp['imdirection'] = imdirection 00214 mytmp['cell'] = cell 00215 mytmp['niter'] = niter 00216 mytmp['threshold'] = threshold 00217 mytmp['graphics'] = graphics 00218 mytmp['verbose'] = verbose 00219 mytmp['overwrite'] = overwrite 00220 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00221 trec = casac.utils().torecord(pathname+'simalma.xml') 00222 00223 casalog.origin('simalma') 00224 if trec.has_key('simalma') and casac.utils().verify(mytmp, trec['simalma']) : 00225 result = task_simalma.simalma(project, skymodel, inbright, indirection, incell, incenter, inwidth, complist, compwidth, setpointings, ptgfile, integration, direction, mapsize, antennalist, hourangle, totaltime, acaratio, acaconfig, pwv, image, imsize, imdirection, cell, niter, threshold, graphics, verbose, overwrite) 00226 00227 else : 00228 result = False 00229 return result