Skip to content

Commit

Permalink
Merge branch 'develop' into libs_wne
Browse files Browse the repository at this point in the history
  • Loading branch information
AlysonStahl-NOAA authored Oct 18, 2024
2 parents d941f40 + d58c83f commit 3df7634
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
13 changes: 13 additions & 0 deletions tests/run_wgrib2_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,18 @@ echo "*** Testing write/read section"
touch secs.txt
diff -w secs.txt simple.txt


echo "*** test pdt 48 ***"
n=`../wgrib2/wgrib2 ./data/gdas.t12z.pgrb2.1p00.anl.75r.grib2 -d 1 -set_pdt +48 -set_byte 4 12 00:12:0 | grep -c "aerosol_size"`
if [ "$n" -ne 1 ] ; then
exit 1
fi
set -x
echo "*** test pdt 49 ***"
n=`../wgrib2/wgrib2 ./data/gdas.t12z.pgrb2.1p00.anl.75r.grib2 -d 1 -set_pdt +49 -set_byte 4 12 00:12:0 | grep -c "aerosol_size"`
if [ "$n" -ne 1 ] ; then
exit 1
fi

echo "*** SUCCESS!"
exit 0
40 changes: 16 additions & 24 deletions wgrib2/Aerosol.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,27 @@

/*
* 2/2012 Public Domain: Wesley Ebisuzaki
* 10/2024 fix to handle all pdts Wesley Ebisuzaki
*/

/*
* HEADER:200:aerosol_size:inv:0:optical properties of an aerosol
*/

int f_aerosol_size(ARG0) {
int pdt, type;
unsigned char *sec4;
unsigned char *ptr;
double size1, size2;

if (mode >= 0) {
pdt = code_table_4_0(sec);
if (pdt < 44 || pdt > 48) return 0;
type = code_table_4_91(sec);
if (type == 255) return 0;
sec4 = sec[4];

size1 = scaled2dbl(INT1(sec4[14]), int4(sec4+15));
size2 = scaled2dbl(INT1(sec4[19]), int4(sec4+20));
ptr = code_table_4_91_location(sec);
if (ptr == NULL) return 0;
if (*ptr == 255) return 0;
size1 = scaled2dbl(INT1(ptr[1]), int4(ptr+2));
size2 = scaled2dbl(INT1(ptr[6]), int4(ptr+7));

sprintf(inv_out,"aerosol_size ");
inv_out += strlen(inv_out);
type = code_table_4_91(sec);
prt_code_table_4_91(type, size1, size2, inv_out);
prt_code_table_4_91(ptr[0], size1, size2, inv_out);

}
return 0;
Expand All @@ -40,23 +36,19 @@ int f_aerosol_size(ARG0) {
*/

int f_aerosol_wavelength(ARG0) {
int pdt, type;
unsigned char *sec4;
unsigned char *ptr;
double wave1, wave2;

if (mode >= 0) {
pdt = code_table_4_0(sec);
if (pdt != 48) return 0;
type = code_table_4_91b(sec);
if (type == 255) return 0;
sec4 = sec[4];

wave1 = scaled2dbl(INT1(sec4[25]), int4(sec4+26));
wave2 = scaled2dbl(INT1(sec4[30]), int4(sec4+31));
ptr = code_table_4_91b_location(sec);
if (ptr == NULL) return 0;
if (*ptr == 255) return 0;
wave1 = scaled2dbl(INT1(ptr[1]), int4(ptr+2));
wave2 = scaled2dbl(INT1(ptr[6]), int4(ptr+7));

sprintf(inv_out,"aerosol_wavelength ");
inv_out += strlen(inv_out);
prt_code_table_4_91(type, wave1, wave2, inv_out);
prt_code_table_4_91(ptr[0], wave1, wave2, inv_out);

}
return 0;
Expand Down
3 changes: 1 addition & 2 deletions wgrib2/ExtName.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,8 @@ int f_misc(ARG0) {
strcat(inv_out,":");
inv_out += strlen(inv_out);
}
if (pdt == 48) {
if (pdt == 48 || pdt == 49) { /* aerosol with optical properties */
f_aerosol_size(call_ARG0(inv_out,NULL));
strcat(inv_out,":");
inv_out += strlen(inv_out);
f_aerosol_wavelength(call_ARG0(inv_out,NULL));
strcat(inv_out,":");
Expand Down

0 comments on commit 3df7634

Please sign in to comment.