Commits

Ville Suoranta authored e1110014e14 Merge
Merge pull request #557 in CASA/casa6 from CAS-13779 to master

* commit '0b4bdf42531f451024e633a779be3be9e398d078': Remove 'modimage' parameter

casatasks/src/private/task_setjy.py

Modified
82 82 except:
83 83 rstatus = False
84 84
85 85 casalog.filter('INFO')
86 86
87 87 return rstatus
88 88
89 89
90 90 def setjy(vis=None, field=None, spw=None,
91 91 selectdata=None, timerange=None, scan=None, intent=None, observation=None,
92 - scalebychan=None, standard=None, model=None, modimage=None,
92 + scalebychan=None, standard=None, model=None,
93 93 listmodels=None, fluxdensity=None, spix=None, reffreq=None, polindex=None,
94 94 polangle=None, rotmeas=None, fluxdict=None,
95 95 useephemdir=None, interpolation=None, usescratch=None, ismms=None):
96 96 """Fills the model column for flux density calibrators."""
97 97
98 98 casalog.origin('setjy')
99 99 casalog.post("standard="+standard,'DEBUG1')
100 100 mylocals = locals()
101 101
102 102 if not listmodels: # listmmodels=T does not require vis
137 137 if isinstance(dict_i,dict) and dict_i:
138 138 retval = dict_i
139 139 break
140 140 else:
141 141 raise RuntimeError("Error in parallel processing of MMS, retval: {}".
142 142 format(retval),'SEVERE')
143 143
144 144 else:
145 145 retval = setjy_core(vis, field, spw, selectdata, timerange,
146 146 scan, intent, observation, scalebychan, standard, model,
147 - modimage, listmodels, fluxdensity, spix, reffreq,
147 + listmodels, fluxdensity, spix, reffreq,
148 148 polindex, polangle, rotmeas, fluxdict,
149 149 useephemdir, interpolation, usescratch, ismms)
150 150
151 151 return retval
152 152
153 153
154 154 def setjy_core(vis=None, field=None, spw=None,
155 155 selectdata=None, timerange=None, scan=None, intent=None, observation=None,
156 - scalebychan=None, standard=None, model=None, modimage=None, listmodels=None,
156 + scalebychan=None, standard=None, model=None, listmodels=None,
157 157 fluxdensity=None, spix=None, reffreq=None,
158 158 polindex=None, polangle=None, rotmeas=None, fluxdict=None,
159 159 useephemdir=None, interpolation=None, usescratch=None, ismms=None):
160 160 """Fills the model column for flux density calibrators."""
161 161
162 162 retval = {}
163 163 clnamelist=[]
164 164 # remove componentlist generated
165 165 deletecomp = True
166 166 #deletecomp = False
227 227 casalog.post("No rows were selected.", "WARNING")
228 228 return {}
229 229 else:
230 230 if (not n_selected_rows):
231 231 raise Exception("No rows were selected. Please check your data selection")
232 232 myim.open(vis, usescratch=usescratch)
233 233
234 234 else:
235 235 raise Exception('Visibility data set not found - please verify the name')
236 236
237 - if modimage==None: # defined as 'hidden' with default '' in the xml
238 - # but the default value does not seem to set so deal
239 - # with it here...
240 - modimage=''
241 - if model:
242 - modimage=model
243 - elif not model and modimage:
244 - casalog.post("The modimage parameter is deprecated please use model instead", "WARNING")
237 + # remove modimage handling to use 'model' parameter only (use modimage internally??)
238 +
239 + #if modimage==None: # defined as 'hidden' with default '' in the xml
240 + # # but the default value does not seem to set so deal
241 + # # with it here...
242 + # modimage=''
243 + #if model:
244 + # modimage=model
245 + #elif not model and modimage:
246 + # casalog.post("The modimage parameter is deprecated please use model instead", "WARNING")
245 247 # If modimage is not an absolute path, see if we can find exactly 1 match in the likely places.
246 - if modimage and modimage[0] != '/':
248 + #if modimage and modimage[0] != '/':
249 + if model and model[0] != '/':
247 250 cwd = os.path.abspath('.')
248 251 calmoddirs = [cwd]
249 252 # casa dict unavailable in CASA6
250 253 if is_CASA6:
251 254 calmoddirs += findCalModels()
252 255 else:
253 256 calmoddirs += findCalModels(roots=[cwd,
254 257 casa['dirs']['data']])
255 258 candidates = []
256 259 for calmoddir in calmoddirs:
257 - cand = os.path.join(calmoddir,modimage)
260 + cand = os.path.join(calmoddir,model)
258 261 if os.path.isdir(cand):
259 262 candidates.append(cand)
260 263 if not candidates:
261 - raise RuntimeError("%s was not found for modimage in %s." %(modimage,
264 + raise RuntimeError("%s was not found for model in %s." %(model,
262 265 ', '.join(calmoddirs)))
263 266
264 267 elif len(candidates) > 1:
265 - casalog.post("More than 1 candidate for modimage was found:",
268 + casalog.post("More than 1 candidate for model was found:",
266 269 'SEVERE')
267 270 for c in candidates:
268 271 casalog.post("\t" + c, 'SEVERE')
269 272 raise RuntimeError("Please pick 1 and use the absolute path (starting with /).")
270 273
271 274 else:
272 - modimage = candidates[0]
273 - casalog.post("Using %s for modimage." % modimage, 'INFO')
275 + model = candidates[0]
276 + casalog.post("Using %s for model." % model, 'INFO')
274 277
275 278 # Write the parameters to HISTORY before the tool writes anything.
276 279 try:
277 280 param_names = setjy.__code__.co_varnames[:setjy.__code__.co_argcount]
278 281 if is_python3:
279 282 vars = locals()
280 283 param_vals = [vars[p] for p in param_names]
281 284 else:
282 285 param_vals = [eval(p) for p in param_names]
283 286
354 357 if fluxdict[selfld]["fitFluxd"]:
355 358 selfluxd = fluxdict[selfld]["fitFluxd"]
356 359 selreffreq = fluxdict[selfld]["fitRefFreq"]
357 360 else:
358 361 # use first selected spw's flux density
359 362 selfluxd = fluxdict[selfld][str(selspw[0])]['fluxd']
360 363 # assuming the fluxscale reporting the center freq of a given spw
361 364 selreffreq=fluxdict["freq"][selspw[0]]
362 365 casalog.post("Use fluxdensity=%s, reffreq=%s, spix=%s" %
363 366 (selfluxd,selreffreq,selspix))
364 - curretval=myim.setjy(field=selfld,spw=selspw,modimage=modimage,
367 + curretval=myim.setjy(field=selfld,spw=selspw,modimage=model,
365 368 # enable spix in list
366 369 fluxdensity=selfluxd, spix=selspix, reffreq=selreffreq,
367 370 #fluxdensity=selfluxd, spix=[selspix], reffreq=selreffreq,
368 371 standard=instandard, scalebychan=scalebychan,
369 372 polindex=polindex, polangle=polangle, rotmeas=rotmeas,
370 373 time=timerange, observation=str(observation), scan=scan,
371 374 intent=intent, interpolation=interpolation)
372 375 retval.update(curretval)
373 376 else:
374 377 raise Exception("No field is selected. Check fluxdict and field selection.")
383 386 # Until CAS-6463 is fixed, need to catch and override inconsistent parameters.
384 387 if userFluxDensity and instandard!='manual':
385 388 influxdensity=-1
386 389 #raise Exception("Use standard=\"manual\" to set the specified fluxdensity.")
387 390 casalog.post("*** fluxdensity > 0 but standard != 'manual' (possibly interaction with globals), override to set fluxdensity=-1.", 'WARN')
388 391
389 392
390 393 if spix==[]: # handle the default
391 394 spix=0.0
392 395 # need to modify imager to accept double array for spix
393 - retval=myim.setjy(field=field, spw=spw, modimage=modimage, fluxdensity=influxdensity,
396 + retval=myim.setjy(field=field, spw=spw, modimage=model, fluxdensity=influxdensity,
394 397 spix=spix, reffreq=reffreq, standard=instandard, scalebychan=scalebychan,
395 398 polindex=polindex, polangle=polangle, rotmeas=rotmeas,
396 399 time=timerange, observation=str(observation), scan=scan, intent=intent,
397 400 interpolation=interpolation)
398 401
399 402 myim.close()
400 403
401 404 finally:
402 405 if standard=='Butler-JPL-Horizons 2012':
403 406 for cln in clnamelist:
414 417 Unlike ls, glob.glob('pat1 pat2') does not return
415 418 the union of matches to pat1 and pat2. This does.
416 419 """
417 420 retset = set([])
418 421 patlist = pats.split()
419 422 for p in patlist:
420 423 retset.update(glob(p))
421 424 return retset
422 425
423 426
424 -def lsmodims(path, modpat='*', header='Candidate modimages'):
427 +def lsmodims(path, modpat='*', header='Candidate models'):
425 428 """
426 429 Does an ls -d of files or directories in path matching modpat.
427 430
428 431 Header describes what is being listed.
429 432 """
430 433 if os.path.isdir(path):
431 434 if better_glob(os.path.join(path,modpat)):
432 435 casalog.post("\n%s (%s) in %s:" % (header, modpat, path))
433 436 sys.stdout.flush()
434 437 os.system('cd ' + path + ';ls -d ' + modpat)

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut