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_vishead 00013 def vishead(vis='', mode='summary', listitems=['telescope', 'observer', 'project', 'field', 'freq_group_name', 'spw_name', 'schedule', 'schedule_type', 'release_date'], hdkey='', hdindex='', hdvalue=''): 00014 00015 """List, summary, get, and put metadata in a measurement set 00016 00017 This task allows the user to manipulate some meta-data parameters in a 00018 measurement set. The mode='list' shows those keywords that are 00019 presently implemented, with their values. The contents associated 00020 with the keywords can be obtained (get) and changed (put). 00021 00022 The modes that are available are: 00023 00024 list --- List all keywords that are recognized, and list the 00025 value(s) for each. Only these keywords can be obtained 00026 (get) or changed (put) 00027 summary --- Equivalent to running taskname='listobs'; verbose=F 00028 get --- Get the specified keyword value(s) from the ms 00029 put --- Put the specified keyword value(s) into the ms 00030 00031 Parameters currently implemented are (June 1, 2009): 00032 00033 cal_grp 00034 field Field names 00035 fld_code Field Observing codes 00036 freq_group_name 00037 log 00038 observer Observer name 00039 project Project name 00040 ptcs Phase tracking centers for each field 00041 release_date 00042 schedule 00043 schedule_type 00044 spw_name Spectral parameters? 00045 source_name Source Names (=Field Names?) 00046 telescope Telescope Name 00047 00048 Keyword arguments: 00049 00050 vis --- Name of input visibility file 00051 default: none, example: vis='my.ms' 00052 00053 mode --- Mode of operation for vishead 00054 default = 'list'; example: mode='get' 00055 00056 hdkey--- keyword to get or put from the ms (used in get/put mode only) 00057 ex: hdkey='telescope' 00058 00059 hdindex--- index (counting from 0) if keyword is an array (used in get/put 00060 mode only) 00061 ex: hdindex='2'; hdindex=''->put/get full array; 00062 00063 hdvalue --- value to be put in the MS (used in put mode only) 00064 ex: hdvalue=array(['MyTelescope']) 00065 00066 00067 00068 00069 Examples: 00070 00071 To transfer the parameters to useful python items requires some care. 00072 00073 taskname = 'vishead' 00074 default() 00075 vis = '3C84C.ms' 00076 mode = 'get' 00077 00078 to get a field name (string), 00079 hdkey = 'field'; hdindex = '2'; hdvalue=vishead(); 00080 print hdvalue[0] = the name for field='2' 00081 00082 to get an phase center (number) 00083 hdkey = 'ptcs'; hdindex = '1'; hdvalue = vishead(); 00084 hdvalue[0][0] gives the ra, hdvalue[0][1] gives the dec in field '1' 00085 00086 00087 taskname = 'vishead' 00088 default() 00089 vis = '3C84C.ms' 00090 mode = 'put' 00091 00092 To change a string, 00093 00094 hdkey = 'field'; hdindex = '2'; hdvalue = 'junk'; vishead() 00095 field='2' is renamed 'junk' 00096 00097 To change a number, (egs. ra of field=1 to 0.5 radian) 00098 is too complicated to figure out! 00099 00100 00101 00102 """ 00103 if type(listitems)==str: listitems=[listitems] 00104 00105 # 00106 # The following is work around to avoid a bug with current python translation 00107 # 00108 mytmp = {} 00109 00110 mytmp['vis'] = vis 00111 mytmp['mode'] = mode 00112 mytmp['listitems'] = listitems 00113 mytmp['hdkey'] = hdkey 00114 mytmp['hdindex'] = hdindex 00115 mytmp['hdvalue'] = hdvalue 00116 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00117 trec = casac.utils().torecord(pathname+'vishead.xml') 00118 00119 casalog.origin('vishead') 00120 if trec.has_key('vishead') and casac.utils().verify(mytmp, trec['vishead']) : 00121 result = task_vishead.vishead(vis, mode, listitems, hdkey, hdindex, hdvalue) 00122 00123 else : 00124 result = False 00125 return result