Skip to content

Commit

Permalink
Added test for KNMI HDF5 file getfeatureInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenplieger committed Jun 23, 2021
1 parent 5e67f33 commit e38c5b5
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 2 deletions.
16 changes: 15 additions & 1 deletion adagucserverEC/CDataPostProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,20 @@ int CDPPExecutor::executeProcessors( CDataSource *dataSource,int mode, double *
CDBError("Constraints for DPP %s are not met",dataPostProcessorList->get(procId)->getId());
}

/*Will be runned when datasource metadata been loaded */
if(mode == CDATAPOSTPROCESSOR_RUNBEFOREREADING){
if(code&CDATAPOSTPROCESSOR_RUNBEFOREREADING){
try{
int status = dataPostProcessorList->get(procId)->execute(proc,dataSource,CDATAPOSTPROCESSOR_RUNBEFOREREADING, NULL, 0);
if(status != 0){
CDBError("Processor %s failed RUNBEFOREREADING, statuscode %d",dataPostProcessorList->get(procId)->getId(),status);
}
}catch(int e){
CDBError("Exception in Processor %s failed RUNBEFOREREADING, exceptioncode %d",dataPostProcessorList->get(procId)->getId(),e);
}
}
}

/*Will be runned when datasource data been loaded */
if(mode == CDATAPOSTPROCESSOR_RUNAFTERREADING){
if(code&CDATAPOSTPROCESSOR_RUNAFTERREADING){
Expand Down Expand Up @@ -1149,6 +1163,7 @@ float CDPDBZtoRR::getRR(float dbZ) {
}

int CDPDBZtoRR::execute(CServerConfig::XMLE_DataPostProc* proc, CDataSource* dataSource,int mode, double *data, size_t numItems){
CDBDebug("CDPDBZtoRR");
if((isApplicable(proc,dataSource)&mode)==false){
return -1;
}
Expand All @@ -1173,7 +1188,6 @@ int CDPDBZtoRR::execute(CServerConfig::XMLE_DataPostProc* proc, CDataSource* dat
return -1;
}
if(mode==CDATAPOSTPROCESSOR_RUNBEFOREREADING){
// dataSource->getDataObject(0)->cdfVariable->setAttributeText("units","mm/hr");
dataSource->getDataObject(0)->setUnits("mm/hr");
}
if(mode==CDATAPOSTPROCESSOR_RUNAFTERREADING){
Expand Down
3 changes: 2 additions & 1 deletion adagucserverEC/CMakeJSONTimeSeries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ class UniqueRequests{
if(projCacheInfo.isOutsideBBOX == false){
CDFObject *cdfObject = CDFObjectStore::getCDFObjectStore()->getCDFObjectHeader(dataSource, dataSource->srvParams,(filemapiterator->first).c_str());


if(cdfObject->getVariableNE("forecast_reference_time")!=NULL){
CDBDebug("IS REFERENCE TIME");
CDF::Dimension *forecastRefDim = new CDF::Dimension();
Expand Down Expand Up @@ -552,6 +551,8 @@ class UniqueRequests{
CDBDebug(" %d %s [%d:%d]",i,"",start[i],count[i]);
}
#endif


/*
* In case a scale_factor and add_offset attribute is present, we need to read the data into the same datatype as this attribute
* This allows it to be unpacked properly to the final scaled values
Expand Down
51 changes: 51 additions & 0 deletions data/config/datasets/adaguc.KNMIHDF5.test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Configuration>

<WMS>
<Title>RADNL_OPER_R___25PCPRR_L3_WMS</Title>
<Abstract>Radar precipitation measurements above the Netherlands, on a 1.0x1.0 km grid, measurements are available in a five minute time interval. The intensity is in kg/m2/hour (mm/hour). The dataset is created from KNMI RAD_NL25_PCP_NA files. For interoperability, the original unit reflectivity in DBZ is converted to precipitation flux in kg/m2/h. The conversion from dbZ to kg/m2/h is applied with the formula R = 10^((PixelValue -109)/32).</Abstract>
<RootLayer>
<Title>RADNL_OPER_R___25PCPRR_L3_WMS</Title>
<Abstract></Abstract>
</RootLayer>
</WMS>

<WCS>
<Title>RADNL_OPER_R___25PCPRR_L3_WCS</Title>
<Label>wcsLabel</Label>
<WCSFormat name="netcdf" driver="ADAGUCNetCDF" mimetype="Content-Type:application/netcdf" options=""/>
<WCSFormat name="NetCDF3" title="GDAL NetCDF3" driver="ADAGUC" mimetype="Content-Type:text/plain" options="FORCENC3=TRUE"/>
<WCSFormat name="NetCDF4" driver="ADAGUC" mimetype="Content-Type:text/plain"/>
</WCS>


<Legend name="KNMIRadarPalette_mmh" type="interval">
<palette min="0" max="38" red="255" green="255" blue="255"/>
<palette min="38" max="80" red="170" green="170" blue="170"/>
<palette min="80" max="118" red="85" green="85" blue="85"/>
<palette min="118" max="160" red="255" green="128" blue="128"/>
<palette min="160" max="198" red="255" green="0" blue="0"/>
<palette min="198" max="255" red="0" green="0" blue="0"/>
</Legend>

<Style name="radar">
<Legend>KNMIRadarPalette_mmh</Legend>
<ValueRange min=".09" max="1000000"/>
<RenderMethod>nearest</RenderMethod>
<Min>0.1</Min>
<Max>100</Max>
<Log>10</Log>
</Style>

<!-- Layers -->
<Layer type="database" hidden="false">
<Name>RAD_NL25_PCP_CM</Name>
<Title>Precipitation Radar NL</Title>
<Variable>image1.image_data</Variable>
<!-- RAD_NL25_PCP_CM_202102170000.h5 -->
<FilePath filter="^RAD_NL25_PCP_CM_.*\.h5$">{ADAGUC_PATH}/data/datasets/test/</FilePath>
<Dimension name="time" units="ISO8601" interval="PT5M" default="max">time</Dimension>
<Styles>radar</Styles>
<DataPostProc algorithm="dbztorr" units="mm/hr"/>
</Layer>
</Configuration>
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/AdagucTests/TestWMS.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,3 +574,17 @@ def test_WMSGetMapCustomCRSEPSG3413Projection_ipcc_cmip5_tas_historical_subset_n
# self.assertEqual(status, 0)
# self.assertEqual(data.getvalue(), AdagucTestTools().readfromfile(self.expectedoutputsspath + filename))

def test_WMSGetFeatureInfo_timeseries_KNMIHDF5_json(self):
AdagucTestTools().cleanTempDir()
ADAGUC_PATH = os.environ['ADAGUC_PATH']
env={'ADAGUC_CONFIG' : ADAGUC_PATH + "/data/config/adaguc.tests.dataset.xml," + ADAGUC_PATH + "/data/config/datasets/adaguc.KNMIHDF5.test.xml"}
config = ADAGUC_PATH + '/data/config/adaguc.tests.dataset.xml,' + ADAGUC_PATH + '/data/config/datasets/adaguc.KNMIHDF5.test.xml'
status,data,headers = AdagucTestTools().runADAGUCServer(args = ['--updatedb', '--config', config], env = self.env, isCGI = False)
self.assertEqual(status, 0)

filename="test_WMSGetFeatureInfo_timeseries_KNMIHDF5_json.json"
status,data,headers = AdagucTestTools().runADAGUCServer("dataset=adaguc.KNMIHDF5.test&service=WMS&request=GetFeatureInfo&version=1.3.0&layers=RAD_NL25_PCP_CM&query_layers=RAD_NL25_PCP_CM&crs=EPSG%3A3857&bbox=467411.5837657447%2C5796421.971094566%2C889884.3758374067%2C7834481.671540775&width=199&height=960&i=103&j=501&format=image%2Fgif&info_format=application%2Fjson&time=1000-01-01T00%3A00%3A00Z%2F3000-01-01T00%3A00%3A00Z&", env = env)
AdagucTestTools().writetofile(self.testresultspath + filename,data.getvalue())
self.assertEqual(status, 0)
self.assertEqual(data.getvalue(), AdagucTestTools().readfromfile(self.expectedoutputsspath + filename))

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"name":"RAD_NL25_PCP_CM","standard_name":"image1.image_data","units":"mm/hr","point":{"SRS":"EPSG:4326","coords":"6.163147,51.837904"},"dims":"time","data":{"2021-06-22T20:00:00Z":"5.225240"}}]

0 comments on commit e38c5b5

Please sign in to comment.