Skip to content

Commit

Permalink
define NODATA and UNDETECT for cartesian objects, new option to requi…
Browse files Browse the repository at this point in the history
…re valid reflectivity in mistnet renderings of radial velocity and spectrum width
  • Loading branch information
adokter committed Nov 23, 2020
1 parent 41a92ec commit 0d70237
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
3 changes: 3 additions & 0 deletions lib/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,6 @@
#define MISTNET_PATH "/MistNet/mistnet_nexrad.pt"
// initializing value of mistnet tensor
#define MISTNET_INIT 0
// require that radial velocity and spectrum width pixels rendered as mistnet input
// have a valid corresponding reflectivity value
#define MISTNET_REQUIRE_DBZ 0
33 changes: 22 additions & 11 deletions lib/librender.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ Cartesian_t* polarVolumeToCartesian(PolarVolume_t* pvol, long dim, long res, dou

// create a cartesian scan parameter with the same name
cartesianParam = Cartesian_createParameter(cartesian,parameterName,RaveDataType_DOUBLE, init);
CartesianParam_setNodata(cartesianParam, PolarScanParam_getNodata(PolarScan_getParameter(scan, scanParameterName)));
CartesianParam_setUndetect(cartesianParam, PolarScanParam_getUndetect(PolarScan_getParameter(scan, scanParameterName)));

double range,azim,distance;
double value;

Expand All @@ -266,12 +269,10 @@ Cartesian_t* polarVolumeToCartesian(PolarVolume_t* pvol, long dim, long res, dou
distance=sqrt(SQUARE(xx)+SQUARE(yy));
range=distance2range(distance,elev);
a=PolarScan_getConvertedParameterValueAtAzimuthAndRange(scan,scanParameterName,azim,range,&value);
if(a==RaveValueType_DATA){
CartesianParam_setValue(cartesianParam, x, y, value);
}
else{
CartesianParam_setValue(cartesianParam, x, y, NAN);
if(a!=RaveValueType_DATA){
PolarScan_getParameterValueAtAzimuthAndRange(scan,scanParameterName,azim,range,&value);
}
CartesianParam_setValue(cartesianParam, x, y, value);
}
}

Expand Down Expand Up @@ -381,6 +382,9 @@ Cartesian_t* polarScanToCartesian(PolarScan_t* scan, long dim, long res, double

// create a cartesian scan parameter with the same name
cartesianParam = Cartesian_createParameter(cartesian,scanParameterName,RaveDataType_DOUBLE, init);
CartesianParam_setNodata(cartesianParam, PolarScanParam_getNodata(PolarScan_getParameter(scan, scanParameterName)));
CartesianParam_setUndetect(cartesianParam, PolarScanParam_getUndetect(PolarScan_getParameter(scan, scanParameterName)));

double range,azim,distance;
double value;

Expand All @@ -394,12 +398,10 @@ Cartesian_t* polarScanToCartesian(PolarScan_t* scan, long dim, long res, double
distance=sqrt(SQUARE(xx)+SQUARE(yy));
range=distance2range(distance,elev);
a=PolarScan_getConvertedParameterValueAtAzimuthAndRange(scan,scanParameterName,azim,range,&value);
if(a==RaveValueType_DATA){
CartesianParam_setValue(cartesianParam, x, y, value);
}
else{
CartesianParam_setValue(cartesianParam, x, y, NAN);
if(a!=RaveValueType_DATA){
PolarScan_getParameterValueAtAzimuthAndRange(scan,scanParameterName,azim,range,&value);
}
CartesianParam_setValue(cartesianParam, x, y, value);
}
}

Expand Down Expand Up @@ -579,8 +581,16 @@ int fill3DTensor(double ***tensor, RaveObjectList_t* list, int dim1, int dim2, i
for(int x = 0; x < xSize; x++){
for(int y = 0; y < ySize; y++){
valueType = CartesianParam_getValue(cartesianParam, x, y, &value);

if (valueType == RaveValueType_DATA){
tensor[iScan+nScan*iOrder][x][y] = value;
// only copy radial velocity and spectrum width values that have a corresponding reflectivity value
// this is to account for occasional sweeps where radial velocity extends to shorter ranges than reflectivity
if(MISTNET_REQUIRE_DBZ && (iOrder > 0) && isnan(tensor[iScan][x][y])){
tensor[iScan+nScan*iOrder][x][y] = NAN;
}
else{
tensor[iScan+nScan*iOrder][x][y] = value;
}
}
else{
tensor[iScan+nScan*iOrder][x][y] = NAN;
Expand All @@ -592,6 +602,7 @@ int fill3DTensor(double ***tensor, RaveObjectList_t* list, int dim1, int dim2, i

} // iParam
} // iOrder

if(dbz_count == 0) fprintf(stderr, "Warning: no reflectivity data found for MistNet input scan %i, initializing with values %i instead.\n", iScan, MISTNET_INIT);
if(vrad_count == 0) fprintf(stderr, "Warning: no radial velocity data found for MistNet input scan %i, initializing with values %i instead.\n", iScan, MISTNET_INIT);
if(wrad_count == 0) fprintf(stderr, "Warning: no spectrum width data found for MistNet input scan %i, initializing with values %i instead.\n", iScan, MISTNET_INIT);
Expand Down

0 comments on commit 0d70237

Please sign in to comment.