@@ -246,9 +246,9 @@ void ncepRapSurfInitialization::checkForValidData()
246246 }
247247 else if ( varList[i] == " Geopotential_height_cloud_tops" ) // units are meters
248248 {
249- if (padfScanline[k] != - 99999.0 ) // means there are clouds
249+ if (padfScanline[k] != dfNoData ) // means there are clouds
250250 {
251- if (padfScanline[k] < -500.0 || padfScanline[k] > 30000.0 )
251+ if (padfScanline[k] < -500.0 )
252252 throw badForecastFile (" Geopotential_height_cloud_tops is out of range in forecast file." );
253253 }
254254 }
@@ -458,14 +458,17 @@ void ncepRapSurfInitialization::setSurfaceGrids( WindNinjaInputs &input,
458458 (double *) CPLMalloc ( sizeof ( double ) * nBandCount );
459459
460460 for ( int b = 0 ;b < srcDS->GetRasterCount ();b++ ) {
461- psWarpOptions->padfDstNoDataReal [b] = dfNoData;
462- psWarpOptions->padfDstNoDataImag [b] = dfNoData;
463- psWarpOptions->panSrcBands [b] = b + 1 ;
464- psWarpOptions->panDstBands [b] = b + 1 ;
461+ psWarpOptions->padfDstNoDataReal [b] = dfNoData;
462+ psWarpOptions->padfDstNoDataImag [b] = dfNoData;
463+ psWarpOptions->panSrcBands [b] = b + 1 ;
464+ psWarpOptions->panDstBands [b] = b + 1 ;
465465 }
466466
467- if ( pbSuccess == false )
468- dfNoData = -9999.0 ;
467+ if ( pbSuccess == false )
468+ dfNoData = -9999.0 ;
469+
470+ if ( dfNoData > 1e10 )
471+ dfNoData = std::numeric_limits<double >::quiet_NaN ();
469472
470473 psWarpOptions->papszWarpOptions =
471474 CSLSetNameValue ( psWarpOptions->papszWarpOptions ,
@@ -482,32 +485,32 @@ void ncepRapSurfInitialization::setSurfaceGrids( WindNinjaInputs &input,
482485 }
483486
484487 if ( varList[i] == " Temperature_height_above_ground" ) {
485- GDAL2AsciiGrid ( wrpDS, bandNum, airGrid );
486- if ( CPLIsNan ( dfNoData ) ) {
487- airGrid.set_noDataValue (-9999.0 );
488- airGrid.replaceNan ( -9999.0 );
489- }
490- }
491- else if ( varList[i] == " v-component_of_wind_height_above_ground" ) {
492- GDAL2AsciiGrid ( wrpDS, bandNum, vGrid );
493- if ( CPLIsNan ( dfNoData ) ) {
494- vGrid.set_noDataValue (-9999.0 );
495- vGrid.replaceNan ( -9999.0 );
496- }
497- }
498- else if ( varList[i] == " u-component_of_wind_height_above_ground" ) {
499- GDAL2AsciiGrid ( wrpDS, bandNum, uGrid );
500- if ( CPLIsNan ( dfNoData ) ) {
501- uGrid.set_noDataValue (-9999.0 );
502- uGrid.replaceNan ( -9999.0 );
488+ GDAL2AsciiGrid ( wrpDS, bandNum, airGrid );
489+ if ( CPLIsNan ( dfNoData ) ) {
490+ airGrid.set_noDataValue (-9999.0 );
491+ airGrid.replaceNan ( -9999.0 );
492+ }
503493 }
494+ else if ( varList[i] == " v-component_of_wind_height_above_ground" ) {
495+ GDAL2AsciiGrid ( wrpDS, bandNum, vGrid );
496+ if ( CPLIsNan ( dfNoData ) ) {
497+ vGrid.set_noDataValue (-9999.0 );
498+ vGrid.replaceNan ( -9999.0 );
499+ }
504500 }
505- else if ( varList[i] == " Geopotential_height_cloud_tops" ) {
506- GDAL2AsciiGrid ( wrpDS, bandNum, cloudGrid );
507- if ( CPLIsNan ( dfNoData ) ) {
508- cloudGrid.set_noDataValue (-9999.0 );
509- cloudGrid.replaceNan ( -99999.0 );
501+ else if ( varList[i] == " u-component_of_wind_height_above_ground" ) {
502+ GDAL2AsciiGrid ( wrpDS, bandNum, uGrid );
503+ if ( CPLIsNan ( dfNoData ) ) {
504+ uGrid.set_noDataValue (-9999.0 );
505+ uGrid.replaceNan ( -9999.0 );
506+ }
510507 }
508+ else if ( varList[i] == " Geopotential_height_cloud_tops" ) {
509+ GDAL2AsciiGrid ( wrpDS, bandNum, cloudGrid );
510+ if ( CPLIsNan ( dfNoData ) ) {
511+ cloudGrid.set_noDataValue (-9999.0 );
512+ cloudGrid.replaceNan ( -99999.0 );
513+ }
511514 }
512515
513516 GDALDestroyWarpOptions ( psWarpOptions );
0 commit comments