Skip to content

Commit ce183b4

Browse files
committed
A few minor changes:
- In writefits.c, CRVAL for the Stokes axis has now (the correct value of) 1 rather than 0. - In writefits.c, CDELT values are written as floats rather than doubles. This is to stop the CASA viewer complaining. - In task_limesolver.py and task_raytrace.py, moldatfile is now expected to be a scalar not a list. - In task_limesolver.py, the user now has the choice to specify scalar values if they want to (instead of single-element lists) for functions ('scalarConst' or 'vectorConstR') which take only one parameter.
1 parent 04ab6d8 commit ce183b4

File tree

5 files changed

+25
-38
lines changed

5 files changed

+25
-38
lines changed

casa/limesolver.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,9 @@ file:///opt/casa/code/xmlcasa/xml/casa.xsd">
7373
<value>17</value>
7474
<allowed kind="range"><value range="min">0</value></allowed>
7575
</param>
76-
<param type="stringArray" name="moldatfile">
77-
<description>Input files with transition rates for radiating molecules</description>
78-
<value type="vector">
79-
<value></value>
80-
</value>
76+
<param type="string" name="moldatfile">
77+
<description>Input file with transition rates for the radiating molecule</description>
78+
<value></value>
8179
</param>
8280
<param type="string" name="dust">
8381
<description>Input file with dust opacity data</description>

casa/raytrace.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ file:///opt/casa/code/xmlcasa/xml/casa.xsd">
1717
<description>Input FITS file</description>
1818
<value></value>
1919
</param>
20-
<param type="stringArray" name="moldatfile">
21-
<description>Input files with transition rates for radiating molecules</description>
22-
<value type="vector">
23-
<value></value>
24-
</value>
20+
<param type="string" name="moldatfile">
21+
<description>Input file with transition rates for the radiating molecule</description>
22+
<value></value>
2523
</param>
2624
<param type="string" name="dust">
2725
<description>Input file containing paired wavelength/opacity values.</description>

casa/task_limesolver.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,15 @@ def run(self):
6363
raysDoneMessageIsPrinted = False
6464
nItersCounted = 0
6565

66-
fnDict = {'dust':dust,'gridInFile':gridInFile}
66+
fnDict = {'dust':dust,'gridInFile':gridInFile,'moldatfile':moldatfile}
6767
for variableName in fnDict.keys():
6868
fileName = fnDict[variableName]
6969
if not fileName is None and fileName!='':
7070
if not os.path.exists(fileName):
7171
casalog.post("Cannot find %s file %s" % (variableName, fileName), priority='ERROR')
7272
return
7373

74-
if not isinstance(moldatfile, list):
75-
moldatfile = [moldatfile]
76-
77-
for i in range(len(moldatfile)):
78-
fileName = moldatfile[i]
79-
if not fileName is None and fileName!='':
80-
if not os.path.exists(fileName):
81-
casalog.post("Cannot find moldatfile[%d] file %s" % (i, fileName), priority='ERROR')
82-
return
74+
moldatfile = [moldatfile]
8375

8476
if (not userModelPath is None) and userModelPath!='':
8577
casalog.post("Supply of a user model is not yet supported.", priority='Warning')
@@ -189,7 +181,13 @@ def run(self):
189181
numArgsRequired = len(argsRequired)
190182
reqArgsStr = '[%s]' % ','.join(argsRequired)
191183

192-
numArgsSupplied = len(funcDict[resultID]['args'])
184+
try:
185+
numArgsSupplied = len(funcDict[resultID]['args'])
186+
except TypeError: # presumably because user has supplied a scalar for this value rather than a list.
187+
if not(functionID=='scalarConst' or functionID=='vectorConstR'):
188+
raise # we need a list.
189+
funcDict[resultID]['args'] = [funcDict[resultID]['args']]
190+
numArgsSupplied = len(funcDict[resultID]['args'])
193191

194192
if numArgsSupplied!=numArgsRequired:
195193
errStr = 'Function %s requires %d arguments but you have supplied %d.' % (functionID, numArgsRequired, numArgsSupplied)

casa/task_raytrace.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,15 @@ def run(self):
6262
raysDoneMessageIsPrinted = False
6363
nItersCounted = 0
6464

65-
fnDict = {'dust':dust,'gridInFile':gridInFile}
65+
fnDict = {'dust':dust,'gridInFile':gridInFile,'moldatfile':moldatfile}
6666
for variableName in fnDict.keys():
6767
fileName = fnDict[variableName]
6868
if not fileName is None and fileName!='':
6969
if not os.path.exists(fileName):
7070
casalog.post("Cannot find %s file %s" % (variableName, fileName), priority='ERROR')
7171
return
7272

