/******************************** * * FILE CHECK.C * * All the functions that check to make sure the input data are * reasonable are in this file. * ************************************/ #include "header.h" void checkModes( void ) /************************* * * This function checks that the mode information read from * the parameter file is okay. * ******************************/ { if( (strcmp(mode.star1, "ON") != 0) && (strcmp(mode.star1, "OFF") != 0) ) quit("STAR1 must be ON or OFF."); if( (strcmp(mode.star1spots, "ON") != 0) && (strcmp(mode.star1spots, "OFF") != 0) ) quit("STAR1SPOTS must be ON or OFF."); if( (strcmp( mode.star1spots, "ON") == 0) && (strcmp( mode.star1, "OFF") == 0) ) quit("STAR1SPOTS cannot be ON if STAR1 is OFF."); if( (strcmp(mode.star2, "ON") != 0) && (strcmp(mode.star2, "OFF") != 0) ) quit("STAR2 must be ON or OFF."); if( (strcmp(mode.star2spots, "ON") != 0) && (strcmp(mode.star2spots, "OFF") != 0) ) quit("STAR2SPOTS must be ON or OFF."); if( (strcmp( mode.star2spots, "ON") == 0) && (strcmp( mode.star2, "OFF") == 0) ) quit("STAR2SPOTS cannot be ON if STAR2 is OFF."); if( (strcmp(mode.disk, "ON") != 0) && (strcmp(mode.disk, "OFF") != 0) ) quit("DISK must be ON or OFF."); if( (strcmp(mode.thirdlight, "ON") != 0) && (strcmp(mode.thirdlight, "OFF") != 0) ) quit("THIRDLIGHT must be ON or OFF."); if( (strcmp(mode.reflection, "ON") != 0) && (strcmp(mode.reflection, "OFF") != 0) ) quit("REFLECTION must be ON or OFF."); if( (strcmp(mode.writegrids, "ON") != 0) && (strcmp(mode.writegrids, "OFF") != 0) ) quit("WRITEGRIDS must be ON or OFF."); if( (strcmp(mode.runtype, "LIGHTCURVE") != 0) && (strcmp(mode.runtype, "LINEIMAGE") != 0) && (strcmp(mode.runtype, "POINTIMAGE") != 0) ) quit("Invalid RUNTYPE."); if( (strcmp(mode.readdata, "ON") != 0) && (strcmp(mode.readdata, "OFF") != 0) ) quit("READDATA must be ON or OFF."); if( (strcmp(mode.normalize, "MAXVALUE") != 0) && (strcmp(mode.normalize, "SETVALUE") != 0) && (strcmp(mode.normalize, "LSQR") != 0) && (strcmp(mode.normalize, "OFF") != 0) ) quit("NORMALIZE must be OFF, SETVALUE, MAXVALUE, or LSQR."); if( strcmp(mode.normalize, "MAXVALUE") == 0) if( starsys.normflux <= 0.0 ) quit("Normalization factor must be greater than zero."); if( strcmp(mode.normalize, "SETVALUE") == 0) { if( starsys.normflux <= 0.0 ) quit("Normalization factor must be greater than zero."); if( (starsys.normphase < -0.5) || (starsys.normphase > 0.5) ) quit("Normalization phase out of range."); } if( strcmp(mode.normalize, "LSQR") == 0) { if( strcmp(mode.readdata, "ON") != 0) quit("Normalization type cannot be LSQR unless READDATA= ON."); if( (mode.fitphase[0] < -0.5) || (mode.fitphase[0] > 1.0) ) quit("Phase1 in NORMALIZE= LSQR is out of range."); if( (mode.fitphase[1] < -0.5) || (mode.fitphase[1] > 1.0) ) quit("Phase2 in NORMALIZE= LSQR is out of range."); if( mode.fitphase[1] <= mode.fitphase[0] ) quit("Phase2 must be greater than phase1 in NORMALIZE= LSQR."); } return; } void checkSysParams( void ) /***************************** * * Check that the parameters referring to the whole system are * within range. * *****************************/ { if( (starsys.q > 100.0) || (starsys.q < 0.01) ) quit("Q out of range."); if( (starsys.mass1 <= 0.0) || (starsys.mass1 > 2.0e35) ) quit("MASS1 out of range."); starsys.mass2 = starsys.mass1 / starsys.q; if( (starsys.mass2 <= 0.0) || (starsys.mass2 > 2.0e35) ) quit("starsys.mass2 out of range."); if( (starsys.inclination > 90.0) || (starsys.inclination < 0.0) ) quit("INCLINATION out of range."); { if( strcmp( starsys.filter, "F135W" ) == 0 ) { if( fabs( starsys.wavelength - 1550.0 ) > 155.0 ) { printf(" Wavelength for filter %s is unreasonable.\n", starsys.filter); quit(""); } } else if( strcmp( starsys.filter, "U" ) == 0 ) { if( fabs( starsys.wavelength - 3500.0 ) > 350.0 ) { printf(" Wavelength for filter %s is unreasonable.\n", starsys.filter); quit(""); } } else if( strcmp( starsys.filter, "B" ) == 0 ) { if( fabs( starsys.wavelength - 4400.0 ) > 440.0 ) { printf(" Wavelength for filter %s is unreasonable.\n", starsys.filter); quit(""); } } else if( strcmp( starsys.filter, "V" ) == 0 ) { if( fabs( starsys.wavelength - 5500.0 ) > 550.0 ) { printf(" Wavelength for filter %s is unreasonable.\n", starsys.filter); quit(""); } } else if( strcmp( starsys.filter, "R" ) == 0 ) { if( fabs( starsys.wavelength - 6700.0 ) > 670.0 ) { printf(" Wavelength for filter %s is unreasonable.\n", starsys.filter); quit(""); } } else if( strcmp( starsys.filter, "I" ) == 0 ) { if( fabs( starsys.wavelength - 9000.0 ) > 900.0 ) { printf(" Wavelength for filter %s is unreasonable.\n", starsys.filter); quit(""); } } else if( strcmp( starsys.filter, "J" ) == 0 ) { if( fabs( starsys.wavelength - 12500. ) > 1250. ) { printf(" Wavelength for filter %s is unreasonable.\n", starsys.filter); quit(""); } } else if( strcmp( starsys.filter, "H" ) == 0 ) { if( fabs( starsys.wavelength - 16500. ) > 1650. ) { printf(" Wavelength for filter %s is unreasonable.\n", starsys.filter); quit(""); } } else if( strcmp( starsys.filter, "K" ) == 0 ) { if( fabs( starsys.wavelength - 22000. ) > 2200. ) { printf(" Wavelength for filter %s is unreasonable.\n", starsys.filter); quit(""); } } else quit("Unrecognized Filter."); } starsys.wavelength = starsys.wavelength * 1.0e-8; if( fabs(starsys.phaseoffset) > 0.50 ) quit("Phase offset out of range."); return; } void checkStarParams( struct starparams star ) /**************** * * Checks to see that the star parameters are within bounds. * *****************/ { if( (star.thetapoints > SIZEDIMEN1) || (star.thetapoints < 5) ) { printf(" THETAPOINTS%1ld out of range.\n", star.whichstar); quit(""); } if( ((star.thetapoints / 2) * 2) == star.thetapoints ) { printf(" THETAPOINTS%1ld must be an odd number.\n", star.whichstar); quit(""); } if( (star.phipoints > SIZEDIMEN2) || (star.phipoints < 8) ) { printf(" PHIPOINTS%1ld out of range.\n", star.whichstar); quit(""); } if( ((star.phipoints/2) * 2 - star.phipoints) != 0 ) { printf(" PHIPOINTS%1ld must be an even number.\n", star.whichstar); quit(""); } if( (star.fracRadius < 0.0001) || (star.fracRadius > 1.0) ) { printf(" FRACRADIUS%1ld out of range.\n", star.whichstar); quit(""); } if( (star.poletemp > 1.0e+6) || (star.poletemp < 100.0) ) { printf(" POLETEMP%1ld out of range.\n", star.whichstar); quit(""); } if( (star.gravbeta > 0.25) || (star.gravbeta < 0.00) ) { printf(" GRAVBETA%1ld out of range.\n", star.whichstar); quit(""); } if( (star.albedo > 1.00) || (star.albedo < 0.0) ) { printf(" ALBEDO%1ld out of range.\n", star.whichstar); quit(""); } if( strcmp(star.fluxsource, "BB") == 0 ) { if( (star.bblimbdark < 0.0) || (star.bblimbdark > 1.0) ) { printf(" bblimbdark for star%1ld out of range.\n", star.whichstar); quit(""); } } if( strcmp(star.fluxsource, "ITABLE") == 0 ) { if( (star.logg < 1.0) || (star.logg > 8.5) ) { printf(" log g for star%1ld out of range.\n", star.whichstar); quit(""); } } return; } void checkStar1SpotParams( void ) /****************************************** * * Check the parameters referring to the star 1 spots. * ***************************************/ { long i; if( strcmp( mode.star1spots, "ON") == 0 ) { if( star1spot.nspots <= 0) quit("STAR1SPOTS= ON, but no spots specified."); for( i = 1; i <= star1spot.nspots; i++ ) { if( (star1spot.theta[i] < 0.0) || (star1spot.theta[i] > PI) ) quit("star1spot.theta out of range."); if( (star1spot.phi[i] < 0.0) || (star1spot.phi[i] > TWOPI) ) quit("star1spot.phi out of range."); if( (star1spot.radius[i] <= 0.0) || (star1spot.radius[i] > PIOVER2) ) quit("star1spot.radius out of range."); if( (star1spot.SpotToverStarT[i] <= 0.0) || (star1spot.SpotToverStarT[i] > 50.0) ) quit("star1spot.SpotToverStarT out of range."); } } } void checkStar2SpotParams( void ) /****************************************** * * Check the parameters referring to the star 2 spots. * ***************************************/ { long i; if( strcmp( mode.star2spots, "ON") == 0 ) { if( star2spot.nspots <= 0) quit("STAR2SPOTS= ON, but no spots specified."); for( i = 1; i <= star2spot.nspots; i++ ) { if( (star2spot.theta[i] < 0.0) || (star2spot.theta[i] > PI) ) quit("star2spot.theta out of range."); if( (star2spot.phi[i] < 0.0) || (star2spot.phi[i] > TWOPI) ) quit("star2spot.phi out of range."); if( (star2spot.radius[i] <= 0.0) || (star2spot.radius[i] > PIOVER2) ) quit("star2spot.radius out of range."); if( (star2spot.SpotToverStarT[i] <= 0.0) || (star2spot.SpotToverStarT[i] > 5.0) ) quit("star2spot.SpotToverStarT out of range."); } } } void checkDiskParams( void ) /**************** * * Checks to see that the disk parameters are within bounds. * *****************/ { if( (disktop.rpoints > SIZEDIMEN1) || (disktop.rpoints < 6) ) quit(" RPOINTSDISK out of range."); if( (disktop.phipoints > SIZEDIMEN2) || (disktop.phipoints < 8) ) quit(" PHIPOINTSDISK out of range."); if( ((disktop.phipoints/2) * 2 - disktop.phipoints) != 0 ) quit(" PHIPOINTSDISK must be an even number."); if( (disktop.outerR > 0.8) || (disktop.outerR <= 0.0) ) quit("RDISKOUT out of range."); if( (disktop.innerR > 0.8) || (disktop.innerR <= 0.0) ) quit("RDISKIN out of range."); if( disktop.outerR <= disktop.innerR ) quit("RDISKOUT must be greater than RDISKIN"); if( (disktop.flareangle > 40.0) || (disktop.flareangle < 0.0) ) quit("FLAREANGLE out of range."); if( (disktop.transmission < 0.0) || (disktop.transmission > 1.0) ) quit("DISKTRANSMIT is out of range."); if( strcmp(disktop.fluxsource, "BB") == 0 ) { if( (disktop.bblimbdark < 0.0) || (disktop.bblimbdark > 1.0) ) quit("bblimbdark for the disk top is out of range.\n"); } if( strcmp(disktop.fluxsource, "ITABLE") == 0 ) { if( (disktop.logg < 1.0) || (disktop.logg > 8.5) ) { quit("log g for the disk top is out of range.\n"); } } if( disktop.spotT >= 1.0e+5 ) quit("Temperature of top spot out of range."); if( disktop.spotT > 0.0 ) { if( disktop.spotr[0] < disktop.innerR ) disktop.spotr[0] = disktop.innerR; if( disktop.spotr[1] > disktop.outerR ) disktop.spotr[1] = disktop.outerR; if( disktop.spotr[0] >= disktop.spotr[1] ) quit("Top spot inner radius must be less than its outer radius."); if( (disktop.spotphi[0] < 0.0) || (disktop.spotphi[0] >= 360.0) ) quit("Top spot phi1 out of range."); if( (disktop.spotphi[1] < 0.0) || (disktop.spotphi[1] >= 360.0) ) quit("Top spot phi2 out of range."); } if( (diskrim.T < 0.0) || (diskrim.T > 1.0e+5) ) { quit("Temperature of the disk rim is out of range.\n"); } if( strcmp(diskrim.fluxsource, "BB") == 0 ) { if( (diskrim.bblimbdark < 0.0) || (diskrim.bblimbdark > 1.0) ) quit("bblimbdark for the disk rim is out of range.\n"); } if( strcmp(diskrim.fluxsource, "ITABLE") == 0 ) { if( (diskrim.logg < 1.0) || (diskrim.logg > 8.5) ) { quit("log g for the disk rim is out of range.\n"); } } if( diskrim.spotT >= 1.0e+5 ) quit("Temperature of the rim spot is out of range."); if( diskrim.spotT > 0.0 ) { if( (diskrim.spotphi[0] < 0.0) || (diskrim.spotphi[0] >= 360.0) ) quit("Rim spot phi1 is out of range."); if( (diskrim.spotphi[1] < 0.0) || (diskrim.spotphi[1] >= 360.0) ) quit("Rim spot phi2 is out of range."); } return; } void checkThirdlightParams( struct thirdlightparams thirdlight ) /**************** * * Checks to see that the star parameters are within bounds. * *****************/ { if( (thirdlight.fraction <0.0) || (thirdlight.fraction >= 1.0) ) { quit(" FRACTION3 is out of range."); } if( (thirdlight.orbphase <-0.5) || (thirdlight.orbphase >= 1.0) ) { quit(" PHASE3 is out of range."); } return; }