Skip to content

Commit

Permalink
added warning message if MistNet input is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
adokter committed Feb 11, 2020
1 parent ec8e1f8 commit bcc76bd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions lib/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,5 @@
#define MISTNET_ELEVS_ONLY 1
// location of mistnet model in pytorch format
#define MISTNET_PATH "/MistNet/mistnet_nexrad.pt"
// initializing value of mistnet tensor
#define MISTNET_INIT 0
20 changes: 15 additions & 5 deletions lib/librender.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ int fill3DTensor(double ***tensor, RaveObjectList_t* list, int dim1, int dim2, i
RaveList_t* cartesianParameterNames = Cartesian_getParameterNames(cartesian);
double value;
RaveValueType valueType;
int dbz_count = 0;
int vrad_count = 0;
int wrad_count = 0;

for(int iOrder = 0; iOrder < 3; iOrder++){
for(int iCartesianParam = 0; iCartesianParam < nCartesianParam; iCartesianParam++){
Expand Down Expand Up @@ -559,13 +562,17 @@ int fill3DTensor(double ***tensor, RaveObjectList_t* list, int dim1, int dim2, i
fprintf(stderr,"Writing Cartesian parameter %s at index %i (scan=%i, param=%i) \n",
parameterName,iScan+nScan*iOrder, iScan, iOrder);
#endif

if(iScan+nScan*iOrder>=dim1){
fprintf(stderr, "Error: exceeding 3D tensor dimension\n");
RAVE_OBJECT_RELEASE(cartesianParam);
return(-1);
}

if(iOrder == 0) dbz_count+=1;
if(iOrder == 1) vrad_count+=1;
if(iOrder == 2) wrad_count+=1;

// fill tensor
for(int x = 0; x < xSize; x++){
for(int y = 0; y < ySize; y++){
Expand All @@ -581,9 +588,12 @@ int fill3DTensor(double ***tensor, RaveObjectList_t* list, int dim1, int dim2, i

RAVE_OBJECT_RELEASE(cartesianParam);

} //iScan
}
}
} // 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);
} // iScan

return 0;
}
Expand Down Expand Up @@ -629,7 +639,7 @@ int polarVolumeTo3DTensor(PolarVolume_t* pvol, double ****tensor, int dim, long
}

// initialize a 3D tensor, and fill it
*tensor = init3DTensor(nCartesianParam,dim,dim,0);
*tensor = init3DTensor(nCartesianParam,dim,dim,MISTNET_INIT);
fill3DTensor(*tensor, list, nCartesianParam, dim, dim);

// clean up
Expand Down
5 changes: 2 additions & 3 deletions lib/libvol2bird.c
Original file line number Diff line number Diff line change
Expand Up @@ -4434,7 +4434,7 @@ PolarVolume_t* vol2birdGetODIMVolume(char* filenames[], int nInputFiles) {
int rot = Rave_ObjectType_UNDEFINED;

for (int i=0; i<nInputFiles; i++){
// read the iris file
// read the file
RaveIO_t* raveio = RaveIO_open(filenames[i]);

if(raveio == NULL){
Expand Down Expand Up @@ -4527,7 +4527,6 @@ PolarVolume_t* vol2birdGetODIMVolume(char* filenames[], int nInputFiles) {
done:

// clean up
RAVE_OBJECT_RELEASE(volume);
RAVE_OBJECT_RELEASE(volume);
RAVE_OBJECT_RELEASE(scan);

Expand Down Expand Up @@ -4856,7 +4855,7 @@ int vol2birdSetUp(PolarVolume_t* volume, vol2bird_t* alldata) {

// Print warning for MistNet mode
if(alldata->options.useMistNet && (alldata->options.dualPol || alldata->options.singlePol)){
fprintf(stderr,"Warning: using Mistnet, disabling other segmentation methods\n");
fprintf(stderr,"Warning: using MistNet, disabling other segmentation methods\n");
alldata->options.singlePol = FALSE;
alldata->options.dualPol = FALSE;
}
Expand Down

0 comments on commit bcc76bd

Please sign in to comment.