73-
if not isinstance(moldatfile, list):
74-
moldatfile = [moldatfile]
75-
76-
for i in range(len(moldatfile)):
77-
fileName = moldatfile[i]
78-
if not fileName is None and fileName!='':
79-
if not os.path.exists(fileName):
80-
casalog.post("Cannot find moldatfile[%d] file %s" % (i, fileName), priority='ERROR')
81-
return
73+
moldatfile = [moldatfile]
8274

8375
#vvvvvvvvvvvvvvvvvvvv
8476
# Bodging up a dummy modellib setting, since Lime won't run without it.

src/writefits.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
#include "lime.h"
1111

1212
void
13-
writeWCS(fitsfile *fptr, const int i, int axesOrder[4], double cdelt[4], double crpix[4], double crval[4], char ctype[4][9], char cunit[4][9]){
13+
writeWCS(fitsfile *fptr, const int i, int axesOrder[4], float cdelt[4], double crpix[4], double crval[4], char ctype[4][9], char cunit[4][9]){
1414
char myStr[9];
1515
int status = 0;
1616

1717
sprintf(myStr, "CTYPE%d ", i+1);
1818
fits_write_key(fptr, TSTRING, myStr, &ctype[axesOrder[i]], "", &status);
1919
sprintf(myStr, "CDELT%d ", i+1);
20-
fits_write_key(fptr, TDOUBLE, myStr, &cdelt[axesOrder[i]], "", &status);
20+
fits_write_key(fptr, TFLOAT, myStr, &cdelt[axesOrder[i]], "", &status);
2121
sprintf(myStr, "CRPIX%d ", i+1);
2222
fits_write_key(fptr, TDOUBLE, myStr, &crpix[axesOrder[i]], "", &status);
2323
sprintf(myStr, "CRVAL%d ", i+1);
@@ -35,7 +35,8 @@ Users have complained that downstream packages (produced by lazy coders >:8) wil
3535
double bscale,bzero,epoch,lonpole,equinox,restfreq;
3636
int axesOrder[] = {0,1,2,3};
3737
char ctype[numAxes][9],cunit[numAxes][9];
38-
double cdelt[numAxes],crpix[numAxes],crval[numAxes];
38+
double crpix[numAxes],crval[numAxes];
39+
float cdelt[numAxes];
3940
double ru3,scale=1.0;
4041
int velref,unitI,i;
4142
float *row;
@@ -82,20 +83,20 @@ Users have complained that downstream packages (produced by lazy coders >:8) wil
8283
velref =257;
8384

8485
sprintf(ctype[axesOrder[0]], "RA---SIN");
85-
cdelt[axesOrder[0]] = -1.8e2*img[im].imgres/M_PI;
86+
cdelt[axesOrder[0]] = -1.8e2*(float)(img[im].imgres/M_PI);
8687
crpix[axesOrder[0]] = ((double)img[im].pxls)/2.0 + 0.5;
8788
crval[axesOrder[0]] = 0.0e0;
8889
sprintf(cunit[axesOrder[0]], "DEG ");
8990

9091
sprintf(ctype[axesOrder[1]], "DEC--SIN");
91-
cdelt[axesOrder[1]] = 1.8e2*img[im].imgres/M_PI;
92+
cdelt[axesOrder[1]] = 1.8e2*(float)(img[im].imgres/M_PI);
9293
crpix[axesOrder[1]] = ((double)img[im].pxls)/2.0 + 0.5;
9394
crval[axesOrder[1]] = 0.0e0;
9495
sprintf(cunit[axesOrder[1]], "DEG ");
9596

9697
sprintf(ctype[axesOrder[2]], "VELO-LSR");
9798
if(img[im].doline)
98-
cdelt[axesOrder[2]] = img[im].velres;
99+
cdelt[axesOrder[2]] = (float)img[im].velres;
99100
else
100101
cdelt[axesOrder[2]] = 1.0;
101102
crpix[axesOrder[2]] = (double) (naxes[axesOrder[2]]-1)/2.+1;
@@ -105,7 +106,7 @@ Users have complained that downstream packages (produced by lazy coders >:8) wil
105106
sprintf(ctype[axesOrder[3]], "STOKES ");
106107
cdelt[axesOrder[3]] = 1.0;
107108
crpix[axesOrder[3]] = (double) (naxes[axesOrder[3]]-1)/2.+1;
108-
crval[axesOrder[3]] = 0.0e0;
109+
crval[axesOrder[3]] = 1.0e0;
109110
sprintf(cunit[axesOrder[3]], " ");
110111

111112
bscale =1.0e0;

0 commit comments

Comments
 (0)