Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add to inv for pdt 49 #273 #274

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading