Skip to content

Commit

Permalink
A few minor changes:
Browse files Browse the repository at this point in the history
  - 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.
  • Loading branch information
imckstewart committed Oct 25, 2017
1 parent 04ab6d8 commit ce183b4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 38 deletions.
8 changes: 3 additions & 5 deletions casa/limesolver.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,9 @@ file:///opt/casa/code/xmlcasa/xml/casa.xsd">
<value>17</value>
<allowed kind="range"><value range="min">0</value></allowed>
</param>
<param type="stringArray" name="moldatfile">
<description>Input files with transition rates for radiating molecules</description>
<value type="vector">
<value></value>
</value>
<param type="string" name="moldatfile">
<description>Input file with transition rates for the radiating molecule</description>
<value></value>
</param>
<param type="string" name="dust">
<description>Input file with dust opacity data</description>
Expand Down
8 changes: 3 additions & 5 deletions casa/raytrace.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ file:///opt/casa/code/xmlcasa/xml/casa.xsd">
<description>Input FITS file</description>
<value></value>
</param>
<param type="stringArray" name="moldatfile">
<description>Input files with transition rates for radiating molecules</description>
<value type="vector">
<value></value>
</value>
<param type="string" name="moldatfile">
<description>Input file with transition rates for the radiating molecule</description>
<value></value>
</param>
<param type="string" name="dust">
<description>Input file containing paired wavelength/opacity values.</description>
Expand Down
20 changes: 9 additions & 11 deletions casa/task_limesolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,15 @@ def run(self):
raysDoneMessageIsPrinted = False
nItersCounted = 0

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

if not isinstance(moldatfile, list):
moldatfile = [moldatfile]

for i in range(len(moldatfile)):
fileName = moldatfile[i]
if not fileName is None and fileName!='':
if not os.path.exists(fileName):
casalog.post("Cannot find moldatfile[%d] file %s" % (i, fileName), priority='ERROR')
return
moldatfile = [moldatfile]

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

numArgsSupplied = len(funcDict[resultID]['args'])
try:
numArgsSupplied = len(funcDict[resultID]['args'])
except TypeError: # presumably because user has supplied a scalar for this value rather than a list.
if not(functionID=='scalarConst' or functionID=='vectorConstR'):
raise # we need a list.
funcDict[resultID]['args'] = [funcDict[resultID]['args']]
numArgsSupplied = len(funcDict[resultID]['args'])

if numArgsSupplied!=numArgsRequired:
errStr = 'Function %s requires %d arguments but you have supplied %d.' % (functionID, numArgsRequired, numArgsSupplied)
Expand Down
12 changes: 2 additions & 10 deletions casa/task_raytrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,15 @@ def run(self):
raysDoneMessageIsPrinted = False
nItersCounted = 0

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

if not isinstance(moldatfile, list):
moldatfile = [moldatfile]

for i in range(len(moldatfile)):
fileName = moldatfile[i]
if not fileName is None and fileName!='':
if not os.path.exists(fileName):
casalog.post("Cannot find moldatfile[%d] file %s" % (i, fileName), priority='ERROR')
return
moldatfile = [moldatfile]

#vvvvvvvvvvvvvvvvvvvv
# Bodging up a dummy modellib setting, since Lime won't run without it.
Expand Down
15 changes: 8 additions & 7 deletions src/writefits.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
#include "lime.h"

void
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]){
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]){
char myStr[9];
int status = 0;

sprintf(myStr, "CTYPE%d ", i+1);
fits_write_key(fptr, TSTRING, myStr, &ctype[axesOrder[i]], "", &status);
sprintf(myStr, "CDELT%d ", i+1);
fits_write_key(fptr, TDOUBLE, myStr, &cdelt[axesOrder[i]], "", &status);
fits_write_key(fptr, TFLOAT, myStr, &cdelt[axesOrder[i]], "", &status);
sprintf(myStr, "CRPIX%d ", i+1);
fits_write_key(fptr, TDOUBLE, myStr, &crpix[axesOrder[i]], "", &status);
sprintf(myStr, "CRVAL%d ", i+1);
Expand All @@ -35,7 +35,8 @@ Users have complained that downstream packages (produced by lazy coders >:8) wil
double bscale,bzero,epoch,lonpole,equinox,restfreq;
int axesOrder[] = {0,1,2,3};
char ctype[numAxes][9],cunit[numAxes][9];
double cdelt[numAxes],crpix[numAxes],crval[numAxes];
double crpix[numAxes],crval[numAxes];
float cdelt[numAxes];
double ru3,scale=1.0;
int velref,unitI,i;
float *row;
Expand Down Expand Up @@ -82,20 +83,20 @@ Users have complained that downstream packages (produced by lazy coders >:8) wil
velref =257;

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

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

sprintf(ctype[axesOrder[2]], "VELO-LSR");
if(img[im].doline)
cdelt[axesOrder[2]] = img[im].velres;
cdelt[axesOrder[2]] = (float)img[im].velres;
else
cdelt[axesOrder[2]] = 1.0;
crpix[axesOrder[2]] = (double) (naxes[axesOrder[2]]-1)/2.+1;
Expand All @@ -105,7 +106,7 @@ Users have complained that downstream packages (produced by lazy coders >:8) wil
sprintf(ctype[axesOrder[3]], "STOKES ");
cdelt[axesOrder[3]] = 1.0;
crpix[axesOrder[3]] = (double) (naxes[axesOrder[3]]-1)/2.+1;
crval[axesOrder[3]] = 0.0e0;
crval[axesOrder[3]] = 1.0e0;
sprintf(cunit[axesOrder[3]], " ");

bscale =1.0e0;
Expand Down

0 comments on commit ce183b4

Please sign in to comment.