Skip to content

Commit

Permalink
vol2bird now reads polar volumes in IRIS RAW format
Browse files Browse the repository at this point in the history
  • Loading branch information
adokter committed Dec 12, 2018
1 parent 79d3d06 commit ad6c87f
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# use gcc if not set already
CC ?= gcc
#CFLAGS += ${RSL_CFLAG} -fPIC -x c -DFPRINTFON
CFLAGS += ${RSL_CFLAG} -fPIC -g -x c
CFLAGS += ${RSL_CFLAG} ${IRIS_CFLAG} -fPIC -g -x c
LDFLAGS += -shared -Wall

# define where the vol2bird stuff is
Expand Down Expand Up @@ -48,7 +48,7 @@ libvol2bird.so : $(LIBVOL2BIRD_DEPS)
$(SRC_VOL2BIRD_DIR)/libdealias.c \
$(SRC_VOL2BIRD_DIR)/librsl.c \
$(LDFLAGS) \
-Wall -o libvol2bird.so $(RAVE_MODULE_LIBRARIES) -lconfuse -lgsl -lgslcblas $(RSL_LIB) -lm
-Wall -o libvol2bird.so $(RAVE_MODULE_LIBRARIES) -lconfuse -lgsl -lgslcblas $(RSL_LIB) ${IRIS_LIB} -lm

.PHONY : install
install : libvol2bird.so
Expand Down
73 changes: 70 additions & 3 deletions lib/libvol2bird.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
#include "librsl.h"
#endif

#ifdef IRIS
#include "iris2odim.h"
#endif


// non-public function prototypes (local to this file/translation unit)

Expand Down Expand Up @@ -131,7 +135,9 @@ static void updateFlagFieldsInPointsArray(const float* yObs, const float* yFitte

static int updateMap(PolarScan_t* scan, CELLPROP *cellProp, const int nCells, vol2bird_t* alldata);


#ifdef IRIS
PolarVolume_t* vol2birdGetIRISVolume(char* filename, float rangeMax, int small);
#endif

// non-public function declarations (local to this file/translation unit)

Expand Down Expand Up @@ -4191,6 +4197,14 @@ PolarVolume_t* vol2birdGetVolume(char* filename, float rangeMax, int small){

PolarVolume_t* volume = NULL;

#ifdef IRIS
// test whether the file is in IRIS format
if (isIRIS(filename)==0){
volume = vol2birdGetIRISVolume(filename, rangeMax, small);
goto done;
}
#endif

RaveIO_t* raveio = RaveIO_open(filename);

// check that a valid RaveIO_t pointer was returned
Expand All @@ -4211,15 +4225,68 @@ PolarVolume_t* vol2birdGetVolume(char* filename, float rangeMax, int small){
// not a rave complient file, attempt to read the file with the RSL library instead
#ifdef RSL
else{
volume = vol2birdGetRSLVolume(filename, rangeMax, small);
volume = vol2birdGetRSLVolume(filename, rangeMax, small);
}
#endif

RAVE_OBJECT_RELEASE(raveio);

return volume;
done:
return volume;
}

#ifdef IRIS
PolarVolume_t* vol2birdGetIRISVolume(char* filename, float rangeMax, int small) {

// initialize a polar volume to return
PolarVolume_t* volume = NULL;

// initialize the rave object type of filename
int rot = Rave_ObjectType_UNDEFINED;

int ret = 0;

// read the iris file
file_element_s* file_element_p = readIRIS(filename);

if(file_element_p == NULL){
fprintf(stderr, "Error: could not read IRIS file.\n");
return volume;
}

rot = objectTypeFromIRIS(file_element_p);

if (rot == Rave_ObjectType_PVOL) {
volume = RAVE_OBJECT_NEW(&PolarVolume_TYPE);

if (volume == NULL) {
RAVE_CRITICAL0("Error: failed to create polarvolume instance");
goto done;
}
}
else{
fprintf(stderr, "Error: IRIS file does not contain a polar volume.\n");
goto done;
}

// read iris data into rave polar volume object
ret = populateObject((RaveCoreObject*) volume, file_element_p);

if( ret != 0) {
fprintf(stderr, "Error: could not populate IRIS data into a polar volume object\n");
RAVE_OBJECT_RELEASE(volume);
volume = (PolarVolume_t*) NULL;
}

// clean up
if(file_element_p != NULL) {
free_IRIS(&file_element_p);
}

done:
return volume;
}
#endif


RaveIO_t* vol2birdIO_open(const char* filename)
Expand Down

0 comments on commit ad6c87f

Please sign in to comment.