Commits
10 10 | imagename, rm, rmerr, pa0, pa0err, nturns, chisq, |
11 11 | sigma, rmfg, rmmax, maxpaerr, |
12 12 | ): |
13 13 | casalog.origin('prom') |
14 14 | myia = image( ) |
15 15 | myia.dohistory(False) |
16 16 | mypo = imagepol( ) |
17 17 | tmpim = "" |
18 18 | try: |
19 19 | if len(imagename) == 0: |
20 - | raise Exception("imagename must be specified.") |
20 + | raise ValueError("imagename must be specified.") |
21 21 | if type(imagename) == type(['s']): |
22 22 | # negative axis value means concatenate along spectral axis |
23 23 | tmpim = tempfile.mkdtemp(suffix=".im", prefix="_rmfit_concat") |
24 24 | myia = myia.imageconcat( |
25 25 | outfile=tmpim, infiles=imagename, relax=True, |
26 26 | axis=-1, overwrite=True |
27 27 | ) |
28 28 | if not myia: |
29 - | raise Exception("Unable to concatenate images.") |
29 + | raise RuntimeError("Unable to concatenate images.") |
30 30 | myia.done() |
31 31 | mypo.open(tmpim) |
32 32 | else: |
33 33 | if (not mypo.open(imagename)): |
34 - | raise Exception("Cannot create image analysis tool using " + imagename) |
34 + | raise RuntimeError("Cannot create image analysis tool using " + imagename) |
35 35 | mypo.rotationmeasure( |
36 36 | rm=rm, rmerr=rmerr, pa0=pa0, pa0err=pa0err, nturns=nturns, chisq=chisq, |
37 37 | sigma=sigma, rmfg=rmfg, rmmax=rmmax, maxpaerr=maxpaerr |
38 38 | ) |
39 39 | try: |
40 40 | param_names = rmfit.func_code.co_varnames[:rmfit.func_code.co_argcount] |
41 41 | param_vals = [eval(p) for p in param_names] |
42 42 | for im in [rm, rmerr, pa0, pa0err, nturns, chisq]: |
43 43 | write_image_history( |
44 44 | im, sys._getframe().f_code.co_name, |
45 45 | param_names, param_vals, casalog |
46 46 | ) |
47 47 | except Exception as instance: |
48 48 | casalog.post("*** Error \'%s\' updating HISTORY" % (instance), 'WARN') |
49 49 | |
50 - | return True |
51 - | except Exception as instance: |
52 - | casalog.post( str( '*** Error ***') + str(instance), 'SEVERE') |
53 - | raise |
54 50 | finally: |
55 51 | if (myia): |
56 52 | myia.done() |
57 53 | if (mypo): |
58 54 | mypo.done() |
59 55 | if len(tmpim) > 0: |
60 56 | try: |
61 57 | shutil.rmtree(tmpim) |
62 58 | except Exception as e: |
63 59 | print("Could not remove " + tmpim + " because " + str(e)) |