Testing: bufr keys iterator, all vs data keys

This commit is contained in:
Shahram Najm 2017-08-21 18:11:40 +01:00
parent 7bc1d59863
commit 69841d460b
2 changed files with 192 additions and 6 deletions

View File

@ -13,10 +13,13 @@
void usage(const char* prog)
{
printf("usage: %s infile\n",prog);
printf("usage: %s [-a|-d] infile\n",prog);
exit(1);
}
#define ITER_ALL_KEYS 1
#define ITER_DATA_KEYS 2
int main(int argc,char* argv[])
{
int err = 0;
@ -24,19 +27,34 @@ int main(int argc,char* argv[])
codes_bufr_keys_iterator* kiter = NULL;
char* input_filename = NULL;
FILE* f = NULL;
int iterator_mode = ITER_ALL_KEYS;
/*grib_context* c = grib_context_get_default();*/
if (argc!=2) usage(argv[0]);
input_filename = argv[1];
if (argc!=3) usage(argv[0]);
if (strcmp(argv[1], "-a")==0) {
iterator_mode = ITER_ALL_KEYS;
} else if (strcmp(argv[1], "-d")==0) {
iterator_mode = ITER_DATA_KEYS;
} else {
assert(!"Invalid mode");
}
input_filename = argv[2];
f = fopen(input_filename, "r");
assert(f);
h = codes_handle_new_from_file(NULL, f, PRODUCT_BUFR, &err);
assert(h);
CODES_CHECK(codes_set_long(h,"unpack",1), 0);
if (iterator_mode == ITER_ALL_KEYS) {
/*printf("Dumping ALL keys\n");*/
kiter = codes_bufr_keys_iterator_new(h, 0);
} else {
/*printf("Dumping only DATA SECTION keys\n");*/
kiter=codes_bufr_data_section_keys_iterator_new(h);
}
/*kiter=codes_bufr_data_section_keys_iterator_new(h);*/
kiter = codes_bufr_keys_iterator_new(h, 0);
while(codes_bufr_keys_iterator_next(kiter))
{
char* kname = codes_bufr_keys_iterator_get_name(kiter);

View File

@ -14,7 +14,10 @@ tempOut=temp.bufr_keys_iter.$$.out
tempRef=temp.bufr_keys_iter.$$.ref
input=${data_dir}/bufr/aaen_55.bufr
${test_dir}/bufr_keys_iter $input > $tempOut
## Iterate over ALL keys and skip none
# ------------------------------------
${test_dir}/bufr_keys_iter -a $input > $tempOut
# Check the output of BUFR keys iterator
# Note: the two hidden keys 'typicalDate' and 'typicalTime' are NOT in the iterator output
@ -225,4 +228,169 @@ EOF
diff $tempRef $tempOut
## Now iterate over Data Section keys and skip all others
# ---------------------------------------------------------
${test_dir}/bufr_keys_iter -d $input > $tempOut
cat > $tempRef<<EOF
#1#tovsOrAtovsProductQualifier
#1#centre
#1#subCentre
#2#tovsOrAtovsProductQualifier
#2#centre
#2#subCentre
#1#satelliteIdentifier
#1#satelliteSensorIndicator
#1#orbitNumber
#1#satelliteAntennaCorrectionsVersionNumber
#1#scanLineNumber
#1#fieldOfViewNumber
#1#majorFrameCount
#1#scanLineStatusFlagsForAtovs
#1#scanLineQualityFlagsForAtovs
#1#year
#1#month
#1#day
#1#hour
#1#minute
#1#second
#1#latitude
#1#longitude
#1#heightOfStation
#1#satelliteZenithAngle
#1#bearingOrAzimuth
#1#solarZenithAngle
#1#solarAzimuth
#1#fieldOfViewQualityFlagsForAtovs
#1#radiometerIdentifier
#1#instrumentTemperature
#2#radiometerIdentifier
#2#instrumentTemperature
#3#radiometerIdentifier
#3#instrumentTemperature
#4#radiometerIdentifier
#4#instrumentTemperature
#1#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#1#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#1#bandwidthCorrectionCoefficient1ForAtovs
#1#bandwidthCorrectionCoefficient2ForAtovs
#1#channelQualityFlagsForAtovs
#1#brightnessTemperature
#2#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#2#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#2#bandwidthCorrectionCoefficient1ForAtovs
#2#bandwidthCorrectionCoefficient2ForAtovs
#2#channelQualityFlagsForAtovs
#2#brightnessTemperature
#3#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#3#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#3#bandwidthCorrectionCoefficient1ForAtovs
#3#bandwidthCorrectionCoefficient2ForAtovs
#3#channelQualityFlagsForAtovs
#3#brightnessTemperature
#4#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#4#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#4#bandwidthCorrectionCoefficient1ForAtovs
#4#bandwidthCorrectionCoefficient2ForAtovs
#4#channelQualityFlagsForAtovs
#4#brightnessTemperature
#5#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#5#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#5#bandwidthCorrectionCoefficient1ForAtovs
#5#bandwidthCorrectionCoefficient2ForAtovs
#5#channelQualityFlagsForAtovs
#5#brightnessTemperature
#6#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#6#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#6#bandwidthCorrectionCoefficient1ForAtovs
#6#bandwidthCorrectionCoefficient2ForAtovs
#6#channelQualityFlagsForAtovs
#6#brightnessTemperature
#7#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#7#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#7#bandwidthCorrectionCoefficient1ForAtovs
#7#bandwidthCorrectionCoefficient2ForAtovs
#7#channelQualityFlagsForAtovs
#7#brightnessTemperature
#8#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#8#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#8#bandwidthCorrectionCoefficient1ForAtovs
#8#bandwidthCorrectionCoefficient2ForAtovs
#8#channelQualityFlagsForAtovs
#8#brightnessTemperature
#9#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#9#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#9#bandwidthCorrectionCoefficient1ForAtovs
#9#bandwidthCorrectionCoefficient2ForAtovs
#9#channelQualityFlagsForAtovs
#9#brightnessTemperature
#10#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#10#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#10#bandwidthCorrectionCoefficient1ForAtovs
#10#bandwidthCorrectionCoefficient2ForAtovs
#10#channelQualityFlagsForAtovs
#10#brightnessTemperature
#11#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#11#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#11#bandwidthCorrectionCoefficient1ForAtovs
#11#bandwidthCorrectionCoefficient2ForAtovs
#11#channelQualityFlagsForAtovs
#11#brightnessTemperature
#12#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#12#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#12#bandwidthCorrectionCoefficient1ForAtovs
#12#bandwidthCorrectionCoefficient2ForAtovs
#12#channelQualityFlagsForAtovs
#12#brightnessTemperature
#13#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#13#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#13#bandwidthCorrectionCoefficient1ForAtovs
#13#bandwidthCorrectionCoefficient2ForAtovs
#13#channelQualityFlagsForAtovs
#13#brightnessTemperature
#14#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#14#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#14#bandwidthCorrectionCoefficient1ForAtovs
#14#bandwidthCorrectionCoefficient2ForAtovs
#14#channelQualityFlagsForAtovs
#14#brightnessTemperature
#15#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#15#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#15#bandwidthCorrectionCoefficient1ForAtovs
#15#bandwidthCorrectionCoefficient2ForAtovs
#15#channelQualityFlagsForAtovs
#15#brightnessTemperature
#16#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#16#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#16#bandwidthCorrectionCoefficient1ForAtovs
#16#bandwidthCorrectionCoefficient2ForAtovs
#16#channelQualityFlagsForAtovs
#16#brightnessTemperature
#17#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#17#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#17#bandwidthCorrectionCoefficient1ForAtovs
#17#bandwidthCorrectionCoefficient2ForAtovs
#17#channelQualityFlagsForAtovs
#17#brightnessTemperature
#18#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#18#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#18#bandwidthCorrectionCoefficient1ForAtovs
#18#bandwidthCorrectionCoefficient2ForAtovs
#18#channelQualityFlagsForAtovs
#18#brightnessTemperature
#19#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#19#log10OfTemperatureRadianceCentralWaveNumberForAtovs
#19#bandwidthCorrectionCoefficient1ForAtovs
#19#bandwidthCorrectionCoefficient2ForAtovs
#19#channelQualityFlagsForAtovs
#19#brightnessTemperature
#20#tovsOrAtovsOrAvhrrInstrumentationChannelNumber
#1#albedoRadianceSolarFilteredIrradianceForAtovs
#1#albedoRadianceEquivalentFilterWidthForAtovs
#20#channelQualityFlagsForAtovs
#1#channelRadiance
EOF
diff $tempRef $tempOut
rm -f $tempRef $tempOut