Adding more quality flag -- VIIRS Aerosol

Issues related to VIIRS EDR algorithms and data
Post Reply
jhuangadl
Posts: 142
Joined: Fri Apr 29, 2011 7:57 am

Adding more quality flag -- VIIRS Aerosol

Post by jhuangadl »

Dear all,
I will deeply appreciate any info on how to add additional quality flag to the VIIRS aerosol code if there are empty bit available?
For example, besides the code changes made to the VIIRS aerosol code itself, what are the relevant configuration files I have to change in the ADL?
Any info or ideas at your earliest convenience will be sincerely appreciated! Thanks a lot!
Sincerely,
Jingfeng
bhenders
Posts: 72
Joined: Wed Jan 05, 2011 9:27 am
Location: Omaha, NE

Re: Adding more quality flag -- VIIRS Aerosol

Post by bhenders »

Jingfeng,

You didn't specify with Aerosol output product you want to add a quality flag to but for now I'm going to assume the product is the Aerosol Optical Thickness IP product.

This is the breakdown of code changes I see to add a quality flag for this product:

$ADL_HOME/xml/VIIRS/VIIRS_AEROS_OPT_THICK_IP.xml (Update XML to add either a new quality flag byte or if you can use the existing two spare bits in the final quality flag byte)

$ADL_HOME/xml/VIIRS/VIIRS_AOT_IP_Heap.xml (Update XML to add the new quality flag byte - note these are unpacked quality flag bits, which is generally what the aerosol science code uses)

$ADL_HOME/include/ProEdrViirsAerosolGbl.h to add the apropriate masks and shifts for the quality flag bits.

$ADL_HOME/EDR/VIIRS/aerosol/src/ProEdrViirsAerosol.cpp (Make similar updates by looking at an existing quality flag, such as residual threshold exceeded.

Here are example updates based on the residual threshold:

memcpy(memoryPtrData_.aotIP.res_Ptr,
memoryPtrData_.aotTmpIP->resPtr + offset,
size/4);
: : :
// byte 5 - bit 6 residual
*(aotIp.QF5_Ptr + pixel) |=
((*(memoryPtrData_.aotIP.res_Ptr + pixel) &
(PRO_AEROS_RESIDUAL_MASK >> PRO_AEROS_RESIDUAL_SHIFT)) <<
PRO_AEROS_RESIDUAL_SHIFT);
: : :
{reinterpret_cast<void**>(&memoryPtrData_.aotIP.res_Ptr), "res"}
: : :
qf_data.res = memoryPtrData_.aotTmpIP->resPtr;
: : :
/* Test for residual exceeding threshold */
if ((aot_data.lowres) >
cfgParmsPtr_->residualLandThsh &&
*(aot_data.faot550 + j) > cfgParmsPtr_->residualAotThsh)
{
if (*(qf_data.aotqf + j) < PRO_AOT_QUAL_DEGRADED)
{
*(qf_data.aotqf + j) = PRO_AOT_QUAL_DEGRADED;
}
*(qf_data.res + j) =
PRO_AOT_RESIDUAL_OUT_OF_RANGE;
}


$ADL_HOME/EDR/VIIRS/aerosol/include/ProEdrViirsAerosolStruct.h (Add the new quality flag name to the FLAG_STRUCT structure and a new field name pointer to ViirsTmpAotIpType structure.

Add lines similar to these:

resPtr = new UInt8[elements];
: : :
if (resPtr != 0)
{
delete [] resPtr;
resPtr = 0;
}
: : :
UInt8* resPtr;


This is a basic outline for adding a new quality flag to the VIIRS AOT IP product. Hope this gets you started.

Thanks,

Bryan Henderson
Raytheon Company
jhuangadl
Posts: 142
Joined: Fri Apr 29, 2011 7:57 am

Re: Adding more quality flag -- VIIRS Aerosol

Post by jhuangadl »

Thank you very much for your prompt help, Bryan
Yes, it is for AOT product.
This is certainly a lot for me to get started.
I will post it back if I encounter any further problems.
Thanks and nice day,
Jingfeng
jhuangadl
Posts: 142
Joined: Fri Apr 29, 2011 7:57 am

Re: Adding more quality flag -- VIIRS Aerosol

Post by jhuangadl »

Dear Bryan,
I am happy reporting back to you that it seems that we had added one QF successfully to the AOT IP product.
Now, my question is I need to add corresponding QF to AOT EDR product as well.
Any chance you can kindly provide me a list of files I need to check to add QF to AOT EDR product?
1) Under $ADL_HOME/xml/VIIRS, I have the following two EDR XML files:
VIIRS_AEROS_EDR.xml --- I believe this is the right one I should change for the QF. I made changes on this file.
VIIRS_AEROS_FEDR.xml --- this seems to be the variables that are in float data type? Not sure. I made similar changes to this file too.
which one I should change? what are the differences between the two?
2) $ADL_HOME/include/ProEdrViirsAerosolGbl.h -- I did this
3) ProEdrViirsAerosol.cpp -- I did this
4) ProEdrViirsAerosolStruct.h -- I did this
Do I need change more files?
Thanks!
bhenders
Posts: 72
Joined: Wed Jan 05, 2011 9:27 am
Location: Omaha, NE

Re: Adding more quality flag -- VIIRS Aerosol

Post by bhenders »

Jingfeng.

Glad to hear you were able to implement the AOT IP quality flag and get it working.

It looks like you already have a handle on the files that need updates for the Aerosol EDR QF.

Any chance you can kindly provide me a list of files I need to check to add QF to AOT EDR product?
1) Under $ADL_HOME/xml/VIIRS, I have the following two EDR XML files:
VIIRS_AEROS_EDR.xml --- I believe this is the right one I should change for the QF. I made changes on this file.
VIIRS_AEROS_FEDR.xml --- this seems to be the variables that are in float data type? Not sure. I made similar changes to this file too.
which one I should change? what are the differences between the two?

BWH: You should change bothof these files, the VIIRS_AEROS_FEDR.xml is the full floating point version of the product, while the VIIRS_AEROS_EDR.xml file is the scaled version that is delivered. The actual algorithm uses the full version product and the scaled one is generated from the full version. You should make the same updates to both XML files to reflect the QF changes.

2) $ADL_HOME/include/ProEdrViirsAerosolGbl.h -- I did this

BWH, agree

3) ProEdrViirsAerosol.cpp -- I did this

BWH, agree, I assume you are using another Aerosol EDR flag as an example to find all of the places in this file to modify/update.

4) ProEdrViirsAerosolStruct.h -- I did this

BWH, agree

Do I need change more files?

BWH, I can't think of any other files that need to be updated off of the top of my head.

Thanks,

Bryan Henderson
Raytheon Company
jhuangadl
Posts: 142
Joined: Fri Apr 29, 2011 7:57 am

Re: Adding more quality flag -- VIIRS Aerosol

Post by jhuangadl »

I see, thank you very much, Bryan! I will test it as guided.
Post Reply