@@ -47,7 +47,7 @@ Where column names contain a lower-case letter, this is a placeholder for a digi
47471 FIRST_NN V # See explanation in section 3 below.
48482 VELj D # 1 col per jth dimension.
49493 DENSITYn D # 1 per nth collision partner.
50- 4 ABUNMOLm E # 1 per mth molecular species.
50+ 4 DENSMOLm E # 1 per mth molecular species. (Note that we will allow reading of ABUNMOLm for backwards compatibility.)
51515 TURBDPLR E # Given Gaussian lineshape exp(-v^2/[B^2 + 2*k*T/m]), this is B.
52526 TEMPKNTC E # From t[0].
53536 TEMPDUST E # From t[1].
@@ -285,10 +285,10 @@ The function does two things:
285285 dataTypeAllCols [colI ] = TDOUBLE ;
286286 }
287287
288- /* should rather have a vector column? */
288+ /* Should rather have a vector column? */
289289 for (i_us = 0 ;i_us < gridInfo .nSpecies ;i_us ++ ){
290290 colI ++ ;
291- sprintf ((* allColNames )[colI ], "ABUNMOL %d" , (int )i_us + 1 );
291+ sprintf ((* allColNames )[colI ], "DENSMOL %d" , (int )i_us + 1 );
292292 if (bitIsSet (dataFlags , DS_bit_abundance )){
293293 colToWriteI ++ ;
294294 (* allColNumbers )[colI ] = colToWriteI ;
@@ -409,7 +409,7 @@ Note that data types in all capitals are defined in fitsio.h.
409409 _Bool * sink = NULL ;/* Probably should be char* but this seems to work. */
410410 unsigned short * numNeigh = NULL ,i_us ,localNumCollPart ;
411411 double * velj = NULL ,* densn = NULL ;
412- float * dopb = NULL , * t = NULL , * abunm = NULL , * bField = NULL ;
412+ float * dopb = NULL , * t = NULL , * densm = NULL , * bField = NULL ;
413413 int status = 0 , colI = 0 , i , di , maxNumCols ;
414414 LONGLONG firstRow = 1 , firstElem = 1 ;
415415 char genericComment [80 ];
@@ -537,25 +537,25 @@ Ok we have a bit of a tricky situation here in that the number of columns we wri
537537 free (densn );
538538 }
539539
540- /* Check if first ABUNMOL column has info:
540+ /* Check if first DENSMOL column has info:
541541 */
542- colI = allColNumbers [getColIndex (allColNames , maxNumCols , "ABUNMOL1 " )];
542+ colI = allColNumbers [getColIndex (allColNames , maxNumCols , "DENSMOL1 " )];
543543 if (colI > 0 ){
544- abunm = malloc (sizeof (* abunm )* totalNumGridPoints );
544+ densm = malloc (sizeof (* densm )* totalNumGridPoints );
545545 for (i_us = 0 ;i_us < gridInfo .nSpecies ;i_us ++ ){
546- sprintf (colName , "ABUNMOL %d" , (int )i_us + 1 );
546+ sprintf (colName , "DENSMOL %d" , (int )i_us + 1 );
547547 colI = allColNumbers [getColIndex (allColNames , maxNumCols , colName )];
548548 if (colI <=0 ){
549549 if (!silent ) bail_out ("This should not occur, it is some sort of bug." );
550550 exit (1 );
551551 }
552552
553553 for (i_ui = 0 ;i_ui < totalNumGridPoints ;i_ui ++ )
554- abunm [i_ui ] = (float )gp [i_ui ].mol [i_us ].abun ;
555- fits_write_col (fptr , colDataTypes [colI - 1 ], colI , firstRow , firstElem , (LONGLONG )totalNumGridPoints , abunm , & status );
554+ densm [i_ui ] = (float )gp [i_ui ].mol [i_us ].nmol ;
555+ fits_write_col (fptr , colDataTypes [colI - 1 ], colI , firstRow , firstElem , (LONGLONG )totalNumGridPoints , densm , & status );
556556 processFitsError (status );
557557 }
558- free (abunm );
558+ free (densm );
559559 }
560560
561561 colI = allColNumbers [getColIndex (allColNames , maxNumCols , "TURBDPLR" )];
@@ -944,10 +944,9 @@ readKeywordsFromFITS(fitsfile *fptr, struct keywordType *kwds\
944944
945945/*....................................................................*/
946946void
947- readGridExtFromFITS (fitsfile * fptr \
948- , struct gridInfoType * gridInfoRead , struct grid * * gp \
949- , unsigned int * * firstNearNeigh , char * * * collPartNames \
950- , int * numCollPartRead , int * dataFlags ){
947+ readGridExtFromFITS (fitsfile * fptr , struct gridInfoType * gridInfoRead \
948+ , struct grid * * gp , unsigned int * * firstNearNeigh , char * * * collPartNames \
949+ , int * numCollPartRead , int * dataFlags , _Bool * densMolColsExists ){
951950 /*
952951The present function mallocs 'gp' and sets defaults for all the simple or first-level struct elements.
953952
@@ -956,17 +955,17 @@ If COLLPARn keywords are found in the GRID extension header then collPartNames i
956955Note that the calling routine needs to free gp, firstNearNeigh and collPartNames after use.
957956 */
958957
959- LONGLONG numGridCells , firstRow = 1 , firstElem = 1 , i_LL ;
960- int status = 0 , colNum , anynul = 0 , i ;
958+ LONGLONG numGridCells ,firstRow = 1 ,firstElem = 1 ,i_LL ;
959+ int status = 0 ,colNum ,anynul = 0 ,i ;
961960 char colName [20 ];
962961 char genericKwd [9 ];
963962 char message [STR_LEN_0 ];
964963 unsigned int * ids = NULL ;
965964 double * xj = NULL ;
966965 _Bool * sink = NULL ;/* Probably should be char* but this seems to work. */
967- unsigned short * numNeigh = NULL , i_us ;
968- double * velj = NULL , * densn = NULL ;
969- float * dopb = NULL , * t = NULL , * abunm = NULL , * bField = NULL ;
966+ unsigned short * numNeigh = NULL ,i_us ;
967+ double * velj = NULL ,* densn = NULL ;
968+ float * dopb = NULL ,* t = NULL ,* abunm = NULL ,* densm = NULL , * bField = NULL ;
970969
971970 /* Go to the GRID extension.
972971 */
@@ -982,9 +981,21 @@ Note that the calling routine needs to free gp, firstNearNeigh and collPartNames
982981 return ; /* I.e. with dataFlags left unchanged. */
983982 }
984983
985- /* Count the numbers of ABUNMOL columns to get the number of species:
984+ /* Find out if the user has supplied ABUNMOLn or DENSMOLn columns.
985+ */
986+ * densMolColsExists = FALSE;
987+ fits_get_colnum (fptr , CASEINSEN , "DENSMOL1" , & colNum , & status );
988+ if (status == 0 )
989+ * densMolColsExists = TRUE;
990+ else
991+ processFitsError (status );
992+
993+ /* Count the numbers of ABUNMOLn/DENSMOLn columns to get the number of species:
986994 */
987- gridInfoRead -> nSpecies = (unsigned short )countColsBasePlusInt (fptr , "ABUNMOL" );
995+ if (* densMolColsExists )
996+ gridInfoRead -> nSpecies = (unsigned short )countColsBasePlusInt (fptr , "DENSMOL" );
997+ else
998+ gridInfoRead -> nSpecies = (unsigned short )countColsBasePlusInt (fptr , "ABUNMOL" );
988999 mallocAndSetDefaultGrid (gp , (size_t )numGridCells , gridInfoRead -> nSpecies );
9891000
9901001 /* Read the columns.
@@ -1144,23 +1155,43 @@ Note that the calling routine needs to free gp, firstNearNeigh and collPartNames
11441155 }
11451156
11461157 if (gridInfoRead -> nSpecies > 0 ){
1147- /* Read the ABUNMOL columns:
1148- */
1149- abunm = malloc (sizeof (* abunm )* numGridCells );
1150- for (i_us = 0 ;i_us < gridInfoRead -> nSpecies ;i_us ++ ){
1151- sprintf (colName , "ABUNMOL%d" , (int )i_us + 1 );
1152- fits_get_colnum (fptr , CASEINSEN , colName , & colNum , & status );
1153- processFitsError (status );
1158+ if (* densMolColsExists ){
1159+ /* Read the DENSMOL columns:
1160+ */
1161+ densm = malloc (sizeof (* densm )* numGridCells );
1162+ for (i_us = 0 ;i_us < gridInfoRead -> nSpecies ;i_us ++ ){
1163+ sprintf (colName , "DENSMOL%d" , (int )i_us + 1 );
1164+ fits_get_colnum (fptr , CASEINSEN , colName , & colNum , & status );
1165+ processFitsError (status );
11541166
1155- fits_read_col (fptr , TFLOAT , colNum , firstRow , firstElem , numGridCells , 0 , abunm , & anynul , & status );
1156- processFitsError (status );
1167+ fits_read_col (fptr , TFLOAT , colNum , firstRow , firstElem , numGridCells , 0 , densm , & anynul , & status );
1168+ processFitsError (status );
11571169
1158- for (i_LL = 0 ;i_LL < numGridCells ;i_LL ++ ) {
1159- (* gp )[i_LL ].mol [i_us ].abun = (double )abunm [i_LL ];
1170+ for (i_LL = 0 ;i_LL < numGridCells ;i_LL ++ ) {
1171+ (* gp )[i_LL ].mol [i_us ].nmol = (double )densm [i_LL ];
1172+ }
1173+ }
1174+ free (densm );
1175+ }else {
1176+ /* Read the ABUNMOL columns:
1177+ */
1178+ abunm = malloc (sizeof (* abunm )* numGridCells );
1179+ for (i_us = 0 ;i_us < gridInfoRead -> nSpecies ;i_us ++ ){
1180+ sprintf (colName , "ABUNMOL%d" , (int )i_us + 1 );
1181+ fits_get_colnum (fptr , CASEINSEN , colName , & colNum , & status );
1182+ processFitsError (status );
1183+
1184+ fits_read_col (fptr , TFLOAT , colNum , firstRow , firstElem , numGridCells , 0 , abunm , & anynul , & status );
1185+ processFitsError (status );
1186+
1187+ for (i_LL = 0 ;i_LL < numGridCells ;i_LL ++ ) {
1188+ (* gp )[i_LL ].mol [i_us ].abun = (double )abunm [i_LL ];
1189+ }
11601190 }
1191+ free (abunm );
11611192 }
1162- free (abunm );
11631193
1194+ // par->useAbun = !densMolColsExists;
11641195 (* dataFlags ) |= (1 << DS_bit_abundance );
11651196 }
11661197
0 commit comments