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_imview 00013 def imview(raster=[], contour=[], zoom=1, axes=[], out=''): 00014 00015 """View an image 00016 The imview task provides access to a subset of all of the configuration 00017 options for loading and configuring the display of images in the casaviewer. 00018 This interface will evolve and eventually provide access to nearly all of 00019 the image options available in the casaviewer. 00020 00021 To simply create a casaviewer to set up interactively, you can use: 00022 00023 imview 00024 00025 To open a particular image: 00026 00027 imview "ngc5921.clean.image" 00028 00029 to open an image and overlay a contour: 00030 00031 imview "ngc5921.clean.image", "ngc5921.clean.image" 00032 00033 or equivalently: 00034 00035 imview( raster="ngc5921.clean.image", contour="ngc5921.clean.image" ) 00036 00037 to output an image: 00038 00039 imview( raster="ngc5921.clean.image", out="ngc5921-01.png" ) 00040 00041 00042 There are five optional parameters for imview -- raster, contour, zoom, 00043 axes, and out. Each of these parameters can take a few different forms and 00044 are treated as python dictionaries: 00045 00046 raster -- (string) image file to open 00047 (dict) file (string) => image file to open 00048 scaling (float) => scaling power cycles 00049 range (float*2) => data range 00050 colormap (string) => name of colormap 00051 colorwedge (bool) => show color wedge? 00052 contour -- (string) file to load as a contour 00053 (dict) file (string) => file to load 00054 levels (float*N) => relative levels 00055 base (numeric) => zero in relative levels 00056 unit (numeric) => one in the relative levels 00057 zoom -- (int) integral zoom level 00058 (string) region file to load as the zoom region 00059 (dict) blc (numeric*2) => bottom left corner 00060 trc (numeric*2) => top right corner 00061 coord (string) => pixel or world 00062 channel (int) => chanel to display 00063 (dict) <region record> => record loaded 00064 e.g. rg.fromfiletorecord( ) 00065 axes -- (string*3) demension to display on the x, y, and z axes 00066 (dict) x => dimension for x-axes 00067 y => dimension for y-axes 00068 z => dimension for z-axes 00069 out -- (string) file with a supported extension 00070 [jpg, pdf, eps, ps, png, xbm, xpm, ppm] 00071 (dict) file (string) => filename 00072 format (string) => valid ext (filename ext overrides) 00073 scale (numeric) => scale for non-eps, non-ps output 00074 dpi (numeric) => dpi for eps or ps output 00075 orient (string) => portrait or landscape 00076 00077 Examples: 00078 00079 1) A subset (zoom) of a raster image. Note the notation of curly brackets: 00080 00081 imview(raster="ngc5921.clean.image", out="ngc5921-02.png", 00082 zoom={'channel': 10, 'blc': [113,109], 'trc': [141,136]} ) 00083 00084 00085 2) An overlay of a raster image, ngc5921.clean.image, with a 00086 contour map of the same image ngc5921.clean.image. Data ranges 00087 are selected, as well as the colormap and the scaling cycles 00088 of the raster image. Contours are autogenerated and The x-axis 00089 will be Declination. The image is written out to a file named 00090 myout.png in the png format. 00091 00092 imview(raster={'file': 'ngc5921.clean.image', 00093 'range': [-0.01,0.03], 00094 'colormap': 'Hot Metal 2', 00095 'scaling': -1}, 00096 contour={'file': 'ngc5921.clean.image'}, 00097 axes={'x':'Declination'} , 00098 zoom={'channel': 7, 'blc': [75,75], 'trc': [175,175], 00099 'coord': 'pixel'}, 00100 out='myout.png') 00101 00102 3) As example (2) but with an integral zoom level and no output to a file 00103 00104 imview(raster={'file': 'ngc5921.clean.image', 00105 'range': [-0.01,0.03], 00106 'colormap': 'Hot Metal 2'}, 00107 contour={'file': 'ngc5921.clean.image'}, 00108 axes={'x':'Declination'} , 00109 zoom=2) 00110 00111 4) Now, the contour levels are explicitely given, a region file is used 00112 to define the zoom area 00113 00114 imview(raster={'file': 'ngc5921.clean.image', 00115 'range': [-0.01,0.03], 00116 'colormap': 'Hot Metal 2'}, 00117 contour={'file': 'ngc5921.clean.image', 00118 'levels': [-0.2, 0.2, 0.25, 0.3, 0.35, 0.4, 0.6, 0.8] }, 00119 zoom='myregion.rgn') 00120 00121 specifying "zoom={'file': 'myregion.rgn', 'channel': 10}" would result 00122 in the same level of zoom and would display channel number 10 from 00123 the cube. 00124 00125 00126 00127 """ 00128 00129 # 00130 # The following is work around to avoid a bug with current python translation 00131 # 00132 mytmp = {} 00133 00134 mytmp['raster'] = raster 00135 mytmp['contour'] = contour 00136 mytmp['zoom'] = zoom 00137 mytmp['axes'] = axes 00138 mytmp['out'] = out 00139 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00140 trec = casac.utils().torecord(pathname+'imview.xml') 00141 00142 casalog.origin('imview') 00143 if trec.has_key('imview') and casac.utils().verify(mytmp, trec['imview']) : 00144 result = task_imview.imview(raster, contour, zoom, axes, out) 00145 00146 else : 00147 result = False 00148 return result