Adding a new product in SeaDAS

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
alakes
Posts: 26
Joined: Fri Aug 26, 2016 7:46 am America/New_York
Answers: 0

Adding a new product in SeaDAS

by alakes » Fri Apr 13, 2018 1:00 am America/New_York

I am trying to implement Shanmugam, 2011 chl ABI algorithm as a new product in SeaDAS. It is already integrated in get_chl.c but I want to try it to add as a different product so that in future I can add any product of my interest.

The following executable c code is in file get_INCOIS_ChlAbi.c :
#include <stdlib.h>
#include <math.h>
#include "l12_proto.h"

/* ---------------------------------------------------------------------------------------------------------------------------- */
/* Implementation of ABI Chlorophyll (Shanmugam, 2011)                                                                          */
/* ---------------------------------------------------------------------------------------------------------------------------- */

void get_chl_shanmugam(l2str *l2rec, float prod[])
{
    static float minval=0.001, maxval=100;
    static long   ip, ipb;
    float chl, chl1, chl2, chl3, chl4, chl5, chl6, chl7, Z;
    float nLw1, nLw2, nLw3;
    static long ib1 =-1, ib2 = -1, ib3 =-1;

    ib1 = bindex_get(443);
    ib2 = bindex_get(488);
    ib3 = bindex_get(547);

    if (ib1 < 0 || ib2 < 0 || ib3 < 0) {
        printf("chl_abi is not compatible with this sensor. \n");
        printf("Check get_INCOIS_HAB.c\n");
        exit(1);
        } else {
            printf("Calculating chl_abi using %7.2f %7.2f %7.2f\n",l2rec->fwave[ib1],l2rec->fwave[ib2],l2rec->fwave[ib3]);
        }

   for (ip=0; ip<l2rec->npix; ip++) {

       ipb = l2rec->nbands*ip;

       nLw1 = l2rec->nLw[ipb+ib1]; //443nm
       nLw2 = l2rec->nLw[ipb+ib2]; //488nm
       nLw3 = l2rec->nLw[ipb+ib3]; //547nm

       if (nLw1 >-10.0){                               //condition to avoid negative nLw
          chl1 = ((nLw2/nLw3)-nLw1)/((nLw2/nLw3)+nLw1);
          chl2 = pow(10.0,chl1);
          chl3 = (((nLw1*nLw2)/47.0)*((nLw1*nLw2)/(nLw3*nLw3)));
          chl4 = chl2*chl3;
          chl5 = 0.1403*(pow(chl4,(-0.572)));
          chl6 = pow(chl5,1.056);
          Z = pow(98,1.056);
          chl7 = chl6/(chl6+Z);
          chl = 125.0*chl7;
          prod[ip]=chl;
       }
    }
}
/* ---------------------------------------------------------------------------------------------------------------------------- */

In l2prod.h I have added the following:
                                                      #define CAT_Checking            322

In prodgen.c I have added the following:
                                                                  case CAT_Checking:
                                                                          get_chl_shanmugam(l2rec, fbuf);`
                                                                          pbuf = (VOIDP) fbuf;
                                                                          break;

In l12_proto.h I have added the following:
                                                                 void  get_chl_shanmugam (l2str *l2rec, float prod[]);

In product.xml I have added the following:

        <product name="HAB_INCOIS">
                <units>mg m^-3</units>
                <category>Miscellaneous</category>
                <displayScale>log</displayScale>
                <type>short</type>
                <range>
                        <validMin>0.01</validMin>
                        <validMax>100</validMax>
                        <displayMin>0.01</displayMin>
                        <displayMax>100</displayMax>
                </range>
                <algorithm name="Checking">
                        <cat_ix>322</cat_ix>
                        <description>Chlorophyll Concentration in mg m^-3, ABI Algorithm</description>
                        <reference>Shanmugam P. (2011), A new bio-optical algorithm for the remote sensing of algal blooms in complex ocean waters, Journal of Geophysical Research, 116(C4), C04016. doi:10.1029/2010JC006796</reference>
                </algorithm>
        </product>

I have added get_INCOIS_ChlAbi.c to add_executable of all the tools, i.e. l2gen, l3gen etc in the CMakeLists.txt

l2gen and other tool are built successfully and installed successfully using make, make install. Then I run l2gen and got the following results for chl_abi(already implemented in SeaDAS) and HAB_INCOIS_Checking (the newly added one).
(I have reprojected the output file manually) .

Please find image for chl_abi here.
https://drive.google.com/file/d/1rZ9A_8ERp38OzG-WemOe3XUA9pH4q5JO/view?usp=sharing

Please find image for HAB_INCOIS_Checking here.
https://drive.google.com/file/d/1Fzc5OKBRxqpALyZqcI7-SYCL05_8G21P/view?usp=sharing

The figure should be same. Can anybody suggest where I am messing up?

Thanks in advance.

Filters:

OB.DAAC - SeanBailey
User Services
User Services
Posts: 1483
Joined: Wed Sep 18, 2019 6:15 pm America/New_York
Answers: 1
Been thanked: 5 times

Adding a new product in SeaDAS

by OB.DAAC - SeanBailey » Sat Apr 14, 2018 7:06 pm America/New_York

The image looks like you have an indexing issue.  I would run l2gen in a debugger and step through the get_chl_shanmugam function.
You could also compare the logic to that of a similar function - one like get_depth.c  (BTW, since ib{1-3} are static, you should wrap the binindex_get calls in a "firstCall" block to prevent unnecessarily recomputing them)

Sean

alakes
Posts: 26
Joined: Fri Aug 26, 2016 7:46 am America/New_York
Answers: 0

Adding a new product in SeaDAS

by alakes » Wed Apr 18, 2018 3:19 am America/New_York

Thanks Sean, I will check.

nrl7331
Posts: 2
Joined: Wed Apr 18, 2018 10:26 am America/New_York
Answers: 0

Adding a new product in SeaDAS

by nrl7331 » Wed Apr 18, 2018 10:42 am America/New_York

Your data product returns a float, but you've set the data type to short in your product.xml.

Post Reply